/* RAABIH PA — shell + component classes (F2). Tokens live in tokens.css.
   Every class here is shown live in #/lab — copy usage from there. */

/* ── Reset / base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; scrollbar-color: var(--edge-strong) transparent; scrollbar-width: thin; }
body {
  margin: 0; min-height: 100%;
  background: var(--void); color: var(--text);
  font: 400 var(--fs-body)/var(--lh-body) var(--font-body);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
body.lock { overflow: hidden; }
h1, h2, h3, h4, p, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--selection); color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--edge-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-xs); }

/* ── Type ─────────────────────────────────────────────────────────────── */
.display, h1, h2, h3 { font-family: var(--font-display); letter-spacing: var(--track-display); line-height: var(--lh-tight); font-weight: 700; text-wrap: balance; }
.hero { font: 800 var(--fs-hero)/.98 var(--font-display); letter-spacing: -0.035em; }
h1, .h1 { font-size: var(--fs-h1); font-weight: 800; }
h2, .h2 { font-size: var(--fs-h2); }
h3, .h3 { font-size: var(--fs-h3); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.lead { font-size: 1.0625rem; color: var(--text-2); max-width: 62ch; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.label { font: 500 var(--fs-xs)/1.2 var(--font-mono); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-3); }
.arabic { font-family: var(--font-arabic); direction: rtl; line-height: var(--lh-arabic); font-size: 1.5rem; }
/* Noor's signature on a WORD: the glyphs stay solid (legible, AA) and the prism is a thin bar of light
   underneath — never gradient-filled text. Reserved for Noor / the owner's name; colour elsewhere means something. */
.prism-text { color: var(--text); background: var(--prism) no-repeat left 96% / 100% .075em; padding-bottom: .04em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; }
:root[data-theme="light"] .prism-text { background-image: linear-gradient(120deg, #00829C, #4F32C8 40%, #B0128A 72%, #8A5A00); }
.ink-v { color: var(--v-ink); }
.ico { width: 1.25em; height: 1.25em; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── Shell layout ─────────────────────────────────────────────────────── */
#app { position: relative; min-height: 100vh; min-height: 100dvh; isolation: isolate; }
.shell { position: relative; z-index: var(--z-stage); display: grid; grid-template-columns: minmax(0, 1fr) auto;
  margin-left: var(--rail-w); min-height: 100vh; min-height: 100dvh; }
.shell-main { min-width: 0; display: flex; flex-direction: column; }
.stage { flex: 1; width: 100%; max-width: var(--stage-max); margin: 0 auto; padding: var(--s-6) var(--s-8) 140px; }
.room { position: relative; min-height: 50vh; }
.room-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); }
.room-head .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* rail — a spine of light. 72px; labels slide out on hover/focus without moving the stage */
/* the rail is ALWAYS laid out at its open width; opening is a clip-path reveal (compositor only) —
   neither the rail's subtree nor the stage relayouts, and clip-path also clips hit-testing so the
   hidden 136px never intercepts clicks meant for the stage */
.rail { position: fixed; inset: 0 auto 0 0; z-index: var(--z-rail); width: var(--rail-w-open);
  display: flex; flex-direction: column; align-items: stretch; gap: var(--s-1); padding: var(--s-3) var(--s-3) var(--s-4);
  background: linear-gradient(180deg, var(--glass-2), var(--glass));
  -webkit-backdrop-filter: blur(var(--blur-heavy)) saturate(140%); backdrop-filter: blur(var(--blur-heavy)) saturate(140%);
  clip-path: inset(0 calc(var(--rail-w-open) - var(--rail-w)) 0 0);
  transition: clip-path var(--d-base) var(--ease-out); }
/* the 1px edge rides along on a transform instead of being a border at the far side of the clip */
.rail::after { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: var(--edge); pointer-events: none;
  transform: translateX(calc(var(--rail-w) - 1px)); transition: transform var(--d-base) var(--ease-out); }
.rail:hover, .rail:focus-within { clip-path: inset(0 0 0 0); }
.rail:hover::after, .rail:focus-within::after { transform: translateX(calc(var(--rail-w-open) - 1px)); }
.rail-orb { width: 48px; height: 48px; margin: 0 0 var(--s-4); flex: none; border-radius: 50%; position: relative; padding: 0; border: 0; background: none; }
.rail-orb .orb { position: absolute; inset: -14px; width: auto; height: auto; aspect-ratio: auto; }
.rail-nav { display: flex; flex-direction: column; gap: var(--s-1); flex: 1; }
.rail-foot { display: flex; flex-direction: column; gap: var(--s-1); }
.rail-item { position: relative; display: flex; align-items: center; gap: var(--s-4); height: 48px; min-width: 48px; padding: 0 12px;
  border-radius: var(--r-md); color: var(--text-2); white-space: nowrap; border: 1px solid transparent; background: none;
  transition: color var(--d-fast), background var(--d-fast), border-color var(--d-fast); text-align: left; }
.rail-item:hover { color: var(--text); background: var(--glass-hover); text-decoration: none; }
.rail-item .ico { flex: none; width: 24px; height: 24px; }
.rail-item .txt { font: 600 .9375rem/1 var(--font-display); letter-spacing: -0.01em; opacity: 0; transform: translateX(-6px);
  transition: opacity var(--d-fast), transform var(--d-base) var(--ease-out); }
.rail-item .kbd { margin-left: auto; opacity: 0; }
.rail:hover .rail-item .txt, .rail:focus-within .rail-item .txt { opacity: 1; transform: none; }
.rail:hover .rail-item .kbd, .rail:focus-within .rail-item .kbd { opacity: .8; }
.rail-item[aria-current="page"] { color: var(--text); background: var(--glass-2); border-color: var(--edge); }
.rail-item[aria-current="page"]::before { content: ''; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0;
  background: var(--prism); background-size: 100% 300%; box-shadow: 0 0 18px var(--violet-glow); }
.rail-item .badge { position: absolute; left: 28px; top: 5px; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); display: inline-grid; place-items: center;
  font: 700 10px/1 var(--font-mono); background: var(--coral); color: #1A0508; box-shadow: 0 0 0 2px var(--void), 0 0 14px var(--coral-glow); }
.kbd { font: 500 10px/1 var(--font-mono); color: var(--text-3); border: 1px solid var(--edge); border-radius: 5px; padding: 3px 5px; }

/* state line bar */
.statebar { position: sticky; top: 0; z-index: calc(var(--z-float) - 1); height: var(--statebar-h);
  display: flex; align-items: center; gap: var(--s-4); padding: 0 var(--s-8);
  isolation: isolate; }
/* a veil, not a bar: content blurs and fades as it slides under the state line */
.statebar::before { content: ''; position: absolute; inset: 0 0 -18px 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, var(--void) 35%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent); mask-image: linear-gradient(180deg, #000 62%, transparent); }
.stateline { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s-3); font: 500 var(--fs-sm)/1.2 var(--font-mono); color: var(--text-2);
  white-space: nowrap; overflow: hidden; }
.stateline .seg-item { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.stateline .seg-item:first-child { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.stateline .seg-item b { color: var(--text); font-weight: 600; }
.stateline .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); flex: none; }
.stateline .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--v, var(--emerald)); box-shadow: 0 0 10px var(--v-glow, var(--emerald-glow)); flex: none; }
.command { position: relative; flex: 0 1 380px; min-width: 0; }
.command input { width: 100%; height: 42px; padding: 0 44px 0 42px; border-radius: var(--r-pill); border: 1px solid var(--edge);
  background: var(--glass); color: var(--text); transition: border-color var(--d-fast), background var(--d-fast), box-shadow var(--d-base); }
.command input::placeholder { color: var(--text-3); }
.command input:focus { border-color: var(--violet); background: var(--glass-2); box-shadow: 0 0 0 4px var(--violet-soft), 0 0 40px var(--violet-soft); outline: none; }
.command .ico { position: absolute; left: 13px; top: 11px; width: 20px; height: 20px; color: var(--text-3); pointer-events: none; }
.command .kbd { position: absolute; right: 12px; top: 12px; }
.statebar-tools { display: flex; align-items: center; gap: var(--s-1); }

/* right context panel */
.context { width: var(--context-w); border-left: 1px solid var(--edge); background: var(--glass); padding: var(--s-6);
  -webkit-backdrop-filter: blur(var(--blur-glass)); backdrop-filter: blur(var(--blur-glass));
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; }
.context-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-4); }

/* floating slots: Quran mini-player + mic. M11 fills #slot-player, M7 may replace #mic-fab */
.float { position: fixed; right: var(--s-6); bottom: var(--s-6); z-index: var(--z-float); display: flex; align-items: flex-end; gap: var(--s-3); pointer-events: none; }
.float > * { pointer-events: auto; }
.slot-player:empty { display: none; }
.mic-fab { width: 60px; height: 60px; border-radius: 50%; border: 0; padding: 0; position: relative; display: grid; place-items: center;
  color: var(--text-on-prism); background: var(--prism); background-size: 200% 200%;
  box-shadow: 0 10px 36px var(--magenta-glow), 0 0 0 1px rgba(255,255,255,.35) inset; transition: transform var(--d-base) var(--ease-snap), box-shadow var(--d-base); }
.mic-fab::before { content: ''; position: absolute; inset: -7px; border-radius: 50%; border: 1px solid var(--magenta); opacity: 0; }
.mic-fab:hover { transform: scale(1.06); }
.mic-fab:active { transform: scale(.95); }
.mic-fab[data-state="listening"]::before { animation: ripple 1.5s var(--ease-out) infinite; }
.mic-fab[data-state="off"] { background: var(--glass-2); color: var(--text-2); box-shadow: var(--shadow-1); border: 1px solid var(--edge);
  -webkit-backdrop-filter: blur(var(--blur-glass)); backdrop-filter: blur(var(--blur-glass)); }
.mic-fab svg { width: 26px; height: 26px; }

/* phone dock */
.dock { display: none; }

/* chrome-less rooms (setup, bedside) */
body[data-chrome="off"] .rail, body[data-chrome="off"] .statebar, body[data-chrome="off"] .dock, body[data-chrome="off"] .float { display: none; }
body[data-chrome="off"] .shell { margin-left: 0; }
body[data-chrome="off"] .stage { max-width: none; padding: 0; }

/* ── FX layers (fx.js) ────────────────────────────────────────────────── */
.fx { position: fixed; inset: 0; z-index: var(--z-fx); overflow: hidden; pointer-events: none; background:
  radial-gradient(120% 80% at 50% -10%, var(--deep), var(--void) 60%); contain: strict; }
.fx-aurora { position: absolute; inset: -20%; }
.fx-blob { position: absolute; border-radius: 50%; will-change: transform; animation: drift 38s var(--ease-in-out) infinite alternate; }
.fx-blob.b1 { width: 62vmax; height: 62vmax; left: -8%; top: -18%; background: radial-gradient(closest-side, var(--aurora-2), transparent 70%); }
.fx-blob.b2 { width: 54vmax; height: 54vmax; right: -6%; top: 4%; background: radial-gradient(closest-side, var(--aurora-1), transparent 70%); animation-duration: 46s; animation-delay: -12s; }
.fx-blob.b3 { width: 58vmax; height: 58vmax; left: 22%; bottom: -30%; background: radial-gradient(closest-side, var(--aurora-3), transparent 70%); animation-duration: 54s; animation-delay: -25s; }
.fx-blob.b4 { width: 40vmax; height: 40vmax; right: 14%; bottom: -12%; background: radial-gradient(closest-side, var(--aurora-4), transparent 70%); animation-duration: 42s; animation-delay: -7s; }
.fx-stars { position: absolute; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px); will-change: transform; }
.fx-stars.far { opacity: .55; }
.fx-grain { position: absolute; inset: 0; opacity: var(--grain-opacity); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
:root[data-theme="light"] .fx-grain { mix-blend-mode: multiply; filter: invert(1); }
.fx-cursor { position: fixed; left: 0; top: 0; width: 520px; height: 520px; margin: -260px 0 0 -260px; border-radius: 50%; z-index: var(--z-fx);
  background: radial-gradient(closest-side, var(--violet-soft), transparent 70%); opacity: 0; transition: opacity var(--d-slow); will-change: transform; pointer-events: none; }
.fx[data-paused="true"] .fx-blob { animation-play-state: paused; }

/* ── Panel (glass) ────────────────────────────────────────────────────── */
.panel { position: relative; padding: var(--s-6); border-radius: var(--r-lg); background: var(--glass-solid);
  border: 1px solid var(--edge); box-shadow: var(--shadow-1); color: var(--text); }
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .panel, .sheet, .modal, .toast { background: var(--glass); -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(150%); backdrop-filter: blur(var(--blur-glass)) saturate(150%); }
  .sheet, .modal { background: var(--glass-2); -webkit-backdrop-filter: blur(var(--blur-heavy)) saturate(150%); backdrop-filter: blur(var(--blur-heavy)) saturate(150%); }
}
/* the lit top edge: light falls on glass from above */
.panel::before { content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(180deg, var(--edge-top), transparent 38%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); opacity: .7; }
.panel.prism::before { background: var(--prism); opacity: .85; }
.panel[data-v]::before { background: linear-gradient(160deg, var(--v), transparent 46%); opacity: .8; }
.panel.flat { box-shadow: none; }
.panel.pad-sm { padding: var(--s-4); border-radius: var(--r-md); }
.panel.risk { border-color: var(--coral); box-shadow: var(--shadow-1), 0 0 0 1px var(--coral-soft), 0 0 40px var(--coral-soft); }
.panel.risk::before { display: none; }
.panel.warn { border-color: var(--amber); }
.panel.warn::before { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.panel-head h3 { display: flex; align-items: center; gap: var(--s-2); }

/* tilt: motion.tilt(el) writes style.transform and drives --mx/--my/--spec for the highlight */
.panel.tilt, .tilt { --mx: 50%; --my: 0%; --spec: 0; will-change: transform; }
.tilt::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: var(--spec);
  background: radial-gradient(420px circle at var(--mx) var(--my), var(--specular), transparent 62%); transition: opacity var(--d-base); mix-blend-mode: soft-light; }
:root:not([data-theme="light"]) .tilt::after { mix-blend-mode: screen; }

/* ── Grid helpers ─────────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--s-4); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack.tight { gap: var(--s-2); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.spread > code, .spread > .chip, .spread > .btn { flex: none; }
.grow { flex: 1; min-width: 0; }

/* ── Chip ─────────────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  font: 600 var(--fs-xs)/1 var(--font-mono); letter-spacing: .04em; white-space: nowrap;
  color: var(--text-2); background: var(--glass-2); border: 1px solid var(--edge); }
.chip svg { width: 13px; height: 13px; }
.chip.ok { color: var(--ok-ink); background: var(--ok-soft); border-color: transparent; }
.chip.warn { color: var(--warn-ink); background: var(--warn-soft); border-color: transparent; }
.chip.risk { color: var(--risk-ink); background: var(--risk-soft); border-color: var(--coral); }
.chip.live { color: var(--live-ink); background: var(--live-soft); border-color: transparent; }
.chip.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 8px var(--magenta-glow); animation: blink 1.6s ease-in-out infinite; }
.chip[data-v] { color: var(--v-ink); background: var(--v-soft); border-color: transparent; }
button.chip { height: 32px; cursor: pointer; transition: background var(--d-fast), border-color var(--d-fast); }
button.chip:hover { border-color: var(--edge-strong); }
button.chip[aria-pressed="true"] { color: var(--text); border-color: var(--violet); background: var(--violet-soft); }

.badge-venture { display: inline-flex; align-items: center; gap: 7px; font: 600 var(--fs-xs)/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--v-ink, var(--text-2)); }
.badge-venture::before { content: ''; width: 8px; height: 8px; border-radius: 3px; rotate: 45deg; background: var(--v, var(--text-3)); box-shadow: 0 0 10px var(--v-glow, transparent); }

/* ── Button ───────────────────────────────────────────────────────────── */
.btn { --bg: var(--glass-2); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5); border-radius: var(--r-md); border: 1px solid var(--edge-strong); background: var(--bg); color: var(--text);
  font: 600 var(--fs-body)/1 var(--font-body); white-space: nowrap; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background var(--d-fast), border-color var(--d-fast), box-shadow var(--d-base), filter var(--d-fast); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { --bg: var(--glass-hover); text-decoration: none; }
.btn:active { filter: brightness(.92); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn.primary { border: 0; color: var(--text-on-prism); background: var(--prism); background-size: 180% 100%; background-position: 0 0;
  box-shadow: 0 8px 30px var(--violet-glow), 0 0 0 1px rgba(255,255,255,.4) inset; transition: background-position var(--d-slow) var(--ease-out), box-shadow var(--d-base); }
.btn.primary:hover { background-position: 100% 0; box-shadow: 0 10px 44px var(--magenta-glow), 0 0 0 1px rgba(255,255,255,.55) inset; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--glass-hover); color: var(--text); }
.btn.danger { color: var(--risk-ink); border-color: var(--coral); background: var(--risk-soft); }
.btn.danger:hover { box-shadow: 0 0 30px var(--coral-soft); }
.btn.icon { width: var(--tap); padding: 0; border-radius: 50%; }
.btn.sm { min-height: 34px; padding: 0 var(--s-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn.sm.icon { width: 34px; }
.btn.block { width: 100%; }
.btn .dotbadge { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 2px var(--void), 0 0 10px var(--coral-glow); }
/* press-and-hold confirm (ui.confirmHold): --hold 0..1 */
.btn.hold { --hold: 0; overflow: hidden; touch-action: none; }
.btn.hold::after { content: ''; position: absolute; inset: 0; background: currentColor; opacity: .2; transform-origin: left; transform: scaleX(var(--hold)); pointer-events: none; }

/* ── Field ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .field-label { font: 500 var(--fs-xs)/1.2 var(--font-mono); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-2); }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: var(--r-sm); border: 1px solid var(--edge-strong);
  background: var(--glass); color: var(--text); transition: border-color var(--d-fast), box-shadow var(--d-base), background var(--d-fast); }
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field select { appearance: none; padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%; background-size: 6px 6px; background-repeat: no-repeat; }
.field select option { background: var(--raise); color: var(--text); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--violet); background: var(--glass-2); box-shadow: 0 0 0 4px var(--violet-soft); }
.field .hint { font-size: var(--fs-sm); color: var(--text-3); }
.field.error input, .field.error textarea, .field.error select { border-color: var(--coral); box-shadow: 0 0 0 4px var(--coral-soft); }
.field.error .hint { color: var(--risk-ink); }
.check { display: inline-flex; align-items: center; gap: var(--s-3); min-height: var(--tap); cursor: pointer; }
.check input { appearance: none; width: 22px; height: 22px; min-height: 0; flex: none; margin: 0; padding: 0; border-radius: 7px; border: 1.5px solid var(--edge-strong); background: var(--glass); display: grid; place-items: center; transition: background var(--d-fast), border-color var(--d-fast); }
.check input::after { content: ''; width: 10px; height: 6px; border: 2px solid var(--text-on-prism); border-top: 0; border-right: 0; rotate: -45deg; translate: 0 -1px; scale: 0; transition: scale var(--d-fast) var(--ease-snap); }
.check input:checked { background: var(--emerald); border-color: var(--emerald); }
.check input:checked::after { scale: 1; }
.check input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.switch { appearance: none; width: 46px; height: 28px; min-height: 0; border-radius: 28px; border: 1px solid var(--edge-strong); background: var(--glass); position: relative; cursor: pointer; flex: none; padding: 0; transition: background var(--d-base); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: transform var(--d-base) var(--ease-snap), background var(--d-fast); }
.switch[aria-checked="true"] { background: var(--violet-soft); border-color: var(--violet); }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: var(--violet); box-shadow: 0 0 12px var(--violet-glow); }

/* ── Segmented + tabstrip ─────────────────────────────────────────────── */
.seg { position: relative; display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--r-md); background: var(--glass); border: 1px solid var(--edge); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button, .seg a { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 var(--s-4); border: 0; border-radius: 11px; background: none;
  font: 600 var(--fs-sm)/1 var(--font-body); color: var(--text-2); white-space: nowrap; transition: color var(--d-fast); }
.seg svg { width: 16px; height: 16px; }
.seg button:hover, .seg a:hover { color: var(--text); text-decoration: none; }
.seg [aria-selected="true"], .seg [aria-current="page"] { color: var(--text); }
.seg .seg-thumb { position: absolute; z-index: 0; top: 4px; left: 0; height: calc(100% - 8px); width: 0; border-radius: 11px; background: var(--glass-hover); border: 1px solid var(--edge-strong); box-shadow: var(--shadow-1); pointer-events: none; }
.tabstrip { margin-bottom: var(--s-6); }

/* ── List ─────────────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }
.list > .row { position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: var(--s-3) var(--s-3); border-radius: var(--r-sm);
  border-bottom: 1px solid var(--edge); transition: background var(--d-fast); }
.list > .row:last-child { border-bottom: 0; }
.list > .row:hover { background: var(--glass); }
.list > .row.is-done .row-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: var(--fs-sm); color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.row-time { font: 500 var(--fs-sm)/1 var(--font-mono); color: var(--text-2); flex: none; }
.row-ico { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--v-soft, var(--glass-2)); color: var(--v-ink, var(--text-2)); }
.row-ico svg { width: 18px; height: 18px; }
.row.risk { border: 1px solid var(--coral); background: var(--risk-soft); margin: 4px 0; }

/* ── KPI ──────────────────────────────────────────────────────────────── */
.kpi { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.kpi-value { white-space: nowrap; font: 800 clamp(1.75rem, 1.2rem + 1.5vw, 2.75rem)/1 var(--font-display); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; color: var(--text); display: flex; align-items: baseline; gap: 6px; }
.kpi-value .unit { font: 500 var(--fs-sm)/1 var(--font-mono); letter-spacing: 0; color: var(--text-3); }
.kpi[data-v] .kpi-value { color: var(--v-ink); text-shadow: 0 0 34px var(--v-glow); }
:root[data-theme="light"] .kpi[data-v] .kpi-value { text-shadow: none; }
.kpi-delta { font: 600 var(--fs-xs)/1 var(--font-mono); display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--ok-ink); } .kpi-delta.down { color: var(--risk-ink); } .kpi-delta.flat { color: var(--text-3); }
.kpi-gap { font-size: var(--fs-sm); color: var(--text-3); } /* honesty: a missing number is a stated gap, never 0 */

/* ── Ring ─────────────────────────────────────────────────────────────── */
.ring { --size: 96px; position: relative; width: var(--size); height: var(--size); flex: none; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; rotate: -90deg; overflow: visible; }
.ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring .ring-track { stroke: var(--edge); }
.ring .ring-bar { stroke: var(--v, var(--violet)); filter: drop-shadow(0 0 6px var(--v-glow, var(--violet-glow))); transition: stroke-dashoffset var(--d-slow) var(--ease-out); }
.ring-label { position: relative; text-align: center; font: 700 1.125rem/1 var(--font-display); letter-spacing: -0.03em; }
.ring-label small { display: block; margin-top: 3px; font: 500 9px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }

/* ── Timeline ─────────────────────────────────────────────────────────── */
.timeline { position: relative; display: flex; flex-direction: column; gap: var(--s-1); padding-left: 100px; }
.timeline::before { content: ''; position: absolute; left: 85px; top: 10px; bottom: 10px; width: 1px; background: linear-gradient(180deg, transparent, var(--edge-strong) 8%, var(--edge-strong) 92%, transparent); }
.tl-item { position: relative; padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); min-height: 52px; transition: background var(--d-fast); }
.tl-item:hover { background: var(--glass); }
.tl-item::before { content: ''; position: absolute; left: -20px; top: 20px; width: 11px; height: 11px; border-radius: 50%; background: var(--void); border: 2px solid var(--v, var(--text-3)); box-shadow: 0 0 12px var(--v-glow, transparent); }
.tl-item.is-now::before { background: var(--v, var(--magenta)); animation: blink 1.8s ease-in-out infinite; }
.tl-item.is-past { opacity: .55; }
.tl-time { position: absolute; left: -100px; top: 16px; width: 68px; text-align: right; white-space: nowrap; font: 500 var(--fs-sm)/1.2 var(--font-mono); color: var(--text-2); }
.tl-title { font-weight: 600; }
.tl-sub { font-size: var(--fs-sm); color: var(--text-2); }

/* ── Overlays: sheet / modal / toast ──────────────────────────────────── */
.overlay { position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; background: var(--scrim); }
.overlay.for-sheet { justify-items: end; }
.overlay.for-modal { place-items: center; padding: var(--s-4); }
.sheet { position: relative; width: min(460px, 100vw); height: 100%; overflow-y: auto; padding: var(--s-6); background: var(--glass-solid);
  border-left: 1px solid var(--edge-strong); box-shadow: var(--shadow-3); display: flex; flex-direction: column; gap: var(--s-4); }
.modal { position: relative; width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: var(--s-8); border-radius: var(--r-xl);
  background: var(--glass-solid); border: 1px solid var(--edge-strong); box-shadow: var(--shadow-3); display: flex; flex-direction: column; gap: var(--s-4); }
.modal.risk { border-color: var(--coral); box-shadow: var(--shadow-3), 0 0 80px var(--coral-soft); }
.overlay-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); }
.overlay-foot { display: flex; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-2); }
.toast-root { position: fixed; left: 50%; bottom: var(--s-8); translate: -50% 0; z-index: var(--z-toast); display: flex; flex-direction: column-reverse; align-items: center; gap: var(--s-2); pointer-events: none; width: min(560px, calc(100vw - 32px)); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s-3); max-width: 100%; padding: 12px 16px 12px 14px; border-radius: var(--r-md);
  background: var(--glass-solid); border: 1px solid var(--edge-strong); box-shadow: var(--shadow-2); font-size: var(--fs-body); }
.toast svg { width: 20px; height: 20px; flex: none; color: var(--v-ink, var(--text-2)); }
.toast.ok { border-color: var(--emerald); --v-ink: var(--ok-ink); }
.toast.warn { border-color: var(--amber); --v-ink: var(--warn-ink); }
.toast.risk { border-color: var(--coral); --v-ink: var(--risk-ink); }
.toast.live { border-color: var(--magenta); --v-ink: var(--live-ink); }
.toast .btn { margin: -6px -8px -6px 4px; }

/* ── Empty / skeleton / notices ───────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3); padding: var(--s-10) var(--s-6); color: var(--text-2); }
.empty-ico { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; color: var(--v-ink, var(--violet-ink)); background: var(--v-soft, var(--violet-soft)); border: 1px solid var(--edge); }
.empty-ico svg { width: 28px; height: 28px; }
.empty h3 { color: var(--text); }
.empty p { max-width: 46ch; }
.skeleton { display: block; border-radius: var(--r-xs); height: 14px; background: linear-gradient(100deg, var(--skeleton-a) 30%, var(--skeleton-b) 50%, var(--skeleton-a) 70%); background-size: 300% 100%; animation: shimmer 1.6s linear infinite; }
.skeleton.block { height: 120px; border-radius: var(--r-lg); }
.notice { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid var(--edge-strong); background: var(--glass); font-size: var(--fs-sm); color: var(--text-2); }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--v-ink, var(--text-2)); }
.notice.warn { border-color: var(--amber); --v-ink: var(--warn-ink); }
.notice.risk { border-color: var(--coral); --v-ink: var(--risk-ink); }
.offline-chip { display: none; }
body[data-offline="true"] .offline-chip { display: inline-flex; }
.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--edge-strong), transparent); border: 0; margin: var(--s-4) 0; }
pre.code, code { font-family: var(--font-mono); font-size: var(--fs-sm); }
pre.code { padding: var(--s-4); border-radius: var(--r-md); background: var(--glass); border: 1px solid var(--edge); overflow-x: auto; color: var(--text-2); line-height: 1.6; tab-size: 2; margin: 0; }
code { padding: 2px 6px; border-radius: 6px; background: var(--glass-2); color: var(--accent-ink); }
pre.code code { padding: 0; background: none; color: inherit; }

/* ── Orb host (orb.js) ────────────────────────────────────────────────── */
.orb { position: relative; width: 100%; aspect-ratio: 1; display: block; }
.orb canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
/* CSS fallback orb — same states, no WebGL */
.orb-css { position: absolute; inset: 18%; border-radius: 50%; --c1: var(--violet); --c2: var(--cyan); --c3: var(--magenta); --amp: 0;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.85), transparent 28%), conic-gradient(from 0deg, var(--c1), var(--c2), var(--c3), var(--c1));
  box-shadow: 0 0 calc(40px + var(--amp) * 60px) var(--c1), inset 0 0 40px rgba(255,255,255,.25); filter: saturate(1.2);
  transform: scale(calc(1 + var(--amp) * .12)); transition: transform var(--d-fast) linear, box-shadow var(--d-base); animation: orbspin 14s linear infinite, breathe 5s ease-in-out infinite; }
.orb-css::after { content: ''; position: absolute; inset: -22%; border-radius: 50%; border: 1px dashed var(--c2); opacity: .35; animation: orbspin 40s linear infinite reverse; }
.orb-css[data-state="listening"] { --c1: var(--magenta); --c2: var(--violet); --c3: var(--coral); }
.orb-css[data-state="thinking"] { --c1: var(--violet); --c2: var(--magenta); --c3: var(--cyan); animation-duration: 3s, 5s; }
.orb-css[data-state="speaking"] { --c1: var(--cyan); --c2: var(--gold); --c3: var(--emerald); }
.orb-css[data-state="alert"] { --c1: var(--coral); --c2: var(--amber); --c3: var(--coral); }

/* ── Room fallback panels ─────────────────────────────────────────────── */
.room-missing { max-width: 640px; margin: 8vh auto 0; }

/* ── Keyframes ────────────────────────────────────────────────────────── */
@keyframes drift { from { transform: translate3d(-4%, -3%, 0) scale(1); } to { transform: translate3d(6%, 5%, 0) scale(1.14); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes ripple { from { opacity: .8; transform: scale(.9); } to { opacity: 0; transform: scale(1.5); } }
@keyframes orbspin { to { rotate: 360deg; } }
@keyframes breathe { 0%, 100% { scale: 1; } 50% { scale: 1.05; } }

/* ── Phone (< 760px) ──────────────────────────────────────────────────── */
@media (max-width: 759.98px) {
  .rail { display: none; }
  .shell { margin-left: 0; grid-template-columns: minmax(0, 1fr); }
  .stage { padding: var(--s-3) var(--s-4) calc(var(--dock-h) + 110px); }
  .statebar { padding: 0 var(--s-4); gap: var(--s-2); height: 56px; }
  .command { display: none; }
  .context { position: fixed; inset: auto 0 0 0; z-index: var(--z-overlay); width: auto; height: auto; max-height: 72dvh; border-left: 0; border-top: 1px solid var(--edge-strong); border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--glass-solid); }
  .dock { position: fixed; inset: auto 0 0 0; z-index: var(--z-dock); height: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px)); padding: 6px 6px env(safe-area-inset-bottom, 0px);
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--glass-solid); border-top: 1px solid var(--edge); }
  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .dock { background: color-mix(in srgb, var(--void) 74%, transparent); -webkit-backdrop-filter: blur(var(--blur-heavy)) saturate(150%); backdrop-filter: blur(var(--blur-heavy)) saturate(150%); }
  }
  .dock-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: var(--tap); border: 0; background: none; color: var(--text-2);
    font: 600 10px/1 var(--font-body); border-radius: var(--r-sm); -webkit-tap-highlight-color: transparent; }
  .dock-item:hover { text-decoration: none; }
  .dock-item svg { width: 23px; height: 23px; }
  .dock-item[aria-current="page"] { color: var(--text); }
  .dock-item[aria-current="page"]::before { content: ''; position: absolute; top: -6px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 4px 4px; background: var(--prism); box-shadow: 0 0 14px var(--violet-glow); }
  .dock-item .badge { position: absolute; top: 2px; left: 54%; }
  .float { right: var(--s-4); bottom: calc(var(--dock-h) + var(--s-4) + env(safe-area-inset-bottom, 0px)); left: var(--s-4); justify-content: flex-end; }
  .toast-root { bottom: calc(var(--dock-h) + 92px); }
  .grid.c2, .grid.c3, .grid.c4, .grid.split { grid-template-columns: minmax(0, 1fr); }
  .grid.c4.keep2, .grid.c3.keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overlay.for-sheet { justify-items: stretch; align-items: end; }
  .sheet { width: 100%; height: auto; max-height: 88dvh; border-left: 0; border-top: 1px solid var(--edge-strong); border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: calc(var(--s-6) + env(safe-area-inset-bottom, 0px)); }
  .sheet::before { content: ''; align-self: center; flex: none; width: 44px; height: 4px; border-radius: 4px; background: var(--edge-strong); margin-bottom: var(--s-1); }
  .modal { padding: var(--s-6); border-radius: var(--r-lg); }
  .panel { padding: var(--s-5); border-radius: 20px; }
  .timeline { padding-left: 92px; } .timeline::before { left: 77px; } .tl-time { left: -92px; width: 62px; font-size: var(--fs-xs); top: 18px; }
  .stateline .hide-phone { display: none; }
  .first-on-phone { order: -1; }
}

/* ── Calm mode + reduced motion: kill ambient animation ───────────────── */
:root[data-calm="true"] .fx-blob, :root[data-calm="true"] .chip.live::before, :root[data-calm="true"] .tl-item.is-now::before,
:root[data-calm="true"] .orb-css, :root[data-calm="true"] .orb-css::after, :root[data-calm="true"] .mic-fab::before { animation: none !important; }
:root[data-calm="true"] .fx-stars, :root[data-calm="true"] .fx-cursor { display: none; }
:root[data-calm="true"] .skeleton { animation-duration: 3.2s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .fx-stars, .fx-cursor { display: none; }
  .rail, .rail::after, .rail-item .txt { transition: none; }
}

/* ── Print: ink on paper, no chrome ───────────────────────────────────── */
@media print {
  :root { --text: #000; --text-2: #222; --text-3: #444; --edge: #bbb; --edge-strong: #888; }
  body { background: #fff; color: #000; }
  .fx, .rail, .dock, .float, .statebar, .toast-root, .overlay, .context { display: none !important; }
  .shell { margin: 0; display: block; }
  .stage { max-width: none; padding: 0; }
  .panel { background: #fff !important; box-shadow: none; border-color: #bbb; break-inside: avoid; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .panel::before, .tilt::after { display: none; }
  .prism-text { color: #000; background: none; }
  .chip, .btn { border: 1px solid #888; background: #fff; color: #000; box-shadow: none; }
}
