/* J.A.R.V.I.S cinematic hologram HUD — projected glass, cyan energy, living microanim */
:root {
  --void: #00040a;
  --bg: #02060f;
  --panel: rgba(2, 10, 20, 0.42);
  --panel-strong: rgba(3, 12, 24, 0.72);
  --line: rgba(94, 240, 255, 0.18);
  --line-strong: rgba(94, 240, 255, 0.5);
  --text: #e6f7ff;
  --muted: #6a9bb4;
  --faint: #2e4a60;
  --cyan: #5ef0ff;
  --cyan2: #4fd2ff;
  --blue: #2a7fff;
  --violet: #9b6cff;
  --magenta: #ff2d7a;
  --mint: #3dffc5;
  --white: #f4fbff;
  --ok: #3dffc5;
  --bad: #ff4d6a;
  --warn: #ffc14d;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
  --shadow: 0 28px 90px rgba(0, 4, 14, 0.78);
  --glow-c: 0 0 48px rgba(94, 240, 255, 0.28);
  --glow-m: 0 0 48px rgba(255, 45, 122, 0.22);
  --glow-v: 0 0 48px rgba(155, 108, 255, 0.28);
  --chrome: linear-gradient(135deg, rgba(94,240,255,0.55), rgba(155,108,255,0.35), rgba(255,45,122,0.25));
  --state-glow: rgba(94, 240, 255, 0.2);
  --state-accent: #5ef0ff;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--void);
  color: var(--text);
  font-family: var(--font);
}

/* ===== 3D stage ===== */
#stage3d {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse at 50% 34%, #0c2240 0%, #071428 28%, #030a16 58%, #000308 100%);
  transition: filter 0.6s ease;
}
body.state-listening #stage3d {
  background:
    radial-gradient(ellipse at 50% 34%, #0a3a3a 0%, #062428 28%, #030e16 58%, #000308 100%);
}
body.state-thinking #stage3d {
  background:
    radial-gradient(ellipse at 50% 34%, #221848 0%, #120e30 28%, #080614 58%, #000208 100%);
}
body.state-speaking #stage3d {
  background:
    radial-gradient(ellipse at 50% 34%, #12385a 0%, #0a1c38 28%, #040e1c 58%, #000308 100%);
}
#c3d { width: 100%; height: 100%; display: block; touch-action: none; }
.stage-fade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 38%, transparent 32%, rgba(1,3,8,.18) 70%, rgba(1,3,8,.52) 100%),
    linear-gradient(180deg, rgba(2,8,18,.2) 0%, transparent 14%, transparent 68%, rgba(1,4,12,.48) 100%),
    repeating-linear-gradient(90deg, transparent 0 72px, rgba(94,240,255,0.015) 72px 73px),
    repeating-linear-gradient(0deg, transparent 0 72px, rgba(94,240,255,0.012) 72px 73px);
}
/* corner chrome brackets */
body::after {
  content: "";
  position: fixed; inset: 10px; z-index: 4; pointer-events: none;
  border: 1px solid rgba(94,240,255,0.08);
  border-radius: 4px;
  box-shadow:
    inset 18px 18px 0 -17px rgba(94,240,255,0.45),
    inset -18px 18px 0 -17px rgba(155,108,255,0.35),
    inset 18px -18px 0 -17px rgba(42,127,255,0.35),
    inset -18px -18px 0 -17px rgba(255,45,122,0.3);
  opacity: 0.85;
}

/* holographic scanline overlay */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 3; pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(79, 210, 255, 0.015) 2px,
    rgba(79, 210, 255, 0.015) 4px
  );
  mix-blend-mode: screen;
  opacity: 0.55;
  animation: scanDrift 12s linear infinite;
}
@keyframes scanDrift {
  from { transform: translateY(0); }
  to { transform: translateY(4px); }
}

/* glass — projected chrome, hologram shows through */
.glass {
  background:
    linear-gradient(155deg, rgba(12, 32, 56, 0.34), rgba(4, 12, 24, 0.28)),
    linear-gradient(180deg, rgba(94,240,255,0.04), transparent 40%);
  border: 1px solid var(--line);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 0 0 1px rgba(94,240,255,0.04),
    var(--glow-c);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  position: relative;
}
.glass::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(120deg, rgba(255,255,255,0.07), transparent 28%, transparent 72%, rgba(155,108,255,0.05));
  opacity: 0.7;
}

/* HUD grid */
#hud {
  position: fixed; inset: 0; z-index: 2;
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 54px 1fr;
  grid-template-areas:
    "top top"
    "rail center";
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

.topbar {
  grid-area: top;
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background:
    linear-gradient(180deg, rgba(3,10,20,0.78), rgba(3,10,20,0.28)),
    linear-gradient(90deg, rgba(94,240,255,0.06), transparent 30%, transparent 70%, rgba(155,108,255,0.05));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 36px rgba(0,0,0,0.4), 0 1px 0 rgba(94,240,255,0.12);
}
.topbar::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--chrome);
  opacity: 0.55;
  pointer-events: none;
}
.brand { display: flex; gap: 12px; align-items: center; }
.sigil {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  box-shadow: 0 0 20px rgba(79,210,255,0.35);
  position: relative;
}
.sigil::before {
  content: "";
  position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid rgba(79,210,255,0.2);
  animation: ringPulse 3.2s ease-in-out infinite;
}
.sigil span {
  width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--cyan) 45%, var(--blue));
  box-shadow: 0 0 14px var(--cyan);
  animation: coreBreath 2.4s ease-in-out infinite;
}
@keyframes coreBreath {
  0%,100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.25); opacity: 1; }
}
@keyframes ringPulse {
  0%,100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
}
.name {
  font-size: 14px; letter-spacing: 0.38em; font-weight: 700;
  color: var(--white);
  text-shadow: 0 0 22px rgba(94,240,255,0.55), 0 0 40px rgba(94,240,255,0.2);
}
.codename {
  font-size: 10px; letter-spacing: 0.22em; color: var(--cyan);
  margin-top: 2px;
  opacity: 0.75;
  text-shadow: 0 0 12px rgba(94,240,255,0.25);
}
.pills { display: flex; gap: 8px; }
.pill {
  font-size: 10px; letter-spacing: 0.14em;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--faint);
  background: rgba(0,0,0,0.25);
  transition: all 0.25s ease;
}
.pill.on {
  color: var(--cyan);
  border-color: rgba(79,210,255,0.45);
  box-shadow: 0 0 16px rgba(79,210,255,0.2);
  text-shadow: 0 0 10px rgba(94,240,255,0.4);
}
.pill.bad { color: var(--bad); border-color: rgba(255,77,106,0.4); }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  background: rgba(8,20,36,0.6);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px; letter-spacing: 0.14em;
  padding: 7px 12px; border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.icon-btn:hover {
  color: var(--cyan);
  border-color: var(--line-strong);
  box-shadow: 0 0 18px rgba(79,210,255,0.18);
  transform: translateY(-1px);
}

/* rail */
.rail {
  grid-area: rail;
  margin: 10px 0 10px 10px;
  border-radius: 14px;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 12px;
  overflow: hidden;
}
.rail-label {
  font-size: 10px; letter-spacing: 0.22em; color: var(--faint);
  margin: 4px 2px 0;
}
.mode-stack { display: flex; flex-direction: column; gap: 8px; }
.mode-btn {
  text-align: left;
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.22s ease;
  position: relative;
  overflow: hidden;
}
.mode-btn::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(79,210,255,0.08), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}
.mode-btn:hover::after { transform: translateX(100%); }
.mode-btn:hover {
  border-color: var(--line-strong);
  box-shadow: 0 0 20px rgba(79,210,255,0.12);
  transform: translateX(2px);
}
.mode-btn.active {
  border-color: rgba(94,240,255,0.7);
  background:
    linear-gradient(135deg, rgba(18,56,92,0.55), rgba(10,24,44,0.55)),
    linear-gradient(90deg, rgba(94,240,255,0.12), transparent 45%);
  box-shadow:
    0 0 28px rgba(94,240,255,0.22),
    inset 0 0 24px rgba(94,240,255,0.08),
    inset 3px 0 0 var(--cyan);
}
.mode-btn .k { color: var(--cyan); font-size: 10px; letter-spacing: 0.16em; }
.mode-btn .t { display: block; font-size: 13px; letter-spacing: 0.12em; margin-top: 2px; }
.mode-btn .s { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }

.sys { display: flex; flex-direction: column; gap: 6px; }
.sys-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; letter-spacing: 0.12em; color: var(--muted);
  padding: 4px 2px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 0 transparent;
  transition: all 0.3s ease;
}
.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(61,255,197,0.7);
  animation: dotPulse 2.2s ease-in-out infinite;
}
.dot.bad {
  background: var(--bad);
  box-shadow: 0 0 10px rgba(255,77,106,0.55);
}
@keyframes dotPulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

.session-list {
  flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px;
  min-height: 80px; max-height: 180px;
}
.session-item {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.18s ease;
}
.session-item:hover, .session-item.active {
  border-color: var(--line-strong);
  box-shadow: 0 0 14px rgba(79,210,255,0.12);
}
.session-item .sid { color: var(--faint); font-size: 10px; margin-top: 2px; }
.rail-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.owner { font-size: 10px; letter-spacing: 0.18em; color: var(--cyan); }
.model-line { font-size: 10px; color: var(--muted); margin-top: 4px; letter-spacing: 0.08em; }

/* center */
.center {
  grid-area: center;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  padding: 10px 14px 12px 8px;
  gap: 8px;
}

.hud-strip {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 11px; letter-spacing: 0.12em;
}
.hud-strip .left { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.hud-strip .right { display: flex; gap: 14px; align-items: center; color: var(--muted); }
.live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: coreBreath 1.8s ease-in-out infinite;
}
.sep { opacity: 0.35; }
.core-caption {
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(94,240,255,0.35);
  transition: color 0.25s ease, text-shadow 0.25s ease;
}
.core-caption.thinking { color: var(--violet); text-shadow: 0 0 14px rgba(123,92,255,0.45); }
.core-caption.speaking { color: var(--white); text-shadow: 0 0 16px rgba(255,255,255,0.4); }
.core-caption.listening { color: var(--magenta); text-shadow: 0 0 14px rgba(255,61,138,0.4); }

.toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  color: var(--muted);
  transition: color 0.2s ease;
}
.toggle:hover { color: var(--cyan); }
.toggle input {
  accent-color: var(--cyan);
  width: 14px; height: 14px;
  cursor: pointer;
}

.core-stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  z-index: 3;
}

/* cinematic HUD corner brackets over stage */
.hud-corners {
  position: absolute;
  inset: 10% 8%;
  z-index: 3;
  pointer-events: none;
}
.hud-corners .c {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(94, 240, 255, 0.55);
  border-style: solid;
  border-width: 0;
  filter: drop-shadow(0 0 8px rgba(94, 240, 255, 0.35));
}
.hud-corners .c.tl { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.hud-corners .c.tr { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }
.hud-corners .c.bl { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; }
.hud-corners .c.br { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }
.orbit-hint {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: rgba(180, 230, 255, 0.55);
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity 0.6s ease;
  text-shadow: 0 0 12px rgba(94,240,255,0.25);
}
body.orbit-hint-hidden .orbit-hint,
body.orbit-dragging .orbit-hint {
  opacity: 0;
}
@media (max-width: 960px) {
  .hud-corners { inset: 14% 6%; }
  .hud-corners .c { width: 22px; height: 22px; }
  .orbit-hint { font-size: 9px; letter-spacing: 0.14em; bottom: 12%; }
}

/* PTT */
.ptt-banner {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-radius: 16px;
  background: rgba(8, 16, 30, 0.55);
  border: 1px solid rgba(255, 61, 138, 0.35);
  box-shadow: var(--glow-m), var(--shadow);
  backdrop-filter: blur(12px);
}
.ptt-banner.on { display: flex; animation: pttIn 0.2s ease; }
@keyframes pttIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.ptt-ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 2px solid var(--magenta);
  box-shadow: 0 0 24px rgba(255,61,138,0.45);
  animation: ringPulse 1s ease-in-out infinite;
}
.ptt-text {
  font-size: 11px; letter-spacing: 0.22em; color: var(--magenta);
}
.ptt-wave { display: flex; gap: 4px; height: 22px; align-items: flex-end; }
.ptt-wave span {
  width: 3px; border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--magenta));
  animation: wave 0.7s ease-in-out infinite;
  height: 8px;
}
.ptt-wave span:nth-child(2) { animation-delay: 0.08s; }
.ptt-wave span:nth-child(3) { animation-delay: 0.16s; }
.ptt-wave span:nth-child(4) { animation-delay: 0.24s; }
.ptt-wave span:nth-child(5) { animation-delay: 0.32s; }
.ptt-wave span:nth-child(6) { animation-delay: 0.4s; }
.ptt-wave span:nth-child(7) { animation-delay: 0.48s; }
@keyframes wave {
  0%,100% { height: 6px; opacity: 0.5; }
  50% { height: 22px; opacity: 1; }
}

/* chat dock — smaller default, resizable via --dock-h */
.chat-dock {
  --dock-h: 22vh;
  display: grid;
  grid-template-rows: 22px minmax(0, 1fr) auto;
  gap: 6px;
  height: var(--dock-h);
  max-height: min(58vh, 520px);
  min-height: 120px;
  min-width: 0;
  position: relative;
  transition: height 0.12s ease;
}
.chat-dock.resizing {
  transition: none;
  user-select: none;
}
.dock-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 22px;
  cursor: ns-resize;
  touch-action: none;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, rgba(12, 28, 48, 0.55), rgba(6, 14, 28, 0.25));
  border: 1px solid rgba(94, 240, 255, 0.18);
  border-bottom: none;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.16em;
  user-select: none;
}
.dock-handle:active,
.chat-dock.resizing .dock-handle {
  background: linear-gradient(180deg, rgba(94, 240, 255, 0.18), rgba(12, 28, 48, 0.4));
  color: var(--cyan);
}
.dock-grip {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, transparent, rgba(94,240,255,0.7), transparent);
  box-shadow: 0 0 10px rgba(94,240,255,0.35);
}
.dock-hint { opacity: 0.75; }
.dock-presets { display: flex; gap: 4px; margin-left: 4px; }
.dpreset {
  width: 22px; height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(94,240,255,0.25);
  background: rgba(0,0,0,0.25);
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.dpreset:hover, .dpreset.on {
  background: rgba(94,240,255,0.18);
  border-color: rgba(94,240,255,0.55);
  box-shadow: 0 0 12px rgba(94,240,255,0.2);
}

.zoom-btns {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 999px;
  border: 1px solid rgba(94,240,255,0.22);
  background: rgba(0,0,0,0.28);
}
.zbtn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(94,240,255,0.3);
  background: rgba(8,20,36,0.7);
  color: var(--cyan);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.zbtn:hover {
  background: rgba(94,240,255,0.18);
  box-shadow: 0 0 14px rgba(94,240,255,0.25);
}
#zoom-readout {
  min-width: 40px;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chat-dock.thinking .transcript {
  box-shadow: inset 0 0 0 1px rgba(155, 108, 255, 0.4), 0 0 36px rgba(155, 108, 255, 0.18);
}
.chat-dock.speaking .transcript {
  box-shadow: inset 0 0 0 1px rgba(94, 240, 255, 0.45), 0 0 36px rgba(94, 240, 255, 0.2);
}
.transcript {
  border-radius: 0 0 12px 12px;
  padding: 8px 10px;
  overflow: auto;
  min-height: 0;
  scroll-behavior: smooth;
  background: linear-gradient(160deg, rgba(6, 18, 34, 0.38), rgba(3, 10, 20, 0.3)) !important;
}
.composer {
  border-radius: 14px !important;
  box-shadow: 0 0 0 1px rgba(94,240,255,0.12), 0 0 30px rgba(94,240,255,0.08) !important;
}
.send {
  background: linear-gradient(135deg, rgba(94,240,255,0.95), rgba(42,127,255,0.9)) !important;
  color: #031018 !important;
  font-weight: 700 !important;
  letter-spacing: 0.14em !important;
  box-shadow: 0 0 22px rgba(94,240,255,0.35) !important;
  border: none !important;
}
.side#btn-mic {
  border-color: rgba(255,45,122,0.45) !important;
  color: var(--magenta) !important;
  box-shadow: 0 0 16px rgba(255,45,122,0.15);
}
.core-caption {
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.msg {
  margin: 0 0 10px;
  max-width: 92%;
  animation: msgIn 0.28s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.user { margin-left: auto; }
.msg .bubble {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  background: rgba(6, 16, 28, 0.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.msg.user .bubble {
  background: linear-gradient(135deg, rgba(20,50,90,0.55), rgba(12,28,50,0.6));
  border-color: rgba(79,210,255,0.28);
}
.msg.assistant .bubble {
  background: linear-gradient(135deg, rgba(18,30,55,0.6), rgba(10,18,34,0.55));
  border-color: rgba(123,92,255,0.25);
  box-shadow: 0 0 18px rgba(79,210,255,0.06);
}
.msg.streaming .bubble {
  border-color: rgba(94,240,255,0.4);
  box-shadow: 0 0 22px rgba(79,210,255,0.12);
}
.msg.streaming .bubble.stream-caret {
  display: inline-block;
  min-height: 1.2em;
}
.msg.streaming .bubble .caret {
  display: inline-block;
  width: 0.55ch;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: linear-gradient(180deg, #8af7ff, #4fd2ff);
  box-shadow: 0 0 10px rgba(79,210,255,0.75);
  animation: caretBlink 0.9s steps(1) infinite;
}
@keyframes caretBlink {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0.15; }
}
.msg.error .bubble {
  border-color: rgba(255,77,106,0.45);
  color: #ffb3c0;
}
.msg .meta {
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.1em;
  margin-top: 4px;
  padding: 0 4px;
}
.msg.user .meta { text-align: right; }

.composer {
  border-radius: 14px;
  padding: 10px 12px;
}
.composer-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; letter-spacing: 0.12em; color: var(--faint);
  margin-bottom: 8px;
}
.composer-meta .hint kbd {
  font-family: var(--mono);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--muted);
  background: rgba(0,0,0,0.25);
}
.composer-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: end; }
#input {
  resize: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0,0,0,0.28);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 10px 12px;
  min-height: 42px;
  max-height: 140px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#input:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 1px rgba(79,210,255,0.15), 0 0 20px rgba(79,210,255,0.1);
}
.side, .send {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(8,20,36,0.7);
  color: var(--muted);
  letter-spacing: 0.14em;
  font-size: 11px;
  padding: 0 14px;
  height: 42px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.side:hover, .send:hover {
  color: var(--cyan);
  border-color: var(--line-strong);
  box-shadow: 0 0 18px rgba(79,210,255,0.15);
  transform: translateY(-1px);
}
.send {
  background: linear-gradient(135deg, rgba(20,70,110,0.8), rgba(40,30,90,0.75));
  color: var(--cyan);
  border-color: rgba(94,240,255,0.35);
}
.send:disabled { opacity: 0.45; cursor: wait; transform: none; }

/* empty state */
.empty-state {
  text-align: center;
  color: var(--faint);
  padding: 18px 8px;
  letter-spacing: 0.12em;
  font-size: 11px;
}
.empty-state strong {
  display: block;
  color: var(--cyan);
  font-size: 13px;
  letter-spacing: 0.2em;
  margin-bottom: 6px;
  text-shadow: 0 0 14px rgba(94,240,255,0.3);
}

/* modal / command center */
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,4,12,.72);
  display: grid; place-items: center;
  backdrop-filter: blur(10px);
}
.modal.hidden { display: none; }
.modal-card, .cc-card {
  width: min(720px, 94vw); max-height: 86vh; overflow: auto;
  border-radius: 16px; padding: 18px;
  background: linear-gradient(160deg, rgba(10,24,42,.95), rgba(4,10,18,.96));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), 0 0 60px rgba(79,210,255,.12);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 14px; letter-spacing: .22em; color: var(--cyan); }
#modal-body {
  background: #040a14; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; color: #7ea0b8; font-size: 11px; overflow: auto; max-height: 36vh;
  margin-top: 10px;
}
#modal-body.hidden { display: none; }
.modal-note { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 12px; }

.cc-banner {
  border-radius: 10px;
  border: 1px solid rgba(94,240,255,0.28);
  background: rgba(6, 18, 32, 0.9);
  color: var(--cyan);
  padding: 10px 12px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.cc-banner.ok { border-color: rgba(61,255,197,0.45); color: #3dffc5; }
.cc-banner.warn { border-color: rgba(255,196,77,0.45); color: #ffc44d; }
.cc-banner.bad { border-color: rgba(255,77,106,0.45); color: #ff4d6a; }

.cc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.cc-cell {
  border-radius: 12px;
  border: 1px solid rgba(94,240,255,0.16);
  background: linear-gradient(160deg, rgba(8,18,32,0.95), rgba(4,10,18,0.98));
  padding: 10px 10px 12px;
  min-height: 74px;
}
.cc-cell.ok { box-shadow: inset 0 0 0 1px rgba(61,255,197,0.12); }
.cc-cell.bad {
  border-color: rgba(255,77,106,0.35);
  box-shadow: inset 0 0 0 1px rgba(255,77,106,0.1);
}
.cc-name {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 4px;
}
.cc-state {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #3dffc5;
}
.cc-cell.bad .cc-state { color: #ff4d6a; }
.cc-detail {
  margin-top: 6px;
  font-size: 11px;
  color: #9bb8c9;
  word-break: break-word;
  line-height: 1.35;
}
.cc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.cc-btn {
  appearance: none;
  border: 1px solid rgba(94,240,255,0.35);
  background: linear-gradient(135deg, rgba(20,48,72,0.95), rgba(8,20,36,0.98));
  color: #d7f7ff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
}
.cc-btn:active { transform: scale(0.98); }
.cc-btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: rgba(140,170,190,0.25);
}
@media (max-width: 720px) {
  .cc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.voice-toast {
  position: fixed;
  left: 50%;
  bottom: 34vh;
  transform: translateX(-50%);
  z-index: 50;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(6,16,28,.92);
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: .08em;
  box-shadow: var(--shadow), var(--glow-c);
  pointer-events: none;
  animation: msgIn 0.25s ease;
}
.voice-toast.hidden { display: none; }

/* thinking shimmer on dock */
.chat-dock.thinking .transcript {
  box-shadow: 0 0 30px rgba(123,92,255,0.12), inset 0 0 20px rgba(123,92,255,0.04);
  border-color: rgba(123,92,255,0.3);
}
.chat-dock.speaking .transcript {
  box-shadow: 0 0 30px rgba(94,240,255,0.12), inset 0 0 20px rgba(94,240,255,0.04);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(79,210,255,.4), rgba(123,92,255,.28));
  border-radius: 8px; border: 2px solid transparent; background-clip: padding-box;
}

.mobile-only { display: none; }

@media (max-width: 960px) {
  #hud {
    grid-template-columns: 1fr;
    grid-template-rows: calc(52px + env(safe-area-inset-top, 0px)) 1fr;
    grid-template-areas: "top" "center";
  }
  .rail { display: none; }
  .desktop-only { display: none !important; }
  .mobile-only { display: inline; }

  .topbar {
    padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px;
    gap: 8px;
  }
  .brand .codename { display: none; }
  .brand .name { font-size: 14px; letter-spacing: 0.16em; }
  .pills { display: none; }
  .top-actions { gap: 6px; }
  .icon-btn { padding: 0 10px; height: 34px; font-size: 10px; }

  .center {
    display: grid;
    grid-template-rows: auto minmax(120px, 1fr) auto;
    min-height: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .hud-strip {
    margin: 8px 10px 0;
    padding: 8px 10px;
    font-size: 11px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .hud-strip .sep { opacity: 0.45; }
  .core-stage { min-height: 120px; }

  .chat-dock {
    --dock-h: 26vh;
    height: var(--dock-h);
    max-height: min(52vh, 420px);
    min-height: 132px;
    margin: 0 10px calc(10px + env(safe-area-inset-bottom, 0px));
    grid-template-rows: 22px minmax(0, 1fr) auto;
  }
  .dock-hint { display: none; }
  .zoom-btns { gap: 2px; }
  .zbtn { width: 28px; height: 28px; }
  #zoom-readout { min-width: 36px; font-size: 9px; }
  .transcript {
    min-height: 0;
    max-height: none;
    padding: 10px;
    font-size: 14px;
  }
  .msg .bubble { font-size: 14px; line-height: 1.45; padding: 10px 12px; }
  .composer { padding: 10px; }
  .composer-meta { font-size: 10px; }
  .composer-row { gap: 8px; }
  #input {
    font-size: 16px; /* iOS: avoid focus zoom */
    min-height: 48px;
    padding: 12px;
  }
  .side, .send {
    height: 48px;
    min-width: 64px;
    font-size: 12px;
    padding: 0 12px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
  }
  #btn-mic {
    min-width: 76px;
    letter-spacing: 0.12em;
  }
  #btn-mic.active {
    color: #02040a;
    background: linear-gradient(135deg, #5ef0ff, #4fd2ff);
    border-color: #5ef0ff;
    box-shadow: 0 0 24px rgba(94, 240, 255, 0.45);
  }
  .ptt-banner .ptt-text { font-size: 12px; letter-spacing: 0.14em; }
  .voice-toast { bottom: 28vh; width: min(92vw, 360px); text-align: center; }
  .modal-card { width: min(96vw, 700px); max-height: 86vh; }
}

/* ===== CSS hologram fallback (phone always sees this if WebGL/CDN fails) ===== */
.holo-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(18, 70, 120, 0.55) 0%, rgba(4, 12, 28, 0.2) 42%, transparent 70%);
}
.hf-grid {
  position: absolute; inset: -20%;
  background:
    repeating-linear-gradient(90deg, transparent 0 48px, rgba(94,240,255,0.04) 48px 49px),
    repeating-linear-gradient(0deg, transparent 0 48px, rgba(94,240,255,0.03) 48px 49px);
  transform: perspective(500px) rotateX(58deg) translateY(18%);
  animation: hfGrid 8s linear infinite;
  opacity: 0.7;
}
@keyframes hfGrid {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 48px, 48px 0; }
}
.hf-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(94, 240, 255, 0.45);
  box-shadow: 0 0 24px rgba(94, 240, 255, 0.25), inset 0 0 20px rgba(94, 240, 255, 0.08);
  animation: hfSpin 12s linear infinite;
}
.hf-ring.r1 { width: min(42vw, 220px); height: min(42vw, 220px); border-color: rgba(94,240,255,0.55); }
.hf-ring.r2 {
  width: min(54vw, 280px); height: min(54vw, 280px);
  border-color: rgba(155,108,255,0.45);
  animation-direction: reverse;
  animation-duration: 16s;
  transform: rotateX(62deg);
}
.hf-ring.r3 {
  width: min(66vw, 340px); height: min(66vw, 340px);
  border-color: rgba(255,45,122,0.35);
  animation-duration: 22s;
  border-style: dashed;
}
.hf-ring.r4 {
  width: min(30vw, 150px); height: min(30vw, 150px);
  border-color: rgba(255,255,255,0.35);
  animation-duration: 7s;
  animation-direction: reverse;
}
.hf-core {
  width: min(10vw, 48px); height: min(10vw, 48px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9) 0%, rgba(94,240,255,0.55) 35%, transparent 70%);
  box-shadow:
    0 0 18px rgba(94,240,255,0.7),
    0 0 40px rgba(94,240,255,0.35);
  animation: hfPulse 2.2s ease-in-out infinite;
  z-index: 2;
}
/* When WebGL boots, hide the CSS ball so you don't get double-rock */
.holo-fallback.webgl-live,
body.webgl-on .holo-fallback {
  opacity: 0.35;
}
body.webgl-on .hf-core {
  width: min(6vw, 28px);
  height: min(6vw, 28px);
  opacity: 0.5;
}
.hf-hex {
  position: absolute;
  width: min(28vw, 140px); height: min(28vw, 140px);
  background: transparent;
  border: 1px solid rgba(155,108,255,0.5);
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  box-shadow: 0 0 30px rgba(155,108,255,0.25);
  animation: hfSpin 9s linear infinite reverse;
  z-index: 1;
}
.hf-scan {
  position: absolute;
  width: min(70vw, 360px); height: 2px;
  background: linear-gradient(90deg, transparent, #5ef0ff, #ff2d7a, transparent);
  box-shadow: 0 0 18px rgba(94,240,255,0.8);
  animation: hfScan 3.2s ease-in-out infinite;
  z-index: 3;
  opacity: 0.85;
}
.hf-label {
  position: absolute;
  bottom: 28%;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: rgba(94,240,255,0.75);
  text-shadow: 0 0 12px rgba(94,240,255,0.5);
  z-index: 4;
  font-weight: 600;
}
@keyframes hfSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes hfPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.9; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes hfScan {
  0%, 100% { transform: translateY(-48px); opacity: 0.2; }
  50% { transform: translateY(48px); opacity: 1; }
}
/* when WebGL canvas is live it sits above fallback */
#c3d { position: relative; z-index: 1; }
.stage-fade { z-index: 2; }

body.build-phone8 .hf-label { color: #5ef0ff; }

@media (max-width: 960px) {
  .holo-fallback {
    /* stronger on phone — this is the visual proof of refresh */
    background:
      radial-gradient(ellipse at 50% 38%, rgba(30, 100, 170, 0.7) 0%, rgba(10, 30, 60, 0.35) 40%, transparent 68%);
  }
  .hf-core {
    width: min(14vw, 56px); height: min(14vw, 56px);
  }
  .hf-label {
    bottom: 32%;
    font-size: 11px;
    letter-spacing: 0.32em;
  }
  .center {
    grid-template-rows: auto minmax(130px, 1fr) auto !important;
  }
  .core-stage { min-height: 130px; }
  .chat-dock {
    --dock-h: 24vh;
  }
}

/* mode-reactive tactical chrome */
body.state-listening {
  --state-glow: rgba(61, 255, 197, 0.28);
  --state-accent: #3dffc5;
  --line: rgba(61, 255, 197, 0.22);
  --line-strong: rgba(61, 255, 197, 0.55);
  --cyan: #3dffc5;
}
body.state-thinking {
  --state-glow: rgba(176, 140, 255, 0.32);
  --state-accent: #b08cff;
  --line: rgba(176, 140, 255, 0.24);
  --line-strong: rgba(176, 140, 255, 0.58);
  --cyan: #b08cff;
}
body.state-speaking {
  --state-glow: rgba(94, 240, 255, 0.34);
  --state-accent: #5ef0ff;
  --line: rgba(94, 240, 255, 0.26);
  --line-strong: rgba(94, 240, 255, 0.6);
}

body.state-listening::before {
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(61, 255, 197, 0.02) 2px, rgba(61, 255, 197, 0.02) 4px
  );
  opacity: 0.7;
  animation-duration: 8s;
}
body.state-thinking::before {
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(176, 140, 255, 0.025) 2px, rgba(176, 140, 255, 0.025) 4px
  );
  opacity: 0.8;
  animation-duration: 5s;
}
body.state-speaking::before {
  opacity: 0.75;
  animation-duration: 6s;
}

body.state-listening::after {
  box-shadow:
    inset 18px 18px 0 -17px rgba(61,255,197,0.55),
    inset -18px 18px 0 -17px rgba(94,240,255,0.35),
    inset 18px -18px 0 -17px rgba(42,127,255,0.3),
    inset -18px -18px 0 -17px rgba(61,255,197,0.35);
}
body.state-thinking::after {
  box-shadow:
    inset 18px 18px 0 -17px rgba(176,140,255,0.55),
    inset -18px 18px 0 -17px rgba(255,77,154,0.35),
    inset 18px -18px 0 -17px rgba(123,92,255,0.4),
    inset -18px -18px 0 -17px rgba(176,140,255,0.35);
}
body.state-speaking::after {
  box-shadow:
    inset 18px 18px 0 -17px rgba(94,240,255,0.6),
    inset -18px 18px 0 -17px rgba(255,45,122,0.4),
    inset 18px -18px 0 -17px rgba(42,127,255,0.4),
    inset -18px -18px 0 -17px rgba(94,240,255,0.4);
}

/* radar sweep on stage when thinking/listening */
.stage-fade::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 38%;
  width: min(70vw, 420px);
  height: min(70vw, 420px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 72%, var(--state-glow) 78%, transparent 86%);
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  transition: opacity 0.4s ease;
}
body.state-listening .stage-fade::after,
body.state-thinking .stage-fade::after,
body.state-speaking .stage-fade::after {
  opacity: 0.35;
  animation: radarSpin 4.5s linear infinite;
}
body.state-thinking .stage-fade::after {
  opacity: 0.48;
  animation-duration: 2.8s;
}
@keyframes radarSpin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.hud-strip {
  box-shadow: 0 0 0 1px var(--line), 0 0 28px var(--state-glow);
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
}
body.state-thinking .hud-strip {
  border-color: rgba(176,140,255,0.45);
}
body.state-listening .hud-strip {
  border-color: rgba(61,255,197,0.4);
}
body.state-speaking .hud-strip {
  border-color: rgba(94,240,255,0.5);
}

.live {
  background: var(--state-accent) !important;
  box-shadow: 0 0 12px var(--state-accent) !important;
}
body.state-thinking .live { animation-duration: 0.7s; }
body.state-listening .live { animation-duration: 1.1s; }
body.state-speaking .live { animation-duration: 0.55s; }

.core-caption.thinking { color: #d4c0ff; text-shadow: 0 0 18px rgba(176,140,255,0.55); }
.core-caption.listening { color: #9fffe0; text-shadow: 0 0 18px rgba(61,255,197,0.5); }
.core-caption.speaking { color: #b8f7ff; text-shadow: 0 0 18px rgba(94,240,255,0.55); }

.topbar {
  background:
    linear-gradient(180deg, rgba(0,6,14,0.88), rgba(0,6,14,0.35)),
    linear-gradient(90deg, transparent, var(--state-glow), transparent) !important;
  border-bottom: 1px solid var(--line);
}
.topbar::after {
  background: linear-gradient(90deg, transparent, var(--state-accent), transparent) !important;
  opacity: 0.55;
}

.glass {
  border-color: var(--line) !important;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.02),
    0 0 32px var(--state-glow),
    inset 0 1px 0 rgba(255,255,255,0.04) !important;
}

.hud-corners .c {
  border-color: var(--state-accent) !important;
  filter: drop-shadow(0 0 10px var(--state-glow));
  transition: border-color 0.35s ease, filter 0.35s ease;
}
body.state-thinking .hud-corners .c { animation: cornerPulse 1.2s ease-in-out infinite; }
@keyframes cornerPulse {
  0%,100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.send {
  box-shadow: 0 0 22px var(--state-glow) !important;
}
body.state-thinking .send {
  background: linear-gradient(135deg, rgba(176,140,255,0.95), rgba(123,92,255,0.9)) !important;
}
body.state-listening .send {
  background: linear-gradient(135deg, rgba(61,255,197,0.92), rgba(42,180,160,0.9)) !important;
  color: #021410 !important;
}

/* denser tactical scan on body when thinking */
body.state-thinking {
  animation: thinkShake 0.01s; /* noop anchor */
}
body.state-thinking .name {
  text-shadow: 0 0 22px rgba(176,140,255,0.55), 0 0 40px rgba(176,140,255,0.25);
}

/* orbit drag feedback */
body.orbit-dragging,
body.orbit-dragging #c3d,
body.orbit-dragging .core-stage,
body.orbit-dragging #stage3d {
  cursor: grabbing !important;
  user-select: none;
}

#stage3d,
#c3d,
.core-stage {
  touch-action: none;
}
.core-stage {
  pointer-events: auto;
  cursor: grab;
}

/* standalone PWA (Add to Home Screen) */
@media (display-mode: standalone) {
  .topbar {
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }
}
