/* =====================================================================
   J.A.R.V.I.S. holographic HUD
   ===================================================================== */
:root {
  --c-rgb: 0, 214, 255;          /* primary hologram colour */
  --hot-rgb: 205, 250, 255;      /* hottest highlights */
  --accent-rgb: 255, 176, 32;    /* thinking / warnings */
  --bg: #02060b;
  --c: rgb(var(--c-rgb));
  --c-soft: rgba(var(--c-rgb), 0.55);
  --c-dim: rgba(var(--c-rgb), 0.18);
  --text: #dff8ff;
  --muted: rgba(200, 235, 245, 0.55);
  --f-display: "Orbitron", "Segoe UI", system-ui, sans-serif;
  --f-ui: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  --f-mono: "Share Tech Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

body.theme-alert     { --c-rgb: 255, 64, 52;  --hot-rgb: 255, 214, 205; }
body.theme-celebrate { --c-rgb: 255, 196, 40; --hot-rgb: 255, 244, 210; }
body.theme-focus     { --c-rgb: 110, 170, 255; --hot-rgb: 215, 230, 255; }
body.theme-party     { --c-rgb: 255, 60, 220; --hot-rgb: 255, 220, 250; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at 50% 45%, #061a26 0%, #030b12 45%, var(--bg) 100%);
  color: var(--text);
  font-family: var(--f-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: --c-rgb 0.6s;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- atmosphere layers ---------- */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.scanlines {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}
.vignette {
  position: fixed; inset: 0; z-index: 49; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.65) 100%);
}
.sweep {
  position: fixed; left: 0; right: 0; top: -20vh; height: 18vh; z-index: 48; pointer-events: none; opacity: 0;
  background: linear-gradient(to bottom, transparent, rgba(var(--c-rgb), 0.10) 70%, rgba(var(--hot-rgb), 0.55) 98%, transparent);
  filter: blur(1px);
}
body.fx-scan .sweep { animation: sweep 1.6s var(--ease) 2; }
@keyframes sweep { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0.6; transform: translateY(125vh); } }
.flash { position: fixed; inset: 0; z-index: 60; pointer-events: none; background: rgb(var(--hot-rgb)); opacity: 0; }
body.fx-flash .flash { animation: flash 0.9s ease-out; }
@keyframes flash { 0% { opacity: 0; } 8% { opacity: 0.55; } 100% { opacity: 0; } }
body.theme-party #hud, body.theme-party #bg { animation: hue 4s linear infinite; }
@keyframes hue { to { filter: hue-rotate(360deg); } }

/* ---------- frame (bracketed holo panel) ---------- */
.frame {
  --b: rgba(var(--c-rgb), 0.7);
  --k: 12px;
  position: relative;
  border: 1px solid rgba(var(--c-rgb), 0.13);
  background:
    linear-gradient(var(--b), var(--b)) top left / var(--k) 1.5px no-repeat,
    linear-gradient(var(--b), var(--b)) top left / 1.5px var(--k) no-repeat,
    linear-gradient(var(--b), var(--b)) top right / var(--k) 1.5px no-repeat,
    linear-gradient(var(--b), var(--b)) top right / 1.5px var(--k) no-repeat,
    linear-gradient(var(--b), var(--b)) bottom left / var(--k) 1.5px no-repeat,
    linear-gradient(var(--b), var(--b)) bottom left / 1.5px var(--k) no-repeat,
    linear-gradient(var(--b), var(--b)) bottom right / var(--k) 1.5px no-repeat,
    linear-gradient(var(--b), var(--b)) bottom right / 1.5px var(--k) no-repeat,
    linear-gradient(180deg, rgba(var(--c-rgb), 0.075), rgba(var(--c-rgb), 0.015) 60%, rgba(var(--c-rgb), 0.04));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: inset 0 0 24px rgba(var(--c-rgb), 0.05), 0 0 30px rgba(0, 0, 0, 0.35);
}
.label {
  font-family: var(--f-display); font-size: 10px; font-weight: 700; letter-spacing: 0.28em;
  color: rgba(var(--c-rgb), 0.85); display: flex; align-items: center; gap: 8px; text-transform: uppercase;
}
.label::before { content: ""; width: 6px; height: 6px; background: var(--c); box-shadow: 0 0 8px var(--c); }
.label-r { margin-left: auto; font-family: var(--f-mono); letter-spacing: 0.08em; font-size: 10px; color: var(--muted); font-weight: 400; }
.blink { animation: blink 1.6s steps(2) infinite; color: rgba(255, 80, 80, 0.9); }
@keyframes blink { 50% { opacity: 0.2; } }

/* =====================================================================
   HUD layout
   ===================================================================== */
#hud {
  position: fixed; inset: 0; z-index: 10;
  display: grid;
  grid-template-columns: minmax(240px, 21vw) 1fr minmax(240px, 21vw);
  grid-template-rows: auto 1fr auto;
  gap: 16px 22px;
  padding: calc(14px + var(--safe-t)) 22px calc(16px + var(--safe-b));
}
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; min-height: 40px; }
.col { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.col-left { grid-column: 1; grid-row: 2; }
.col-right { grid-column: 3; grid-row: 2; }
.center { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; position: relative; }
.cmdbar { grid-column: 2; grid-row: 3; display: flex; flex-direction: column; align-items: center; gap: 8px; }

/* hide-until-online choreography */
.topbar, .panel, .cmdbar, .status-line, .captions { transition: opacity 0.8s var(--ease), transform 0.8s var(--ease), filter 0.8s; }
body:not(.hud-on) .panel { opacity: 0; transform: translateY(14px) scale(0.98); filter: blur(4px); }
body:not(.hud-on) .topbar, body:not(.hud-on) .cmdbar { opacity: 0; transform: translateY(-6px); }
body.hud-on .panel { transition-delay: calc(var(--d, 0) * 140ms); }
body:not(.hud-on) .status-line, body:not(.hud-on) .captions { opacity: 0; }
body.state-gate #hud, body.state-init #hud { visibility: hidden; }

/* ---------- top bar ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--c); box-shadow: 0 0 12px var(--c), inset 0 0 8px var(--c);
  position: relative;
}
.brand-mark::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: rgb(var(--hot-rgb)); box-shadow: 0 0 10px var(--c); }
.brand-name { font-family: var(--f-display); font-weight: 900; letter-spacing: 0.32em; font-size: 15px; text-shadow: 0 0 14px rgba(var(--c-rgb), 0.8); }
.brand-ver { font-family: var(--f-mono); font-size: 10px; color: var(--muted); border: 1px solid var(--c-dim); padding: 1px 6px; }
.top-status { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; justify-content: center; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px;
  border: 1px solid var(--c-dim); background: rgba(var(--c-rgb), 0.05);
  font-family: var(--f-display); font-size: 9.5px; letter-spacing: 0.2em; color: rgba(var(--c-rgb), 0.85);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.pill em { font-style: normal; font-family: var(--f-mono); letter-spacing: 0.05em; color: var(--text); font-size: 11px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #3dff9a; box-shadow: 0 0 8px #3dff9a; }
.pill.warn .dot { background: rgb(var(--accent-rgb)); box-shadow: 0 0 8px rgb(var(--accent-rgb)); }
.pill.off .dot { background: #ff4a4a; box-shadow: 0 0 8px #ff4a4a; }
.top-right { display: flex; align-items: center; gap: 12px; }
.top-clock { font-family: var(--f-mono); font-size: 15px; letter-spacing: 0.08em; color: rgba(var(--hot-rgb), 0.9); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  background: rgba(var(--c-rgb), 0.06); border: 1px solid var(--c-dim); border-radius: 50%;
  transition: background 0.2s, transform 0.3s;
}
.icon-btn:hover { background: rgba(var(--c-rgb), 0.16); transform: rotate(30deg); }
.icon-btn svg { width: 18px; height: 18px; fill: var(--c); }

/* ---------- panels ---------- */
.panel { padding: 14px 16px 16px; }
.clock-big { display: flex; align-items: baseline; gap: 6px; margin-top: 10px; font-family: var(--f-display); }
#clock-hm { font-size: 46px; font-weight: 700; letter-spacing: 0.04em; text-shadow: 0 0 22px rgba(var(--c-rgb), 0.55); }
.clock-s { font-family: var(--f-mono); font-size: 18px; color: var(--c); }
.clock-ampm { font-size: 13px; color: var(--muted); letter-spacing: 0.15em; }
.clock-date { font-family: var(--f-display); font-size: 11px; letter-spacing: 0.25em; color: var(--muted); margin-top: 2px; text-transform: uppercase; }
.tickbar {
  margin-top: 14px; height: 6px; position: relative;
  background: repeating-linear-gradient(90deg, rgba(var(--c-rgb), 0.25) 0 2px, transparent 2px 6px);
}
.tickbar span { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(90deg, var(--c) 0 2px, transparent 2px 6px); box-shadow: 0 0 10px rgba(var(--c-rgb), 0.5); }
.mini-row, .kv, .meter-head { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 11px; color: var(--muted); margin-top: 6px; letter-spacing: 0.06em; }
.kv b, .meter-head b { color: var(--text); font-weight: 400; }
.meter { margin-top: 10px; }
.bar { height: 5px; background: rgba(var(--c-rgb), 0.12); margin-top: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, rgba(var(--c-rgb), 0.5), var(--c)); box-shadow: 0 0 10px var(--c); transition: width 1s var(--ease); }
.bar span.hot { background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.5), rgb(var(--accent-rgb))); box-shadow: 0 0 10px rgb(var(--accent-rgb)); }
.spark { width: 100%; height: 34px; display: block; margin-top: 6px; }

.log-panel { flex: 1; min-height: 120px; display: flex; flex-direction: column; overflow: hidden; }
.log { list-style: none; margin: 10px 0 0; padding: 0; font-family: var(--f-mono); font-size: 11px; line-height: 1.55; color: var(--muted); overflow: hidden; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; mask-image: linear-gradient(to bottom, transparent, #000 35%); -webkit-mask-image: linear-gradient(to bottom, transparent, #000 35%); }
.log li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: logIn 0.35s var(--ease); }
.log li time { color: rgba(var(--c-rgb), 0.7); margin-right: 6px; }
.log li.u { color: var(--text); }
.log li.t { color: rgb(var(--accent-rgb)); }
.log li.e { color: #ff7a7a; }
@keyframes logIn { from { opacity: 0; transform: translateX(-8px); } }

.wx-main { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.wx-temp { font-family: var(--f-display); font-size: 50px; font-weight: 700; text-shadow: 0 0 22px rgba(var(--c-rgb), 0.55); }
.wx-temp sup { font-size: 16px; color: var(--c); margin-left: 2px; }
.wx-icon { width: 58px; height: 58px; }
.wx-icon svg { width: 100%; height: 100%; stroke: var(--c); fill: none; stroke-width: 1.6; filter: drop-shadow(0 0 6px rgba(var(--c-rgb), 0.7)); }
.wx-cond { font-family: var(--f-display); font-size: 11px; letter-spacing: 0.22em; color: var(--text); text-transform: uppercase; }
.wx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 12px; }
.wx-grid div { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 11px; color: var(--muted); border-bottom: 1px dashed var(--c-dim); padding-bottom: 3px; }
.wx-grid b { color: var(--text); font-weight: 400; }

.devices { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.devices li { display: flex; align-items: center; gap: 10px; font-family: var(--f-mono); font-size: 12px; padding: 7px 9px; background: rgba(var(--c-rgb), 0.05); border-left: 2px solid var(--c); animation: logIn 0.4s var(--ease); }
.devices li svg { width: 18px; height: 18px; fill: none; stroke: var(--c); stroke-width: 1.6; flex: none; }
.devices li .dname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.devices li .dtag { font-size: 9px; color: #3dff9a; letter-spacing: 0.1em; }
.devices li.call { border-left-color: rgb(var(--accent-rgb)); }
.devices li.call .dtag { color: rgb(var(--accent-rgb)); }
.pair { margin-top: 12px; font-family: var(--f-display); font-size: 9.5px; letter-spacing: 0.22em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.pair b { font-family: var(--f-mono); font-size: 16px; letter-spacing: 0.3em; color: var(--text); text-shadow: 0 0 10px rgba(var(--c-rgb), 0.7); }

.protocols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.proto {
  cursor: pointer; padding: 9px 8px; text-align: left; position: relative; overflow: hidden;
  background: rgba(var(--c-rgb), 0.05); border: 1px solid var(--c-dim);
  font-family: var(--f-display); font-size: 9.5px; letter-spacing: 0.16em; color: var(--text);
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.proto small { display: block; font-family: var(--f-mono); font-size: 9px; color: var(--muted); letter-spacing: 0.08em; margin-bottom: 2px; }
.proto:hover { background: rgba(var(--c-rgb), 0.15); border-color: var(--c-soft); }
.proto:active { transform: scale(0.97); }
.proto.running::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(var(--c-rgb), 0.35), transparent); animation: shimmer 1s linear infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- reactor + captions ---------- */
.reactor-wrap { position: relative; width: min(56vh, 40vw, 640px); aspect-ratio: 1; flex: none; }
#reactor { width: 100%; height: 100%; display: block; }
.reactor-hit { position: absolute; inset: 18%; border-radius: 50%; background: transparent; border: 0; cursor: pointer; outline: none; }
.status-line {
  display: flex; align-items: center; gap: 10px; margin-top: -6px;
  font-family: var(--f-display); font-size: 11px; letter-spacing: 0.42em; color: rgba(var(--c-rgb), 0.9);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
body.state-listening .status-dot { animation: pulse 0.9s ease-in-out infinite; background: rgb(var(--hot-rgb)); }
body.state-thinking .status-dot { background: rgb(var(--accent-rgb)); box-shadow: 0 0 10px rgb(var(--accent-rgb)); animation: pulse 0.5s infinite; }
body.state-thinking .status-line { color: rgb(var(--accent-rgb)); }
@keyframes pulse { 50% { transform: scale(1.8); opacity: 0.5; } }
.status-tool { font-family: var(--f-mono); letter-spacing: 0.12em; font-size: 10px; color: rgb(var(--accent-rgb)); }
.status-tool:not(:empty)::before { content: "// "; opacity: 0.6; }

.captions { min-height: 120px; max-width: min(820px, 92%); text-align: center; margin-top: 18px; }
.cap-user { font-family: var(--f-ui); font-size: 17px; color: var(--muted); min-height: 24px; letter-spacing: 0.02em; transition: opacity 0.4s; }
.cap-user:not(:empty)::before { content: "› "; color: var(--c); }
.cap-user .interim { opacity: 0.6; }
.cap-user .from { font-family: var(--f-display); font-size: 9px; letter-spacing: 0.2em; color: rgb(var(--accent-rgb)); margin-right: 8px; border: 1px solid rgba(var(--accent-rgb), 0.5); padding: 1px 6px; vertical-align: middle; }
.cap-ai {
  margin-top: 8px; font-family: var(--f-ui); font-weight: 500; font-size: clamp(20px, 2.1vw, 30px); line-height: 1.3;
  color: #effcff; text-shadow: 0 0 18px rgba(var(--c-rgb), 0.55), 0 0 2px rgba(var(--c-rgb), 0.9); min-height: 40px;
}
.cap-ai .w { opacity: 0; display: inline-block; filter: blur(6px); transform: translateY(4px); transition: opacity 0.35s, filter 0.35s, transform 0.35s; white-space: pre; }
.cap-ai .w.on { opacity: 1; filter: none; transform: none; }
.captions.fade .cap-ai, .captions.fade .cap-user { opacity: 0.35; transition: opacity 2s; }

/* ---------- command bar ---------- */
.cmd { display: flex; align-items: center; gap: 10px; width: min(640px, 100%); padding: 6px 6px 6px 16px; }
.cmd-prompt { font-family: var(--f-mono); color: var(--c); font-size: 18px; }
#cmd-input { flex: 1; background: transparent; border: 0; outline: none; font-size: 17px; letter-spacing: 0.02em; color: var(--text); min-width: 0; user-select: text; }
#cmd-input::placeholder { color: rgba(200, 235, 245, 0.35); }
.mic-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: none;
  background: radial-gradient(circle, rgba(var(--c-rgb), 0.35), rgba(var(--c-rgb), 0.08)); border: 1px solid var(--c-soft);
  box-shadow: 0 0 16px rgba(var(--c-rgb), 0.35); transition: transform 0.15s, box-shadow 0.3s;
}
.mic-btn svg { width: 20px; height: 20px; fill: rgb(var(--hot-rgb)); }
.mic-btn:active { transform: scale(0.92); }
body.state-listening .mic-btn { box-shadow: 0 0 0 6px rgba(var(--c-rgb), 0.15), 0 0 30px var(--c); animation: micPulse 1.2s infinite; }
@keyframes micPulse { 50% { box-shadow: 0 0 0 12px rgba(var(--c-rgb), 0.05), 0 0 40px var(--c); } }
.hint { font-family: var(--f-display); font-size: 9px; letter-spacing: 0.25em; color: rgba(200, 235, 245, 0.35); }
.hint b { color: rgba(var(--c-rgb), 0.8); font-weight: 700; }
kbd { font-family: var(--f-mono); border: 1px solid var(--c-dim); padding: 0 5px; color: var(--muted); }

/* ---------- boot log ---------- */
.bootlog {
  position: fixed; left: 4vw; bottom: 16vh; z-index: 30; pointer-events: none;
  font-family: var(--f-mono); font-size: clamp(11px, 1.05vw, 14px); line-height: 1.75; color: rgba(var(--c-rgb), 0.95);
  text-shadow: 0 0 8px rgba(var(--c-rgb), 0.6); white-space: pre;
}
.bootlog .ok { color: #3dff9a; text-shadow: 0 0 8px rgba(61, 255, 154, 0.6); }
.bootlog .warn { color: rgb(var(--accent-rgb)); }
.bootlog .head { color: rgb(var(--hot-rgb)); letter-spacing: 0.2em; }
.bootlog.out { opacity: 0; transition: opacity 1s; }

/* ---------- overlays: init + gate ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; }
.init-btn { position: relative; width: min(46vw, 260px); aspect-ratio: 1; border-radius: 50%; border: 0; background: transparent; cursor: pointer; }
.init-ring { position: absolute; border-radius: 50%; border: 1.5px solid rgba(var(--c-rgb), 0.35); inset: 0; }
.init-ring.r1 { border-style: dashed; animation: spin 18s linear infinite; }
.init-ring.r2 { inset: 14%; border-color: rgba(var(--c-rgb), 0.55); border-left-color: transparent; border-right-color: transparent; animation: spin 6s linear infinite reverse; }
.init-ring.r3 { inset: 28%; border-width: 3px; border-color: rgba(var(--c-rgb), 0.7); border-bottom-color: transparent; animation: spin 3s linear infinite; }
.init-core { position: absolute; inset: 40%; border-radius: 50%; background: radial-gradient(circle, #fff, var(--c) 45%, transparent 72%); box-shadow: 0 0 40px var(--c); animation: breathe 2.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(0.82); opacity: 0.7; } }
.init-title { font-family: var(--f-display); font-weight: 900; font-size: clamp(26px, 5vw, 46px); letter-spacing: 0.45em; padding-left: 0.45em; text-shadow: 0 0 24px rgba(var(--c-rgb), 0.85); }
.init-title i { font-style: normal; color: var(--c); }
.init-sub { font-family: var(--f-display); font-size: 11px; letter-spacing: 0.6em; padding-left: 0.6em; color: var(--muted); animation: blink 1.8s steps(2) infinite; }

.gate-box { padding: 34px 30px 26px; width: min(440px, 92vw); text-align: center; }
.gate-box .label { justify-content: center; }
.gate-title { font-family: var(--f-display); font-size: clamp(17px, 4vw, 22px); letter-spacing: 0.24em; margin: 16px 0 6px; text-shadow: 0 0 16px rgba(var(--c-rgb), 0.7); }
.gate-sub { color: var(--muted); margin: 0 0 22px; font-size: 15px; }
.code-boxes { display: flex; gap: 9px; justify-content: center; }
.code-boxes input {
  width: 44px; height: 56px; text-align: center; font-family: var(--f-mono); font-size: 26px; background: rgba(var(--c-rgb), 0.06);
  border: 1px solid var(--c-dim); outline: none; color: var(--text); caret-color: var(--c); user-select: text;
}
.code-boxes input:focus { border-color: var(--c); box-shadow: 0 0 14px rgba(var(--c-rgb), 0.45); }
.gate-msg { margin-top: 16px; min-height: 20px; font-family: var(--f-display); font-size: 10px; letter-spacing: 0.25em; color: #ff6b6b; }
.gate-msg.ok { color: #3dff9a; }
.gate-box.shake { animation: shake 0.45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- timers + toasts ---------- */
.timers { position: fixed; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 35; display: flex; gap: 10px; }
.timer { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; font-family: var(--f-mono); animation: logIn 0.4s var(--ease); }
.timer svg { width: 30px; height: 30px; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 3; }
.timer .tl { font-family: var(--f-display); font-size: 9px; letter-spacing: 0.22em; color: var(--muted); display: block; }
.timer .tv { font-size: 18px; color: var(--text); }
.timer.done { animation: blink 0.5s steps(2) 8; }
.toasts { position: fixed; top: 21%; left: 50%; transform: translateX(-50%); z-index: 36; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { padding: 9px 20px; font-family: var(--f-display); font-size: 12px; letter-spacing: 0.3em; color: var(--text); animation: toast 2.8s var(--ease) forwards; text-shadow: 0 0 12px var(--c); }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px) scaleX(0.6); } 10% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }

/* ---------- holographic document ---------- */
.doc {
  position: fixed; z-index: 37; top: calc(76px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  width: min(600px, 92vw); max-height: min(72vh, 760px); display: flex; flex-direction: column;
  background-color: rgba(2, 12, 20, 0.86); padding: 14px 18px 18px; animation: docIn 0.5s var(--ease);
  box-shadow: 0 0 60px rgba(var(--c-rgb), 0.18), inset 0 0 30px rgba(var(--c-rgb), 0.06);
}
@keyframes docIn { from { opacity: 0; transform: translate(-50%, 16px) scaleY(0.6); filter: blur(6px); } }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--c-dim); }
.doc-head .icon-btn { width: 30px; height: 30px; font-size: 13px; }
.doc-body { overflow-y: auto; padding-top: 10px; font-size: 17px; line-height: 1.45; color: var(--text); user-select: text; scrollbar-width: thin; scrollbar-color: var(--c-dim) transparent; }
.doc-body h3 { font-family: var(--f-display); font-size: 12px; letter-spacing: 0.22em; color: var(--c); margin: 16px 0 6px; text-transform: uppercase; }
.doc-body h3:first-child { margin-top: 4px; }
.doc-body p { margin: 6px 0; }
.doc-body ul, .doc-body ol { margin: 6px 0; padding-left: 20px; }
.doc-body li { margin: 4px 0; }
.doc-body ul li::marker { color: var(--c); }
.doc-body ol li::marker { color: var(--c); font-family: var(--f-mono); }
.doc-body b { color: #fff; font-weight: 600; }
@media (max-width: 860px) { .doc { top: calc(60px + var(--safe-t)); max-height: 64vh; font-size: 16px; } }

/* ---------- drawer ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 45; padding: calc(18px + var(--safe-t)) 20px 20px; background-color: rgba(2, 10, 16, 0.92); overflow-y: auto; animation: drawerIn 0.35s var(--ease); }
@keyframes drawerIn { from { transform: translateX(100%); } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-family: var(--f-display); font-size: 9.5px; letter-spacing: 0.22em; color: var(--muted); }
.field select { background: rgba(var(--c-rgb), 0.06); border: 1px solid var(--c-dim); padding: 9px; font-family: var(--f-ui); font-size: 15px; letter-spacing: 0; color: var(--text); outline: none; }
.field select option { background: #041018; }
.toggle { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-size: 15px; cursor: pointer; }
.toggle input { appearance: none; width: 38px; height: 20px; border: 1px solid var(--c-soft); border-radius: 20px; position: relative; flex: none; cursor: pointer; transition: background 0.2s; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform 0.2s, background 0.2s; }
.toggle input:checked { background: rgba(var(--c-rgb), 0.25); }
.toggle input:checked::after { transform: translateX(18px); background: var(--c); box-shadow: 0 0 8px var(--c); }
.drawer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.btn { padding: 10px 8px; cursor: pointer; background: rgba(var(--c-rgb), 0.07); border: 1px solid var(--c-dim); font-family: var(--f-display); font-size: 9.5px; letter-spacing: 0.18em; transition: background 0.2s; }
.btn:hover { background: rgba(var(--c-rgb), 0.18); }
.btn.danger { border-color: rgba(255, 80, 80, 0.5); color: #ff9b9b; }
.drawer-info { margin-top: 22px; font-family: var(--f-mono); font-size: 11px; line-height: 1.7; color: var(--muted); white-space: pre-wrap; user-select: text; }

/* ---------- states ---------- */
body.state-standby .panel, body.state-standby .topbar, body.state-standby .cmdbar, body.state-standby .captions { opacity: 0 !important; pointer-events: none; }
body.state-standby .status-line { opacity: 0.4; }
body.present .cmdbar, body.present .icon-btn, body.present .hint { opacity: 0 !important; pointer-events: none; }
body.present #pair { display: none !important; } /* never film the pair code: it unlocks JARVIS */
body.present, body.present * { cursor: none !important; }
body.theme-focus .panel { opacity: 0.55; }

/* =====================================================================
   Responsive: tablet + phone
   ===================================================================== */
.show-sm { display: none; }
@media (max-width: 1180px) {
  #hud { grid-template-columns: minmax(210px, 24vw) 1fr minmax(210px, 24vw); gap: 14px 16px; padding-left: 16px; padding-right: 16px; }
  #clock-hm { font-size: 38px; }
  .wx-temp { font-size: 42px; }
}
@media (max-width: 860px) {
  #hud { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; padding: calc(10px + var(--safe-t)) 14px calc(12px + var(--safe-b)); }
  .col { display: none; }
  .center { grid-column: 1; }
  .cmdbar { grid-column: 1; }
  .hide-sm { display: none !important; }
  .show-sm { display: flex; }
  .topbar { gap: 10px; }
  .brand-name { font-size: 13px; letter-spacing: 0.24em; }
  .brand-ver { display: none; }
  .top-status { justify-content: flex-end; }
  .top-clock { display: none; }
  .reactor-wrap { width: min(84vw, 46vh); }
  .captions { margin-top: 10px; min-height: 96px; }
  .cap-ai { font-size: clamp(19px, 5.4vw, 24px); }
  .cap-user { font-size: 15px; }
  .chips { gap: 8px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
  .chip { font-family: var(--f-mono); font-size: 11px; padding: 4px 10px; border: 1px solid var(--c-dim); background: rgba(var(--c-rgb), 0.05); color: var(--text); letter-spacing: 0.06em; }
  .cmd { padding: 5px 5px 5px 14px; }
  .mic-btn { width: 54px; height: 54px; }
  .mic-btn svg { width: 24px; height: 24px; }
  #cmd-input { font-size: 16px; }
  .bootlog { left: 6vw; right: 6vw; bottom: auto; top: 12vh; font-size: 11px; }
  .timers { top: calc(56px + var(--safe-t)); }
}
@media (max-height: 560px) and (max-width: 960px) {
  .reactor-wrap { width: min(44vh, 60vw); }
  .captions { min-height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .init-ring, .init-core { animation: none; }
}
