/* tokens.css — THE design system. ONE token family, one component vocabulary.
 *
 * Lineage: 1.6 deleted 5 competing token families + 24 copies of token(); this is the merged
 * survivor (--txt/--ink/--fg were three names for one slot). This pass GROWS that survivor into a
 * real system — full color/space/type/elevation scales + a semantic component layer — so screens
 * stop hand-rolling inline styles and inherit one look. See docs/DESIGN-SYSTEM.md.
 *
 * Two axes, kept independent:
 *   1. TENANT accent — set by the shell on <html data-tenant="lh"> (the tenant IS the accent:
 *      "you know where you are before you read a word"). Weak tints derive from it via color-mix,
 *      so a new tenant color flows everywhere for free.
 *   2. THEME (light/dark) — set by the shell on <html data-theme="…">; default follows the OS via
 *      prefers-color-scheme. Only the neutral + semantic tokens flip; components never re-declare.
 */

/* ---- DARK is the base (:root). Light is layered on top. ---------------------------------- */
:root {
  /* neutral ground → text, four surfaces + two borders + three text tiers.
     WARM-neutral (the readback "paper ground" look): the ramp carries a faint warm cast rather
     than the old cool blue-black, so the ground reads calm and the per-tenant accent pops off it. */
  --bg:        #1a1917;   /* warm charcoal — the cockpit-v3 mock's dark "ground" (was too-black #14130f) */
  --surface:   #232220;
  --surface-2: #2b2926;   /* raised / hover / inset */
  --card: var(--surface); /* back-compat alias — modules + atlas-bar.js read var(--card) */
  --line:      #302e2a;
  --line-2:    #3d3a34;   /* stronger divider / control border on hover */
  --txt:       #eceae4;
  --dim:       #98938a;   /* secondary text */
  --faint:     #6c685f;   /* tertiary / placeholder / captions */

  /* accent (per-tenant, overridden below) + tints derived from whatever it is.
     The ROOT default is CLAY — the warm terracotta of the Atlas Today / Readback prototypes. It
     only shows where no data-tenant is stamped (artifacts, tenant-less previews); every live tenant
     overrides it below, so this changes the prototype ground, never a company's identity colour. */
  --accent:      #c25a3c;
  --accent-weak: color-mix(in srgb, var(--accent) 15%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 40%, transparent);
  --accent-fg:   #fff8f2;                                   /* text on an accent fill */

  /* semantic — SEPARATE from accent (good / warning / critical / info), each with a weak fill.
     Semantic hues never bend to the tenant accent (docs/DESIGN-SYSTEM.md: accent ≠ semantic). */
  --ok:     #4fb85e;  --ok-weak:     color-mix(in srgb, var(--ok) 16%, transparent);
  --warn:   #e0a12a;  --warn-weak:   color-mix(in srgb, var(--warn) 17%, transparent);  /* was USED 12× but never defined */
  --danger: #ff6b6b;  --danger-weak: color-mix(in srgb, var(--danger) 15%, transparent);
  --info:   #3fb6c4;  --info-weak:   color-mix(in srgb, var(--info) 16%, transparent);  /* calm teal — "on track", never the accent */

  /* ---- STATE LANGUAGE — the ONE scanning layer, reused on every list / board / row. --------
     David: "auto colour coding — oh, the green ones are mine." Four states, the SAME hue on every
     surface, so state reads pre-attentively. COLOURBLIND-SAFE by construction: the .state chip /
     .sdot marker below always pair the hue with a distinct SHAPE and a word — colour is never the
     only carrier (mine=green and urgent=red are the classic confusion pair, so they get the most
     distinct shapes: disc vs diamond). Map, don't reinvent: these alias the semantic hues. */
  --state-mine:    var(--ok);     --state-mine-weak:    var(--ok-weak);      /* green  ● — yours to do        */
  --state-waiting: var(--warn);   --state-waiting-weak: var(--warn-weak);    /* amber  ◗ — waiting on someone */
  --state-urgent:  var(--danger); --state-urgent-weak:  var(--danger-weak);  /* red    ◆ — needs you now      */
  --state-track:   var(--info);   --state-track-weak:   var(--info-weak);    /* teal   ▪ — on track, no action */

  /* spacing scale (4px grid). --gap kept as the old name = --s3 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s8: 48px;
  --gap: var(--s3);

  /* radius scale. --radius kept as the old name = --r */
  --r-sm: 6px; --r: 8px; --r-lg: 14px; --r-pill: 999px;   /* --r-lg softened 12→14 toward the mocks' 13–16 */
  --radius: var(--r);
  /* the resting-card LIFT — the mocks' signature: a card floats a hair off the ground, not flat on
     it. Deliberately ONE value for both themes (like the mock), and far gentler than --shadow-1
     (which is for menus/popovers): a card at rest should be barely-there, felt not seen. */
  --card-lift: 0 1px 2px rgba(0,0,0,.05);

  /* type — one clean grotesque (Inter target, self-host later), mono for ids/figures */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --fs-caption: 11px; --fs-sm: 12px; --fs-body: 13.5px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 22px;

  /* elevation + focus */
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 12px 32px -12px rgba(0,0,0,.6);
  --ring: 0 0 0 3px var(--accent-weak);
  /* scrim — the darkening layer behind a slide-over / modal. One value for both themes: it dims
     whatever is under it, so it reads correctly on a light or a dark surface alike. */
  --scrim: rgba(0,0,0,.4);
}

/* ---- LIGHT — OS preference, unless the shell has stamped an explicit theme.
   Warm PAPER ground (off-white with a faint warm cast), warm-gray ink + borders: the light half of
   the readback look. Semantic + state hues carry through from :root unchanged. ------------------ */
@media (prefers-color-scheme: light) { :root:not([data-theme]) { color-scheme: light;
  --bg:#fafaf7; --surface:#ffffff; --surface-2:#f5f2eb; --line:#e8e4dc; --line-2:#dcd6cc;
  --txt:#22201c; --dim:#857f74; --faint:#b4afa4; --accent-fg:#fff8f2;
  --shadow-1:0 1px 2px rgba(40,32,20,.06); --shadow-2:0 14px 30px -12px rgba(40,32,20,.16);
} }
/* explicit toggle wins over the media query, both directions */
:root[data-theme="light"] { color-scheme: light;
  --bg:#fafaf7; --surface:#ffffff; --surface-2:#f5f2eb; --line:#e8e4dc; --line-2:#dcd6cc;
  --txt:#22201c; --dim:#857f74; --faint:#b4afa4; --accent-fg:#fff8f2;
  --shadow-1:0 1px 2px rgba(40,32,20,.06); --shadow-2:0 14px 30px -12px rgba(40,32,20,.16);
}
:root[data-theme="dark"] { color-scheme: dark;
  --bg:#1a1917; --surface:#232220; --surface-2:#2b2926; --line:#302e2a; --line-2:#3d3a34;
  --txt:#eceae4; --dim:#98938a; --faint:#6c685f; --accent-fg:#fff8f2;
  --shadow-1:0 1px 2px rgba(0,0,0,.4); --shadow-2:0 12px 32px -12px rgba(0,0,0,.6);
}

/* tenant accents — one hue per entity, so "which company am I in" is pre-attentive */
:root[data-tenant="lh"]    { --accent: #4c8dff; }  /* LH blue   */
:root[data-tenant="fh"]    { --accent: #3fb950; }  /* FH green  */
:root[data-tenant="wh"]    { --accent: #d29922; }  /* WH amber  */
:root[data-tenant="tc"]    { --accent: #a371f7; }  /* TC purple */
:root[data-tenant="atlas"] { --accent: #e05d9f; }  /* atlas pink — must NOT share LH's blue */
:root[data-tenant^="personal-"] { --accent: #8b949e; }  /* personal = neutral, not a company */

/* user-chosen accent — a PERSONAL override (per-browser preference) that wins over the tenant hue.
   Same specificity as the tenant rules above but later in source, so it takes precedence when present.
   Absent = follow the tenant. Set/cleared from the top-bar accent picker; -weak/-line derive from it. */
:root[data-accent="clay"]    { --accent: #c25a3c; }  /* warm terracotta — the Readback prototype ground */
:root[data-accent="blue"]    { --accent: #4c8dff; }
:root[data-accent="green"]   { --accent: #3fb950; }
:root[data-accent="amber"]   { --accent: #d29922; }
:root[data-accent="purple"]  { --accent: #a371f7; }
:root[data-accent="pink"]    { --accent: #e05d9f; }
:root[data-accent="teal"]    { --accent: #29a898; }
:root[data-accent="neutral"] { --accent: #8b949e; }

/* ============================================================================
   BASE ELEMENTS — every module already uses these; evolved, not renamed.
   ============================================================================ */
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: var(--fs-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font: inherit; font-size: var(--fs-body); font-weight: 500; line-height: 1;
  padding: 8px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--txt);
  cursor: pointer; transition: background .14s, border-color .14s, filter .14s;
}
button:hover { border-color: var(--line-2); background: var(--surface); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.primary:hover { background: var(--accent); filter: brightness(1.08); }
button.danger  { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover { background: var(--surface-2); color: var(--txt); }
button.sm { padding: 5px 9px; font-size: var(--fs-sm); }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  font: inherit; font-size: var(--fs-body); color: var(--txt);
  padding: 8px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg);
  transition: border-color .14s, box-shadow .14s;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: var(--ring); }
select { cursor: pointer; }
label { font-size: var(--fs-caption); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--dim); font-weight: 600; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .04em; }

h1, h2, h3 { text-wrap: balance; letter-spacing: -.01em; }

/* ============================================================================
   COMPONENT LAYER — the vocabulary screens reach for. All additive class names.
   ============================================================================ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); box-shadow: var(--card-lift); }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.muted { color: var(--dim); }

/* pill / badge — a quiet chip, and its semantic-severity variants */
.pill { display: inline-block; padding: 1px 8px; border-radius: var(--r-pill);
  border: 1px solid var(--line); font-size: var(--fs-sm); color: var(--dim); }
.badge { display: inline-block; font-size: var(--fs-caption); font-weight: 600; letter-spacing: .02em;
  padding: 3px 9px; border-radius: var(--r-pill); white-space: nowrap; }
.badge-neutral { color: var(--dim);   background: var(--surface-2); }
.badge-low     { color: var(--faint); background: var(--bg); border: 1px solid var(--line); }
.badge-ok      { color: var(--ok);     background: var(--ok-weak); }
.badge-warn    { color: var(--warn);   background: var(--warn-weak); }
.badge-danger  { color: var(--danger); background: var(--danger-weak); }
.badge-info    { color: var(--info);   background: var(--info-weak); }
.badge-accent  { color: var(--accent); background: var(--accent-weak); }

/* ---- STATE — the scanning layer, one vocabulary across every list / board / row. ----------
   .state is a labelled chip (shape glyph + word + colour); .sdot is the bare marker for dense rows.
   COLOURBLIND-SAFE: the glyph is a distinct SHAPE per state, so the state survives with colour
   stripped — never rely on hue alone. Always give a bare .sdot a title/aria-label (its word). */
.state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm);
  font-weight: 600; padding: 2px 9px 2px 7px; border-radius: var(--r-pill); white-space: nowrap; }
.state::before { content: ""; display: inline-block; width: 8px; height: 8px; flex: none; }
.sdot { display: inline-block; width: 9px; height: 9px; flex: none; vertical-align: middle; }
/* mine → green DISC · waiting → amber HALF · urgent → red DIAMOND · track → teal SQUARE.
   Shapes chosen so the red/green pair (urgent vs mine) never share a silhouette. */
.state-mine    { color: var(--state-mine);    background: var(--state-mine-weak); }
.state-waiting { color: var(--state-waiting); background: var(--state-waiting-weak); }
.state-urgent  { color: var(--state-urgent);  background: var(--state-urgent-weak); }
.state-track   { color: var(--state-track);   background: var(--state-track-weak); }
.state-mine::before,    .sdot.state-mine    { background: var(--state-mine);    border-radius: 50%; }
.state-waiting::before, .sdot.state-waiting { background: linear-gradient(90deg, var(--state-waiting) 50%, transparent 50%);
  border: 1.5px solid var(--state-waiting); border-radius: 50%; }
.state-urgent::before,  .sdot.state-urgent  { background: var(--state-urgent);  border-radius: 1px; transform: rotate(45deg); }
.state-track::before,   .sdot.state-track   { background: var(--state-track);   border-radius: 1px; }

/* segmented control — a set of exclusive quiet buttons (filters, view switches) */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r); }
.seg > button { border: 0; background: transparent; color: var(--dim); font-weight: 550;
  padding: 6px 13px; border-radius: var(--r-sm); }
.seg > button:hover { background: transparent; color: var(--txt); }
.seg > button[aria-pressed="true"], .seg > button.on { background: var(--accent-weak); color: var(--accent); }

/* field — a labelled control stack (caption over input) */
.field { display: flex; flex-direction: column; gap: 6px; }

/* list row — a dense, hoverable record row with an optional left severity stripe.
   The grid columns are set by the caller (they vary with what's shown). */
.trow { align-items: center; gap: var(--s3); padding: 10px 12px;
  border-top: 1px solid var(--line); border-left: 3px solid transparent; transition: background .12s; }
.trow:first-child { border-top: 0; }
.trow:hover { background: var(--surface-2); }
.trow.high   { border-left-color: var(--warn); }
.trow.urgent { border-left-color: var(--danger); }
.trow a.t { color: var(--txt); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.trow a.t:hover { color: var(--accent); text-decoration: none; }
.trow .over { color: var(--danger); font-weight: 600; }

/* warn callout — kept, now tokenized to --warn instead of a hardcoded brown/amber */
.warn { border: 1px solid var(--accent-line); border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: var(--warn-weak); color: var(--warn);
  padding: 10px 12px; border-radius: var(--r); font-size: var(--fs-body); }

/* tiny curated utility set — the handful of helpers worth having, deliberately not a framework */
.stack   { display: flex; flex-direction: column; gap: var(--s3); }
.cluster { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.spacer  { flex: 1; }
.tnum    { font-variant-numeric: tabular-nums; }
.mono    { font-family: var(--mono); }

/* KPI header — glanceable stat tiles (a leading row of headline numbers). Grown out of the
   hand-rolled stat tile that Invoicing/Reports each carried privately: ONE component now, so a
   KPI row reads the same everywhere and stays theme-aware for free. Each tile can carry a --src
   line (where the number came from) — the number is only trustworthy if it's traceable. */
.kpigrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s3); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kpi-k   { font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.kpi-v   { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-v.na { font-size: var(--fs-md); font-weight: 600; color: var(--faint); }
.kpi-sub { font-size: var(--fs-caption); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-src { font-size: var(--fs-caption); color: var(--faint); margin-top: 2px; }
.kpi-src::before { content: "↳ "; }

/* KPI enrichment (round-2 Stripe lens) — an OPTIONAL trend/delta/freshness layer on the same tile, so
   a money number can carry "is this good or bad, and how fresh?" without a click. Every piece is
   opt-in from the render helper (shell.js `kpiRow`); a bare tile shows none of it. Colour discipline:
   the sparkline is monochrome (--dim), and colour is spent ONLY on the ▲/▼ delta's semantic hue. */
.kpi-spark { width: 100%; height: 22px; margin: 3px 0 1px; display: block; overflow: visible; }
.kpi-cmp { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: var(--fs-caption);
  font-variant-numeric: tabular-nums; margin-top: 1px; }
.kpi-delta { font-weight: 700; }
.kpi-delta.up   { color: var(--ok); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--dim); }
.kpi-prior  { color: var(--dim); font-weight: 600; }
.kpi-cmplbl { color: var(--faint); }
.kpi-fresh { font-size: var(--fs-caption); color: var(--faint); margin-top: 2px; }
.kpi-fresh::before { content: "◷ "; }
.kpi-badge { margin: 4px 0 1px; }

/* ============================================================================
   HOST LAYOUT — the surface container (#host) the shell mounts every screen into.
   Width is a PER-SURFACE choice, not one hardcoded cap: a screen declares its
   measure (module `width`: "prose" | "normal" | "full", default "normal") and the
   shell stamps it as data-width on #host. Padding is uniform; only the measure
   changes — prose stays readable (~65ch), normal is the comfortable app column,
   full-bleed boards get the whole monitor. No inline cap, no dead gutters.
   ============================================================================ */
#host { padding: var(--s5) var(--s4); margin: 0 auto; width: 100%; }
#host[data-width="prose"]  { max-width: 65ch; }
#host[data-width="normal"] { max-width: none; }   /* edge-to-edge: every page uses the whole width (David 2026-08-10). `prose` (65ch) is the only reading cap; opt into it per-surface. */
#host[data-width="full"]   { max-width: none; }

/* ============================================================================
   SHELL CHROME — the two-row top bar + pin bar (styled by shell.js markup).
   ============================================================================ */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar-row { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s4); min-height: 48px; }
.topbar-row.row2 { min-height: 40px; border-top: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--accent); font-size: var(--fs-md); letter-spacing: -.01em; }

.topbar nav { display: flex; gap: 2px; margin-left: var(--s1); flex-wrap: wrap; }
.topbar nav button { background: transparent; border: 1px solid transparent; color: var(--dim);
  font-weight: 500; padding: 7px 11px; position: relative; }
.topbar nav button:hover { background: var(--surface-2); color: var(--txt); }
.topbar nav button[aria-current="page"] { color: var(--txt); background: var(--surface-2); }
.topbar nav button[aria-current="page"]::after { content: ""; position: absolute; left: 11px; right: 11px;
  bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }

.iconbtn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border-radius: var(--r-sm); background: transparent; border: 1px solid transparent; color: var(--dim); font-size: 15px; }
.iconbtn:hover { background: var(--surface-2); color: var(--txt); }

/* pin bar (row 2) — user-pinned surfaces as chips + a manage affordance */
.pinlabel { font-size: var(--fs-caption); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.pin { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: var(--fs-sm);
  font-weight: 500; padding: 5px 11px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--bg); }

/* ============================================================================
   KEYBOARD LAYER — a fast, self-teaching single-key layer over the list surfaces
   (shell.js initKeyNav). j/k move a selection through rows, e opens, x toggles
   done, c creates, / searches, ? opens the cheat-sheet. Everything here is pure
   presentation off the ONE token family; the behaviour is unchanged for the
   mouse — a row only wears .krow once someone reaches for the keys.
   ============================================================================ */
/* the selected row — a calm accent wash + a left stripe that reads "you are here",
   sitting on the same left-border slot .trow already reserves for severity. */
.krow { position: relative; background: var(--accent-weak) !important; border-left-color: var(--accent) !important; }
.kcard.krow { box-shadow: var(--ring); }

/* a keycap — the dim badge that teaches a shortcut. Used inline in the cheat-sheet
   and floated on a control by .keycue below. */
kbd.kkey { font: 600 var(--fs-caption)/1.5 var(--mono); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 1px 6px; color: var(--dim); }

/* self-teaching: a control marked .keycue (data-key="…") reveals its keycap just
   below itself on hover or keyboard focus — discover the key without a manual, and
   never in your way until you look for it. */
.keycue { position: relative; }
.keycue::after { content: attr(data-key); position: absolute; top: calc(100% + 4px); left: 50%;
  transform: translate(-50%, 3px); z-index: 40; pointer-events: none; white-space: nowrap;
  font: 600 var(--fs-caption)/1.4 var(--mono); background: var(--surface-2); color: var(--dim);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 1px 5px;
  opacity: 0; transition: opacity .15s, transform .15s; }
.keycue:hover::after, .keycue:focus-visible::after, .keycue:focus-within::after {
  opacity: 1; transform: translate(-50%, 0); }

/* the hint bar — a quiet status pill that appears the moment someone starts moving
   by keyboard, teaching the whole motion set at once, then gets out of the way. */
.knav-cue { position: fixed; left: 16px; bottom: 16px; z-index: 79; display: none; align-items: center;
  gap: 10px; background: var(--surface); color: var(--dim); border: 1px solid var(--line);
  border-radius: var(--r-pill); box-shadow: var(--shadow-2); padding: 6px 13px; font-size: var(--fs-sm);
  opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
.knav-cue.on { display: flex; opacity: 1; transform: translateY(0); }
.knav-cue kbd { font: 600 var(--fs-caption)/1.4 var(--mono); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 5px; color: var(--txt); }
@media (max-width: 640px) { .knav-cue { display: none !important; } }

/* the get-through-it drain — a quiet "N of M done" pill that sits just above the hint bar while a
   lane is being worked by keyboard, so the pile draining is felt. Same calm status vocabulary as the
   cue; goes accent-tinted the moment the lane is cleared. */
.klane-drain { position: fixed; left: 16px; bottom: 52px; z-index: 79; display: none;
  background: var(--surface); color: var(--txt); border: 1px solid var(--line);
  border-radius: var(--r-pill); box-shadow: var(--shadow-2); padding: 6px 13px;
  font-size: var(--fs-sm); font-weight: 600; letter-spacing: .2px;
  opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
.klane-drain.on { display: block; opacity: 1; transform: translateY(0); }
.klane-drain.done { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
@media (max-width: 640px) { .klane-drain { display: none !important; } }

/* MULTI-SELECT (batch-collapse) — the shipped lane cursor FLOWS the judged items one by one; this
   COLLAPSES the homogeneous batch you needn't visit, so a range gets ONE action. A marked row wears a
   filled accent stripe on the SAME left-border slot .krow uses for focus (the two stack: a row can be
   both focused AND marked). Pure presentation off the ONE token family; nothing shows until keys are
   used. */
.kmark { position: relative; background: var(--accent-weak) !important; border-left-color: var(--accent) !important; }
.kmark::before { content: ""; position: absolute; left: -1px; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.kcard.kmark { box-shadow: inset 3px 0 0 var(--accent); }

/* the bulk bar — one calm bar, bottom-centre, shown only while a range is marked: "N selected" plus
   the SAFE, reversible terminal verbs the marked rows already own (fired as ONE count-confirmed
   undo-toast). Off the same surface / line / shadow vocabulary as the cue and the toasts. */
.kbulk { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 8px); z-index: 80;
  display: none; align-items: center; gap: 12px; background: var(--surface); color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--r-pill); box-shadow: var(--shadow-2);
  padding: 8px 10px 8px 16px; font-size: var(--fs-sm); opacity: 0; transition: opacity .18s, transform .18s; }
.kbulk.on { display: flex; opacity: 1; transform: translate(-50%, 0); }
.kbulk .kbulk-n { font-weight: 600; letter-spacing: .2px; }
.kbulk .kbulk-sep { width: 1px; align-self: stretch; background: var(--line); margin: -2px 0; }
@media (max-width: 640px) { .kbulk { left: 12px; right: 12px; transform: translateY(8px); justify-content: center; flex-wrap: wrap; }
  .kbulk.on { transform: translateY(0); } }

/* ============================================================================
   ASSISTANT DOCK — the omnipresent chat bar (modules/chat), mounted by the shell
   as a chrome sibling of #host so it survives navigation. One component, on the
   tokens above, theme-aware for free.
   ============================================================================ */
.adock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.adock-panel, .adock-bar { pointer-events: auto; width: 100%; max-width: 1040px; }
.adock-bar { display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s4); background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: var(--shadow-2); }
.adock-bar input { flex: 1; }
.adock-spark { flex: none; width: 30px; height: 30px; padding: 0; cursor: pointer;
  border-radius: var(--r-pill); border: 1px solid var(--accent-line);
  background: var(--accent-weak); color: var(--accent); }
.adock-panel { display: flex; flex-direction: column; overflow: hidden;
  max-height: min(52vh, 440px); background: var(--surface);
  border: 1px solid var(--line); border-bottom: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-2); }
.adock-panel[hidden] { display: none; }
.adock-head { display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s4); border-bottom: 1px solid var(--line); }
.adock-thread { overflow-y: auto; padding: 0 var(--s4) var(--s2); }
.adock-msg { margin: var(--s3) 0; }
.adock-msg b { display: block; margin-bottom: 2px; }
.adock-msg.me > div { display: inline-block; background: var(--accent-weak);
  padding: var(--s2) var(--s3); border-radius: var(--r); }
.adock-prop { margin-top: var(--s2); padding: var(--s2) var(--s3); font-size: var(--fs-sm);
  color: var(--txt); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.adock-prop code { background: var(--bg); padding: 1px 5px; border-radius: var(--r-sm); color: var(--dim); }
.adock-draft { margin-top: var(--s1); padding: var(--s2); background: var(--surface);
  border-left: 2px solid var(--accent-line); border-radius: 0; }
.adock-run { background: var(--accent); color: var(--accent-fg); border: 1px solid var(--accent);
  border-radius: var(--r-sm); padding: 4px 12px; cursor: pointer; }
.adock-run:hover { filter: brightness(1.08); }
.adock-dismiss { background: transparent; color: var(--dim); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 4px 12px; cursor: pointer; margin-left: 4px; }
.adock-dismiss:hover { color: var(--txt); border-color: var(--line-2); }
.adock-done { color: var(--ok); font-size: var(--fs-sm); }
.pin:hover { color: var(--txt); border-color: var(--line-2); text-decoration: none; }
.pin[aria-current="page"] { color: var(--accent); border-color: var(--accent-line); background: var(--accent-weak); }
.pin .g { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.pin.add { color: var(--faint); border-style: dashed; }
.pin.add:hover { color: var(--txt); }

/* a dropdown menu surface (settings menu, pin picker) */
.menu { position: absolute; z-index: 40; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 6px; min-width: 200px; box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; gap: 2px; }
.menu button { text-align: left; border: none; border-radius: var(--r-sm); background: transparent; }
.menu button:hover { background: var(--surface-2); }

/* a SECTIONED dropdown — labelled groups under one trigger (the ⚙ workspace menu), so a long list
   of surfaces reads as a hierarchy instead of a flat dump. Caps its own height and scrolls. */
.menu-grouped { min-width: 244px; max-height: min(70vh, 520px); overflow-y: auto; }
.menu-label { padding: 8px 8px 2px; font-size: var(--fs-caption); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.menu-label:first-child { padding-top: 2px; }
.menu-lead { font-weight: 600; color: var(--txt); }         /* the promoted top entry (your Settings) */
.menu-sep { height: 1px; background: var(--line); margin: 6px 2px; }

/* GLOBAL FIND — the always-visible top-bar search (shell.js findBox). "Search is the reach": one box
   that finds any record or party from anywhere. The panel reuses .menu; only the input + rows are new. */
.findbox { position: relative; flex: 0 1 300px; min-width: 140px; }
.find-input { width: 100%; height: 32px; padding: 0 var(--s3); border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-sm); }
.find-input:focus { background: var(--surface); }
.findmenu { min-width: min(420px, 84vw); max-height: min(64vh, 460px); overflow-y: auto; padding: 4px; }
.find-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3);
  padding: 7px var(--s2); text-align: left; border: none; border-radius: var(--r-sm); background: transparent; width: 100%; }
.find-row:hover, .find-row.on { background: var(--surface-2); }
.find-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.find-name { color: var(--txt); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the preview line (who · status) + the content snippet — a calm second row so a hit reads without
   opening it. Both single-line and clipped so a long note can never blow out the palette. */
.find-sub { font-size: var(--fs-caption); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.find-snip { font-size: var(--fs-caption); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }
.find-kind { color: var(--faint); font-size: var(--fs-caption); flex: none; margin-top: 1px; }
/* a section label above a group (e.g. "Recent") — the palette's quiet heading. */
.find-head { padding: 6px var(--s2) 3px; font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .04em; }
.find-empty { padding: 8px var(--s2); font-size: var(--fs-sm); }

/* transient "Saved ✓" confirmation — notes autosave on blur (no Save button), so this fade-in is
   the only signal the write landed. Fades out after 3s; .show is toggled from JS (cockpit). */
.saved-flash { margin-left: 8px; font-size: var(--fs-caption); font-weight: 600; letter-spacing: 0;
  text-transform: none; color: var(--ok); opacity: 0; transition: opacity .25s ease; pointer-events: none; }
.saved-flash.show { opacity: 1; }

/* ============================================================================
   SLIDE-OVER SHEET — a review-and-release cockpit that opens IN CONTEXT over the
   current screen (the brief↔cockpit feel: act on a thing without losing your
   place). One component on the tokens above, theme-aware for free. Mounted by
   shell.openSheet(); the Outbox approval cockpit and the Inbox handling plan both
   ride it. Backdrop dims the page; the panel slides from the right (full-width on
   a phone). Above the assistant dock (z 60).
   ============================================================================ */
.sheet-backdrop { position: fixed; inset: 0; z-index: 70; background: color-mix(in srgb, var(--txt) 32%, transparent);
  opacity: 0; transition: opacity .18s ease; display: flex; justify-content: flex-end;
  /* isolate → a self-contained stacking context, so the overlay (z 70) reliably paints ABOVE the
   * sticky .topbar (z 30). Without it the sticky header's hoisted compositing layer bled THROUGH the
   * drawer, colliding with the sheet title and the command palette up top (live-verify, help overlay). */
  isolation: isolate; }
.sheet-backdrop.on { opacity: 1; }
.sheet { width: min(560px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2); display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(24px); transition: transform .18s ease; }
.sheet-backdrop.on .sheet { transform: translateX(0); }
.sheet-head { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s4);
  border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: var(--fs-lg); }
.sheet-head .sub { color: var(--dim); font-size: var(--fs-sm); margin-top: 2px; }
.sheet-x { margin-left: auto; flex: none; }
.sheet-body { padding: var(--s4); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: var(--s4); }
.sheet-foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
/* a labelled context block inside a sheet — "Situation", "Latest ask", "Draft" */
.sheet-sec > .lbl { font-size: var(--fs-caption); letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; margin-bottom: 6px; }
@media (max-width: 640px) { .sheet { width: 100%; border-left: none; } }

/* TOASTS — the one transient-notice surface, replacing native alert() for confirmations/info. Bottom
   centre, stacked, click to dismiss; colour-coded by kind off the semantic tokens (never a raw hex). */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: var(--s2); align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--surface); color: var(--txt); border: 1px solid var(--line);
  border-left: 3px solid var(--dim); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  padding: 10px 14px; font-size: var(--fs-sm); max-width: min(440px, 92vw); cursor: pointer;
  opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s; }
.toast.on { opacity: 1; transform: translateY(0); }
.toast-ok     { border-left-color: var(--ok); }
.toast-warn   { border-left-color: var(--warn); }
.toast-danger { border-left-color: var(--danger); }
.toast-info   { border-left-color: var(--info); }

/* update-nudge — the "a new version is available" bar (shell.startVersionWatch). One calm, dismissible
 * strip; sits just above where a toast would, off the same surface/line tokens so it belongs. */
.update-nudge { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px); z-index: 81;
  display: flex; align-items: center; gap: var(--s3); background: var(--surface); color: var(--txt);
  border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); padding: 10px 14px; font-size: var(--fs-sm); max-width: min(440px, 92vw);
  opacity: 0; transition: opacity .18s, transform .18s; }
.update-nudge.on { opacity: 1; transform: translate(-50%, 0); }
.update-nudge-msg { flex: 1; min-width: 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
