/* ===========================================================================
   admin.hemishthanki.com — the console's design language ("colour with a job").

   ONE stylesheet for the shell and every shared component. View files add only
   prefixed classes (ov- pp- ap- ac- st-) and never restyle an unprefixed class
   except through a prefixed ancestor — collisions across files broke the
   crossword once, so the rule is structural, not stylistic.

   The canvas is neutral warm paper; colour is carried by CONTENT: each app has a
   fixed hue (HC.appColor), each person a gradient from hash(id), and the accent
   (Settings → Appearance) marks only interaction and selection. Nothing here is
   encoded by colour alone — every coloured mark also carries a word or a number.

   Loaded ONLY by the console (Root/index.html). styles.css stays for the gate,
   the account pages and anything else that still links it; this file never
   touches them.
   =========================================================================== */

/* ------------------------------------------------------------ tokens ------- */
:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --panel: #ffffff;
  --panel2: #efece5;
  --panel3: #e6e2d8;
  --ink: #17181c;
  --ink2: #5d6068;
  --ink3: #8b8d94;              /* decoration only (≥3:1) — never body copy */
  --line: #e4e0d6;
  --line-strong: #d2cdc1;
  /* Status inks are dark enough to stay ≥ 4.5:1 on their own 13–15 % tints. */
  --ok: #146c3a;
  --warn: #8a4f00;
  --danger: #bf2636;
  --on-danger: #ffffff;
  --scrim: rgba(23, 24, 28, .38);
  --tip-bg: #17181c;
  --tip-ink: #f5f3ee;

  /* App/person hue tokens. HC.appColor builds oklch(L C <hue>) strings from
     these, so ONE hue per app reads correctly in both themes: the lightness and
     chroma move with the theme, the hue never does. Chosen for contrast:
     ink-on-tint and white-on-strong are both ≥ 4.5:1 for every hue. */
  --hue-l: .62;  --hue-c: .16;          /* solid marks: charts, dots, icon tiles */
  --hue-strong-l: .50;                  /* bands that carry white text */
  --hue-tint-l: .955; --hue-tint-c: .035;
  --hue-ink-l: .45;  --hue-ink-c: .14;  /* text on tint or on the panel */
  /* sRGB fallbacks for browsers without oklch() (see the @supports block). */
  --hsl-s: 62%; --hsl-l: 48%; --hsl-strong-l: 38%; --hsl-tint-l: 95%; --hsl-ink-l: 32%;

  --font-display: 'Google Sans', 'Google Sans Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Google Sans Text', 'Google Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --radius-btn: 12px;
  --topbar-h: 64px;
  --side-w: 248px;
  --main-max: 1240px;
  --pad: 20px;          /* card inset; density=compact tightens these ~25 % */
  --pad-sm: 12px;
  --gap: 16px;
  --ctl-h: 40px;
  --row-h: 56px;

  --e1: 0 1px 2px rgba(23, 24, 28, .05), 0 1px 1px rgba(23, 24, 28, .03);
  --e2: 0 12px 28px -14px rgba(23, 24, 28, .22), 0 2px 6px rgba(23, 24, 28, .05);
  --e3: 0 28px 70px -24px rgba(23, 24, 28, .38), 0 6px 16px rgba(23, 24, 28, .08);
  --dur: .18s;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);

  /* Accent — one of six, chosen in Settings. Each accent names its light and
     dark shades; the theme blocks below pick which pair is live. --accent is
     the brand colour (rings, focus, indicators); --accent-fill is the one that
     carries white text at ≥ 4.5:1; --accent-ink is text on panel or tint. */
  --acc-l: #5b5bd6; --acc-d: #8f90f7; --acc-ink-l: #4646c2; --acc-ink-d: #b8b9ff;
  --acc-fill-l: #5b5bd6; --acc-fill-d: #6262dc; --acc-on-l: #ffffff; --acc-on-d: #ffffff;
  --accent: var(--acc-l);
  --accent-ink: var(--acc-ink-l);
  --accent-fill: var(--acc-fill-l);
  --on-accent: var(--acc-on-l);
  --accent-tint: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-tint-strong: color-mix(in srgb, var(--accent) 19%, transparent);
  --accent-hover: color-mix(in srgb, var(--accent-fill) 86%, #000);
}
:root[data-accent="ember"] { --acc-l: #e5484d; --acc-d: #ff7477; --acc-ink-l: #c02a31; --acc-ink-d: #ff9ea0; --acc-fill-l: #d13438; --acc-fill-d: #d63a3f; }
:root[data-accent="jade"]  { --acc-l: #12a594; --acc-d: #2fd5b6; --acc-ink-l: #08705f; --acc-ink-d: #6de6cc; --acc-fill-l: #0a8074; --acc-fill-d: #0a8074; }
:root[data-accent="ocean"] { --acc-l: #0090ff; --acc-d: #45adff; --acc-ink-l: #0062bd; --acc-ink-d: #8ecbff; --acc-fill-l: #006fd6; --acc-fill-d: #006fd6; }
:root[data-accent="rose"]  { --acc-l: #d6409f; --acc-d: #f06cbc; --acc-ink-l: #aa2379; --acc-ink-d: #ffa3d9; --acc-fill-l: #bd2f89; --acc-fill-d: #c7378f; }
/* Mono: the accent IS the ink, so the filled button inverts with the theme. */
:root[data-accent="mono"]  { --acc-l: #17181c; --acc-d: #eceef2; --acc-ink-l: #17181c; --acc-ink-d: #eceef2; --acc-fill-l: #17181c; --acc-fill-d: #eceef2; --acc-on-l: #ffffff; --acc-on-d: #0d0f13; }

/* Dark — written twice (explicit choice, and "auto" following the OS), exactly
   like the old stylesheet, because a media query cannot be combined with an
   attribute selector into one block. Keep the two in step. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f13; --panel: #15181e; --panel2: #1c2028; --panel3: #242933;
  --ink: #eceef2; --ink2: #9aa1ad; --ink3: #6b717d;
  --line: #262b34; --line-strong: #353b47;
  --ok: #4cc38a; --warn: #f1a33b; --danger: #ff6b72; --on-danger: #1a0506;
  --scrim: rgba(0, 0, 0, .62); --tip-bg: #eceef2; --tip-ink: #0d0f13;
  --hue-l: .72; --hue-c: .15; --hue-strong-l: .50; --hue-tint-l: .29; --hue-tint-c: .06; --hue-ink-l: .86; --hue-ink-c: .11;
  --hsl-s: 70%; --hsl-l: 62%; --hsl-strong-l: 38%; --hsl-tint-l: 18%; --hsl-ink-l: 82%;
  --accent: var(--acc-d); --accent-ink: var(--acc-ink-d); --accent-fill: var(--acc-fill-d); --on-accent: var(--acc-on-d);
  --accent-tint: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-tint-strong: color-mix(in srgb, var(--accent) 27%, transparent);
  --accent-hover: color-mix(in srgb, var(--accent-fill) 86%, #fff);
  --e1: 0 1px 2px rgba(0, 0, 0, .45);
  --e2: 0 14px 30px -14px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .35);
  --e3: 0 30px 80px -20px rgba(0, 0, 0, .85), 0 6px 18px rgba(0, 0, 0, .45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0f13; --panel: #15181e; --panel2: #1c2028; --panel3: #242933;
    --ink: #eceef2; --ink2: #9aa1ad; --ink3: #6b717d;
    --line: #262b34; --line-strong: #353b47;
    --ok: #4cc38a; --warn: #f1a33b; --danger: #ff6b72; --on-danger: #1a0506;
    --scrim: rgba(0, 0, 0, .62); --tip-bg: #eceef2; --tip-ink: #0d0f13;
    --hue-l: .72; --hue-c: .15; --hue-strong-l: .50; --hue-tint-l: .29; --hue-tint-c: .06; --hue-ink-l: .86; --hue-ink-c: .11;
    --hsl-s: 70%; --hsl-l: 62%; --hsl-strong-l: 38%; --hsl-tint-l: 18%; --hsl-ink-l: 82%;
    --accent: var(--acc-d); --accent-ink: var(--acc-ink-d); --accent-fill: var(--acc-fill-d); --on-accent: var(--acc-on-d);
    --accent-tint: color-mix(in srgb, var(--accent) 16%, transparent);
    --accent-tint-strong: color-mix(in srgb, var(--accent) 27%, transparent);
    --accent-hover: color-mix(in srgb, var(--accent-fill) 86%, #fff);
    --e1: 0 1px 2px rgba(0, 0, 0, .45);
    --e2: 0 14px 30px -14px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .35);
    --e3: 0 30px 80px -20px rgba(0, 0, 0, .85), 0 6px 18px rgba(0, 0, 0, .45);
  }
}

:root[data-density="compact"] {
  --pad: 15px; --pad-sm: 9px; --gap: 12px; --ctl-h: 36px; --row-h: 46px; --radius: 16px;
}

/* Per-element hue scope. Custom properties that reference other custom
   properties resolve on the element that DECLARES them — so the derived colours
   are declared on every component that carries its own --hue (set inline by
   HC.appColor(...).vars, HC.avatar, HC.appIcon…), never once on :root. */
.hued, .app-icon, .kpi, .card, .chip-hue, .badge-hue, .progress, .sect, .empty-state, .lr-ic, .chart, .kit-swatch {
  --h-c: oklch(var(--hue-l) calc(var(--hue-c) * var(--cs, 1)) var(--hue, 277));
  --h-strong: oklch(var(--hue-strong-l) calc(var(--hue-c) * var(--cs, 1)) var(--hue, 277));
  --h-tint: oklch(var(--hue-tint-l) calc(var(--hue-tint-c) * var(--cs, 1)) var(--hue, 277));
  --h-ink: oklch(var(--hue-ink-l) calc(var(--hue-ink-c) * var(--cs, 1)) var(--hue, 277));
}
@supports not (color: oklch(0.5 0.1 100)) {
  .hued, .app-icon, .kpi, .card, .chip-hue, .badge-hue, .progress, .sect, .empty-state, .lr-ic, .chart, .kit-swatch {
    --h-c: hsl(var(--hue, 245) var(--hsl-s) var(--hsl-l));
    --h-strong: hsl(var(--hue, 245) var(--hsl-s) var(--hsl-strong-l));
    --h-tint: hsl(var(--hue, 245) 60% var(--hsl-tint-l));
    --h-ink: hsl(var(--hue, 245) 60% var(--hsl-ink-l));
  }
}

/* ------------------------------------------------------------ base --------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; overflow-x: hidden;
}
html.has-dialog, html.has-dialog body { overflow: hidden; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-appearance: none; }
code, .mono { font-family: var(--font-mono); font-size: .88em; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px; }
kbd, .kbd {
  display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  line-height: 1; padding: 4px 6px; border-radius: 6px; color: var(--ink2);
  background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px;
}
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
::selection { background: var(--accent-tint-strong); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink2); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 1100; padding: 10px 14px; border-radius: 10px;
  background: var(--panel); color: var(--ink); box-shadow: var(--e2); text-decoration: none; font-weight: 500;
}
.skip-link:focus { top: 12px; }

/* Material Symbols: hidden until the icon font is confirmed (core.js adds
   html.icons-ready, or after a 2 s grace), so a slow or blocked Google Fonts
   request never flashes raw ligature words like "space_dashboard". */
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal; font-style: normal; font-size: 22px; line-height: 1;
  letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap;
  direction: ltr; -webkit-font-feature-settings: 'liga'; font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased; user-select: none; flex: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.material-symbols-rounded.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
html:not(.icons-ready) .material-symbols-rounded { visibility: hidden; }

/* ------------------------------------------------------------ boot --------- */
/* Visible from the first paint until HC.start() decides between sign-in and
   the console. If core.js never runs, the message fades in by itself (pure
   CSS delay), so a blocked script is never a silent white page. */
.boot { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; align-content: center; gap: 18px; background: var(--bg); }
.boot-mark { width: 56px; height: 56px; border-radius: 50%; box-shadow: var(--e2); animation: bootPulse 1.6s var(--ease) infinite; }
.boot-msg { color: var(--ink2); font-size: 14px; text-align: center; max-width: 34ch; padding: 0 20px; opacity: 0; animation: fadeIn .4s 6s forwards; }
.boot.is-failed .boot-msg { animation: none; opacity: 1; }
.boot.is-failed .boot-mark { animation: none; filter: grayscale(1); opacity: .6; }
@keyframes bootPulse { 50% { transform: scale(.92); opacity: .75; } }

/* ------------------------------------------------------------ buttons ------ */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--ctl-h); padding: 0 16px; border-radius: var(--radius-btn); border: 1px solid transparent;
  font-family: var(--font-display); font-weight: 500; font-size: 14px; letter-spacing: .005em; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: background var(--dur), border-color var(--dur), color var(--dur), box-shadow var(--dur), transform .08s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn .material-symbols-rounded { font-size: 19px; margin-left: -2px; }
.btn-filled { background: var(--accent-fill); color: var(--on-accent); box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 1px 2px rgba(0, 0, 0, .14); }
.btn-filled:hover:not(:disabled) { background: var(--accent-hover); }
.btn-tonal { background: var(--accent-tint); color: var(--accent-ink); }
.btn-tonal:hover:not(:disabled) { background: var(--accent-tint-strong); }
.btn-outline { background: var(--panel); border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover:not(:disabled) { background: var(--panel2); }
.btn-text { background: none; color: var(--accent-ink); padding: 0 12px; }
.btn-text:hover:not(:disabled) { background: var(--accent-tint); }
.btn-quiet { background: var(--panel2); color: var(--ink); }
.btn-quiet:hover:not(:disabled) { background: var(--panel3); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); }
/* A destructive action BESIDE the primary one (delete from an edit dialog):
   text weight so it never competes with Save, but red. */
.btn-text.is-danger, .btn-outline.is-danger { color: var(--danger); }
.btn-text.is-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 11%, transparent); }
.btn-block { width: 100%; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; gap: 6px; }
.btn-sm .material-symbols-rounded { font-size: 17px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 15px; border-radius: 14px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .48; cursor: not-allowed; }
/* HC.busy(btn, …): the label stays (so the width never jumps) under a spinner. */
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--busy-c, var(--ink2)) transparent var(--busy-c, var(--ink2)) transparent;
  animation: spin .7s linear infinite;
}
.btn-filled.is-busy { --busy-c: var(--on-accent); }
.btn-danger.is-busy { --busy-c: var(--on-danger); }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 12px; border: none; background: transparent; color: var(--ink2); cursor: pointer; text-decoration: none;
  transition: background var(--dur), color var(--dur);
}
.icon-btn:hover:not(:disabled) { background: var(--panel2); color: var(--ink); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn .material-symbols-rounded { font-size: 22px; }
.icon-btn.is-sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.is-sm .material-symbols-rounded { font-size: 19px; }
.icon-btn.is-on { background: var(--accent-tint); color: var(--accent-ink); }
.icon-btn.is-danger:hover:not(:disabled) { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.icon-btn.spinning .material-symbols-rounded, .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* CSS tooltips for HTML controls: data-tooltip="…" (+ data-tooltip-pos=bottom).
   Hover-capable pointers and keyboard focus only — a tap should never leave a
   tooltip stranded on a phone. Chart marks use the JS tip (.chart-tip). */
@media (hover: hover) {
  [data-tooltip]:hover::after, [data-tooltip]:focus-visible::after {
    content: attr(data-tooltip); position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 30;
    transform: translateX(-50%); padding: 5px 9px; border-radius: 8px; pointer-events: none;
    background: var(--tip-bg); color: var(--tip-ink); font: 500 12px/1.3 var(--font-body); letter-spacing: 0;
    white-space: nowrap; box-shadow: var(--e2); animation: tipIn .12s var(--ease-out);
  }
  [data-tooltip][data-tooltip-pos="bottom"]:hover::after, [data-tooltip][data-tooltip-pos="bottom"]:focus-visible::after { top: calc(100% + 8px); bottom: auto; }
  [data-tooltip][data-tooltip-pos="end"]:hover::after, [data-tooltip][data-tooltip-pos="end"]:focus-visible::after { left: auto; right: 0; transform: none; }
}
@keyframes tipIn { from { opacity: 0; margin-bottom: -3px; } }

/* ------------------------------------------------------------ fields ------- */
.field { display: block; text-align: left; min-width: 0; }
.field + .field { margin-top: 14px; }
.field-label { display: block; font-family: var(--font-display); font-weight: 500; font-size: 13px; color: var(--ink2); margin: 0 0 6px 2px; }
.field-hint { display: block; margin: 6px 2px 0; color: var(--ink2); font-size: 12.5px; line-height: 1.45; }
.field-error { display: flex; gap: 6px; align-items: center; margin: 6px 2px 0; color: var(--danger); font-size: 12.5px; }
.field-error .material-symbols-rounded { font-size: 16px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field-row + .field, .field + .field-row, .field-row + .field-row { margin-top: 14px; }
.field-row > .field + .field { margin-top: 0; }

.input, select.input, textarea.input {
  display: block; width: 100%; min-height: var(--ctl-h); padding: 9px 12px;
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-btn);
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
  appearance: none; -webkit-appearance: none;
}
.input::placeholder { color: var(--ink2); opacity: .75; }
.input:hover:not(:disabled):not(:focus) { border-color: var(--ink3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint-strong); }
.input:disabled { background: var(--panel2); color: var(--ink2); cursor: not-allowed; }
.input.is-err, .input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent); }
select.input {
  padding-right: 38px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink2) 50%), linear-gradient(135deg, var(--ink2) 50%, transparent 50%);
  background-position: calc(100% - 19px) 55%, calc(100% - 14px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
textarea.input { min-height: 92px; resize: vertical; line-height: 1.45; }
input[type="date"].input { min-height: var(--ctl-h); }

/* An input with a leading icon and optional trailing button (search, password). */
.field-box {
  display: flex; align-items: center; gap: 8px; padding: 0 6px 0 12px; min-height: var(--ctl-h);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-btn);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.field-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint-strong); }
.field-box input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--ink); font-family: var(--font-body); font-size: 15px; padding: 10px 0; }
.field-box input::placeholder { color: var(--ink2); opacity: .75; }
.field-icon { color: var(--ink2); font-size: 20px; }
.field-btn { width: 34px; height: 34px; border-radius: 9px; }

/* Switch: a real checkbox with role=switch, so it is keyboard- and form-native. */
.switch-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; cursor: pointer; }
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.switch-label { font-family: var(--font-display); font-weight: 500; font-size: 14.5px; }
.switch-sub { color: var(--ink2); font-size: 13px; line-height: 1.4; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  width: 44px; height: 26px; border-radius: 999px; background: var(--line-strong);
  transition: background var(--dur) var(--ease);
}
.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform var(--dur) var(--ease-out);
}
.switch:checked { background: var(--accent-fill); }
.switch:checked::before { transform: translateX(18px); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.switch-row:has(.switch:disabled) { cursor: not-allowed; }

/* Checkbox tiles (grant pickers, Home Studio's app shortcuts). Both label.chk
   (with a real checkbox inside) and button.chk are in use. */
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 8px; }
.chk {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; min-height: 46px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius-btn); background: var(--panel); cursor: pointer; text-align: left;
  font-family: var(--font-display); font-weight: 500; font-size: 13.5px; color: var(--ink); user-select: none;
  transition: background var(--dur), border-color var(--dur), box-shadow var(--dur);
}
.chk:hover { border-color: var(--line-strong); background: var(--panel2); }
.chk > span:not(.material-symbols-rounded):not(.app-icon) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chk .material-symbols-rounded { font-size: 19px; color: var(--ink2); }
.chk input[type="checkbox"], .chk input[type="radio"] { accent-color: var(--accent-fill); width: 18px; height: 18px; flex: none; margin: 0; }
.chk.on, .chk.is-on, .chk:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent); }
.chk:has(input:disabled) { opacity: .55; cursor: not-allowed; }

/* Segmented control — div.seg > button[aria-pressed]. The raised-pill look
   (not an accent fill) keeps it quiet enough to sit beside a primary button. */
.seg { display: inline-flex; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button, .seg .seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  border: none; background: none; cursor: pointer; color: var(--ink2);
  font-family: var(--font-display); font-weight: 500; font-size: 13px;
  padding: 6px 12px; min-height: 30px; border-radius: 9px; transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.seg button .material-symbols-rounded { font-size: 17px; }
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button.is-on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 0 0 1px var(--line); }
.seg button:disabled { opacity: .5; cursor: default; }
.seg.is-block { display: flex; width: 100%; }
.seg.is-block button { flex: 1; }

/* ------------------------------------------------- chips / badges / tags --- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 3px 10px; border-radius: 999px;
  font-family: var(--font-body); font-size: 12.5px; font-weight: 500; line-height: 1.2;
  background: var(--panel2); color: var(--ink2); white-space: nowrap; max-width: 100%;
}
.chip .material-symbols-rounded { font-size: 16px; }
a.chip, button.chip { border: 0; cursor: pointer; text-decoration: none; }
a.chip:hover, button.chip:hover { background: var(--panel3); color: var(--ink); }
.chip-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
/* chip-warn = a PROBLEM (red) — Home Studio's contrast warnings use it. For a
   gentler "heads up" use chip-caution (amber). */
.chip-warn, .chip-err { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.chip-caution { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.chip-accent, .chip-info { background: var(--accent-tint); color: var(--accent-ink); }
.chip-hue { background: var(--h-tint); color: var(--h-ink); }
.chip-outline { background: none; box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip.is-on { background: var(--ink); color: var(--bg); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 7px;
  font-family: var(--font-display); font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--panel2); color: var(--ink2);
}
.badge .material-symbols-rounded { font-size: 15px; }
.badge-accent { background: var(--accent-tint); color: var(--accent-ink); }
.badge-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge-warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge-err { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.badge-hue { background: var(--h-tint); color: var(--h-ink); }
.badge-solid { background: var(--ink); color: var(--bg); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 6px; background: var(--panel2); color: var(--ink2); }
.tag .material-symbols-rounded { font-size: 13px; }
.tag-off { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tag-locked, .tag-private { background: var(--accent-tint-strong); color: var(--accent-ink); }
.tag-contribute { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.tag-open, .tag-public { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tag-disabled { background: var(--panel2); color: var(--ink2); }
/* A tag on a ticked .chk tile: its tint goes over a solid panel instead of
   stacking on the tile's own accent tint (two translucent layers took the
   status inks to 3.7–4.4:1). Keeps every accent ≥ 4.5:1 in both themes. */
.chk:has(input:checked) :is(.tag-private, .tag-locked), :is(.chk.on, .chk.is-on) :is(.tag-private, .tag-locked) {
  background: linear-gradient(var(--accent-tint-strong), var(--accent-tint-strong)) var(--panel);
}
.chk:has(input:checked) .tag-contribute, :is(.chk.on, .chk.is-on) .tag-contribute {
  background: linear-gradient(color-mix(in srgb, var(--warn) 15%, transparent), color-mix(in srgb, var(--warn) 15%, transparent)) var(--panel);
}
.chk:has(input:checked) :is(.tag-public, .tag-open), :is(.chk.on, .chk.is-on) :is(.tag-public, .tag-open) {
  background: linear-gradient(color-mix(in srgb, var(--ok) 15%, transparent), color-mix(in srgb, var(--ok) 15%, transparent)) var(--panel);
}

/* Status dots: always paired with a word (colour is never the only signal). */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink3); flex: none; }
.dot.is-ok { background: var(--ok); } .dot.is-warn { background: var(--warn); } .dot.is-err { background: var(--danger); } .dot.is-accent { background: var(--accent); }
.live-dot { position: relative; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ping 1.8s var(--ease-out) infinite; }
@keyframes ping { 0% { transform: scale(.5); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }

/* ------------------------------------------------------------ cards -------- */
.card {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--e1);
  transition: box-shadow var(--dur), border-color var(--dur), transform var(--dur);
}
a.card, .card.is-link { color: inherit; text-decoration: none; cursor: pointer; }
a.card:hover, .card.is-link:hover { box-shadow: var(--e2); border-color: var(--line-strong); transform: translateY(-1px); }
.card-head { display: flex; align-items: center; gap: 12px; padding: var(--pad) var(--pad) 0; min-width: 0; }
.card-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex: none; background: var(--h-tint); color: var(--h-ink); }
.card-ic .material-symbols-rounded { font-size: 20px; }
.card:not(.hued) .card-ic { background: var(--accent-tint); color: var(--accent-ink); }
.card-heading { flex: 1; min-width: 0; }
.card-eyebrow { font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); margin-bottom: 2px; }
.card-title { font-size: 16px; font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.card-sub { color: var(--ink2); font-size: 13px; margin-top: 2px; }
.card-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
.card-body { flex: 1; min-width: 0; padding: 14px var(--pad) var(--pad); }
.card-body.is-flush { padding: 8px 0 6px; }
.card-head + .card-body.is-flush { padding-top: 10px; }
.card-foot { display: flex; align-items: center; gap: 8px; padding: 12px var(--pad); border-top: 1px solid var(--line); color: var(--ink2); font-size: 13px; }
/* The coloured header band (an app's card on a profile, a person's hero). */
.card-band { overflow: hidden; }
.card-band > .card-head { padding-bottom: 14px; background: linear-gradient(180deg, var(--h-tint), color-mix(in srgb, var(--h-tint) 35%, var(--panel))); border-bottom: 1px solid color-mix(in srgb, var(--h-c) 18%, var(--line)); }
.card-band > .card-head::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--h-c); }
.card-band > .card-head .card-title, .card-band > .card-head .card-eyebrow { color: var(--h-ink); }
.card-flat { box-shadow: none; background: var(--panel2); border-color: transparent; }

/* Bento: a 12-column grid with varied spans, so a page is a composition, not
   a stack of identical rows. Children default to full width. */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); grid-auto-flow: row dense; align-items: stretch; }
.bento > * { grid-column: span 12; min-width: 0; }
.bento > .span-2 { grid-column: span 2; } .bento > .span-3 { grid-column: span 3; } .bento > .span-4 { grid-column: span 4; }
.bento > .span-5 { grid-column: span 5; } .bento > .span-6 { grid-column: span 6; } .bento > .span-7 { grid-column: span 7; }
.bento > .span-8 { grid-column: span 8; } .bento > .span-9 { grid-column: span 9; } .bento > .span-12 { grid-column: span 12; }
.bento > .rows-2 { grid-row: span 2; }
:where(.bento, .card) + :where(.bento, .card) { margin-top: var(--gap); }
/* Grid children get their spacing from `gap`, never from sibling margins. */
.bento > *, .grid-auto > *, .stack > * { margin-top: 0; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--min, 240px), 1fr)); gap: var(--gap); }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.hstack { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* KPI tile: the number is the headline; the sparkline bleeds to the edges. */
.kpi {
  position: relative; overflow: hidden; display: flex; flex-direction: column; min-width: 0; min-height: 150px;
  padding: var(--pad) var(--pad) 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--e1); color: inherit; text-decoration: none;
  transition: box-shadow var(--dur), border-color var(--dur), transform var(--dur);
}
a.kpi:hover, button.kpi:hover { box-shadow: var(--e2); border-color: var(--line-strong); transform: translateY(-1px); }
button.kpi { font: inherit; text-align: left; cursor: pointer; }
.kpi-top { display: flex; align-items: center; gap: 10px; color: var(--ink2); font-family: var(--font-display); font-weight: 500; font-size: 13.5px; min-width: 0; }
.kpi-top > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; flex: none; background: var(--h-tint); color: var(--h-ink); }
.kpi-ic .material-symbols-rounded { font-size: 18px; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.kpi-value { font-family: var(--font-display); font-weight: 500; font-size: clamp(28px, 2.1vw + 14px, 40px); letter-spacing: -.025em; line-height: 1.05; margin-top: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-unit { font-size: .5em; color: var(--ink2); margin-left: 3px; letter-spacing: 0; }
.kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; color: var(--ink2); font-size: 12.5px; }
.kpi-delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 500; font-variant-numeric: tabular-nums; padding: 1px 7px 1px 4px; border-radius: 999px; background: var(--panel2); color: var(--ink2); }
.kpi-delta .material-symbols-rounded { font-size: 16px; }
.kpi-delta.is-up { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.kpi-delta.is-down { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.kpi-spark { margin: auto calc(var(--pad) * -1) 0; padding-top: 10px; height: 52px; }
.kpi-spark > .chart, .kpi-spark .spark { height: 100%; }
.kpi-spark .spark { width: calc(100% - 6px); }   /* keeps the "latest" dot inside the tile */
.kpi.is-plain { min-height: 0; padding-bottom: var(--pad); }

/* Key facts: a definition list that wraps into columns. */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 18px; margin: 0; }
.fact { min-width: 0; }
.fact dt { display: flex; align-items: center; gap: 6px; color: var(--ink2); font-size: 12.5px; font-family: var(--font-display); font-weight: 500; }
.fact dt .material-symbols-rounded { font-size: 16px; }
.fact dd { margin: 3px 0 0; font-size: 14.5px; overflow-wrap: anywhere; }
.fact dd.mono { font-family: var(--font-mono); font-size: 13px; }

/* List rows (people, apps, sign-ins…). */
.list { display: flex; flex-direction: column; min-width: 0; }
.lr {
  display: flex; align-items: center; gap: 12px; min-height: var(--row-h); padding: 8px var(--pad); min-width: 0;
  color: inherit; text-decoration: none; background: none; border: 0; border-top: 1px solid var(--line); width: 100%; text-align: left; font: inherit;
  transition: background var(--dur);
}
.list > .lr:first-child { border-top: 0; }
a.lr, button.lr, .lr.is-link { cursor: pointer; }
a.lr:hover, button.lr:hover, .lr.is-link:hover { background: color-mix(in srgb, var(--panel2) 70%, transparent); }
.lr-lead { flex: none; display: grid; place-items: center; }
.lr-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--h-tint); color: var(--h-ink); flex: none; }
.lr-ic .material-symbols-rounded { font-size: 20px; }
.lr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lr-title { font-family: var(--font-display); font-weight: 500; font-size: 14.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.lr-title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lr-sub { color: var(--ink2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-meta { color: var(--ink2); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; text-align: right; }
.lr-trail { display: flex; align-items: center; gap: 4px; flex: none; }
.lr-chev { color: var(--ink3); font-size: 20px; }

/* Tabs — role=tablist, roving tabindex (HC.tabs). */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 14px; flex: none;
  border: 0; background: none; cursor: pointer; color: var(--ink2); white-space: nowrap;
  font-family: var(--font-display); font-weight: 500; font-size: 14px; border-radius: 10px 10px 0 0;
  transition: color var(--dur), background var(--dur);
}
.tab .material-symbols-rounded { font-size: 19px; }
.tab:hover { color: var(--ink); background: color-mix(in srgb, var(--panel2) 60%, transparent); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"] .material-symbols-rounded { color: var(--accent-ink); font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.tab::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); transform: scaleX(0); transition: transform .22s var(--ease-out); }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab-count { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--panel2); color: var(--ink2); }
.tab[aria-selected="true"] .tab-count { background: var(--accent-tint); color: var(--accent-ink); }
.tabs.is-pills { border-bottom: 0; gap: 6px; }
.tabs.is-pills .tab { height: 36px; border-radius: 999px; padding: 0 14px; }
.tabs.is-pills .tab::after { display: none; }
.tabs.is-pills .tab[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.tabs.is-pills .tab[aria-selected="true"] .material-symbols-rounded { color: inherit; }
.tabs.is-pills .tab[aria-selected="true"] .tab-count { background: color-mix(in srgb, var(--bg) 22%, transparent); color: inherit; }

/* Section header: tinted icon + eyebrow + title (+ actions). */
.sect { display: flex; align-items: center; gap: 12px; margin: 30px 0 14px; min-width: 0; }
.sect:first-child { margin-top: 0; }
.sect-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; flex: none; background: var(--accent-tint); color: var(--accent-ink); }
.sect.hued .sect-ic, .sect[style*="--hue"] .sect-ic { background: var(--h-tint); color: var(--h-ink); }
.sect-ic .material-symbols-rounded { font-size: 20px; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.sect-heading { flex: 1; min-width: 0; }
.sect-eyebrow { font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent-ink); }
.sect[style*="--hue"] .sect-eyebrow { color: var(--h-ink); }
.sect-title { font-size: 19px; font-weight: 500; line-height: 1.25; }
.sect-sub { color: var(--ink2); font-size: 13.5px; margin-top: 2px; }
.sect-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }

/* ---------------------------------------------------- avatars / app icons -- */
.avatar {
  --size: 36px; position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); border-radius: 50%; overflow: hidden; user-select: none;
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: calc(var(--size) * .38); letter-spacing: .02em; line-height: 1;
  background: linear-gradient(135deg, hsl(var(--hue, 245) 55% 42%), hsl(calc(var(--hue, 245) + 40) 60% 30%));
  background: linear-gradient(135deg, oklch(.56 .15 var(--hue, 245)), oklch(.44 .16 calc(var(--hue, 245) + 40)));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), inset 0 -8px 16px -8px rgba(0, 0, 0, .25);
}
.avatar.is-square { border-radius: 30%; }
.avatar.is-muted { filter: grayscale(.9); opacity: .7; }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack > * { box-shadow: 0 0 0 2px var(--panel); }
.avatar-stack > * + * { margin-left: calc(var(--size, 28px) * -.32); }
.avatar-more {
  --size: 28px; display: inline-grid; place-items: center; width: var(--size); height: var(--size); border-radius: 50%;
  background: var(--panel2); color: var(--ink2); font-family: var(--font-display); font-weight: 500; font-size: calc(var(--size) * .36); flex: none;
}

.app-icon {
  --size: 40px; position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); border-radius: calc(var(--size) * .3); color: #fff;
  background: linear-gradient(150deg, hsl(var(--hue, 245) 70% 58%), hsl(calc(var(--hue, 245) - 18) 70% 42%));
  background: linear-gradient(150deg, oklch(.72 calc(.15 * var(--cs, 1)) calc(var(--hue, 245) + 10)), oklch(.54 calc(.17 * var(--cs, 1)) calc(var(--hue, 245) - 14)));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), inset 0 -1px 0 rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .12);
}
.app-icon .material-symbols-rounded { font-size: calc(var(--size) * .56); font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; text-shadow: 0 1px 1px rgba(0, 0, 0, .15); }
.app-icon.is-soft { background: var(--h-tint); color: var(--h-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--h-c) 18%, transparent); }
.app-icon.is-soft .material-symbols-rounded { text-shadow: none; }
.app-icon.is-muted { filter: grayscale(1); opacity: .55; }

/* Progress bar + head. */
.progress { position: relative; height: 8px; border-radius: 999px; background: var(--panel2); overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: inherit; background: var(--h-c); transition: width .7s var(--ease-out); }
.progress:not(.hued):not([style*="--hue"]) .progress-fill { background: var(--accent); }
.progress.is-thin { height: 5px; }
.progress.is-thick { height: 12px; }
.progress-wrap { display: grid; gap: 6px; min-width: 0; }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; }
.progress-head > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-head > span:last-child { color: var(--ink2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------- messages / notes / legacy */
/* .msg is rewritten wholesale by HC.say (className = "msg" + kind) — keep its
   look self-contained. */
.msg { min-height: 1.2em; margin: 12px 0 0; font-size: 13.5px; display: flex; align-items: center; gap: 7px; color: var(--ink2); }
.msg:empty { margin: 0; min-height: 0; }
.msg .material-symbols-rounded { font-size: 18px; }
.msg-err { color: var(--danger); }
.msg-ok { color: var(--ok); }
.note { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.45; margin: 0 0 16px; background: var(--panel2); color: var(--ink2); }
.note .material-symbols-rounded { font-size: 20px; flex: none; }
.note-info { background: var(--accent-tint); color: var(--accent-ink); }
.note-warn { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.note-caution { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.note-ok { background: color-mix(in srgb, var(--ok) 11%, transparent); color: var(--ok); }
.note > div, .note > span:last-child { min-width: 0; }
.note strong { font-weight: 500; color: inherit; }
.empty { text-align: center; color: var(--ink2); padding: 28px 20px; font-size: 14px; margin: 0; }
.section-label { font-family: var(--font-display); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--ink2); margin: 26px 2px 12px; }
.section-label:first-child { margin-top: 4px; }
.ins-sub, .meta-note { color: var(--ink2); font-size: 12.5px; margin: 0; }
/* Held at reduced opacity while refetching — no skeleton flash, no jump. */
.is-stale { opacity: .5; transition: opacity var(--dur); pointer-events: none; }

/* Legacy panel family (Home Studio's inspector boxes, older markup). */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--e1); min-width: 0; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--accent-tint); color: var(--accent-ink); flex: none; }
.panel-ic .material-symbols-rounded { font-size: 20px; }
.panel-heading { flex: 1; min-width: 0; }
.panel-title { font-family: var(--font-display); font-weight: 500; font-size: 16px; margin: 0; }
.panel-sub { margin: 2px 0 0; color: var(--ink2); font-size: 12.5px; }
.panel-body { padding: 16px 18px; }
.panel-note { margin: 0; padding: 14px 18px; color: var(--ink2); font-size: 13.5px; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------------ menus -------- */
.menu {
  position: fixed; z-index: 600; min-width: 230px; max-width: min(340px, calc(100vw - 16px)); max-height: min(70vh, 520px); overflow: auto;
  padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--e3);
  animation: menuIn .14s var(--ease-out); transform-origin: top right;
}
.menu.is-up { transform-origin: bottom right; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-item {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 38px; padding: 7px 10px; border: 0; border-radius: 9px;
  background: none; color: var(--ink); font-family: var(--font-body); font-size: 14px; text-align: left; cursor: pointer; text-decoration: none;
}
.menu-item:hover, .menu-item:focus { background: var(--panel2); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.menu-item:disabled { opacity: .45; cursor: default; background: none; }
.menu-item .material-symbols-rounded { font-size: 19px; color: var(--ink2); }
.menu-item.is-danger, .menu-item.is-danger .material-symbols-rounded { color: var(--danger); }
.menu-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-label small { color: var(--ink2); font-size: 12px; line-height: 1.3; }
.menu-hint { margin-left: auto; color: var(--ink2); font-size: 12px; }
.menu-check { margin-left: auto; color: var(--accent-ink) !important; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-head { display: flex; align-items: center; gap: 11px; padding: 10px 10px 10px; min-width: 0; }
.menu-head-text { min-width: 0; display: flex; flex-direction: column; }
.menu-head-text strong { font-family: var(--font-display); font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head-text span { color: var(--ink2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-group { padding: 8px 10px 4px; color: var(--ink2); font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

/* ------------------------------------------------------------ dialogs ------ */
/* One scrim + one wrap per dialog; they stack (z from --z, set by core.js) and
   everything beneath the top one is inert. ≤640 px every dialog is a bottom
   sheet. The drawer sits at z 60, so a dialog is always above it (old bug B11). */
.scrim { position: fixed; inset: 0; z-index: var(--z, 100); background: var(--scrim); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); animation: fadeIn .18s ease-out; }
.scrim.is-stacked { background: rgba(0, 0, 0, .16); backdrop-filter: none; -webkit-backdrop-filter: none; }
.dialog { position: fixed; inset: 0; z-index: calc(var(--z, 100) + 1); display: grid; place-items: center; padding: 24px; overflow: hidden; }
.dialog-card {
  position: relative; display: flex; flex-direction: column; width: min(560px, 100%); max-height: min(88dvh, 880px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--e3);
  animation: dialogIn .22s var(--ease-out); outline: none; overflow: hidden;
}
.dialog-card.is-sm { width: min(430px, 100%); }
.dialog-card.is-lg { width: min(760px, 100%); }
.dialog-card.is-xl { width: min(1000px, 100%); }
@keyframes dialogIn { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes fadeIn { from { opacity: 0; } }
.dialog.is-leaving, .scrim.is-leaving { pointer-events: none; animation: fadeOut .14s ease-in forwards; }
@keyframes fadeOut { to { opacity: 0; } }
.dialog-grab { display: none; }
.dialog-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 22px 4px 24px; flex: none; }
.dialog-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: none; background: var(--accent-tint); color: var(--accent-ink); }
.dialog-ic.is-danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.dialog-ic .material-symbols-rounded { font-size: 22px; }
.dialog-heading { flex: 1; min-width: 0; padding-top: 2px; }
.dialog-title { font-family: var(--font-display); font-weight: 500; font-size: 20px; line-height: 1.3; margin: 0; letter-spacing: -.01em; overflow-wrap: anywhere; }
.dialog-sub { margin: 4px 0 0; color: var(--ink2); font-size: 14px; line-height: 1.45; }
.dialog-close { margin: -6px -8px 0 0; }
.dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 16px 24px 10px; overscroll-behavior: contain; }
.dialog-text { color: var(--ink2); font-size: 14.5px; line-height: 1.55; margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 24px 20px; flex: none; }
.dialog-actions:empty { display: none; }
.dialog-actions > .is-start { margin-right: auto; }

/* The command palette is a dialog variant pinned near the top. */
.dialog.is-palette { place-items: start center; padding-top: min(12vh, 110px); }
.dialog.is-palette .dialog-card { width: min(660px, 100%); max-height: min(72dvh, 620px); border-radius: 18px; }
.dialog.is-palette .dialog-head { display: none; }
.dialog.is-palette .dialog-body { padding: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ------------------------------------------------------------ toasts ------- */
.toasts {
  position: fixed; z-index: 500; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%);
  width: min(460px, calc(100% - 24px)); display: flex; flex-direction: column-reverse; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 100%; min-height: 48px;
  padding: 8px 8px 8px 14px; border-radius: 14px; background: var(--tip-bg); color: var(--tip-ink);
  box-shadow: var(--e3); font-size: 14px; line-height: 1.4; animation: toastIn .26s var(--ease-out);
}
.toast.is-leaving { animation: toastOut .18s ease-in forwards; }
.toast > .material-symbols-rounded:first-child { font-size: 20px; }
.toast-ok > .material-symbols-rounded:first-child { color: #4cc38a; }
.toast-err > .material-symbols-rounded:first-child { color: #ff6b72; }
.toast-info > .material-symbols-rounded:first-child { color: color-mix(in srgb, var(--accent) 60%, #fff); }
.toast-text { flex: 1; min-width: 0; padding-right: 4px; }
.toast-action { border: 0; background: none; color: inherit; font-family: var(--font-display); font-weight: 700; font-size: 13.5px; padding: 8px 10px; border-radius: 9px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.toast-action:hover { background: rgba(127, 127, 127, .18); }
.toast-close { border: 0; background: none; color: inherit; opacity: .7; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; cursor: pointer; }
.toast-close:hover { opacity: 1; background: rgba(127, 127, 127, .18); }
.toast-close .material-symbols-rounded { font-size: 18px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------------------------------------------------- skeleton / states ---- */
.skel {
  display: block; border-radius: 8px;
  background: linear-gradient(90deg, var(--panel2) 0%, var(--panel3) 45%, var(--panel2) 90%);
  background-size: 300% 100%; animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }
.skel-line { height: 11px; }
.skel-line + .skel-line { margin-top: 9px; }
.skel-title { height: 18px; width: 42%; margin-bottom: 14px; }
.skel-num { height: 34px; width: 55%; margin: 14px 0 12px; border-radius: 10px; }
.skel-circle { border-radius: 50%; flex: none; }
.skel-block { height: 150px; border-radius: 14px; }
.skel-row { display: flex; align-items: center; gap: 12px; padding: 12px var(--pad); }
.skel-row + .skel-row { border-top: 1px solid var(--line); }
.skel-row > div { flex: 1; }
.skel-hero { display: flex; align-items: center; gap: 22px; padding: 26px var(--pad); }
.skel-wrap { display: block; }

.empty-state { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 46px 24px; }
.empty-state.is-compact { padding: 24px 16px; }
.es-art { position: relative; display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 12px; }
.es-art::before, .es-art::after { content: ""; position: absolute; inset: 0; border-radius: 20px; }
.es-art::before { background: var(--panel2); transform: rotate(9deg) translate(6px, 2px); }
.es-art::after { background: var(--h-tint); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--h-c) 16%, transparent); transform: rotate(-5deg); }
.es-art .material-symbols-rounded { position: relative; z-index: 1; font-size: 30px; color: var(--h-ink); transform: rotate(-5deg); }
.empty-state.is-compact .es-art { width: 48px; height: 48px; margin-bottom: 8px; }
.empty-state.is-compact .es-art .material-symbols-rounded { font-size: 24px; }
.es-title { font-size: 17px; font-weight: 500; }
.es-text { color: var(--ink2); font-size: 14px; max-width: 46ch; line-height: 1.5; }
.es-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.es-code { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink3); margin-top: 2px; }
.error-state .es-art::after { background: color-mix(in srgb, var(--danger) 11%, var(--panel)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 20%, transparent); }
.error-state .es-art .material-symbols-rounded { color: var(--danger); }

/* Accent fallbacks for hue-scoped pieces rendered WITHOUT a hue of their own. */
.kpi:not(.hued) .kpi-ic { background: var(--accent-tint); color: var(--accent-ink); }
.lr-ic:not(.hued) { background: var(--panel2); color: var(--ink2); }
.empty-state:not(.hued):not(.error-state) .es-art::after { background: var(--accent-tint); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent); }
.empty-state:not(.hued):not(.error-state) .es-art .material-symbols-rounded { color: var(--accent-ink); }
.card:not(.hued).card-band > .card-head { background: linear-gradient(180deg, var(--accent-tint), transparent); }
.card:not(.hued).card-band > .card-head::before { background: var(--accent); }
.card:not(.hued).card-band > .card-head .card-title { color: var(--ink); }

/* ============================================================ CHARTS =======
   Hand-built SVG/HTML, no library (CSP: script-src 'self'). Every chart is a
   <figure class="chart"> carrying --c (its colour; an app hue or the accent),
   an aria-hidden drawing and an sr-only table twin. Marks with data-tip get the
   floating .chart-tip on hover. Axis text is HTML, never inside a stretched
   SVG, so it stays crisp at any width. */
.chart { position: relative; margin: 0; min-width: 0; --c: var(--accent); }
.chart.hued, .hued .chart { --c: var(--h-c); }
.chart svg { display: block; overflow: visible; }
.chart-caption { color: var(--ink2); font-size: 12.5px; margin-top: 10px; }
.chart-empty { display: grid; place-items: center; color: var(--ink2); font-size: 13px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.chart-tip {
  position: fixed; z-index: 700; pointer-events: none; left: 0; top: 0;
  padding: 6px 10px; border-radius: 9px; background: var(--tip-bg); color: var(--tip-ink);
  font: 500 12px/1.35 var(--font-body); white-space: nowrap; box-shadow: var(--e2);
  transform: translate(-50%, calc(-100% - 10px)); transition: opacity .1s;
}
.chart-tip[hidden] { display: block !important; opacity: 0; }
.chart-tip b { font-weight: 700; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip .tip-sw { width: 8px; height: 8px; border-radius: 3px; flex: none; }

/* Sparkline. */
.spark { display: block; width: 100%; height: var(--h, 36px); position: relative; }
.spark svg { width: 100%; height: 100%; }
.spark-line { fill: none; stroke: var(--c); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--panel); transform: translate(-50%, -50%); }
.spark.is-flat .spark-line { stroke: var(--line-strong); }

/* Area (and multi-series line) chart. */
.ch-area-wrap { position: relative; padding-left: 46px; }
.ch-plot { position: relative; height: var(--h, 200px); touch-action: pan-y; }
.ch-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ch-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 3 5; }
.ch-grid.is-base { stroke: var(--line-strong); stroke-dasharray: none; }
.ch-line { fill: none; stroke: var(--c); stroke-width: 2.25; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.ch-ylab { position: absolute; right: calc(100% + 7px); text-align: right; white-space: nowrap; transform: translateY(-50%); font: 400 10.5px/1 var(--font-mono); color: var(--ink2); font-variant-numeric: tabular-nums; }
.ch-xlabs { position: relative; height: 16px; margin-top: 8px; }
.ch-xlab { position: absolute; top: 0; transform: translateX(-50%); font: 400 10.5px/1.4 var(--font-mono); color: var(--ink2); white-space: nowrap; }
.ch-xlab.is-first { transform: none; }
.ch-xlab.is-last { transform: translateX(-100%); }
.ch-guide { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-strong); pointer-events: none; opacity: 0; }
.ch-hover-dot { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--dc, var(--c)); border: 2.5px solid var(--panel); transform: translate(-50%, -50%); pointer-events: none; opacity: 0; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.ch-plot.is-hover .ch-guide, .ch-plot.is-hover .ch-hover-dot { opacity: 1; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12.5px; color: var(--ink2); }
.ch-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ch-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--dc); display: inline-block; }

/* Columns. */
.ch-cols { display: flex; align-items: flex-end; gap: var(--col-gap, 3px); height: var(--h, 160px); border-bottom: 1px solid var(--line-strong); }
.ch-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.ch-col i { display: block; width: 100%; max-width: 30px; min-height: 2px; border-radius: 5px 5px 1px 1px; background: var(--c); opacity: .85; transition: opacity var(--dur), transform var(--dur); transform-origin: bottom; }
.ch-col:hover i { opacity: 1; }
.ch-col.is-zero i { background: var(--line-strong); opacity: .6; }
.ch-col.is-peak i { opacity: 1; }
.ch-col.is-muted i { opacity: .35; }
.ch-cols-x { display: flex; gap: var(--col-gap, 3px); margin-top: 7px; }
/* Each label is a column wide (often < 10 px) and wider than that, and
   text-align can't place text wider than its box — it would start at the
   column's left edge and run past the card. As a flex box, the text is an
   item that overflows both ways when centred, and inwards at the two ends. */
.ch-cols-x span { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; font: 400 10.5px/1.3 var(--font-mono); color: var(--ink2); white-space: nowrap; }
.ch-cols-x span:first-child { justify-content: flex-start; }
.ch-cols-x span:last-child { justify-content: flex-end; }

/* Ranked bars. */
.ch-bars { display: grid; gap: 14px; }
.ch-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "lead label val" "lead track track"; align-items: center; gap: 6px 10px; color: inherit; text-decoration: none; min-width: 0; }
a.ch-bar, button.ch-bar { border: 0; background: none; font: inherit; text-align: left; padding: 6px 8px; margin: -6px -8px; border-radius: 12px; cursor: pointer; transition: background var(--dur); }
a.ch-bar:hover, button.ch-bar:hover { background: var(--panel2); }
.ch-bar-lead { grid-area: lead; display: grid; place-items: center; }
.ch-bar-lead:empty { display: none; }
.ch-bar-label { grid-area: label; min-width: 0; font-family: var(--font-display); font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-bar-label small { font-family: var(--font-body); font-weight: 400; color: var(--ink2); font-size: 12.5px; margin-left: 6px; }
.ch-bar-val { grid-area: val; font-size: 13px; color: var(--ink2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ch-bar-track { grid-area: track; height: 8px; border-radius: 999px; background: var(--panel2); overflow: hidden; }
.ch-bar-fill { display: block; height: 100%; min-width: 4px; border-radius: 999px; background: var(--bc, var(--c)); transition: width .7s var(--ease-out); }
.ch-bar-sub { grid-column: 2 / -1; color: var(--ink2); font-size: 12px; margin-top: -2px; }
.ch-bar.no-lead { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label val" "track track"; }
.ch-bar.no-lead .ch-bar-sub { grid-column: 1 / -1; }

/* Donut + legend. */
.ch-donut { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.ch-donut-ring { position: relative; flex: none; }
.ch-donut-ring svg { transform: rotate(-90deg); }
.ch-seg { fill: none; transition: stroke-width var(--dur), opacity var(--dur); }
.ch-donut-ring:hover .ch-seg { opacity: .55; }
.ch-donut-ring .ch-seg:hover { opacity: 1; }
.ch-donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.ch-donut-center strong { font-family: var(--font-display); font-weight: 500; font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ch-donut-center span { color: var(--ink2); font-size: 11.5px; }
/* Beside the ring only when a whole row fits (swatch, "Android tablet", a
   5-digit count, a percentage ≈ 210 px); otherwise it wraps below it. */
.ch-donut-legend { flex: 1 1 210px; min-width: min(210px, 100%); display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ch-donut-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; font-size: 13px; }
.ch-donut-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--dc); }
.ch-donut-legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-donut-legend b { font-weight: 500; font-variant-numeric: tabular-nums; }
.ch-donut-legend em { font-style: normal; color: var(--ink2); font-size: 12px; min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }

/* Ring (a single progress value). */
.ch-ring { display: inline-flex; flex-direction: column; align-items: center; gap: 8px; }
.ch-ring-box { position: relative; }
.ch-ring-box svg { transform: rotate(-90deg); }
.ch-ring-track { fill: none; stroke: var(--panel2); }
.ch-ring-fill { fill: none; stroke: var(--c); stroke-linecap: round; transition: stroke-dashoffset .9s var(--ease-out); }
.ch-ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ch-ring-center strong { font-family: var(--font-display); font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1; }
.ch-ring-center span { color: var(--ink2); font-size: 11px; margin-top: 2px; }
.ch-ring-label { font-size: 12.5px; color: var(--ink2); text-align: center; max-width: 14em; }

/* Calendar heatmap (GitHub-style; weeks are columns, Monday first). */
.ch-heat { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; max-width: calc(var(--weeks) * 24px + 40px); }
.ch-heat-months { grid-column: 2; display: grid; grid-template-columns: repeat(var(--weeks), minmax(0, 1fr)); gap: var(--cell-gap, 3px); height: 16px; }
.ch-heat-months span { font: 400 10.5px/1 var(--font-mono); color: var(--ink2); white-space: nowrap; overflow: visible; }
.ch-heat-days { display: grid; grid-template-rows: repeat(7, minmax(0, 1fr)); gap: var(--cell-gap, 3px); }
.ch-heat-days span { font: 400 10px/1 var(--font-mono); color: var(--ink2); display: flex; align-items: center; }
.ch-heat-grid { display: grid; grid-auto-flow: column; grid-template-columns: repeat(var(--weeks), minmax(0, 1fr)); grid-template-rows: repeat(7, auto); gap: var(--cell-gap, 3px); }
.ch-cell { aspect-ratio: 1; border-radius: 3px; background: var(--panel2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 4%, transparent); }
.ch-cell.is-out { visibility: hidden; }
.ch-cell.is-today { box-shadow: inset 0 0 0 1.5px var(--ink2); }
.ch-cell[data-l="1"] { background: color-mix(in srgb, var(--c) 28%, var(--panel2)); }
.ch-cell[data-l="2"] { background: color-mix(in srgb, var(--c) 52%, var(--panel2)); }
.ch-cell[data-l="3"] { background: color-mix(in srgb, var(--c) 76%, var(--panel2)); }
.ch-cell[data-l="4"] { background: var(--c); }
.ch-heat-foot { grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--ink2); }
.ch-heat-legend { display: inline-flex; align-items: center; gap: 4px; }
.ch-heat-legend .ch-cell { width: 11px; height: 11px; aspect-ratio: auto; }
.ch-heat-legend b { font-weight: 400; margin: 0 4px; }

/* 24-hour clock. */
.ch-hours { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.ch-hours svg { flex: none; }
.ch-wedge { fill: var(--c); transition: opacity var(--dur); }
.ch-wedge.is-zero { fill: var(--panel2); }
.ch-hours svg:hover .ch-wedge { opacity: .55; }
.ch-hours svg .ch-wedge:hover { opacity: 1; }
.ch-hours-face { fill: var(--panel2); }
.ch-hours-tick { font: 500 9.5px var(--font-mono); fill: var(--ink2); }
.ch-hours-mid { font-family: var(--font-display); fill: var(--ink); }
.ch-hours-hand { stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.ch-hours-note { flex: 1; min-width: 150px; font-size: 13px; color: var(--ink2); display: grid; gap: 4px; }
.ch-hours-note strong { color: var(--ink); font-family: var(--font-display); font-weight: 500; font-size: 18px; }

/* Distribution (e.g. wordle guesses). */
.ch-dist { display: grid; gap: 5px; }
.ch-dist-row { display: grid; grid-template-columns: 2.2em minmax(0, 1fr); align-items: center; gap: 8px; }
.ch-dist-row > span { font: 500 12.5px var(--font-mono); color: var(--ink2); text-align: right; }
.ch-dist-bar { display: flex; justify-content: flex-end; align-items: center; min-width: 26px; height: 22px; padding: 0 8px; border-radius: 6px; background: color-mix(in srgb, var(--c) 30%, var(--panel2)); color: var(--ink); font: 500 12px var(--font-mono); font-variant-numeric: tabular-nums; transition: width .7s var(--ease-out); }
/* Dark ink, not white: app colours are L .62 (light) / .72 (dark) for solid
   marks, where white is 2.2–3.5:1. #0d0f13 on any hue is ≥ 4.8:1 in both. */
.ch-dist-row.is-hi .ch-dist-bar { background: var(--c); color: #0d0f13; }
.ch-dist-row.is-zero .ch-dist-bar { background: var(--panel2); color: var(--ink2); }

/* ============================================================ SHELL ========= */
/* isolation + a z-index:-1 glow, NOT a z-index on .shell: a stacking context
   on the shell would trap the fixed mobile drawer beneath the topbar/scrim. */
.app { position: relative; min-height: 100dvh; isolation: isolate; }
/* A faint accent glow at the top of the paper — life without noise. */
.app::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 560px; pointer-events: none; z-index: -1;
  background: radial-gradient(900px 360px at 72% -140px, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%);
}
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding: 0 18px 0 20px; padding-top: env(safe-area-inset-top, 0px); height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; flex: none; border-radius: 12px; padding: 4px 6px 4px 4px; margin-left: -4px; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 0 0 1px rgba(0, 0, 0, .04); }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-name { font-family: var(--font-display); font-weight: 500; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.brand-tag { font-family: var(--font-display); font-weight: 700; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink); background: var(--accent-tint); padding: 4px 8px; border-radius: 7px; white-space: nowrap; }
.search-btn {
  display: flex; align-items: center; gap: 10px; flex: 0 1 440px; min-width: 0; height: 42px; margin: 0 auto 0 max(16px, calc((100% - 1100px) / 4));
  padding: 0 8px 0 13px; border-radius: 13px; border: 1px solid var(--line); background: var(--panel); color: var(--ink2);
  font-family: var(--font-body); font-size: 14px; cursor: pointer; text-align: left; box-shadow: var(--e1);
  transition: border-color var(--dur), box-shadow var(--dur), color var(--dur);
}
.search-btn:hover { border-color: var(--line-strong); color: var(--ink); box-shadow: var(--e2); }
.search-btn .material-symbols-rounded { font-size: 21px; }
.search-btn-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
.account-btn {
  display: flex; align-items: center; gap: 9px; height: 42px; padding: 0 8px 0 4px; margin-left: 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; box-shadow: var(--e1);
  font-family: var(--font-display); font-weight: 500; font-size: 14px; max-width: 240px;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.account-btn:hover, .account-btn[aria-expanded="true"] { border-color: var(--line-strong); box-shadow: var(--e2); }
.account-btn .avatar { --size: 32px; }
.account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn > .material-symbols-rounded { font-size: 20px; color: var(--ink2); }
.nav-toggle, .drawer-head, .nav-scrim { display: none; }

.shell { position: relative; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); align-items: start; max-width: 1680px; }
.sidebar {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: 22px; padding: 22px 14px 18px 16px; overflow-y: auto; scrollbar-width: thin;
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-eyebrow { font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink2); padding: 0 12px 7px; margin: 0; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 10px 0 12px;
  border-radius: 12px; color: var(--ink2); text-decoration: none; border: 0; background: none; width: 100%; cursor: pointer;
  font-family: var(--font-display); font-weight: 500; font-size: 14.5px; text-align: left;
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.nav-item .material-symbols-rounded { font-size: 22px; transition: color var(--dur); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: color-mix(in srgb, var(--panel2) 80%, transparent); color: var(--ink); }
.nav-item.is-on { background: var(--panel); color: var(--ink); box-shadow: var(--e1), 0 0 0 1px var(--line); }
.nav-item.is-on .material-symbols-rounded { color: var(--accent-ink); font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.nav-item.is-on::before { content: ""; position: absolute; left: -9px; top: 11px; bottom: 11px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav-badge { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; line-height: 1; padding: 4px 7px; border-radius: 999px; background: var(--panel2); color: var(--ink2); flex: none; }
.nav-badge .material-symbols-rounded { font-size: 13px !important; color: inherit !important; }
.nav-item.is-on .nav-badge { background: var(--accent-tint); color: var(--accent-ink); }
.nav-badge.is-alert { background: var(--danger); color: var(--on-danger); }
.side-foot { margin-top: auto; display: grid; gap: 2px; padding: 12px 4px 0; border-top: 1px solid var(--line); }
.side-link { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 9px; color: var(--ink2); text-decoration: none; font-size: 13px; }
.side-link:hover { color: var(--ink); background: var(--panel2); }
.side-link .material-symbols-rounded { font-size: 17px; }

.main { position: relative; min-width: 0; width: 100%; max-width: var(--main-max); margin: 0 auto; padding: 26px 32px calc(90px + var(--safe-b)); }
.main:focus { outline: none; }
.main.is-wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; gap: 14px 18px; flex-wrap: wrap; margin-bottom: 22px; min-height: 44px; }
.page-heading { flex: 1 1 280px; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; margin: 0 0 6px -6px; font-size: 13px; color: var(--ink2); }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--ink2); text-decoration: none; padding: 3px 6px; border-radius: 7px; }
.crumbs a:hover { color: var(--ink); background: var(--panel2); }
.crumbs .material-symbols-rounded { font-size: 17px; }
.crumbs > span { padding: 3px 4px; }
.page-title { font-size: clamp(26px, 1.2vw + 20px, 34px); font-weight: 500; letter-spacing: -.022em; line-height: 1.15; overflow-wrap: anywhere; }
.page-title:focus { outline: none; }
.page-sub { color: var(--ink2); font-size: 14.5px; margin-top: 5px; }
.appbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.appbar-actions:empty { display: none; }
.view { position: relative; min-width: 0; }
.view.is-entering { animation: viewIn .26s var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
/* Staggered entrance for up to six children — anything after that arrives with
   the sixth, so a long list never makes the page feel slow. */
.stagger > * { animation: riseIn .32s var(--ease-out) both; }
.stagger > *:nth-child(2) { animation-delay: 30ms; } .stagger > *:nth-child(3) { animation-delay: 60ms; }
.stagger > *:nth-child(4) { animation-delay: 90ms; } .stagger > *:nth-child(5) { animation-delay: 120ms; }
.stagger > *:nth-child(n+6) { animation-delay: 150ms; }
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } }

/* ============================================================ LOGIN ========= */
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--panel); }
.login-art {
  position: relative; overflow: hidden; isolation: isolate; color: #fff; background: #101218;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 48px 52px; min-height: 100%;
}
.login-art::after { /* legibility scrim under the copy + a soft vignette */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(16, 18, 24, .15) 0%, rgba(16, 18, 24, .35) 45%, rgba(16, 18, 24, .96) 88%),
              radial-gradient(120% 80% at 50% 0%, transparent 40%, rgba(16, 18, 24, .5) 100%);
}
.login-mosaic {
  position: absolute; z-index: -2; top: -14%; left: -18%; right: -18%; display: flex; justify-content: center; gap: 18px;
  transform: rotate(-11deg);
}
.lm-col { display: flex; flex-direction: column; gap: 18px; animation: lmDrift 26s ease-in-out infinite alternate; }
.lm-col:nth-child(even) { animation-direction: alternate-reverse; margin-top: 64px; }
.lm-col:nth-child(3n) { animation-duration: 32s; }
.lm-tile {
  display: grid; place-items: center; width: 96px; height: 96px; border-radius: 28px; color: #fff; flex: none;
  background: linear-gradient(150deg, hsl(var(--hue) 70% 58%), hsl(calc(var(--hue) - 20) 72% 40%));
  background: linear-gradient(150deg, oklch(.74 .16 calc(var(--hue) + 10)), oklch(.52 .18 calc(var(--hue) - 16)));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 18px 40px -18px rgba(0, 0, 0, .8);
}
.lm-tile .material-symbols-rounded { font-size: 46px; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 48; }
.lm-tile.is-ghost { background: rgba(255, 255, 255, .06); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
@keyframes lmDrift { from { transform: translateY(0); } to { transform: translateY(-90px); } }
.login-art-copy { position: relative; max-width: 460px; }
.login-kicker { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 500; font-size: 14px; color: rgba(255, 255, 255, .78); margin-bottom: 18px; }
.login-kicker img { width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(255, 255, 255, .2); }
.login-headline { font-size: clamp(30px, 2.6vw + 10px, 44px); font-weight: 500; letter-spacing: -.028em; line-height: 1.08; color: #fff; }
.login-lede { margin-top: 14px; color: rgba(255, 255, 255, .72); font-size: 15.5px; line-height: 1.55; max-width: 40ch; }
.login-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 28px; background: var(--panel); min-width: 0; }
.login-card { width: min(392px, 100%); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; }
.login-brand .brand-mark { width: 40px; height: 40px; }
.login-title { font-size: 30px; font-weight: 500; letter-spacing: -.02em; line-height: 1.15; }
.login-sub { color: var(--ink2); font-size: 15px; margin: 6px 0 24px; }
.login-card .field { margin-top: 14px; }
.login-card .field-box { min-height: 48px; border-radius: 13px; background: var(--bg); border-color: var(--line); }
.login-card .field-box:focus-within { background: var(--panel); }
.login-actions { display: grid; gap: 10px; margin-top: 20px; }
.login-or { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--ink2); font-size: 12.5px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-sent { color: var(--ink2); font-size: 14.5px; line-height: 1.5; margin: -8px 0 6px; }
.login-sent strong { color: var(--ink); font-weight: 500; }
.code-input { font-family: var(--font-mono) !important; font-size: 24px !important; letter-spacing: .5em; text-align: center; padding-left: .5em !important; font-variant-numeric: tabular-nums; }
.login-card .msg { justify-content: flex-start; margin-top: 16px; }
.login-card .note { margin: 0 0 14px; }
.login-foot { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 36px; color: var(--ink2); font-size: 13px; }
.login-foot a { color: var(--ink2); text-decoration: none; }
.login-foot a:hover { color: var(--ink); text-decoration: underline; }

/* ====================================================== COMMAND PALETTE ===== */
.cmdk { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.cmdk-bar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex: none; }
.cmdk-bar > .material-symbols-rounded { color: var(--ink2); font-size: 24px; }
.cmdk-input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--ink); font-family: var(--font-display); font-size: 18px; padding: 6px 0; }
.cmdk-input::placeholder { color: var(--ink2); opacity: .8; }
.cmdk-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; overscroll-behavior: contain; scroll-padding: 8px; }
.cmdk-group { padding: 12px 10px 6px; color: var(--ink2); font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.cmdk-item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 10px; border-radius: 11px; cursor: pointer; color: var(--ink); }
.cmdk-item[aria-selected="true"] { background: var(--accent-tint); }
.cmdk-item[aria-selected="true"] .cmdk-go { opacity: 1; }
.cmdk-lead { display: grid; place-items: center; width: 34px; height: 34px; flex: none; }
.cmdk-lead > .material-symbols-rounded { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--panel2); color: var(--ink2); font-size: 19px; }
.cmdk-lead .avatar { --size: 32px; }
.cmdk-lead .app-icon { --size: 32px; }
.cmdk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cmdk-title { font-family: var(--font-display); font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-title mark { background: none; color: var(--accent-ink); font-weight: 700; }
.cmdk-sub { color: var(--ink2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-go { color: var(--ink2); font-size: 12px; opacity: 0; display: inline-flex; align-items: center; gap: 4px; flex: none; }
.cmdk-go .material-symbols-rounded { font-size: 18px; }
.cmdk-empty { padding: 36px 16px; text-align: center; color: var(--ink2); font-size: 14px; }
.cmdk-foot { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--ink2); font-size: 12px; flex: none; flex-wrap: wrap; }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ============================================================ KIT =========== */
/* #/kit — the living style guide (core-owned, hidden from the nav). */
.kit-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 26px; }
.kit-sec + .kit-sec { margin-top: 44px; }
.kit-sample { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.kit-sample + .kit-sample { margin-top: 14px; }
.kit-label { font-family: var(--font-mono); font-size: 11px; color: var(--ink2); margin: 18px 0 8px; }
.kit-label:first-child { margin-top: 0; }
.kit-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.kit-swatch { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.kit-swatch i { display: block; height: 58px; }
.kit-swatch div { padding: 8px 10px; font-size: 12.5px; }
.kit-swatch code { display: block; background: none; padding: 0; color: var(--ink2); font-size: 11px; margin-top: 2px; }
.kit-apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.kit-app { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--h-tint); color: var(--h-ink); min-width: 0; }
.kit-app strong { display: block; font-family: var(--font-display); font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kit-app > div > span { font: 400 11px var(--font-mono); opacity: .85; }
.kit-app > div { min-width: 0; }
.kit-type > * + * { margin-top: 10px; }
.kit-fmt { width: 100%; border-collapse: collapse; font-size: 13px; }
.kit-fmt td, .kit-fmt th { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.kit-fmt th { font-family: var(--font-display); font-weight: 500; color: var(--ink2); font-size: 12px; border-top: 0; }
.kit-fmt td:first-child { font-family: var(--font-mono); font-size: 12px; color: var(--accent-ink); white-space: nowrap; }
.kit-band { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: var(--radius); background: var(--h-strong); color: #fff; }
.kit-band .avatar { --size: 56px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
.kit-band strong { display: block; font-family: var(--font-display); font-weight: 500; font-size: 20px; }
.kit-band > div > span { opacity: .85; font-size: 13.5px; }


/* ---- Home Studio: copied VERBATIM from styles.css lines 617-762 (DESIGN.md §7.5).
   Do not restyle here; if the studio needs a tweak, add a rule below the block. ---- */
/* ========================================================== HOME STUDIO =====
   The home-page editor (#/home). Layout: a live preview canvas on the left —
   the real page, rendered by the same template Publish uses, inside a scaled
   iframe — and an inspector rail on the right (Page / Sidebar / Theme). All
   studio-only classes carry the hs- prefix so none of it can leak into the
   console's own components. */
.hs-wrap { display: flex; gap: 18px; align-items: flex-start; }
.hs-canvas { flex: 1 1 auto; min-width: 0; position: sticky; top: calc(var(--topbar-h) + 14px + env(safe-area-inset-top, 0px)); }
.hs-canvas-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.hs-canvas-bar .seg button { padding: 5px 11px; }
.hs-canvas-note { font-family: var(--font-mono); font-size: 11px; color: var(--ink2); margin-left: auto; }
.hs-frame-box {
  position: relative; overflow: hidden;
  height: calc(100dvh - var(--topbar-h) - 205px); min-height: 400px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius);
}
.hs-frame { display: block; border: none; transform-origin: top left; background: transparent; }
.hs-frame-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink2); font-size: 13.5px; padding: 24px; text-align: center; }

.hs-rail { flex: none; width: 340px; min-width: 0; }
.hs-tabs .seg { display: flex; width: 100%; }
.hs-tabs .seg button { flex: 1; }
.hs-rail-body { margin-top: 12px; display: grid; gap: 12px; align-content: start; }

/* Inspector lists (sections / sidebar tree). */
.hs-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--e1); overflow: hidden; }
.hs-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--line); transition: background var(--dur); user-select: none;
}
.hs-row:last-child { border-bottom: none; }
.hs-row:hover { background: var(--panel2); }
.hs-row.is-sel { background: var(--accent-tint); }
.hs-row.hs-sub { padding-left: 36px; }
.hs-row-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--panel2); color: var(--ink2); flex: none; }
.hs-row-ic .material-symbols-rounded { font-size: 18px; }
.hs-row.is-sel .hs-row-ic { background: var(--accent-tint-strong); color: var(--accent-ink); }
.hs-row-main { flex: 1; min-width: 0; }
.hs-row-title { font-family: var(--font-display); font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-row-meta { color: var(--ink2); font-family: var(--font-mono); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.hs-row-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.hs-mini-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 8px; border: none; background: transparent; color: var(--ink2); cursor: pointer;
  transition: background var(--dur), color var(--dur), opacity var(--dur);
}
.hs-mini-btn:hover:not(:disabled) { background: var(--accent-tint); color: var(--ink); }
.hs-mini-btn:disabled { opacity: .3; cursor: default; }
.hs-mini-btn .material-symbols-rounded { font-size: 17px; }
.hs-drag-handle { cursor: grab; color: var(--ink2); }
.hs-row.hs-dragging { opacity: .35; }
.hs-row.hs-drop-above { box-shadow: inset 0 2px 0 var(--accent); }
.hs-row.hs-drop-below { box-shadow: inset 0 -2px 0 var(--accent); }

.hs-add {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 11px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: none; color: var(--ink2); cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
  transition: border-color var(--dur), color var(--dur), background var(--dur);
}
.hs-add:hover { border-color: var(--accent); color: var(--ink); background: var(--accent-tint); }
.hs-add .material-symbols-rounded { font-size: 19px; }

/* Theme tab. */
.hs-pal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.hs-pal {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; cursor: pointer;
  background: var(--panel); transition: border-color var(--dur), background var(--dur); text-align: left;
}
.hs-pal:hover { border-color: var(--line-strong); background: var(--panel2); }
.hs-pal.is-on { border-color: var(--accent); }
.hs-pal-sw { display: flex; height: 34px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.hs-pal-sw i { flex: 1; }
.hs-pal-name { display: block; font-family: var(--font-display); font-weight: 600; font-size: 12px; margin-top: 6px; color: var(--ink); }
.hs-color-row { display: flex; align-items: center; gap: 10px; }
.hs-color-row + .hs-color-row { margin-top: 8px; }
.hs-color-swatch { width: 44px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: none; cursor: pointer; flex: none; }
.hs-color-label { flex: 1; min-width: 0; font-family: var(--font-display); font-weight: 600; font-size: 13px; }
.hs-color-hex { width: 92px; flex: none; font-family: var(--font-mono); font-size: 12.5px; padding: 8px 10px; }
.hs-contrast { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.chip-ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.chip.chip-warn { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* Skin cards (mini previews of the three side-panel looks). */
.hs-skin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hs-skin {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px; cursor: pointer;
  background: var(--panel); text-align: center; transition: border-color var(--dur);
}
.hs-skin:hover { border-color: var(--line-strong); }
.hs-skin.is-on { border-color: var(--accent); }
.hs-skin-prev { display: flex; flex-direction: column; gap: 3px; justify-content: center; height: 52px; padding: 6px; border-radius: 8px; }
.hs-skin-prev span { display: block; height: 9px; border-radius: 4px; }
.hs-skin-name { display: block; font-family: var(--font-display); font-weight: 600; font-size: 11px; margin-top: 5px; color: var(--ink2); }
.hs-skin.is-on .hs-skin-name { color: var(--ink); }

/* Add-a-section palette dialog. */
.hs-block-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.hs-block-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px; cursor: pointer;
  background: var(--panel); text-align: left; transition: border-color var(--dur), transform var(--dur), box-shadow var(--dur);
}
.hs-block-card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--e1); }
.hs-block-thumb { height: 72px; border-radius: 8px; overflow: hidden; position: relative; margin-bottom: 8px; border: 1px solid var(--line); }
.hs-block-name { font-family: var(--font-display); font-weight: 600; font-size: 12.5px; }
.hs-block-sub { color: var(--ink2); font-size: 11px; margin-top: 2px; line-height: 1.35; }

/* Picture picker. */
.hs-asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.hs-asset { position: relative; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; cursor: pointer; background: var(--panel2); padding: 0; }
.hs-asset:hover { border-color: var(--line-strong); }
.hs-asset.is-on { outline: 2px solid var(--accent); outline-offset: 1px; }
.hs-asset img { width: 100%; height: 68px; object-fit: cover; display: block; }
.hs-asset-name { display: block; font-family: var(--font-mono); font-size: 9.5px; color: var(--ink2); padding: 3px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-asset-del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; border: none; display: grid; place-items: center; cursor: pointer; }
.hs-asset-del .material-symbols-rounded { font-size: 14px; }

/* Icon picker. */
.hs-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; max-height: 260px; overflow-y: auto; padding: 2px; }
.hs-icon-cell {
  display: grid; place-items: center; height: 44px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); color: var(--ink); cursor: pointer; transition: background var(--dur), border-color var(--dur);
}
.hs-icon-cell:hover { background: var(--panel2); border-color: var(--line-strong); }
.hs-icon-cell.is-on { background: var(--accent-tint); border-color: var(--accent); }
.hs-icon-cell .material-symbols-rounded { font-size: 21px; }

/* Small editors inside dialogs (button-row links, quote lines). */
.hs-mini-list { display: grid; gap: 8px; }
.hs-mini-row { display: flex; align-items: center; gap: 8px; }
.hs-mini-row .input { flex: 1; min-width: 0; }
.hs-mini-row .input.hs-narrow { flex: none; width: 110px; }

/* Appbar status. */
.hs-status { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink2); white-space: nowrap; }
.hs-status.is-err { color: var(--danger); }
.hs-status.is-live { color: var(--ok); }

@media (max-width: 1180px) { .hs-rail { width: 300px; } }
@media (max-width: 820px) {
  .hs-wrap { flex-direction: column; }
  .hs-canvas { position: static; width: 100%; }
  .hs-frame-box { height: 58vh; min-height: 320px; }
  .hs-rail { width: 100%; }
}

/* The studio wants every pixel: #/home switches the main column to .is-wide. */
.main.is-wide .hs-wrap { gap: 20px; }

/* ======================================================== RESPONSIVE ======== */
@media (max-width: 1280px) {
  :root { --side-w: 228px; }
  .main { padding-left: 26px; padding-right: 26px; }
}
@media (max-width: 1180px) {
  .bento > .span-2 { grid-column: span 4; }
  .bento > .span-3, .bento > .span-4, .bento > .span-5 { grid-column: span 6; }
  .bento > .span-7, .bento > .span-8, .bento > .span-9 { grid-column: span 12; }
}
/* ≤ 900 px: the sidebar becomes an off-canvas drawer opened from the topbar.
   visibility (not just the transform) so a closed drawer leaves the tab order. */
@media (max-width: 900px) {
  :root { --topbar-h: 58px; }
  .topbar { gap: 8px; padding: 0 10px; padding-top: env(safe-area-inset-top, 0px); }
  .nav-toggle { display: inline-grid; }
  .brand-name { font-size: 16px; }
  .search-btn { flex: none; width: 40px; height: 40px; padding: 0; justify-content: center; margin: 0 0 0 auto; border-radius: 12px; box-shadow: none; border-color: transparent; background: none; color: var(--ink2); }
  .search-btn-text, .search-btn .kbd { display: none; }
  .topbar-actions { margin-left: 0; gap: 2px; }
  .account-btn { padding: 0 4px; border-color: transparent; box-shadow: none; background: none; }
  .account-name, .account-btn > .material-symbols-rounded { display: none; }

  .shell { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(86vw, 312px); height: 100dvh;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px calc(18px + var(--safe-b));
    background: var(--panel); border-right: 1px solid var(--line); box-shadow: var(--e3);
    overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-104%); visibility: hidden;
    transition: transform .26s var(--ease-out), visibility .26s linear;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  body.nav-open { overflow: hidden; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0 4px 4px; }
  .nav-item.is-on::before { display: none; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: var(--scrim); opacity: 0; visibility: hidden; transition: opacity .26s, visibility .26s linear; }
  body.nav-open .nav-scrim { opacity: 1; visibility: visible; }

  .main { padding: 18px 16px calc(64px + var(--safe-b)); }
  .page-head { margin-bottom: 18px; }
  .appbar-actions { margin-left: 0; justify-content: flex-start; width: 100%; }
  .page-head:has(.appbar-actions:empty) { margin-bottom: 16px; }

  .login { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; background: var(--panel); }
  .login-art { min-height: 0; height: 230px; padding: 24px; justify-content: flex-end; }
  .login-art::after { background: linear-gradient(180deg, rgba(16, 18, 24, 0) 20%, rgba(16, 18, 24, .92) 100%); }
  .login-mosaic { top: -40%; }
  .lm-tile { width: 70px; height: 70px; border-radius: 21px; }
  .lm-tile .material-symbols-rounded { font-size: 34px; }
  .login-headline { font-size: 24px; }
  .login-lede { display: none; }
  .login-kicker { margin-bottom: 10px; }
  .login-panel { justify-content: flex-start; padding: 28px 20px calc(28px + var(--safe-b)); }
  .login-brand { display: none; }
}
@media (max-width: 720px) {
  .bento > .span-2, .bento > .span-3 { grid-column: span 6; }
  .bento > .span-4, .bento > .span-5, .bento > .span-6 { grid-column: span 12; }
  .bento > .rows-2 { grid-row: auto; }
  .kpi { min-height: 132px; }
  .kpi-spark { height: 40px; }
  .facts { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .lr-meta { display: none; }
  .lr .lr-meta.is-keep { display: block; }
}
/* ≤ 640 px: every dialog is a bottom sheet, actions full-width at the thumb. */
@media (max-width: 640px) {
  .dialog { place-items: end stretch; padding: 0; }
  .dialog-card, .dialog-card.is-sm, .dialog-card.is-lg, .dialog-card.is-xl {
    width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; border-bottom: 0;
    padding-bottom: var(--safe-b); animation: sheetIn .28s var(--ease-out);
  }
  .dialog-grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 9px auto 0; flex: none; }
  .dialog-head { padding: 12px 16px 2px 20px; }
  .dialog-body { padding: 12px 20px 8px; }
  .dialog-actions { padding: 12px 20px 16px; }
  .dialog-actions > .btn { flex: 1 1 auto; }
  .dialog.is-palette { place-items: start stretch; padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 0; }
  .dialog.is-palette .dialog-card { border-radius: 18px; max-height: 78dvh; border-bottom: 1px solid var(--line); animation: dialogIn .2s var(--ease-out); }
  .cmdk-foot { display: none; }
  .toasts { bottom: calc(14px + var(--safe-b)); }
  .chk-grid { grid-template-columns: 1fr 1fr; }
  .btn { min-height: max(var(--ctl-h), 42px); }
  .btn-sm { min-height: 36px; }
}
@keyframes sheetIn { from { transform: translateY(100%); } }
@media (max-width: 420px) {
  .brand-tag { display: none; }
  .chk-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 26px; }
}
@media (min-width: 1600px) { :root { --main-max: 1360px; } }

/* ============================================================ MOTION ======== */
/* Honour the OS setting AND the console's own Settings → motion=reduced. The
   durations collapse to ~0 rather than to none, so animationend/transitionend
   listeners still fire. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after {
  animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important;
}
/* The shimmer carries meaning ("still loading"), so under reduced motion it
   becomes a still, slightly darker block instead of disappearing. */
@media (prefers-reduced-motion: reduce) { .skel { background: var(--panel3); } }
:root[data-motion="reduced"] .skel { background: var(--panel3); }

@media print {
  .topbar, .sidebar, .appbar-actions, .toasts, .nav-scrim { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
}
