/* Labels web UI (rebuild 2026-11-27, polish pass 2026-11-30: POLISH-2026-11-30.md).
   One set of tokens and one set of components; views build only from these
   (core.js has the builders). A look that two views need is a component here,
   never a copy. --control: input borders, 3:1 against the surface (WCAG 1.4.11);
   --line stays the soft divider. Text greys (raised 2026-11-30 after Ian found
   the UI hard to read at AA): --muted >= 7:1 and --faint >= 5.8:1 on every
   background, light and dark. Lists sit on --surface, not on --ground. */
:root{
  font-size:100%;color-scheme:light;
  --ground:#F2F4F7;--surface:#FFF;--raised:#F6F8FA;--ink:#131922;--muted:#46515D;
  --faint:#55606C;--line:#D3DAE1;--control:#8794A1;--line-soft:#E3E8ED;--accent:#2F4F8F;--accent-soft:#E4EAF5;
  --accent-ink:#FFF;--ok:#0D7360;--okbg:#E5F4EF;--warnbg:#FDF3E3;--warnink:#8A5A12;--warnline:#E8CFA0;
  --errbg:#FCEDEC;--errink:#9B2C22;--errline:#EDC4C0;--stock:#FFF;--stock-ring:#AEB9C5;--liner:#DDE2E8;
  --shadow-pop:0 10px 30px rgba(0,0,0,.16);--shadow-hover:0 4px 14px rgba(0,0,0,.08);
  --ease-out:cubic-bezier(.23,1,.32,1);--press:120ms var(--ease-out);
  --sans:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  --mono:"IBM Plex Mono",ui-monospace,Menlo,monospace;
  /* Spacing: 4 8 12 16 24 32 48. Groups sit twice as far apart as their parts. */
  --s1:4px;--s2:8px;--s3:12px;--s4:16px;--s5:24px;--s6:32px;--s7:48px;
  --r-s:6px;--r:8px;--r-l:12px;
  /* Control height: 36 px with a mouse, 44 px wherever a finger taps. */
  --h:36px;--h-small:30px;--h-big:44px;
  --thumb-w:96px;--thumb-h:58px;
  --bar:60px;
}
@media (prefers-color-scheme:dark){:root{
  color-scheme:dark;
  --ground:#12161C;--surface:#1A2029;--raised:#212934;--ink:#E4E9EF;--muted:#AEB8C4;
  --faint:#9CA7B4;--line:#2A333E;--control:#6A7684;--line-soft:#222A34;--accent:#86A8E6;--accent-soft:#1E2A3E;
  --accent-ink:#0E1420;--ok:#45C0A4;--okbg:#14302A;--warnbg:#2E2716;--warnink:#E3BE74;--warnline:#4A3C1E;
  --errbg:#2E1A18;--errink:#E99189;--errline:#4C2723;--stock:#FAFBFC;--stock-ring:#495666;--liner:#3A4452;
  --shadow-pop:0 10px 30px rgba(0,0,0,.5);--shadow-hover:0 4px 14px rgba(0,0,0,.3);
}}
@media (pointer:coarse),(max-width:640px){:root{--h:44px;--h-small:44px;--h-big:48px;--thumb-w:72px;--thumb-h:44px}}

*{box-sizing:border-box}
[hidden]{display:none!important}
html{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;scroll-padding-top:calc(var(--bar) + 12px);
  -webkit-tap-highlight-color:transparent}
body{margin:0;background:var(--ground);color:var(--ink);font:0.9375rem/1.5 var(--sans);min-height:100dvh}
a{color:var(--accent);text-underline-offset:2px}
h1,h2,h3{margin:0;text-wrap:balance}
h1{font-size:1.5rem;font-weight:650;line-height:1.2;letter-spacing:-.02em;overflow-wrap:anywhere}
h2{font-size:1rem;font-weight:600;line-height:1.3;letter-spacing:-.01em}
p{margin:0}
.mono{font-family:var(--mono)}
.grow{flex:1;min-width:0}
/* Text styles: body, caption (secondary, 13 px), eyebrow (a group's name). */
.caption{font-size:.8125rem;line-height:1.45;color:var(--muted);text-wrap:pretty}
.caption.ok{color:var(--ok)}.caption.bad{color:var(--errink)}.caption.warn{color:var(--warnink)}
.eyebrow{font-size:.75rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
button,input,select,textarea{font:inherit;touch-action:manipulation}

/* ------------------------------------------------------------------ bar */
.bar{position:sticky;top:0;z-index:20;height:var(--bar);display:flex;align-items:center;gap:20px;
  padding:0 20px;background:color-mix(in srgb,var(--surface) 80%,transparent);
  -webkit-backdrop-filter:blur(20px) saturate(180%);backdrop-filter:blur(20px) saturate(180%);
  border-bottom:1px solid var(--line)}
.brand{font-weight:650;font-size:1rem;letter-spacing:-.02em;color:var(--ink);text-decoration:none;white-space:nowrap}
.nav{display:flex;gap:2px;min-width:0;overflow-x:auto;scrollbar-width:none}
.nav::-webkit-scrollbar{display:none}
.nav a{display:inline-flex;align-items:center;gap:6px;height:var(--h);padding:0 12px;border-radius:var(--r);
  color:var(--muted);text-decoration:none;font-size:.875rem;font-weight:500;white-space:nowrap}
/* The nav scrolls sideways, which clips anything drawn outside a link: the ring goes inside. */
.nav a:focus-visible{outline-offset:-2px}
.nav a[aria-current="page"]{color:var(--ink);background:var(--raised)}
.count{display:inline-block;min-width:1.25rem;padding:0 6px;border-radius:999px;background:var(--accent);
  color:var(--accent-ink);font-size:.6875rem;font-weight:600;line-height:1.25rem;text-align:center;
  font-variant-numeric:tabular-nums}
.count:empty{display:none}
.bar .printer{margin-left:0}
/* Search: a quiet field-shaped button in the bar; ⌘K opens the same palette. */
.search-trigger{margin-left:auto;display:inline-flex;align-items:center;gap:8px;height:var(--h);padding:0 8px 0 10px;
  border:1px solid var(--line);border-radius:var(--r);background:var(--surface);color:var(--muted);font-size:.875rem;
  cursor:pointer;transition:transform var(--press)}
.search-trigger svg{width:16px;height:16px}
.search-trigger:active{transform:scale(.97)}
.search-key,.palette-esc{font:500 .6875rem/1 var(--sans);color:var(--muted);padding:3px 5px;border:1px solid var(--line);
  border-radius:4px;background:var(--raised)}
@media (hover:hover){.search-trigger:hover{color:var(--ink);border-color:var(--control)}}
@media (pointer:coarse){.search-key{display:none}}
@media (max-width:860px){.search-label,.search-key{display:none}.search-trigger{width:var(--h);justify-content:center;padding:0}}
/* ------------------------------------------------------------ palette */
.palette{width:min(640px,calc(100vw - 24px));max-height:min(520px,calc(100dvh - 120px));margin:12vh auto auto;padding:0;
  border:1px solid var(--line);border-radius:var(--r-l);background:var(--surface);color:var(--ink);
  box-shadow:var(--shadow-pop);overflow:hidden;overscroll-behavior:contain}
.palette[open]{display:flex;flex-direction:column}
.palette::backdrop{background:rgba(10,14,20,.35)}
@media (prefers-color-scheme:dark){.palette::backdrop{background:rgba(0,0,0,.55)}}
.palette-field{display:flex;align-items:center;gap:10px;padding:0 14px;border-bottom:1px solid var(--line-soft)}
.palette-glass{display:inline-flex;color:var(--muted)}.palette-glass svg{width:18px;height:18px}
.palette .palette-input{flex:1;min-width:0;height:52px;padding:0;border:0;border-radius:0;background:none;color:var(--ink);
  font-size:1.0625rem;box-shadow:none;outline:none}
/* The whole palette is the focused control: no ring around the field inside it. */
.palette .palette-input:focus-visible{outline:none;box-shadow:none}
.palette-input::-webkit-search-cancel-button{display:none}
.palette-list{overflow-y:auto;overscroll-behavior:contain;padding:6px}
.palette-head{padding:10px 10px 4px;font-size:.75rem;font-weight:600;color:var(--muted)}
.palette-option{display:grid;grid-template-columns:40px minmax(0,1fr) auto;align-items:center;gap:12px;
  min-height:48px;padding:6px 10px;border-radius:var(--r);cursor:pointer}
.palette-option[aria-selected="true"]{background:var(--accent-soft)}
.palette-thumb{display:flex;align-items:center;justify-content:center;width:40px;height:28px;border-radius:4px;
  background:var(--raised);color:var(--muted);overflow:hidden}
.palette-thumb img{width:100%;height:100%;object-fit:cover;background:var(--stock)}
.palette-thumb svg{width:18px;height:18px}
.palette-text{display:flex;flex-direction:column;min-width:0}
.palette-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}
.palette-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.8125rem;color:var(--muted)}
.palette-id{font-size:.8125rem;color:var(--muted)}
/* ------------------------------------------------------------- home */
.home{display:flex;flex-direction:column;gap:var(--s6)}
.home>.page-head{margin-bottom:calc(var(--s3) - var(--s6))}
.home-search{display:flex;align-items:center;gap:var(--s3);width:100%;max-width:40rem;height:52px;padding:0 12px 0 16px;
  border:1px solid var(--line);border-radius:var(--r-l);background:var(--surface);color:var(--muted);font-size:1rem;
  text-align:start;cursor:text;transition:transform var(--press)}
.home-search>span:first-child{display:inline-flex}.home-search svg{width:20px;height:20px}
.home-search:active{transform:scale(.99)}
@media (hover:hover){.home-search:hover{border-color:var(--control);color:var(--ink)}}
.home-section{display:flex;flex-direction:column;gap:var(--s3)}
.home-section-head{display:flex;align-items:baseline;justify-content:space-between;gap:var(--s3)}
.home-section-head a{font-size:.875rem;font-weight:500;text-decoration:none}
.quick{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:var(--s3)}
.quick-action{display:flex;flex-direction:column;align-items:flex-start;gap:var(--s3);min-height:44px;padding:var(--s4);
  border:1px solid var(--line-soft);border-radius:var(--r-l);background:var(--surface);color:var(--ink);font:inherit;
  text-align:start;text-decoration:none;cursor:pointer;transition:transform var(--press),box-shadow 160ms ease,border-color 160ms ease}
.quick-action:active{transform:scale(.98)}
.quick-action:disabled{opacity:.6;cursor:default}
@media (hover:hover){.quick-action:hover{border-color:var(--line);box-shadow:var(--shadow-hover)}}
.quick-icon{display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:10px;
  background:var(--accent-soft);color:var(--accent)}
.quick-icon svg,.todo-icon svg{width:22px;height:22px}
.quick-text{display:flex;flex-direction:column;gap:2px}
.quick-text b{font-weight:600}
.row-item>.thumb:has(.todo-icon){width:40px;height:40px;padding:0;display:flex;align-items:center;justify-content:center;background:var(--accent-soft);
  color:var(--accent);border-radius:var(--r)}
.todo-icon{display:inline-flex}
.home-none{padding:var(--s4) var(--s2)}
@media (max-width:860px){.quick{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:640px){.quick-action{flex-direction:row;align-items:center;padding:var(--s3)}
  .quick-text .caption{display:none}.home-search .search-key{display:none}}
.caption.learned{display:flex;align-items:center;gap:var(--s2);flex-wrap:wrap}
.palette-empty{padding:20px 10px;color:var(--muted)}
@media (max-width:640px){.palette{margin-top:8px;max-height:calc(100dvh - 16px)}.palette-esc{display:none}}

/* -------------------------------------------------------------- page */
main{max-width:1180px;margin:0 auto;padding:28px 20px 96px}
@media (min-width:860px){main{padding:40px 40px 96px}}
.page-head{display:flex;flex-direction:column;gap:var(--s1);margin-bottom:var(--s5)}
.page-head .title-row{display:flex;align-items:center;gap:var(--s3);min-height:var(--h);flex-wrap:wrap}
.page-head .actions{display:flex;align-items:center;gap:var(--s2);flex-wrap:wrap;margin-left:auto}
.page-head .caption{max-width:44rem}
.crumbs ol{display:flex;flex-wrap:wrap;align-items:center;margin:0;padding:0;list-style:none;font-size:.875rem}
.crumbs li{display:flex;align-items:center;min-width:0}
.crumbs li+li::before{content:"›";margin:0 8px;color:var(--faint)}
.crumbs a{display:inline-flex;align-items:center;min-height:28px;max-width:16rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  color:var(--muted);text-decoration:none}
.section{display:flex;flex-direction:column;gap:var(--s3)}
.section-head{display:flex;align-items:center;justify-content:space-between;gap:var(--s3);min-height:var(--h-small);flex-wrap:wrap}
.stack{display:flex;flex-direction:column;gap:var(--s6)}
.toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:var(--s4)}
.toolbar input[type=search]{flex:1;min-width:12rem;max-width:22rem}
.toolbar select{width:auto}
.two-col{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);gap:var(--s6);align-items:start}
.two-col>.side{position:sticky;top:calc(var(--bar) + 20px)}

/* Panel: the one raised surface (a group of drafts, a type, a scan, the label). */
.panel{display:flex;flex-direction:column;gap:var(--s3);padding:var(--s4);background:var(--surface);
  border:1px solid var(--line-soft);border-radius:var(--r-l);min-width:0}
.panel-foot{display:flex;align-items:center;gap:var(--s3);flex-wrap:wrap}
.panel.chosen{outline:2px solid var(--accent);outline-offset:-2px}

/* Empty state: what this place is, and the next step. */
.empty{max-width:30rem;margin:var(--s7) auto;display:flex;flex-direction:column;align-items:center;gap:var(--s2);text-align:center}
.empty b{font-size:1rem;font-weight:600}
.empty p{color:var(--muted);text-wrap:pretty}
.empty>:last-child:not(p):not(b){margin-top:var(--s2)}
.panel .empty,.section .empty{margin:var(--s4) auto}

/* ------------------------------------------------------------- controls */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:var(--h);padding:0 14px;
  border:1px solid var(--line);border-radius:var(--r);background:var(--surface);color:var(--ink);
  font-size:.875rem;font-weight:500;cursor:pointer;white-space:nowrap;text-decoration:none;
  transition:transform var(--press),background var(--press)}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.quiet{border-color:transparent;background:transparent;color:var(--muted)}
.btn.danger{color:var(--errink)}
.btn.small{height:var(--h-small);padding:0 10px;font-size:.8125rem}
.btn.big{height:var(--h-big);padding:0 22px;font-size:.9375rem}
.btn.icon{width:var(--h);padding:0}
.btn.small.icon{width:var(--h-small)}
.btn.icon svg{width:18px;height:18px;display:block}
.linkish{border:0;padding:0;background:none;color:var(--accent);font:inherit;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
/* Hover only where a pointer hovers: on touch, :hover sticks after a tap. */
@media (hover:hover){
  .btn:hover:not(:disabled):not(.primary),.nav a:hover,.menu .item:hover{background:var(--raised)}
  .nav a:hover,.crumbs a:hover,.btn.quiet:hover:not(:disabled):not(.danger){color:var(--ink)}
  .combo [role=option]:hover{background:var(--accent-soft)}
  .row-item.link:hover,.tile:hover,.card:hover{background:var(--raised)}
  .card:hover{box-shadow:var(--shadow-hover)}
}
/* Every press answers at once. */
:is(.btn,.segmented button,.chip,.printer>button,.combo .open,.card,.tile):active:not(:disabled){transform:scale(.97)}
.nav a:active,.menu .item:active,.row-item.link:active{background:var(--raised)}
:is(.segmented button,.chip,.printer>button,.combo .open,.card,.tile){transition:transform var(--press),background var(--press)}

input,select,textarea{font-size:.9375rem;color:var(--ink);background:var(--surface);border:1px solid var(--control);
  border-radius:var(--r);padding:0 10px;height:calc(var(--h) + 4px);width:100%;min-width:0}
textarea{height:auto;padding:8px 10px;resize:vertical;line-height:1.45}
/* A field shows focus with its own border and a soft halo; the transparent
   outline keeps a ring in forced-colors mode, where shadows are dropped. */
input:not([type=checkbox]):focus-visible,select:focus-visible,textarea:focus-visible{outline:2px solid transparent;outline-offset:0;
  border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in oklab,var(--accent) 28%,transparent)}
input[type=checkbox]{width:18px;height:18px;padding:0;margin:0;accent-color:var(--accent);flex:none}
select{appearance:none;-webkit-appearance:none;padding-right:30px;cursor:pointer;
  background:var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%23788492' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center}
::placeholder{color:var(--faint)}
[aria-invalid="true"]{border-color:var(--errink)}
/* Field: a label above its control, a hint or an error below. */
.field{display:flex;flex-direction:column;gap:5px;min-width:0}
.field>.name{font-size:.8125rem;font-weight:500;color:var(--muted)}
.field>.name em{font-style:normal;font-weight:400;color:var(--faint)}
.field .error{color:var(--errink);font-size:.75rem}
.field .error:empty{display:none}
.fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,12rem),1fr));gap:var(--s3)}
.check{display:inline-flex;align-items:center;gap:8px;min-height:var(--h);font-size:.875rem;cursor:pointer}
.segmented{align-self:flex-start;display:inline-flex;gap:2px;padding:3px;border-radius:9px;background:var(--raised);border:1px solid var(--line-soft);max-width:100%;overflow-x:auto;scrollbar-width:none}
.segmented button{height:calc(var(--h) - 4px);padding:0 12px;border:0;border-radius:6px;background:transparent;color:var(--muted);
  font-size:.8125rem;font-weight:500;cursor:pointer;white-space:nowrap}
.segmented button:focus-visible{outline-offset:-2px}
.segmented button[aria-pressed="true"]{background:var(--surface);color:var(--ink);box-shadow:0 1px 3px rgba(0,0,0,.12)}

/* Note: a sentence that needs attention, with its one fix beside it. */
.note{display:flex;align-items:center;gap:var(--s3);flex-wrap:wrap;border-radius:10px;padding:10px 12px;font-size:.875rem;
  background:var(--raised);border:1px solid var(--line-soft);text-wrap:pretty}
.note>.text{flex:1 1 14rem;min-width:0;overflow-wrap:anywhere}
.note.warn{background:var(--warnbg);border-color:var(--warnline);color:var(--warnink)}
.note.error{background:var(--errbg);border-color:var(--errline);color:var(--errink)}
.note.ok{background:var(--okbg);border-color:transparent;color:var(--ok)}
.note .btn{color:var(--ink)}
.notes{display:flex;flex-direction:column;gap:var(--s2)}
.notes:empty{display:none}

/* Tag: a short state word. Never color alone: the word carries it. */
.tag{display:inline-flex;align-items:center;gap:4px;font-size:.75rem;font-weight:600;color:var(--muted);background:var(--raised);
  border-radius:var(--r-s);padding:2px 7px;white-space:nowrap;line-height:1.5}
.tag:empty{display:none}
.tag.ok{color:var(--ok);background:var(--okbg)}
.tag.warn{color:var(--warnink);background:var(--warnbg)}
.tag.bad{color:var(--errink);background:var(--errbg)}

/* Dropzone: click, tap or drop files. */
.drop{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-height:9rem;padding:var(--s5) var(--s4);
  border:1.5px dashed var(--line);border-radius:var(--r-l);background:var(--surface);color:var(--muted);font-size:.8125rem;
  cursor:pointer;text-align:center;text-wrap:balance;transition:border-color var(--press),background var(--press)}
.drop b{color:var(--ink);font-weight:600;font-size:.9375rem}
.drop-icon{display:grid;place-items:center;width:40px;height:40px;margin-bottom:6px;border-radius:50%;background:var(--accent-soft);color:var(--accent)}
.drop-icon svg{width:22px;height:22px}
.drop:focus-visible{outline-offset:-1.5px;border-color:transparent}
@media (hover:hover){.drop:hover{border-color:var(--accent)}}
.drop.over{border-color:var(--accent);background:var(--accent-soft)}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{min-height:var(--h);padding:6px 10px;border:1px solid var(--line);border-radius:var(--r);background:var(--surface);color:var(--ink);font-size:.8125rem;cursor:pointer;text-align:start}
.chip:disabled{opacity:.5;cursor:not-allowed}
/* Settings: grouped rows, text left, control right. */
.settings{display:flex;flex-direction:column;gap:var(--s5);max-width:720px}
.settings h2{margin:0 0 var(--s2);font-size:.8125rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}
.setting-list{background:var(--surface);border:1px solid var(--line-soft);border-radius:var(--r-l)}
.setting{display:flex;align-items:center;gap:var(--s4);padding:var(--s3) var(--s4);min-height:56px}
.setting + .setting{border-top:1px solid var(--line-soft)}
.setting-text{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}
.setting-text b{font-weight:500}
/* Switch: 44 px wide track, the knob slides; state never by colour alone (knob side). */
.switch{position:relative;flex:none;width:44px;height:26px;padding:0;border:0;border-radius:999px;background:var(--control);
  cursor:pointer;transition:background 160ms ease}
.switch::before{content:"";position:absolute;inset:-9px -2px}
.switch .knob{position:absolute;top:2px;left:2px;width:22px;height:22px;border-radius:50%;background:#fff;
  box-shadow:0 1px 3px rgba(0,0,0,.25);transition:transform 200ms cubic-bezier(.23,1,.32,1)}
.switch[aria-checked="true"]{background:var(--accent)}
.switch[aria-checked="true"] .knob{transform:translateX(18px)}
.switch:disabled{opacity:.5;cursor:not-allowed}
@media (prefers-reduced-motion:reduce){.switch,.switch .knob{transition:none}}
/* The settings link in the bar: an icon button the height of Search. */
.bar-icon{display:inline-grid;place-items:center;width:var(--h);height:var(--h);border:1px solid var(--line);border-radius:var(--r);
  background:var(--surface);color:var(--muted)}
.bar-icon svg{width:18px;height:18px}
.bar-icon[aria-current="page"]{color:var(--ink);background:var(--raised)}
@media (hover:hover){.bar-icon:hover{color:var(--ink);border-color:var(--control)}}
/* filterBar: one row that scrolls sideways on a phone, wraps on a wide screen. */
.filters{display:flex;gap:8px;margin:0 -20px var(--s4);padding:0 20px;overflow-x:auto;scrollbar-width:none;
  overscroll-behavior-x:contain}
.filters::-webkit-scrollbar{display:none}
@media (min-width:720px){.filters{flex-wrap:wrap;margin-inline:0;padding:0}}
.chip.filter{display:inline-flex;align-items:center;gap:6px;flex:none;min-height:var(--h);padding:0 14px;border-radius:999px;font-size:.875rem;white-space:nowrap}
.chip-count{color:var(--faint);font-variant-numeric:tabular-nums;font-size:.8125rem}
.chip.filter[aria-pressed="true"]{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.chip.filter[aria-pressed="true"] .chip-count{color:inherit;opacity:.8}
@media (hover:hover){.chip.filter:hover:not(:disabled):not([aria-pressed="true"]){border-color:var(--accent)}}

/* Combobox: a text field with a list that always shows every suggestion. */
.combo{position:relative}
.combo input{padding-right:36px}
.combo .open{position:absolute;right:2px;top:2px;width:34px;height:calc(100% - 4px);border:0;background:transparent;
  color:var(--faint);cursor:pointer;border-radius:6px}
.combo [role=listbox]{position:absolute;left:0;min-width:100%;width:max-content;max-width:min(26rem,calc(100vw - 24px));top:calc(100% + 4px);z-index:30;margin:0;padding:4px;
  list-style:none;background:var(--surface);border:1px solid var(--line);border-radius:10px;
  box-shadow:var(--shadow-pop);max-height:16rem;overflow:auto;overscroll-behavior:contain}
.combo [role=option]{display:flex;align-items:baseline;gap:12px;min-height:40px;padding:9px 10px;border-radius:6px;cursor:pointer;font-size:.9375rem;overflow-wrap:anywhere}
.combo [role=option] .muted{color:var(--muted)}
.combo [role=option] .hint{color:var(--muted);font-size:.8125rem;white-space:nowrap}
.combo [role=option][aria-selected="true"]{background:var(--accent-soft)}

/* Menu: a popover list (printer control, New item). */
.popover{position:relative;display:inline-flex;flex-direction:column;gap:4px}
.menu{position:absolute;right:0;top:calc(100% + 6px);z-index:30;min-width:16rem;max-width:calc(100vw - 24px);padding:6px;background:var(--surface);
  border:1px solid var(--line);border-radius:var(--r-l);box-shadow:var(--shadow-pop);max-height:70vh;overflow:auto;overscroll-behavior:contain}
.menu .item{display:flex;align-items:center;gap:8px;width:100%;min-height:var(--h);padding:6px 10px;border:0;border-radius:var(--r);
  background:transparent;color:var(--ink);font-size:.875rem;text-align:start;cursor:pointer}
.menu .item:focus-visible{outline-offset:-2px}
.menu a.item{color:var(--ink);text-decoration:none}
.menu .item.danger{color:var(--errink)}
.menu .item.danger[data-armed]{background:var(--errbg);font-weight:600}
.menu .item[aria-checked="true"]{background:var(--raised)}
.menu .item[aria-checked="true"]::after{content:"✓";margin-left:auto;color:var(--accent)}
.menu .item .caption{margin-left:auto}
.menu .label{padding:6px 10px 2px;font-size:.75rem;color:var(--muted);font-weight:500}
.menu hr{border:0;border-top:1px solid var(--line-soft);margin:6px 0}
.menu .note{margin:4px}

/* Printer control: fixed width so nothing in the bar moves when it updates. */
.printer{position:relative}
.printer>button{display:flex;align-items:center;gap:8px;height:var(--h);width:15.5rem;padding:0 12px;
  border:1px solid var(--line);border-radius:var(--r);background:var(--surface);color:var(--ink);font-size:.8125rem;
  cursor:pointer;font-variant-numeric:tabular-nums}
.printer .dot{width:8px;height:8px;border-radius:50%;background:var(--faint);flex:none}
.printer .dot.on{background:var(--ok)}
.printer .what{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;text-align:start}

/* Dialog: a modal, here the photo viewer. */
.dialog{width:min(96vw,1100px);max-height:94vh;padding:0;border:0;border-radius:var(--r-l);background:var(--surface);color:var(--ink);overflow:hidden;overscroll-behavior:contain}
.dialog::backdrop{background:rgba(10,14,20,.72)}
.dialog img{display:block;width:100%;max-height:calc(94vh - 64px);object-fit:contain;background:#000}
/* The photo viewer (core.viewPhotos): the photo fills the stage, the step
   buttons sit on its edges, the bar says where you are and what it shows. */
.dialog.viewer:focus{outline:none}
.viewer-stage{position:relative;background:#000;touch-action:pan-y}
.viewer-stage img{height:min(80vh,calc(94vh - 64px))}
.viewer-step{position:absolute;top:50%;transform:translateY(-50%);width:44px;height:44px;border:0;border-radius:50%;
  background:rgba(20,24,30,.55);color:#fff;font-size:1.75rem;line-height:1;cursor:pointer;
  -webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);transition:background-color 120ms ease}
.viewer-step:active{transform:translateY(-50%) scale(.94)}
.viewer-step.prev{left:12px}.viewer-step.next{right:12px}
@media (hover:hover){.viewer-step:hover{background:rgba(20,24,30,.8)}}
.viewer-title{display:flex;align-items:baseline;gap:var(--s2);min-width:0}
.viewer-title>:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
img.zoom{cursor:zoom-in}
.dialog-bar{display:flex;align-items:center;gap:8px;padding:10px 12px;flex-wrap:wrap}

/* Select bar: what is chosen, and what to do with it. */
.selectbar{position:sticky;bottom:16px;z-index:10;display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-top:16px;padding:10px 12px;
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r-l);box-shadow:var(--shadow-pop)}

/* -------------------------------------------------------------- previews */
.stock{display:block;width:100%;height:auto;background:var(--stock);border-radius:6px;
  box-shadow:0 0 0 1px var(--stock-ring);image-rendering:pixelated}
.thumb{display:flex;align-items:center;justify-content:center;background:var(--raised);border-radius:var(--r);
  overflow:hidden;flex:none;color:var(--faint)}
.thumb img{max-width:100%;max-height:100%}
.thumb img.photo{width:100%;height:100%;object-fit:cover}
.thumb svg{width:22px;height:22px}
.stock-canvas{display:block;max-width:100%;max-height:100%;width:auto;height:auto;border-radius:4px}
.skeleton{background:linear-gradient(90deg,var(--raised),var(--line-soft),var(--raised));background-size:200% 100%;
  animation:shimmer 1.2s linear infinite;border-radius:var(--r)}
@keyframes shimmer{to{background-position:-200% 0}}
@media (prefers-reduced-motion:reduce){.skeleton{animation:none}
  :is(.btn,.segmented button,.chip,.printer>button,.combo .open,.card,.tile):active{transform:none}}

/* ------------------------------------------------------------ list rows */
/* A row: [checkbox] [thumbnail] title and details [trailing]. On a phone the
   trailing part moves under the details instead of squeezing them. */
/* A list is a white sheet: grey text on the grey page read poorly. */
.list{display:flex;flex-direction:column;padding:4px 12px;background:var(--surface);border:1px solid var(--line-soft);border-radius:var(--r-l)}
.list>.row-item:last-child{border-bottom:0}
.row-item{display:grid;grid-template-columns:auto auto minmax(0,1fr) auto;align-items:center;min-height:56px;
  padding:10px 8px;border-bottom:1px solid var(--line-soft);color:inherit;text-decoration:none;border-radius:0}
.row-item.link{cursor:pointer}
.row-item>.pick{grid-column:1;display:flex;align-items:center;justify-content:center;width:var(--h);height:var(--h);margin:-6px 6px -6px -8px;cursor:pointer}
.row-item>.thumb{grid-column:2;width:var(--thumb-w);height:var(--thumb-h);padding:4px;margin-right:14px}
.row-item>.main{grid-column:3;min-width:0;display:flex;flex-direction:column;gap:2px}
.row-item>.end{grid-column:4;display:flex;align-items:center;gap:8px;margin-left:14px;font-size:.8125rem;color:var(--muted);white-space:nowrap}
.row-item .title{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row-item .sub{font-size:.8125rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row-item .chev{color:var(--faint);font-size:1.1rem;line-height:1}
.row-item .thumb img{background:var(--stock);border-radius:3px}
.row-item .thumb img.photo{border-radius:0}
.list>.eyebrow{margin:18px 0 4px;padding-inline:8px}
.list>.eyebrow:first-child{margin-top:12px}
/* Off-screen rows skip rendering (~30 ms less layout per visit), so a row must
   be as tall unrendered as rendered: the height is fixed (thumb + 20px padding
   + 1px border). Until 2026-12-03 an unrendered row stood in at 77px content
   + padding = 98px against 79px rendered, so the list changed height under
   the saved position and Back landed rows away from where Ian left it. */
.items>.row-item{content-visibility:auto;height:calc(var(--thumb-h) + 21px)}

/* -------------------------------------------------------------- cards */
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(15rem,1fr));gap:14px}
.cards>.eyebrow{grid-column:1/-1;margin:14px 0 -2px}
.cards>.eyebrow:first-child{margin-top:0}
.card{display:flex;flex-direction:column;gap:10px;padding:12px;border:1px solid var(--line-soft);border-radius:var(--r-l);
  background:var(--surface);color:inherit;text-decoration:none}
.card .thumb{aspect-ratio:5/3;padding:10px}
.card-title{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:4px 8px}
.card b{font-size:.9375rem;font-weight:600}
/* Tile: one draft, or one printer row of drafts. The whole top opens it. */
.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(8.5rem,1fr));gap:var(--s3)}
.tiles.rows{grid-template-columns:repeat(auto-fill,minmax(17rem,1fr))}
.tile-wrap{display:flex;flex-direction:column;gap:var(--s2);padding:8px;border:1px solid var(--line-soft);border-radius:10px;background:var(--raised);min-width:0}
.tile-wrap.done{opacity:.6}
.tile{display:flex;flex-direction:column;gap:6px;width:100%;padding:0;border:0;border-radius:var(--r-s);background:none;color:inherit;font:inherit;text-align:start;cursor:pointer}
.tile .thumb{width:100%;aspect-ratio:5/3;background:transparent;padding:0}
.tile .thumb canvas{max-height:100%}
.tile .name{font-size:.875rem;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
.tile.row{flex-direction:row;align-items:center;gap:var(--s3)}
.tile.row .thumb{width:auto;height:132px;aspect-ratio:auto;flex:none}
.tile .slots{display:flex;flex-direction:column;gap:2px;font-size:.8125rem;min-width:0;flex:1}
.tile .slot{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tile .slot b{display:inline-block;width:1.1rem;color:var(--muted);font-variant-numeric:tabular-nums}
.tile .slot.done{color:var(--muted);text-decoration:line-through}
.tile-meta{display:flex;align-items:center;justify-content:space-between;gap:6px;flex-wrap:wrap}
.tile-desc{font-size:.75rem;color:var(--muted);display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
.tile-foot{display:flex;gap:6px;flex-wrap:wrap;margin-top:auto}
details.more>summary{cursor:pointer;font-size:.8125rem;line-height:24px;color:var(--muted);display:block;width:max-content;max-width:100%;white-space:nowrap;list-style:none;
  padding:2px 8px;margin-inline-start:-8px;border-radius:6px}
details.more>summary::-webkit-details-marker{display:none}
/* The native marker differs per browser, so the disclosure arrow is drawn here. */
details.more>summary::before{content:"›";display:inline-block;width:.6em;margin-right:6px;text-align:center;transition:transform var(--press)}
details.more[open]>summary::before{transform:rotate(90deg)}
details.more[open]>summary{margin-bottom:var(--s2)}
details.more .pre{white-space:pre-wrap;font-size:.8125rem;color:var(--muted)}
.inset{padding:10px 12px;border-radius:var(--r);background:var(--raised)}

/* ---------------------------------------------------------------- editor */
.editor-form{display:flex;flex-direction:column;gap:var(--s5)}
.lines{display:flex;flex-direction:column;gap:8px}
.lines:empty{display:none}
.line{display:grid;grid-template-columns:7.5rem minmax(0,1fr) var(--h);gap:8px;align-items:center}
.line .role{font-size:.8125rem;color:var(--muted)}
.form-actions{display:flex;align-items:center;gap:var(--s2);flex-wrap:wrap}
.form-actions .btn:last-child:not(:first-child){margin-left:auto}
.form-actions .btn.clear{margin-left:auto}
.stickers{display:grid;grid-template-columns:repeat(auto-fill,minmax(13rem,1fr));gap:12px}
.sticker{display:flex;flex-direction:column;gap:8px;padding:12px;border:1px solid var(--line-soft);border-radius:10px;background:var(--surface);min-width:0}
.sticker>.btn.quiet{align-self:flex-start}
.options{display:flex;flex-wrap:wrap;gap:16px 24px}
.barcode{display:grid;grid-template-columns:minmax(0,1fr) 9rem;gap:12px}
.preview{padding:var(--s5);background:var(--raised);border-radius:var(--r)}
.preview{--cap:min(60vh,34rem)}
.preview .frame{position:relative;width:100%;aspect-ratio:var(--ratio,5/3);max-height:var(--cap);margin:0 auto;display:flex;align-items:center;justify-content:center}
.preview .frame>img,.preview .frame>canvas{max-height:var(--cap)}
.preview .frame img{max-width:100%;width:auto;height:auto}
.preview .frame.pending canvas{opacity:.55;transition:opacity .15s}
.printbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.printbar .copies{display:flex;align-items:center;gap:8px;font-size:.875rem;color:var(--muted)}
.printbar .copies input{width:4.5rem;text-align:center}

/* ------------------------------------------------------------- item page */
.details{display:grid;grid-template-columns:minmax(6rem,max-content) minmax(0,1fr);gap:var(--s2) var(--s5);margin:0}
.details dt{color:var(--muted);font-size:.875rem}
.details dd{margin:0;overflow-wrap:anywhere}
.prose{overflow-wrap:anywhere;text-wrap:pretty;max-width:42rem;display:flex;flex-direction:column;gap:var(--s3)}
.prose :is(h3,h4){font-weight:600;margin:var(--s2) 0 0}
.prose h3{font-size:1rem}
.prose h4{font-size:.9375rem}
.prose :is(h3,h4)+*{margin-top:calc(var(--s3) / -2)}
.prose ul,.prose ol{margin:0;padding-inline-start:1.25rem;display:flex;flex-direction:column;gap:2px}
.prose code{font:.875em var(--mono);padding:1px 4px;border-radius:4px;background:var(--raised)}
.prose hr{width:100%;border:0;border-top:1px solid var(--line-soft);margin:var(--s2) 0}
.title-input{font-size:1.25rem;font-weight:600}
.kv{display:grid;grid-template-columns:minmax(0,.8fr) minmax(0,1.4fr) var(--h);gap:8px;align-items:center}
.files{display:grid;grid-template-columns:repeat(auto-fill,minmax(7.5rem,1fr));gap:10px}
.file{display:flex;flex-direction:column;gap:4px;font-size:.75rem;color:var(--muted);min-width:0}
.file .thumb{aspect-ratio:1;outline:1px solid oklch(0 0 0 / .1);outline-offset:-1px;text-decoration:none;color:var(--muted)}
.file .thumb img{width:100%;height:100%;object-fit:cover}
.file .name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.label-preview{display:flex;justify-content:center;padding:var(--s3);background:var(--raised);border-radius:10px}
/* Item page: one preview per printer; the picked one carries the accent ring. */
.label-variants{display:grid;grid-template-columns:repeat(auto-fit,minmax(9rem,1fr));gap:var(--s2)}
.label-variant{display:flex;flex-direction:column;gap:var(--s1);align-items:stretch;padding:var(--s1);border:0;border-radius:12px;
  background:none;color:inherit;font:inherit;text-align:center;cursor:pointer;box-shadow:0 0 0 1px var(--line-soft);
  transition:box-shadow 120ms ease,transform 120ms ease}
.label-variant:active{transform:scale(.98)}
.label-variant[aria-checked="true"]{box-shadow:0 0 0 2px var(--accent)}
.label-variant[aria-checked="true"] .caption{color:var(--ink)}
.label-variant .label-preview{height:100%;align-items:center}
.label-frame{width:100%;max-height:140px;border-radius:4px}
.label-preview img,.label-preview canvas{max-width:100%;max-height:140px;border-radius:4px;box-shadow:0 0 0 1px var(--stock-ring)}

/* ------------------------------------------------------------------ scan */
.scan-list{display:flex;flex-direction:column;gap:var(--s4)}
.scan{display:grid;grid-template-columns:112px minmax(0,1fr);gap:var(--s4);align-items:start}
.scan-photos{display:flex;flex-direction:column;gap:10px}
.scan-shot{display:flex;flex-direction:column;align-items:center;gap:2px}
.scan-photo{display:block;width:112px;height:112px;object-fit:cover;border-radius:var(--r);background:var(--raised)}
.scan-main{display:flex;flex-direction:column;align-items:flex-start;gap:10px;min-width:0}
.scan-head{display:flex;align-items:center;gap:4px;align-self:stretch;flex-wrap:wrap}
.values{display:flex;flex-direction:column;align-self:stretch;border:1px solid var(--line-soft);border-radius:10px;overflow:hidden}
.value-row{display:grid;grid-template-columns:8rem minmax(0,1fr) auto 3.25rem;gap:12px;align-items:center;min-height:var(--h);
  padding:8px 12px;border:0;border-top:1px solid var(--line-soft);background:none;color:var(--ink);font:inherit;text-align:start}
.value-row:first-child{border-top:0}
button.value-row{cursor:pointer}
.value-row .kind{font-size:.8125rem;color:var(--muted)}
.values.bare .value-row{grid-template-columns:minmax(0,1fr) auto 3.25rem}
.values.bare .value-row .kind{display:none}
.value-row .value{overflow-wrap:anywhere;font-size:.9375rem}
.value-row small{display:block;margin-top:2px;font-size:.75rem;color:var(--muted)}
.value-row small.also{color:var(--warnink)}
.value-row .copy{font-size:.75rem;color:var(--faint);text-align:end}
.value-row .copy.copied{color:var(--ok)}
/* Edit: the kind is a real menu, and there is nothing to copy. */
.editing .value-row{grid-template-columns:10rem minmax(0,1fr) auto}
.editing .value-row select{font-size:.8125rem}
.scan.editing{box-shadow:0 0 0 1.5px var(--accent)}
.scan-actions{display:flex;gap:8px;flex-wrap:wrap;align-self:stretch}
/* A card being saved or looked up keeps its layout; its buttons wait. */
.btn[aria-disabled="true"]{opacity:.55;cursor:default}
.scan[aria-busy="true"] .scan-actions .btn,.scan[aria-busy="true"] .scan-head .btn{pointer-events:none;opacity:.55}
/* Look up's proposal: the product, its properties as a two-column list, where it was found. */
.product{display:flex;flex-direction:column;gap:6px;align-self:stretch;padding:var(--s3) var(--s4);
  border:1px solid var(--line-soft);border-radius:10px;background:var(--raised)}
.product b{font-weight:600;overflow-wrap:anywhere;text-wrap:balance}
/* Specs as name/value pairs, as many columns as fit: eight specs in one
   column left most of a desktop card empty (2026-11-30). */
.product dl{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(13rem,calc(50% - 8px)),1fr));gap:6px 16px;
  margin:0;font-size:.875rem}
.product dl div{display:flex;flex-direction:column;min-width:0}
.product dt{color:var(--muted);font-size:.75rem}
.product dd{margin:0;overflow-wrap:anywhere}
.scan-text{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:.75rem;line-height:1.5;color:var(--muted);max-height:10rem;overflow:auto;overscroll-behavior:contain}
.clamp{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden}
@media (hover:hover){button.value-row:hover{background:var(--raised)}button.value-row:hover .copy:not(.copied){color:var(--ink)}}
/* A row of drop target once the page has content: the list is the point. */
.drop.compact{flex-direction:row;min-height:0;padding:12px var(--s4);gap:12px}
.drop.compact .drop-icon{margin:0;width:32px;height:32px}
.drop.compact .drop-icon svg{width:18px;height:18px}
.drop.compact span:not(.drop-icon){display:none}
@media (pointer:fine){.touch-only{display:none}}

/* ------------------------------------------------------------- parcels */
.parcel-pair{display:flex;gap:8px}
.parcel-pair .thumb{width:120px;aspect-ratio:424/240;height:auto;background:transparent}

@media (max-width:860px){
  .two-col{grid-template-columns:minmax(0,1fr)}
  .two-col>.side{position:static}
  .two-col.preview-first>.side{order:-1}
}
@media (max-width:640px){
  :root{--bar:108px}
  .bar{flex-wrap:wrap;align-content:center;gap:6px 10px;padding:6px 12px}
  .nav{order:3;width:calc(100% + 24px);margin:0 -12px;padding:0 6px;
    -webkit-mask-image:linear-gradient(90deg,#000 85%,transparent);mask-image:linear-gradient(90deg,#000 85%,transparent)}
  .printer>button{width:auto;max-width:13rem}
  main{padding:20px 14px 96px}
  .cards{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .card{padding:8px}
  .card>.caption{display:none}
  .row-item{grid-template-columns:auto auto minmax(0,1fr)}
  .row-item>.pick,.row-item>.thumb{grid-row:span 2}
  .row-item>.end{grid-column:3;margin:2px 0 0;white-space:normal}
  .row-item>.end:empty{display:none}
  .row-item .chev{display:none}
  .line{grid-template-columns:6rem minmax(0,1fr) var(--h)}
  .kv{grid-template-columns:minmax(0,1fr) var(--h)}
  .kv>input:first-child{grid-column:1/-1}
  .scan{grid-template-columns:minmax(0,1fr);gap:12px}
  .scan-photo{width:64px;height:64px}
  .scan-photos{flex-direction:row;overflow-x:auto;gap:8px}
  .value-row{grid-template-columns:minmax(0,1fr) auto 3.25rem;row-gap:2px}
  .value-row .kind{grid-column:1/-1}
  .editing .value-row{grid-template-columns:minmax(0,1fr) auto}
  .editing .value-row select{grid-column:1/-1;justify-self:start}
  .tile.row .thumb{height:112px}
  input,select,textarea{font-size:1rem}
  .details{grid-template-columns:minmax(0,1fr);gap:0}
  .details dd{margin-bottom:var(--s2)}
}
/* Wherever a finger taps, every target is at least 44 px (WCAG 2.5.5). Last,
   so it wins over the base rules above. */
@media (pointer:coarse),(max-width:640px){
  .brand,.crumbs a,.home-section-head a{min-height:44px;display:inline-flex;align-items:center}
  details.more>summary{line-height:40px}
  .segmented button{height:var(--h)}
}

/* Print labels (several items): a count per item, and every row of the print. */
.stepper{display:inline-flex;align-items:center;gap:2px;border:1px solid var(--line);border-radius:var(--r);background:var(--surface)}
.stepper-n{min-width:2ch;text-align:center;font-variant-numeric:tabular-nums;font-weight:600}
.print-rows{display:flex;flex-wrap:wrap;justify-content:center;align-items:flex-start;gap:12px;min-height:120px}
.print-rows>canvas{max-height:min(40vh,320px);max-width:100%;width:auto;height:auto}
.print-rows.pending>canvas{opacity:.55;transition:opacity .15s}

/* ------------------------------------------------------------------ sign-in (login.html) */
.signin{max-width:360px;margin:0 auto;min-height:100dvh;display:flex;flex-direction:column;justify-content:center;
  gap:var(--s4);padding:var(--s5)}
.signin .btn{width:100%}
