/* ══════════════════════════════════════════════════════════════════════════
   canon-doc-v3.css — the quote & invoice editor overhaul (feature_doc_editor_v3)

   Draws what invoices/doc-v3.js arranges: the editor as the paper it prints
   on, the send panel beside it, the issued "Get paid" panel, the one add-line
   search, line cards on a phone and the pinned send bar. Research and mockup:
   docs/quote-invoice-editor-overhaul-research.md, _doc-editor-overhaul-mockup.html.

   Every rule hangs off #editorView.is-v3, which doc-v3.js adds only when it
   mounts — so with the flag off not one rule here matches anything, and the
   editor is exactly the canon-editor.css / canon-doc.css editor it was.
   Layered with the rest of the canon; loaded after canon-doc.css, and one class
   more specific than canon-editor.css's own #editorView rules.
   ══════════════════════════════════════════════════════════════════════════ */

@layer components {

  /* ── What the paper layout replaces ───────────────────────────────────── */
  /* The section pills scroll a long form; the paper is short enough not to need them. */
  :root.canon-v5 #editorView.is-v3 .ui-docrail { display: none; }
  /* The send panel (or the pinned bar) owns the primary action now. */
  :root.canon-v5 #editorView.is-v3 .ed-head2__act .btn-primary { display: none; }
  :root.canon-v5 #editorView.is-v3 .ed-head2__act:not(:has(#saveHint:not(:empty))) { display: none; }
  /* On a draft the bar keeps only what the panel does not: Duplicate, options,
     link a job, delete — all inside its More menu. */
  :root.canon-v5 #editorView.is-v3:not(.is-v3-ro) .ed-actions > [onclick^="finalize"],
  :root.canon-v5 #editorView.is-v3:not(.is-v3-ro) .ed-actions > [onclick^="saveDraft"],
  :root.canon-v5 #editorView.is-v3:not(.is-v3-ro) .ed-actions > [onclick^="previewPdf"] { display: none; }
  /* The line toolbar loses the buttons the add-line search now holds. */
  :root.canon-v5 #editorView.is-v3 .items-head [onclick^="estimateFromNote"],
  :root.canon-v5 #editorView.is-v3 .items-head [onclick^="aiDraftItems"],
  :root.canon-v5 #editorView.is-v3 .items-head [onclick^="openInvCatalog"],
  :root.canon-v5 #editorView.is-v3 .items-head [onclick^="openCatalogPicker"],
  :root.canon-v5 #editorView.is-v3 .items-head [onclick^="addItem"] { display: none; }

  /* ── The two columns ──────────────────────────────────────────────────── */
  :root.canon-v5 #editorView.is-v3 .v3-layout {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start;
  }
  :root.canon-v5 #editorView.is-v3 .v3-main { min-width: 0; }
  :root.canon-v5 #editorView.is-v3 .v3-side { min-width: 0; }
  @media (min-width: 1024px) {
    :root.canon-v5 #editorView.is-v3 .v3-layout { grid-template-columns: minmax(0, 1fr) 340px; }
    :root.canon-v5 #editorView.is-v3 .v3-side { position: sticky; top: 70px; }
  }

  /* ── The paper ────────────────────────────────────────────────────────── */
  :root.canon-v5 #editorView.is-v3 .v3-paper {
    min-width: 0; overflow: hidden;
    border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-card);
    box-shadow: var(--lift), var(--lift-edge);
  }
  :root.canon-v5 #editorView.is-v3 .v3-letter {
    display: flex; align-items: center; gap: 12px; padding: 18px 28px 16px; border-bottom: 1px solid var(--c-border);
  }
  :root.canon-v5 #editorView.is-v3 .v3-letter__logo {
    flex: none; width: 32px; height: 32px; border-radius: 6px; object-fit: contain;
  }
  :root.canon-v5 #editorView.is-v3 .v3-letter__logo.is-blank {
    display: grid; place-items: center; border: 1px solid var(--c-border); background: var(--c-sunken); color: var(--c-cap); font-size: 17px;
  }
  :root.canon-v5 #editorView.is-v3 .v3-letter__id { display: flex; flex-direction: column; min-width: 0; }
  :root.canon-v5 #editorView.is-v3 .v3-letter__id b { font-size: 14px; font-weight: 600; color: var(--c-text); }
  :root.canon-v5 #editorView.is-v3 .v3-letter__id span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-letter__doc {
    flex: none; margin-left: auto; font-size: 10px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--c-cap);
  }

  /* The header fields become the document's own: no card of their own. */
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid {
    gap: 4px 36px; padding: 22px 28px 8px; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  }
  :root.canon-v5 #editorView.is-v3 .v3-paper .lbl { margin: 12px 0 2px; }
  :root.canon-v5 #editorView.is-v3 .v3-paper .lbl .hint { display: none; }
  /* A field that reads as text until you reach for it: invisible at rest,
     sunken on hover, accent-edged on focus (the mockup's .fld). */
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid input:not([type="checkbox"]):not([type="radio"]),
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid select,
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid textarea {
    height: 32px; margin: 0 -8px; padding: 0 8px; width: calc(100% + 16px);
    border-color: transparent; background: transparent; font-size: 14px;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  }
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid textarea { height: auto; min-height: 64px; padding: 6px 8px; }
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid input:not([type="checkbox"]):not([type="radio"]):hover,
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid select:hover,
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid textarea:hover { border-color: var(--c-border); background: var(--c-sunken); }
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid input:not([type="checkbox"]):not([type="radio"]):focus,
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid select:focus,
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid textarea:focus {
    outline: none; border-color: var(--c-accent-edge); background: var(--c-card); box-shadow: 0 0 0 3px var(--c-accent-soft);
  }
  :root.canon-v5 #editorView.is-v3 .v3-paper #cName { height: 36px; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
  :root.canon-v5 #editorView.is-v3 .v3-paper #jobName { font-weight: 600; }
  /* Issued: values, not boxes — and an empty field is nothing at all. */
  :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid :disabled { border-color: transparent; }
  :root.canon-v5 #editorView.is-v3 .v3-paper .v3-empty,
  :root.canon-v5 #editorView.is-v3 .v3-paper .v3-field[hidden] { display: none; }
  :root.canon-v5 #editorView.is-v3 .v3-field { display: block; }

  /* Fields not on this document yet. Dashed = "could be here". */
  :root.canon-v5 #editorView.is-v3 .v3-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 28px 20px; }
  :root.canon-v5 #editorView.is-v3 .v3-chips[hidden] { display: none; }
  :root.canon-v5 #editorView.is-v3 .v3-addf {
    display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px;
    border: 1px dashed var(--c-border-2); border-radius: 999px; background: transparent;
    font-family: inherit; font-size: 12px; font-weight: 500; color: var(--c-text-2); cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  }
  :root.canon-v5 #editorView.is-v3 .v3-addf:hover { border-style: solid; background: var(--c-card-2); color: var(--c-text); }
  :root.canon-v5 #editorView.is-v3 .v3-addf i { font-size: 13px; color: var(--c-cap); }

  /* The lines, inside the paper rather than in a card of their own. */
  :root.canon-v5 #editorView.is-v3 .v3-paper .items-head { margin: 0; padding: 4px 28px 10px; border-top: 1px solid var(--c-border); padding-top: 16px; }
  :root.canon-v5 #editorView.is-v3 .v3-paper #priceDisplayRow { margin: 0 28px 10px; }
  :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items {
    border: 0; border-top: 1px solid var(--c-border); border-radius: 0; box-shadow: none;
  }
  :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items th:first-child,
  :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td:first-child { padding-left: 20px; }
  :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items th:last-child,
  :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td:last-child { padding-right: 20px; }
  :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items tbody tr:last-child td { border-bottom: 1px solid var(--c-border); }

  /* One search to add a line. */
  :root.canon-v5 #editorView.is-v3 .v3-addline {
    position: relative; display: flex; align-items: center; gap: 10px;
    padding: 0 20px; border-bottom: 1px solid var(--c-border); background: var(--c-sunken);
  }
  :root.canon-v5 #editorView.is-v3 .v3-addline > i { flex: none; font-size: 16px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-addline input#v3AddIn {
    flex: 1; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 14px;
  }
  :root.canon-v5 #editorView.is-v3 .v3-addline input#v3AddIn:focus { outline: none; box-shadow: none; }
  :root.canon-v5 #editorView.is-v3 .v3-addline:focus-within { box-shadow: inset 2px 0 0 var(--c-accent); }
  :root.canon-v5 #editorView.is-v3 .v3-ta {
    position: absolute; z-index: 30; top: calc(100% + 4px); left: 12px; right: 12px; max-height: 340px; overflow-y: auto;
    padding: 6px; border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-card); box-shadow: var(--float);
  }
  :root.canon-v5 #editorView.is-v3 .v3-ta[hidden] { display: none; }
  :root.canon-v5 #editorView.is-v3 .v3-ta__cap { display: block; padding: 8px 10px 4px; }
  :root.canon-v5 #editorView.is-v3 .v3-ta__rule { display: block; height: 1px; margin: 6px 8px; background: var(--c-border); }
  :root.canon-v5 #editorView.is-v3 .v3-ta__i {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px;
    background: transparent; color: var(--c-text); font-family: inherit; text-align: left; cursor: pointer;
  }
  :root.canon-v5 #editorView.is-v3 .v3-ta__i:hover,
  :root.canon-v5 #editorView.is-v3 .v3-ta__i[aria-selected="true"] { background: var(--c-card-2); }
  :root.canon-v5 #editorView.is-v3 .v3-ta__i > i { flex: none; font-size: 15px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-ta__i > i.ti-sparkles,
  :root.canon-v5 #editorView.is-v3 .v3-ta__i > i.ti-calculator { color: var(--c-on-wash-accent); }
  :root.canon-v5 #editorView.is-v3 .v3-ta__m { display: flex; flex-direction: column; min-width: 0; flex: 1; }
  :root.canon-v5 #editorView.is-v3 .v3-ta__m b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
  :root.canon-v5 #editorView.is-v3 .v3-ta__m small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-ta__p {
    flex: none; font-family: "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--c-text-2);
  }

  /* Totals close the paper, right-aligned as they print. */
  :root.canon-v5 #editorView.is-v3 .v3-foot { display: flex; justify-content: flex-end; padding: 6px 28px 18px; }
  :root.canon-v5 #editorView.is-v3 .v3-foot .ed-totals {
    width: 300px; margin: 0; padding: 10px 0 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  }
  :root.canon-v5 #editorView.is-v3 .v3-terms {
    margin: 0; padding: 12px 28px 14px; border: 0; border-top: 1px solid var(--c-border); border-radius: 0;
    background: var(--c-sunken); font-size: 12px; color: var(--c-text-2);
  }
  :root.canon-v5 #editorView.is-v3 .v3-terms .lbl { margin: 0 0 4px; }

  /* Under the paper: the things that never print. */
  :root.canon-v5 #editorView.is-v3 .v3-below > :first-child { margin-top: 16px; }

  /* ── The side panel ───────────────────────────────────────────────────── */
  :root.canon-v5 #editorView.is-v3 .v3-card {
    display: flex; flex-direction: column; border: 1px solid var(--c-border); border-radius: 10px;
    background: var(--c-card); box-shadow: var(--lift), var(--lift-edge);
  }
  :root.canon-v5 #editorView.is-v3 .v3-card__head { display: flex; align-items: center; gap: 8px; padding: 18px 20px 8px; }
  :root.canon-v5 #editorView.is-v3 .v3-card__head .pill { margin-left: auto; }
  :root.canon-v5 #editorView.is-v3 .v3-chks { padding: 0 20px; }
  :root.canon-v5 #editorView.is-v3 .v3-chk { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; font-size: 13px; line-height: 1.45; color: var(--c-text-2); }
  :root.canon-v5 #editorView.is-v3 .v3-chk > i { flex: none; margin-top: 1px; font-size: 16px; }
  :root.canon-v5 #editorView.is-v3 .v3-chk b { font-weight: 500; color: var(--c-text); }
  :root.canon-v5 #editorView.is-v3 .v3-chk.is-ok > i { color: var(--c-on-wash-ok); }
  :root.canon-v5 #editorView.is-v3 .v3-chk.is-need > i { color: var(--c-on-wash-warn); }
  :root.canon-v5 #editorView.is-v3 .v3-chk.is-na > i { color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-sec { padding: 14px 20px 0; }
  :root.canon-v5 #editorView.is-v3 .v3-sec > .cap { display: block; margin-bottom: 8px; }
  :root.canon-v5 #editorView.is-v3 .v3-step { display: flex; gap: 8px; padding: 3px 0; font-size: 13px; color: var(--c-text-2); }
  :root.canon-v5 #editorView.is-v3 .v3-step i { flex: none; font-size: 15px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-step b { font-weight: 600; color: var(--c-text); }

  /* A delivery channel, as a switch. */
  :root.canon-v5 #editorView.is-v3 .v3-chan {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
    border: 1px solid var(--c-border); border-radius: 6px; background: var(--c-card);
    font-family: inherit; color: var(--c-text); text-align: left; cursor: pointer;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  :root.canon-v5 #editorView.is-v3 .v3-chan + .v3-chan { margin-top: 6px; }
  :root.canon-v5 #editorView.is-v3 .v3-chan:hover:not(:disabled) { border-color: var(--c-border-2); }
  :root.canon-v5 #editorView.is-v3 .v3-chan[aria-checked="true"] { border-color: var(--c-accent-edge); background: var(--c-accent-soft); }
  :root.canon-v5 #editorView.is-v3 .v3-chan:disabled { cursor: default; background: var(--c-sunken); }
  :root.canon-v5 #editorView.is-v3 .v3-chan > i { flex: none; font-size: 17px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-chan__t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
  :root.canon-v5 #editorView.is-v3 .v3-chan__t b { font-size: 13px; font-weight: 500; }
  :root.canon-v5 #editorView.is-v3 .v3-chan__t small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-sw {
    position: relative; flex: none; width: 30px; height: 18px; border-radius: 999px; background: var(--c-border-2);
    transition: background var(--dur) var(--ease);
  }
  :root.canon-v5 #editorView.is-v3 .v3-sw::after {
    content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%;
    background: var(--c-card); box-shadow: var(--lift); transition: transform var(--dur) var(--ease);
  }
  :root.canon-v5 #editorView.is-v3 [aria-checked="true"] > .v3-sw { background: var(--c-cta); }
  :root.canon-v5 #editorView.is-v3 [aria-checked="true"] > .v3-sw::after { transform: translateX(12px); }
  :root.canon-v5 #editorView.is-v3 .v3-chan:disabled > .v3-sw { visibility: hidden; }

  :root.canon-v5 #editorView.is-v3 .v3-links { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-lnk {
    padding: 0; border: 0; background: none; font-family: inherit; font-size: inherit; font-weight: 500;
    color: var(--c-on-wash-accent); cursor: pointer;
  }
  :root.canon-v5 #editorView.is-v3 .v3-lnk:hover { text-decoration: underline; text-underline-offset: 2px; }

  :root.canon-v5 #editorView.is-v3 .v3-go { padding: 16px 20px 18px; }
  :root.canon-v5 #editorView.is-v3 .v3-send { width: 100%; min-height: 40px; justify-content: center; gap: 8px; font-size: 14px; }
  :root.canon-v5 #editorView.is-v3 .v3-kbd {
    display: inline-flex; align-items: center; height: 18px; padding: 0 5px; border: 1px solid currentColor; border-radius: 3px;
    font-family: inherit; font-size: 10px; font-weight: 600; opacity: .8;
  }
  :root.canon-v5 #editorView.is-v3 .v3-note { margin: 10px 0 0; text-align: center; font-size: 11px; line-height: 1.5; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-alt { padding: 14px 20px 16px; border-top: 1px solid var(--c-border); }
  :root.canon-v5 #editorView.is-v3 .v3-alt > span { display: block; margin-bottom: 8px; font-size: 12px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-alt > div { display: flex; flex-wrap: wrap; gap: 6px; }
  :root.canon-v5 #editorView.is-v3 .v3-alt .btn-ghost { height: 28px; padding: 0 10px; font-size: 12px; }

  /* Issued: the one figure, what the customer did, the next move. */
  :root.canon-v5 #editorView.is-v3 .v3-figwrap { padding: 2px 20px 0; }
  :root.canon-v5 #editorView.is-v3 .v3-fig {
    font-family: "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums;
    font-size: 32px; font-weight: 600; line-height: 1.1; letter-spacing: -.035em; color: var(--c-text);
  }
  :root.canon-v5 #editorView.is-v3 .v3-fig.is-danger { color: var(--c-on-wash-danger); }
  :root.canon-v5 #editorView.is-v3 .v3-fig.is-ok { color: var(--c-on-wash-ok); }
  :root.canon-v5 #editorView.is-v3 .v3-sub { margin: 6px 0 0; font-size: 12px; color: var(--c-text-2); }
  :root.canon-v5 #editorView.is-v3 .v3-band {
    display: flex; align-items: flex-start; gap: 10px; margin: 14px 20px 0; padding: 10px 12px;
    border: 1px solid var(--c-accent-edge); border-radius: 6px; background: var(--c-accent-soft);
    font-size: 12px; line-height: 1.5; color: var(--c-on-wash-accent);
  }
  :root.canon-v5 #editorView.is-v3 .v3-band > i { flex: none; font-size: 16px; }
  :root.canon-v5 #editorView.is-v3 .v3-tls { padding: 10px 20px 0; }
  :root.canon-v5 #editorView.is-v3 .v3-tl { position: relative; display: flex; align-items: baseline; gap: 10px; padding: 6px 0 6px 20px; font-size: 13px; }
  :root.canon-v5 #editorView.is-v3 .v3-tl::before {
    content: ""; position: absolute; left: 4px; top: 22px; bottom: -6px; width: 1px; background: var(--c-border);
  }
  :root.canon-v5 #editorView.is-v3 .v3-tl:last-child::before { display: none; }
  :root.canon-v5 #editorView.is-v3 .v3-tl__dot {
    position: absolute; left: 0; top: 11px; width: 9px; height: 9px; border-radius: 50%;
    border: 2px solid var(--c-border-2); background: var(--c-card);
  }
  :root.canon-v5 #editorView.is-v3 .v3-tl.is-done .v3-tl__dot { border-color: var(--c-ok); background: var(--c-ok); }
  :root.canon-v5 #editorView.is-v3 .v3-tl.is-now .v3-tl__dot { border-color: var(--c-accent); background: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }
  :root.canon-v5 #editorView.is-v3 .v3-tl__t { flex: 1; min-width: 0; color: var(--c-text); }
  :root.canon-v5 #editorView.is-v3 .v3-tl__w { flex: none; font-family: "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--c-cap); }
  :root.canon-v5 #editorView.is-v3 .v3-foot-note { margin: 0; padding: 10px 20px 16px; border-top: 1px solid var(--c-border); font-size: 12px; color: var(--c-cap); }

  /* ── Below 1024px: the panel follows the paper, and a bar holds the verb ── */
  :root.canon-v5 #editorView.is-v3 .v3-mbar { display: none; }
  @media (max-width: 1023px) {
    :root.canon-v5 body.has-doc-v3 { padding-bottom: 76px; }
    :root.canon-v5 #editorView.is-v3 .v3-mbar:not([hidden]) {
      position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
      display: flex; align-items: center; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
      border-top: 1px solid var(--c-border); background: var(--c-surface);
    }
    :root.canon-v5.nd-tabbar #editorView.is-v3 .v3-mbar:not([hidden]) { bottom: var(--nd-tabbar-h, 64px); }
    :root.canon-v5 #editorView.is-v3 .v3-mbar__fig { display: flex; flex-direction: column; min-width: 0; }
    :root.canon-v5 #editorView.is-v3 .v3-mbar__fig small {
      font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--c-cap);
    }
    :root.canon-v5 #editorView.is-v3 .v3-mbar__fig b {
      font-family: "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600; color: var(--c-text);
    }
    :root.canon-v5 #editorView.is-v3 .v3-mbar .btn-primary { min-height: 44px; margin-left: auto; padding: 0 20px; font-size: 14px; }
    /* A draft's panel lives in the sheet the bar opens — drawn inline as well it
       would be the same controls twice. An issued document keeps it inline: it is
       the record of what the customer did, not a control. */
    :root.canon-v5 #editorView.is-v3:not(.is-v3-ro) .v3-side:not(.is-sheet) { display: none; }
    /* No keyboard to press it on. */
    :root.canon-v5 #editorView.is-v3 .v3-kbd { display: none; }
    /* The send panel as a bottom sheet, opened from the bar. */
    :root.canon-v5 #editorView.is-v3 .v3-side.is-sheet {
      position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-height: 88vh; overflow-y: auto;
      padding-bottom: env(safe-area-inset-bottom);
    }
    :root.canon-v5 #editorView.is-v3 .v3-side.is-sheet .v3-card { border-radius: 16px 16px 0 0; box-shadow: var(--float); }
    :root.canon-v5 #editorView.is-v3 .v3-side.is-sheet .v3-send,
    :root.canon-v5 #editorView.is-v3 .v3-side.is-sheet .v3-chan { min-height: 44px; }
  }
  :root.canon-v5 .v3-scrim { position: fixed; inset: 0; z-index: 55; background: color-mix(in srgb, var(--c-text) 38%, transparent); }

  /* ── Phone: the paper narrows and the lines become cards ──────────────── */
  @media (max-width: 640px) {
    :root.canon-v5 #editorView.is-v3 .v3-letter { padding: 14px 16px; }
    :root.canon-v5 #editorView.is-v3 .v3-letter__doc { display: none; }
    :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid { padding: 16px 16px 4px; }
    :root.canon-v5 #editorView.is-v3 .v3-chips { padding: 8px 16px 16px; }
    :root.canon-v5 #editorView.is-v3 .v3-paper .items-head { padding: 14px 16px 10px; }
    :root.canon-v5 #editorView.is-v3 .v3-paper #priceDisplayRow { margin: 0 16px 10px; }
    :root.canon-v5 #editorView.is-v3 .v3-addline { padding: 0 16px; }
    :root.canon-v5 #editorView.is-v3 .v3-foot { padding: 4px 16px 14px; }
    :root.canon-v5 #editorView.is-v3 .v3-foot .ed-totals { width: 100%; }
    :root.canon-v5 #editorView.is-v3 .v3-terms { padding: 12px 16px; }
    :root.canon-v5 #editorView.is-v3 .v3-paper .ed-grid input:not([type="checkbox"]):not([type="radio"]) { height: 42px; font-size: 16px; }

    /* Each line a card: description across the top, the numbers under it. The
       cells already carry data-label (core/ui/lineitems.js) for exactly this. */
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items,
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items tbody { display: block; overflow: visible; }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items thead { display: none; }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items tr {
      position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px;
      padding: 12px 16px; border-bottom: 1px solid var(--c-border);
    }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td { display: block; padding: 0; border: 0; }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td:first-child,
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td:last-child { padding: 0; }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td.dragcell { display: none; }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td.it-desc { grid-column: 1 / -1; padding-right: 64px; }
    :root.canon-v5 #editorView.is-v3.is-v3-ro .v3-paper table.ed-items td.it-desc { padding-right: 0; }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td[data-label]::before {
      content: attr(data-label); display: block; margin-bottom: 3px;
      font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--c-cap);
    }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td.num { grid-column: 1 / -1; text-align: right; font-size: 15px; }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td.it-actions { position: absolute; top: 10px; right: 12px; display: flex; gap: 2px; }
    /* The expand-to-edit button would sit under the line's own actions; on a phone
       the description box is already full width, so it goes. */
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items .it-desc-expand { display: none; }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items tr.li-heading,
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items tr.li-text { grid-template-columns: minmax(0, 1fr); }
    :root.canon-v5 #editorView.is-v3 .v3-paper table.ed-items td input:not([type="checkbox"]):not([type="radio"]) { height: 40px; font-size: 16px; }
  }

  /* ── "See what they get" ──────────────────────────────────────────────── */
  :root.canon-v5 .v3-pv {
    position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: color-mix(in srgb, var(--c-text) 38%, transparent);
  }
  :root.canon-v5 .v3-pv__box {
    display: flex; flex-direction: column; width: min(720px, 100%); max-height: 100%; overflow: hidden;
    border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-card); box-shadow: var(--float);
  }
  :root.canon-v5 .v3-pv__head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--c-border); }
  :root.canon-v5 .v3-pv__head h3 { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 600; color: var(--c-text); }
  :root.canon-v5 .v3-pv__x {
    display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 6px;
    background: transparent; color: var(--c-cap); font-size: 18px; cursor: pointer;
  }
  :root.canon-v5 .v3-pv__x:hover { background: var(--c-card-2); color: var(--c-text); }
  :root.canon-v5 .v3-seg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--c-border); border-radius: 6px; background: var(--c-sunken); }
  :root.canon-v5 .v3-seg button {
    padding: 4px 10px; border: 0; border-radius: 4px; background: transparent;
    font-family: inherit; font-size: 12px; font-weight: 500; color: var(--c-cap); cursor: pointer;
  }
  :root.canon-v5 .v3-seg button[aria-selected="true"] { background: var(--c-card); color: var(--c-text); box-shadow: var(--lift); }
  :root.canon-v5 .v3-pv__body { overflow-y: auto; padding: 16px; background: var(--c-card-2); }
  :root.canon-v5 .v3-pv__meta { margin: 0 0 10px; font-size: 12px; line-height: 1.5; color: var(--c-text-2); }
  :root.canon-v5 .v3-pv__meta b { font-weight: 600; color: var(--c-text); }
  /* The email is the customer's own copy: a white page in both themes, as it
     will arrive. The frame is sandboxed with no scripts. */
  :root.canon-v5 .v3-pv__frame { display: block; width: 100%; height: 520px; border: 1px solid var(--c-border); border-radius: 6px; background: var(--c-surface); }
  :root.canon-v5 .v3-pv__bubble {
    max-width: 340px; padding: 12px 14px; border: 1px solid var(--c-border); border-radius: 18px 18px 18px 4px;
    background: var(--c-card); font-size: 14px; line-height: 1.5; color: var(--c-text); white-space: pre-wrap; overflow-wrap: anywhere;
  }
  :root.canon-v5 .v3-pv__fine { margin: 12px 0 0; font-size: 11px; color: var(--c-cap); }
  @media (max-width: 640px) {
    :root.canon-v5 .v3-pv { align-items: flex-end; padding: 0; }
    :root.canon-v5 .v3-pv__box { max-height: 92vh; border-radius: 16px 16px 0 0; }
    :root.canon-v5 .v3-pv__head { flex-wrap: wrap; }
    :root.canon-v5 .v3-pv__frame { height: 60vh; }
  }

  /* ── The stepper's bad-news tones (docsteps.js `tone`) — flag-independent:
     an overdue invoice was drawn in the accent like any current step. ───── */
  :root.canon-v5 .ui-steps__step.is-now.is-danger {
    border-color: color-mix(in srgb, var(--c-danger) 36%, transparent); background: var(--c-danger-soft); color: var(--c-on-wash-danger);
  }
  :root.canon-v5 .ui-steps__step.is-now.is-warn {
    border-color: color-mix(in srgb, var(--c-warn) 34%, transparent); background: color-mix(in srgb, var(--c-warn) 10%, transparent); color: var(--c-on-wash-warn);
  }
}
