/* J.A.R.V.I.S. Neural Core HUD — one stylesheet, three layouts: body.mode-tv | mode-desktop | mode-mobile */

@property --hud   { syntax: '<color>'; inherits: true; initial-value: #3FA7FF; }
@property --hud-2 { syntax: '<color>'; inherits: true; initial-value: #8FE3FF; }

:root {
  --bg: #02050a;
  --ink: #E3EDF6;
  --ink-dim: #8EA2B4;
  --ink-faint: #4E5F6F;
  --panel: rgba(5, 11, 19, 0.5);
  --panel-solid: #060b12;
  --ok: #7CF2B0;
  --warn: #FFB000;
  --bad: #FF3B00;
  --cyan: #00F0FF;
  --font-ui: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --gutter: 20px;
  --top-h: 64px;
  color-scheme: dark;
}

/* --hud / --hud-2 and the ink/panel tints are set from js/core/palette.js (theme x state), the single source. */
body { --hud: #3FA7FF; --hud-2: #8FE3FF; transition: --hud 0.9s ease, --hud-2 0.9s ease, background-color 0.9s ease; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1px solid var(--hud); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── Stage ─────────────────────────────────────────────────────────────── */
#stage { position: fixed; inset: 0; z-index: 0; }
.core-canvas { display: block; width: 100%; height: 100%; }
body.no-webgl #stage {
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--hud) 55%, transparent) 0 6%,
              color-mix(in srgb, var(--hud) 18%, transparent) 14%, transparent 34%);
  animation: orb 3s ease-in-out infinite;
}
@keyframes orb { 50% { transform: scale(1.06); filter: brightness(1.3); } }

/* ── Top bar ───────────────────────────────────────────────────────────── */
.hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 6;
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--gutter);
  background: linear-gradient(to bottom, rgba(3, 3, 3, 0.75), transparent);
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.brand { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; }
.brand-mark {
  font-weight: 700; font-size: 20px; letter-spacing: 0.32em; color: var(--hud);
  text-shadow: 0 0 18px color-mix(in srgb, var(--hud) 55%, transparent);
}
.brand-sub { font: 500 11px var(--font-mono); letter-spacing: 0.24em; color: var(--ink-dim); text-transform: uppercase; }

.state-readout {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  font: 500 12px var(--font-mono); letter-spacing: 0.2em; color: var(--hud);
}
.state-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--hud); flex: none;
  box-shadow: 0 0 10px var(--hud), 0 0 22px var(--hud);
  animation: beat 2.4s ease-in-out infinite;
}
body[data-state="thinking"] .state-dot, body[data-state="executing"] .state-dot { animation-duration: 0.6s; }
body[data-state="alert"] .state-dot { animation-duration: 0.35s; }
@keyframes beat { 50% { opacity: 0.35; transform: scale(0.8); } }
#state-msg { color: var(--ink-dim); letter-spacing: 0.06em; text-transform: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }

.top-right { display: flex; align-items: center; gap: 10px; }
.pill {
  font: 500 10px var(--font-mono); letter-spacing: 0.2em; padding: 4px 8px; border-radius: 2px;
  border: 1px solid color-mix(in srgb, var(--bad) 60%, transparent); color: var(--bad);
}
.pill[data-up="true"] { border-color: color-mix(in srgb, var(--ok) 50%, transparent); color: var(--ok); }
.clock { font: 500 13px var(--font-mono); letter-spacing: 0.12em; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  background: rgba(10, 8, 6, 0.4); border: 1px solid color-mix(in srgb, var(--hud) 25%, transparent);
  border-radius: 3px; color: var(--ink-dim); font: 500 11px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase;
}
.icon-btn:hover { color: var(--ink); border-color: color-mix(in srgb, var(--hud) 55%, transparent); }
.icon-btn[aria-pressed="true"] { color: var(--hud); border-color: var(--hud); }
.icon-btn.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 60%, transparent); }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-btn[aria-pressed="false"] .wave { opacity: 0.25; }

/* ── Panels (glass) ────────────────────────────────────────────────────── */
.panel {
  position: fixed; z-index: 4; top: calc(var(--top-h) + 8px); bottom: 24px;
  width: clamp(270px, 22vw, 370px);
  display: flex; flex-direction: column; gap: 14px; min-height: 0;
}
.panel-left { left: var(--gutter); }
.panel-right { right: var(--gutter); }
.card {
  position: relative; padding: 14px 16px 16px;
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.25); -webkit-backdrop-filter: blur(14px) saturate(1.25);
  border: 1px solid color-mix(in srgb, var(--hud) 16%, transparent);
  border-radius: 3px;
  min-height: 0;
}
.card::before, .card::after {
  content: ''; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border-color: var(--hud); border-style: solid; opacity: 0.85;
}
.card::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.card::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }
.card h2 {
  margin: 0 0 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font: 500 10.5px var(--font-mono); letter-spacing: 0.22em; text-transform: uppercase; color: var(--hud);
}
.h2-meta { color: var(--ink-faint); letter-spacing: 0.12em; }
.empty { margin: 0; color: var(--ink-faint); font-size: 13px; }
.card-console { flex: 1; display: flex; flex-direction: column; }
#card-power { flex: 1; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--hud) 30%, transparent) transparent; }

/* devices */
.device-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.device {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px;
  padding: 7px 10px; border-left: 2px solid color-mix(in srgb, var(--hud) 45%, transparent);
  background: rgba(255, 255, 255, 0.02);
}
.device.disabled { opacity: 0.38; border-left-color: var(--ink-faint); }
.device-name { font-weight: 600; font-size: 14.5px; letter-spacing: 0.03em; }
.device-state { font: 500 11px var(--font-mono); letter-spacing: 0.12em; color: var(--hud); text-align: right; white-space: nowrap; }
.device-state.warn { color: var(--bad); }
.device-meta { grid-column: 1 / -1; display: flex; gap: 8px; font: 400 10px var(--font-mono); color: var(--ink-faint); letter-spacing: 0.1em; text-transform: uppercase; }
.badge { padding: 0 5px; border: 1px solid currentColor; border-radius: 2px; }
.badge.sim { color: var(--ink-dim); }
.badge.live { color: var(--ok); }

/* telemetry */
.telemetry { display: grid; gap: 14px; }
.tele-device h3 { margin: 0 0 8px; display: flex; justify-content: space-between; font: 600 13px var(--font-ui); letter-spacing: 0.06em; }
.tele-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 2px 10px; margin-bottom: 8px; }
.tele-label { font: 400 11px var(--font-mono); color: var(--ink-dim); letter-spacing: 0.08em; }
.tele-value { font: 500 15px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); text-align: right; }
.tele-value.warn { color: var(--warn); }
.tele-value.bad { color: var(--bad); }
.tele-spark { grid-column: 1 / -1; width: 100%; min-width: 0; height: 26px; display: block; }

/* project */
.project-name { font-size: 22px; font-weight: 700; letter-spacing: 0.06em; margin: 0; }
.project-path { font: 400 11px var(--font-mono); color: var(--ink-faint); word-break: break-all; margin: 2px 0 10px; }
.project-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font: 400 11px var(--font-mono); color: var(--ink-dim); margin-bottom: 10px; }
.project-stats b { color: var(--hud); font-weight: 500; }
.recs { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.recs li { font-size: 13px; color: var(--ink-dim); padding-left: 14px; position: relative; line-height: 1.35; }
.recs li::before { content: ''; position: absolute; left: 0; top: 0.55em; width: 6px; height: 1px; background: var(--hud); }

/* console */
.console {
  list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto;
  font: 400 11.5px/1.5 var(--font-mono); scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--hud) 30%, transparent) transparent;
}
.console li { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; padding: 1px 0; color: var(--ink-dim); }
.console time { color: var(--ink-faint); }
.console .src { color: var(--hud); opacity: 0.8; text-transform: uppercase; font-size: 10px; letter-spacing: 0.08em; padding-top: 1px; }
.console .msg { color: var(--ink); overflow-wrap: anywhere; }
.console li.lv-warn .msg { color: var(--warn); }
.console li.lv-error .msg, .console li.lv-alert .msg { color: var(--bad); }
.console li.lv-ok .msg { color: var(--ok); }
.console li.lv-tool .msg { color: var(--ink-dim); }

/* ── Room status chips ─────────────────────────────────────────────────── */
.room-status { position: fixed; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px;
  font: 500 11px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase;
  background: rgba(10, 8, 6, 0.42); border: 1px solid color-mix(in srgb, var(--hud) 22%, transparent); border-radius: 2px;
  color: var(--ink-dim);
}
.chip b { color: var(--hud); font-weight: 500; }
.chip.warn b { color: var(--bad); }

/* ── Tool-execution overlay ────────────────────────────────────────────── */
.tool-overlay {
  position: fixed; z-index: 3; left: 50%; transform: translateX(-50%);
  top: calc(50% + 27vh); width: min(560px, 44vw);
  display: grid; gap: 2px; text-align: center; pointer-events: none;
  font: 400 12px var(--font-mono); letter-spacing: 0.06em; color: var(--hud);
  opacity: 0; transition: opacity 0.6s ease;
}
body[data-state="thinking"] .tool-overlay, body[data-state="executing"] .tool-overlay, body[data-state="alert"] .tool-overlay { opacity: 1; }
.tool-overlay div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: line-in 0.35s ease both; }
.tool-overlay div:nth-last-child(n+2) { opacity: 0.55; }
.tool-overlay div:nth-last-child(n+4) { opacity: 0.25; }
@keyframes line-in { from { opacity: 0; transform: translateY(6px); filter: blur(2px); } }

/* ── Captions ──────────────────────────────────────────────────────────── */
.captions {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%);
  bottom: 150px; width: min(760px, calc(100vw - 2 * clamp(270px, 22vw, 370px) - 80px));
  text-align: center; pointer-events: none;
}
.caption-user { font: 400 12px var(--font-mono); color: var(--ink-faint); letter-spacing: 0.06em; min-height: 1.2em; }
.caption-user:not(:empty)::before { content: '› '; color: var(--hud); }
.caption-text {
  font-size: 20px; font-weight: 500; letter-spacing: 0.02em; color: var(--ink); min-height: 1.4em;
  text-shadow: 0 0 22px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
  transition: opacity 0.8s ease;
}
.caption-text.fade { opacity: 0; }
.caption-text .cursor { display: inline-block; width: 0.5ch; height: 1em; vertical-align: -0.12em; background: var(--hud); margin-left: 2px; animation: beat 0.8s steps(2) infinite; }

/* ── Command deck ──────────────────────────────────────────────────────── */
.command-deck {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%); bottom: 22px;
  width: min(640px, calc(100vw - 2 * clamp(270px, 22vw, 370px) - 80px));
  display: grid; gap: 10px;
}
.cmd-form {
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid color-mix(in srgb, var(--hud) 30%, transparent); border-radius: 3px;
}
.cmd-form input {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px; background: transparent; border: 0; outline: none;
  font-size: 16px; letter-spacing: 0.03em;
}
.cmd-form input::placeholder { color: var(--ink-faint); }
.mic-btn, .send-btn {
  width: 40px; height: 40px; display: grid; place-items: center; flex: none;
  background: transparent; border: 1px solid color-mix(in srgb, var(--hud) 30%, transparent); border-radius: 2px; color: var(--hud);
}
.mic-btn svg, .send-btn svg { width: 18px; height: 18px; }
.mic-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--cyan) 22%, transparent); border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 18px color-mix(in srgb, var(--cyan) 45%, transparent); }
.mic-hint { margin: 0; font: 400 11px var(--font-mono); color: var(--warn); text-align: center; }
.mic-hint a { color: var(--hud); }

.quick-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.qa {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 12px;
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--hud) 25%, transparent); border-radius: 2px;
  font: 500 11px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.qa:hover { color: var(--ink); border-color: color-mix(in srgb, var(--hud) 60%, transparent); }
.qa.busy { color: var(--hud); }
.qa.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.qa .fill, .btn.hold .fill {
  position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--p, 0));
  background: color-mix(in srgb, var(--hud) 30%, transparent); pointer-events: none;
}
.qa > span, .qa > svg { position: relative; }

/* ── Toast & dialogs ───────────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 20; left: 50%; top: calc(var(--top-h) + 10px); transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px)); padding: 10px 14px;
  background: var(--panel-solid); border: 1px solid var(--hud); border-radius: 3px;
  font: 400 12.5px var(--font-mono); color: var(--ink); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.toast a { color: var(--hud); }
.dialog {
  width: min(420px, calc(100vw - 32px)); padding: 22px; color: var(--ink);
  background: var(--panel-solid); border: 1px solid var(--hud); border-radius: 4px;
  box-shadow: 0 0 60px color-mix(in srgb, var(--hud) 20%, transparent);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(3px); }
.dialog h3 { margin: 0 0 8px; font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--hud); }
.dialog p { margin: 0 0 14px; color: var(--ink-dim); }
.dialog input { width: 100%; height: 42px; padding: 0 12px; margin-bottom: 12px; background: #000; border: 1px solid color-mix(in srgb, var(--hud) 40%, transparent); border-radius: 2px; font-family: var(--font-mono); }
.dialog .error { color: var(--bad); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn {
  position: relative; overflow: hidden; height: 40px; padding: 0 16px; border-radius: 2px;
  background: color-mix(in srgb, var(--hud) 18%, transparent); border: 1px solid var(--hud); color: var(--hud);
  font: 500 12px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase;
}
.btn.ghost { background: transparent; border-color: var(--ink-faint); color: var(--ink-dim); }
.btn.danger { --hud: var(--bad); }
.btn > span { position: relative; }

/* ═════════════════════════════════════════════════════════════════════════
   TV / PROJECTOR — ambient core, minimal chrome, big captions
   ═════════════════════════════════════════════════════════════════════════ */
body.mode-tv { --gutter: clamp(20px, 2.4vw, 64px); --top-h: clamp(60px, 7vh, 110px); }
body.mode-tv .panel, body.mode-tv .command-deck, body.mode-tv #btn-pair { display: none !important; }
body.mode-tv .hud-top { background: none; }
body.mode-tv .brand-mark { font-size: clamp(18px, 1.5vw, 36px); }
body.mode-tv .brand-sub, body.mode-tv .clock, body.mode-tv .state-readout { font-size: clamp(11px, 0.85vw, 20px); }
body.mode-tv .icon-btn { opacity: 0; transition: opacity 0.4s; }
body.mode-tv.show-cursor .icon-btn, body.mode-tv .icon-btn:focus-visible { opacity: 1; }
body.mode-tv:not(.show-cursor) { cursor: none; }
body.mode-tv .room-status { left: var(--gutter); bottom: var(--gutter); gap: clamp(8px, 0.7vw, 16px); }
body.mode-tv .chip { font-size: clamp(11px, 0.8vw, 19px); padding: 0.45em 0.9em; }
body.mode-tv .captions { bottom: clamp(70px, 11vh, 200px); width: min(72vw, 1500px); }
body.mode-tv .caption-text { font-size: clamp(22px, 2.2vw, 54px); font-weight: 500; }
body.mode-tv .caption-user { font-size: clamp(12px, 0.9vw, 22px); }
body.mode-tv .tool-overlay { top: calc(50% + 31vh); font-size: clamp(11px, 0.8vw, 18px); width: min(900px, 50vw); }

/* ═════════════════════════════════════════════════════════════════════════
   DESKTOP — engineering workbench
   ═════════════════════════════════════════════════════════════════════════ */
body.mode-desktop .room-status { left: 50%; transform: translateX(-50%); top: calc(var(--top-h) + 6px); justify-content: center; max-width: 44vw; }

/* ═════════════════════════════════════════════════════════════════════════
   MOBILE — pocket terminal, single scrolling column
   ═════════════════════════════════════════════════════════════════════════ */
body.mode-mobile {
  --gutter: 16px; --top-h: 52px;
  overflow-x: hidden; overflow-y: auto; height: auto; min-height: 100%;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
body.mode-mobile #stage { position: relative; order: 0; height: 40svh; min-height: 250px; flex: none; }
body.mode-mobile .hud-top { padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top)); }
body.mode-mobile .brand-sub, body.mode-mobile .clock, body.mode-mobile #state-msg { display: none; }
body.mode-mobile .brand-mark { font-size: 15px; letter-spacing: 0.26em; }
body.mode-mobile .state-readout { position: absolute; left: 50%; top: calc(var(--top-h) + env(safe-area-inset-top) + 4px); transform: translateX(-50%); font-size: 11px; }
body.mode-mobile .icon-btn { padding: 0 8px; }
body.mode-mobile .icon-btn span { display: none; }
body.mode-mobile .top-right { gap: 6px; }
body.mode-mobile .pill { display: none; }
body.mode-mobile .room-status { position: static; order: 1; justify-content: center; padding: 0 var(--gutter); margin-top: -6px; }
body.mode-mobile .chip { font-size: 10px; padding: 4px 8px; }
body.mode-mobile .tool-overlay { position: absolute; top: calc(40svh - 64px); width: calc(100vw - 32px); font-size: 10.5px; }
body.mode-mobile .captions { position: static; order: 2; transform: none; width: auto; padding: 12px var(--gutter) 4px; }
body.mode-mobile .caption-text { font-size: 17px; }
body.mode-mobile .command-deck { position: static; order: 3; transform: none; width: auto; padding: 6px var(--gutter) 14px; }
body.mode-mobile .cmd-form input { font-size: 16px; } /* ≥16px: no iOS zoom-on-focus */
body.mode-mobile .quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
body.mode-mobile .qa { min-height: 54px; font-size: 11.5px; justify-content: flex-start; padding: 0 14px; }
body.mode-mobile .qa svg { width: 20px; height: 20px; }
body.mode-mobile .qa.wide { grid-column: 1 / -1; }
body.mode-mobile .panel { position: static; width: auto; padding: 0 var(--gutter); margin-bottom: 14px; }
body.mode-mobile .panel-right { order: 4; }
body.mode-mobile .panel-left { order: 5; }
body.mode-mobile .card-console .console { max-height: 210px; }
body.mode-mobile #card-power { overflow: visible; }

/* narrow desktop windows fall back gracefully */
@media (max-width: 1100px) {
  body.mode-desktop .panel { width: 250px; }
  body.mode-desktop .captions, body.mode-desktop .command-deck { width: calc(100vw - 2 * 250px - 70px); }
}

@media (prefers-reduced-motion: reduce) {
  .state-dot, .caption-text .cursor { animation: none; }
  .tool-overlay div { animation: none; }
}

/* ═════════════════════════════════════════════════════════════════════════
   v2: dual-brain toggle, budget, systems checklist, printer, inbox, idle widgets
   ═════════════════════════════════════════════════════════════════════════ */
.brain-toggle {
  display: inline-flex; height: 32px; padding: 2px; gap: 2px; border-radius: 3px;
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--hud) 35%, transparent);
  font: 600 11px var(--font-mono); letter-spacing: 0.16em;
}
.brain-toggle .seg { display: grid; place-items: center; padding: 0 10px; border-radius: 2px; color: var(--ink-faint); transition: background .3s, color .3s; }
body[data-brain="local"] .brain-toggle .seg-local { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
body[data-brain="cloud"] .brain-toggle .seg-cloud { background: color-mix(in srgb, var(--cyan) 22%, transparent); color: var(--cyan); }
body[data-brain="cloud"] .brain-toggle { border-color: color-mix(in srgb, var(--cyan) 60%, transparent); box-shadow: 0 0 14px color-mix(in srgb, var(--cyan) 30%, transparent); }
.pill.budget { border-color: color-mix(in srgb, var(--hud) 35%, transparent); color: var(--ink-dim); letter-spacing: 0.08em; }
.pill.budget.hot { border-color: var(--bad); color: var(--bad); }

.setup-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.setup-list li { display: grid; grid-template-columns: 10px 1fr; gap: 2px 8px; align-items: baseline; font-size: 13.5px; }
.setup-list .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); align-self: center; }
.setup-list li.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.setup-list li.todo .dot { background: var(--warn); }
.setup-list .name { font-weight: 600; letter-spacing: 0.04em; }
.setup-list .detail { grid-column: 2; font: 400 10.5px var(--font-mono); color: var(--ink-faint); overflow-wrap: anywhere; }
.setup-list .code { color: var(--hud); font-weight: 500; letter-spacing: 0.2em; }
.device-list .empty { font-size: 12.5px; color: var(--ink-faint); padding: 2px 0 6px; }
.budget-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--hud) 12%, transparent); }
.mini-btn { height: 24px; padding: 0 8px; background: transparent; border: 1px solid color-mix(in srgb, var(--hud) 35%, transparent); border-radius: 2px; color: var(--hud); font: 500 10px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; }
.mini-btn:hover { background: color-mix(in srgb, var(--hud) 14%, transparent); }

.printer .p-file { font-weight: 600; font-size: 15px; margin: 0 0 6px; }
.printer .p-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font: 400 11px var(--font-mono); color: var(--ink-dim); margin-top: 6px; }
.printer .p-stats b { color: var(--ink); font-weight: 500; }
.bar { height: 6px; background: rgba(255, 255, 255, 0.06); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--hud-2), var(--hud)); box-shadow: 0 0 10px var(--hud); transition: width .8s ease; }

.inbox { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 32vh; overflow-y: auto; scrollbar-width: thin; }
.inbox .empty { font-size: 13px; color: var(--ink-faint); }
.inbox-item { padding: 8px 10px; border-left: 2px solid var(--hud); background: rgba(255, 255, 255, 0.025); }
.inbox-item.reviewed, .inbox-item.archived { opacity: 0.45; border-left-color: var(--ink-faint); }
.inbox-item .i-title { font-weight: 600; font-size: 14px; line-height: 1.25; }
.inbox-item .i-meta { font: 400 10px var(--font-mono); color: var(--ink-faint); letter-spacing: 0.08em; text-transform: uppercase; margin: 2px 0 4px; }
.inbox-item .i-sum { font-size: 12.5px; color: var(--ink-dim); line-height: 1.35; }
.inbox-item .i-actions { display: flex; gap: 6px; margin-top: 6px; }
.inbox-item.focus { animation: pulse-in 1.2s ease 2; }
@keyframes pulse-in { 50% { background: color-mix(in srgb, var(--hud) 16%, transparent); } }

.caption-text { max-height: 34vh; overflow-y: auto; white-space: pre-wrap; scrollbar-width: thin; }
body.mode-desktop .captions { pointer-events: auto; }
body.mode-desktop .caption-text { font-size: 18px; text-align: left; }
body.mode-desktop .caption-text:not(:empty) { background: var(--panel); backdrop-filter: blur(10px); padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--hud) 15%, transparent); border-radius: 3px; }

.idle-widgets { position: fixed; z-index: 4; display: none; pointer-events: none; }
.idle-clock { font: 600 clamp(48px, 7vw, 150px)/1 var(--font-ui); letter-spacing: 0.04em; color: var(--ink); text-shadow: 0 0 30px color-mix(in srgb, var(--hud) 45%, transparent); font-variant-numeric: tabular-nums; }
.idle-date { font: 500 clamp(12px, 1vw, 22px) var(--font-mono); letter-spacing: 0.25em; text-transform: uppercase; color: var(--hud); margin: 6px 0 16px; }
.idle-row { display: flex; flex-wrap: wrap; gap: 10px; }
.idle-printer { margin-top: 16px; width: min(420px, 34vw); }
.idle-printer-label { display: flex; justify-content: space-between; font: 500 clamp(11px, .85vw, 18px) var(--font-mono); letter-spacing: 0.1em; color: var(--ink-dim); margin-bottom: 6px; }
#idle-inbox-chip.has b { color: var(--bad); }

/* TV / projector and laptop idle (screensaver) share the ambient layout */
body.mode-tv .idle-widgets, body.idle .idle-widgets { display: block; left: var(--gutter); bottom: calc(var(--gutter) + 52px); }
body.mode-tv .room-status { bottom: var(--gutter); }
body.mode-tv .idle-clock { font-size: clamp(56px, 8vw, 170px); }
body.idle .panel, body.idle .command-deck, body.idle .room-status { opacity: 0; pointer-events: none; transition: opacity .8s ease; }
body.idle .captions { bottom: 10vh; }
body.idle:not(.mode-tv) { cursor: none; }
body.mode-mobile .idle-widgets { display: none !important; }

.field { display: grid; gap: 4px; font: 500 11px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 10px; }
.field input { margin: 0; }


/* ═════════════════════════════════════════════════════════════════════════
   v3: themes, hands-free, markets, per-screen views, brain explorer, connections
   ═════════════════════════════════════════════════════════════════════════ */
body.hands-free.mode-desktop #btn-mic { display: none; }
.ear-btn[aria-pressed="true"] { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 55%, transparent); }
.ear-btn[aria-pressed="true"] svg { animation: ear 2.4s ease-in-out infinite; }
.ear-btn[aria-pressed="false"] { color: var(--ink-faint); }
@keyframes ear { 50% { filter: drop-shadow(0 0 5px var(--cyan)); } }
body[data-state="listening"] .ear-btn { background: color-mix(in srgb, var(--cyan) 20%, transparent); }

.screens-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--hud) 12%, transparent); }
.screens-row .h2-meta { margin-right: auto; }

/* markets card */
.card-markets { flex: 1; display: flex; flex-direction: column; min-height: 180px; }
.markets { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; overflow-y: auto; scrollbar-width: thin; min-height: 0; }
.mrow { display: grid; grid-template-columns: 46px minmax(36px, 1fr) auto 58px; align-items: center; gap: 6px; padding: 4px 4px; border-radius: 2px; cursor: pointer; font: 500 12px var(--font-mono); }
.mrow:hover { background: color-mix(in srgb, var(--hud) 10%, transparent); }
.msym { color: var(--ink); letter-spacing: 0.04em; }
.mspark { width: 100%; height: 22px; display: block; }
.mprice { text-align: right; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.mchg { text-align: right; font-variant-numeric: tabular-nums; }
.mrow.up .mchg { color: #22D67A; }
.mrow.down .mchg { color: #FF4D5E; }
.markets-note { margin: 8px 0 0; font: 400 10px var(--font-mono); color: var(--ink-faint); }

/* project card (compact + big) */
.pcard-name { font-size: 22px; font-weight: 700; letter-spacing: 0.05em; }
.pcard-brief { margin: 4px 0 8px; color: var(--ink-dim); font-size: 13.5px; line-height: 1.4; }
.pcard-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.pcard-chips .chip { font: 500 10px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 7px; border: 1px solid color-mix(in srgb, var(--hud) 30%, transparent); border-radius: 2px; color: var(--ink-dim); }
.pcard h4 { margin: 10px 0 4px; font: 500 10px var(--font-mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--hud); }
.pcard ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.pcard li { font-size: 13px; color: var(--ink); padding-left: 14px; position: relative; line-height: 1.35; }
.pcard li::before { content: ''; position: absolute; left: 0; top: 0.5em; width: 7px; height: 7px; border: 1px solid var(--hud); border-radius: 1px; }
.pcard-dec li::before, .pcard-ins li::before, .pcard-goals li::before { width: 6px; height: 1px; border: 0; background: var(--hud); top: 0.6em; }
.pcard-hint { font: 400 11px var(--font-mono); color: var(--ink-faint); margin: 8px 0; }
#project .mini-btn { margin-top: 10px; }
.pcard.big { max-width: 1100px; margin: 0 auto; }
.pcard.big .pcard-name { font-size: clamp(30px, 3.4vw, 72px); }
.pcard.big .pcard-brief { font-size: clamp(16px, 1.3vw, 30px); }
.pcard.big h4 { font-size: clamp(11px, 0.85vw, 18px); margin-top: 22px; }
.pcard.big li { font-size: clamp(15px, 1.15vw, 26px); }

/* per-screen views (stocks board / chart / project) */
.screen-view { position: fixed; z-index: 7; inset: calc(var(--top-h) + 6px) var(--gutter) 24px; padding: 22px 26px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid color-mix(in srgb, var(--hud) 22%, transparent); border-radius: 4px; overflow-y: auto; }
.sv-close { position: absolute; top: 12px; right: 12px; }
body.mode-tv .sv-close { display: none; }
body.viewing .panel, body.viewing .captions { opacity: 0; pointer-events: none; }
body.mode-tv .screen-view { inset: calc(var(--top-h)) var(--gutter) var(--gutter); background: color-mix(in srgb, var(--bg) 70%, transparent); }
.sv-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.sv-head h2 { margin: 0; font-size: clamp(22px, 2vw, 48px); letter-spacing: 0.14em; text-transform: uppercase; color: var(--hud); }
.sv-pill { font: 600 clamp(10px, 0.8vw, 18px) var(--font-mono); letter-spacing: 0.18em; padding: 3px 9px; border: 1px solid var(--ink-faint); color: var(--ink-faint); border-radius: 2px; }
.sv-pill.live { color: #22D67A; border-color: #22D67A; box-shadow: 0 0 12px rgba(34, 214, 122, 0.35); }
.sv-sub { font: 400 clamp(11px, 0.75vw, 17px) var(--font-mono); color: var(--ink-faint); }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(200px, 17vw, 380px), 1fr)); gap: clamp(10px, 1vw, 22px); }
.tile { padding: clamp(10px, 0.9vw, 20px); border: 1px solid color-mix(in srgb, var(--hud) 18%, transparent); border-left-width: 3px; border-radius: 3px; background: color-mix(in srgb, var(--panel-solid) 70%, transparent); cursor: pointer; }
.tile.up { border-left-color: #22D67A; }
.tile.down { border-left-color: #FF4D5E; }
.tile-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tile-sym { font: 600 clamp(15px, 1.2vw, 28px) var(--font-mono); letter-spacing: 0.06em; }
.tile-name { color: var(--ink-faint); font-size: clamp(11px, 0.8vw, 18px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-mid { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0; }
.tile-price { font: 600 clamp(20px, 1.8vw, 44px) var(--font-ui); font-variant-numeric: tabular-nums; }
.tile-chg { font: 600 clamp(12px, 0.95vw, 22px) var(--font-mono); }
.tile.up .tile-chg { color: #22D67A; }
.tile.down .tile-chg { color: #FF4D5E; }
.tile-spark { width: 100%; height: clamp(40px, 4.5vw, 110px); display: block; }
.tile-foot { font: 400 clamp(10px, 0.7vw, 16px) var(--font-mono); color: var(--ink-faint); margin-top: 6px; }
.sv-chart, .chart-body { display: grid; grid-template-rows: auto auto 1fr auto auto; gap: 8px; height: 100%; min-height: 0; }
.sv-chart { height: calc(100% - 4px); }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.chart-sym { font: 700 clamp(20px, 1.8vw, 46px) var(--font-mono); color: var(--ink); }
.chart-name { color: var(--ink-dim); font-size: clamp(14px, 1vw, 24px); }
.chart-price { font: 600 clamp(20px, 1.8vw, 46px) var(--font-ui); font-variant-numeric: tabular-nums; }
.chart-chg { font: 600 clamp(13px, 1vw, 24px) var(--font-mono); }
.chart-chg.up { color: #22D67A; }
.chart-chg.down { color: #FF4D5E; }
.chart-open { font: 600 10px var(--font-mono); letter-spacing: 0.18em; color: var(--ink-faint); }
.chart-open.live { color: #22D67A; }
.chart-ranges { display: flex; gap: 6px; }
.chart-ranges .mini-btn.on { background: color-mix(in srgb, var(--hud) 25%, transparent); color: var(--ink); }
.chart-canvas { width: 100%; height: 100%; min-height: 260px; display: block; }
.chart-readout { font: 400 12px var(--font-mono); color: var(--ink-dim); min-height: 1.4em; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font: 400 10.5px var(--font-mono); color: var(--ink-faint); }
.dialog-wide { width: min(1100px, calc(100vw - 32px)); }
#chart-dialog .chart-body { height: min(70vh, 640px); }

/* brain explorer */
.explorer { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
.explorer > * { pointer-events: auto; }
.ex-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.kl { position: absolute; left: 0; top: 0; pointer-events: auto; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; padding: 1px 6px; background: color-mix(in srgb, var(--bg) 55%, transparent); border: 0; border-radius: 2px; font: 500 11px var(--font-mono); color: var(--ink-dim); letter-spacing: 0.03em; will-change: transform; }
.kl:hover, .kl.lit { color: var(--ink); background: color-mix(in srgb, var(--hud) 22%, transparent); }
.kl-category { font: 600 13px var(--font-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--hud); background: transparent; border-bottom: 1px solid color-mix(in srgb, var(--hud) 45%, transparent); }
.kl-project { color: var(--ink); font-weight: 600; }
.ex-top { position: absolute; top: calc(var(--top-h) + 8px); left: 50%; transform: translateX(-50%); width: min(620px, calc(100vw - 32px)); display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid color-mix(in srgb, var(--hud) 40%, transparent); border-radius: 3px; }
.ex-top svg { color: var(--hud); margin-left: 4px; }
.ex-top input { flex: 1; min-width: 0; height: 36px; background: transparent; border: 0; outline: none; font-size: 16px; color: var(--ink); }
.ex-cats { position: absolute; top: calc(var(--top-h) + 62px); left: 50%; transform: translateX(-50%); width: min(900px, calc(100vw - 32px)); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.ex-cat { display: inline-flex; gap: 6px; align-items: baseline; padding: 3px 9px; background: var(--panel); border: 1px solid color-mix(in srgb, var(--hud) 25%, transparent); border-radius: 2px; font: 500 11px var(--font-mono); letter-spacing: 0.06em; color: var(--ink-dim); }
.ex-cat b { color: var(--hud); font-weight: 500; }
.ex-cat:hover { color: var(--ink); border-color: var(--hud); }
.ex-side { position: absolute; left: var(--gutter); top: calc(var(--top-h) + 120px); width: min(320px, 40vw); max-height: calc(100vh - var(--top-h) - 220px); overflow-y: auto; }
.ex-status { margin: 0 0 8px; font: 400 11.5px var(--font-mono); color: var(--ink-dim); }
.ex-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ex-hit { display: grid; padding: 6px 10px; background: var(--panel); border-left: 2px solid var(--hud); cursor: pointer; }
.ex-hit:hover { background: color-mix(in srgb, var(--hud) 14%, transparent); }
.ex-hit-title { font-weight: 600; font-size: 14px; }
.ex-hit-meta { font: 400 10px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.ex-none { display: flex; gap: 6px; }
.ex-card { position: absolute; right: var(--gutter); top: calc(var(--top-h) + 120px); width: min(380px, 44vw); max-height: calc(100vh - var(--top-h) - 220px); overflow-y: auto; padding: 16px; background: var(--panel-solid); border: 1px solid var(--hud); border-radius: 3px; box-shadow: 0 0 40px color-mix(in srgb, var(--hud) 18%, transparent); }
.ex-card h3 { margin: 4px 0 8px; font-size: 19px; line-height: 1.2; }
.ex-card-type { font: 500 10px var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--hud); }
.ex-sum { color: var(--ink-dim); font-size: 13.5px; line-height: 1.45; }
.ex-path { display: block; font: 400 10.5px var(--font-mono); color: var(--ink-faint); word-break: break-all; margin: 6px 0 10px; }
.ex-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ex-read { margin: 10px 0 0; max-height: 40vh; overflow: auto; white-space: pre-wrap; font: 400 11.5px/1.5 var(--font-mono); color: var(--ink-dim); background: rgba(0, 0, 0, 0.35); padding: 10px; }
.ex-hint { position: absolute; top: calc(var(--top-h) + 96px); left: 50%; transform: translateX(-50%); margin: 0; font: 400 10.5px var(--font-mono); letter-spacing: 0.1em; color: var(--ink-faint); white-space: nowrap; pointer-events: none; }
body.exploring .panel, body.exploring .captions, body.exploring .room-status, body.exploring .idle-widgets { opacity: 0; pointer-events: none; transition: opacity .5s; }
body.exploring #stage { cursor: grab; }
body.mode-tv .ex-top, body.mode-tv .ex-side, body.mode-tv .ex-hint, body.mode-tv .ex-card .ex-actions { display: none; }
body.mode-tv .kl { font-size: clamp(11px, 0.8vw, 20px); }
body.mode-tv .kl-category { font-size: clamp(13px, 1.1vw, 28px); }
body.mode-tv .ex-cats { top: calc(var(--top-h) + 8px); }

/* connections */
.conn-list { max-height: 62vh; overflow-y: auto; padding-right: 6px; margin-bottom: 14px; }
.conn-group { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; font: 500 11px var(--font-mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--hud); }
.conn-ok { color: var(--ok); font-size: 10px; letter-spacing: 0.1em; }
.conn-row { padding: 10px 12px; margin-bottom: 6px; background: rgba(255, 255, 255, 0.025); border-left: 2px solid var(--warn); }
.conn-row.set { border-left-color: var(--ok); }
.conn-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.conn-name .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.conn-row.set .conn-name .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.conn-state { margin-left: auto; font: 400 10px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
.conn-help { margin: 4px 0 8px !important; font-size: 12.5px; line-height: 1.4; }
.conn-help a { color: var(--hud); }
.conn-form { display: flex; gap: 6px; align-items: center; }
.conn-form input { margin: 0 !important; height: 32px !important; flex: 1; }
.conn-form .mini-btn { height: 32px; }

/* phone layout for the new overlays */
body.mode-mobile .screen-view { inset: calc(var(--top-h) + 4px) 8px 8px; padding: 14px; }
body.mode-mobile .ex-side { left: 8px; right: 8px; width: auto; top: auto; bottom: 150px; max-height: 26vh; }
body.mode-mobile .ex-card { left: 8px; right: 8px; width: auto; top: calc(var(--top-h) + 110px); max-height: 44vh; }
body.mode-mobile .ex-hint { display: none; }
body.mode-mobile .mrow { grid-template-columns: 50px 1fr 60px 58px; }

/* phone anywhere */
.remote { padding: 4px 0 8px; border-bottom: 1px solid color-mix(in srgb, var(--hud) 15%, transparent); margin-bottom: 6px; }
.remote-steps { margin: 6px 0 10px; padding-left: 20px; display: grid; gap: 5px; font-size: 13px; color: var(--ink-dim); }
.remote-steps li.done { color: var(--ok); }
.remote-steps li.done::marker { content: '✓  '; }
.remote-steps code { color: var(--ink); }
.remote-steps a { color: var(--hud); }
.pair-qr { display: block; width: 220px; height: 220px; margin: 10px 0; image-rendering: pixelated; background: #fff; padding: 6px; border-radius: 4px; }

/* pairing by code */
.pair-code { font: 600 clamp(40px, 9vw, 72px)/1.1 var(--font-mono); letter-spacing: 0.18em; text-align: center; color: var(--hud); margin: 10px 0 4px; text-shadow: 0 0 24px color-mix(in srgb, var(--hud) 50%, transparent); }
.pair-wait { text-align: center; font: 400 12px var(--font-mono); }
.pair-manual { margin: 6px 0 12px; color: var(--ink-faint); font-size: 12px; }
.pair-manual summary { cursor: pointer; margin-bottom: 8px; }
.pair-manual .btn { width: 100%; }
body.mode-tv #pair-dialog { width: min(720px, 80vw); }

.pair-list { display: grid; gap: 6px; margin-bottom: 10px; padding: 8px 10px; border: 1px solid var(--warn); border-radius: 2px; background: color-mix(in srgb, var(--warn) 10%, transparent); }
.pair-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pair-row b { font-family: var(--font-mono); letter-spacing: 0.12em; color: var(--warn); }
.pair-row .mini-btn { margin-left: auto; }
