/* ═══════════════════════════════════════════════════════════
   MIA COMMAND INTERFACE — STYLE
   Aesthetic: Cyberpunk Space / Neo-pixel / JRPG Sci-Fi
   ═══════════════════════════════════════════════════════════ */

/* ── TOKENS ── */
:root {
  --bg: #04040e;
  --bg-1: #080818;
  --bg-2: #0c0c20;
  --bg-3: #10102a;
  --surface: #0d1225;
  --surface-2: #121830;

  --blue: #00d4ff;
  --blue-dim: #0088aa;
  --blue-dark: #003350;
  --violet: #a855f7;
  --violet-dim: #7c3aed;
  --white: #e8f4ff;
  --amber: #f59e0b;
  --amber-dim: #b45309;
  --red: #ef4444;
  --red-dim: #991b1b;
  --green: #22c55e;
  --green-dim: #166534;

  --text-main: #c8e0f0;
  --text-dim: #6080a0;
  --text-muted: #304060;

  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
  --font-display: 'Rajdhani', sans-serif;

  --glow-blue: 0 0 8px rgba(0, 212, 255, 0.7), 0 0 20px rgba(0, 212, 255, 0.3);
  --glow-violet: 0 0 8px rgba(168, 85, 247, 0.7), 0 0 20px rgba(168, 85, 247, 0.3);
  --glow-amber: 0 0 8px rgba(245, 158, 11, 0.7), 0 0 20px rgba(245, 158, 11, 0.3);
  --glow-red: 0 0 8px rgba(239, 68, 68, 0.8), 0 0 24px rgba(239, 68, 68, 0.4);

  --status-bar-h: 44px;
  --chat-panel-h: 200px;
  --scene-h: calc(100vh - var(--status-bar-h) - var(--chat-panel-h));
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 13px;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBARS ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--blue-dim); border-radius: 2px; }

/* ── UTILS ── */
.hidden { display: none !important; }
.blink { animation: blink 1.2s step-end infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ═══════════════════════════════════════════════════════════
   AUTH OVERLAY
   ═══════════════════════════════════════════════════════════ */
#auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#auth-overlay::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 30% 50%, rgba(0,212,255,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 70% 50%, rgba(168,85,247,0.05) 0%, transparent 70%);
  pointer-events: none;
}
.auth-scanline {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,212,255,0.015) 2px, rgba(0,212,255,0.015) 4px);
  pointer-events: none; z-index: 1;
  animation: scanMove 8s linear infinite;
}
@keyframes scanMove { from{background-position:0 0} to{background-position:0 100px} }

.auth-panel {
  position: relative; z-index: 2;
  width: 420px;
  border: 1px solid rgba(0,212,255,0.25);
  background: var(--surface);
  padding: 48px 40px;
  text-align: center;
  clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 24px 100%, 0 calc(100% - 24px));
  box-shadow: 0 0 60px rgba(0,212,255,0.1), inset 0 0 40px rgba(0,0,30,0.5);
}
.auth-panel::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 24px; height: 24px;
  border-top: 1px solid rgba(0,212,255,0.6);
  border-right: 1px solid rgba(0,212,255,0.6);
  pointer-events: none;
}
.auth-panel::after {
  content: '';
  position: absolute; bottom: 0; left: 0;
  width: 24px; height: 24px;
  border-bottom: 1px solid rgba(0,212,255,0.6);
  border-left: 1px solid rgba(0,212,255,0.6);
  pointer-events: none;
}

.auth-logo { margin-bottom: 16px; filter: drop-shadow(var(--glow-blue)); }
.auth-title {
  font-family: var(--font-display); font-size: 42px; font-weight: 700;
  color: var(--white); letter-spacing: 12px;
  text-shadow: var(--glow-blue);
  margin-bottom: 8px;
}
.auth-subtitle {
  font-size: 10px; letter-spacing: 4px; color: var(--text-dim);
  text-transform: uppercase; margin-bottom: 32px;
}
.auth-divider {
  width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  margin-bottom: 32px; opacity: 0.4;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-label { font-size: 10px; letter-spacing: 3px; color: var(--blue); opacity: 0.8; }
.auth-input-wrap { position: relative; }
.auth-input-wrap input {
  width: 100%; padding: 12px 16px;
  background: var(--bg-2); border: 1px solid rgba(0,212,255,0.2);
  color: var(--text-main); font-family: var(--font-mono); font-size: 14px;
  outline: none; transition: border-color 0.2s;
}
.auth-input-wrap input:focus { border-color: var(--blue); }
.auth-input-wrap input:focus + .auth-input-glow { opacity: 1; }
.auth-input-glow {
  position: absolute; inset: -1px; pointer-events: none; opacity: 0;
  box-shadow: var(--glow-blue); transition: opacity 0.2s; border-radius: 2px;
}
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 24px; margin-top: 8px;
  background: transparent; border: 1px solid var(--blue);
  color: var(--blue); font-family: var(--font-mono); font-size: 12px; letter-spacing: 3px;
  cursor: pointer; transition: all 0.2s; text-transform: uppercase;
}
.btn-primary:hover {
  background: rgba(0,212,255,0.1);
  box-shadow: var(--glow-blue);
}
.btn-primary:active { transform: scale(0.98); }
.auth-status {
  min-height: 18px; margin-top: 12px;
  font-size: 11px; letter-spacing: 2px; text-align: center;
}
.auth-status.error { color: var(--red); }
.auth-status.info { color: var(--blue); animation: blink 0.8s step-end infinite; }
.auth-status.ok { color: var(--green); }
.auth-footer { margin-top: 24px; font-size: 9px; letter-spacing: 2px; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   MAIN INTERFACE
   ═══════════════════════════════════════════════════════════ */
#interface { width: 100vw; height: 100vh; display: flex; flex-direction: column; }

/* ── STATUS BAR ── */
#status-bar {
  height: var(--status-bar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid rgba(0,212,255,0.12);
  z-index: 100; flex-shrink: 0;
}
.status-left { display: flex; align-items: center; gap: 12px; }
.logo-text {
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
  color: var(--white); letter-spacing: 6px;
  text-shadow: 0 0 12px rgba(0,212,255,0.6);
}
.version-text { font-size: 10px; color: var(--text-muted); letter-spacing: 2px; }

.status-center { display: flex; align-items: center; gap: 20px; }

.conn-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; letter-spacing: 2px; color: var(--text-dim);
}
.conn-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
}
.conn-badge.connected .conn-dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: connPulse 2s ease-in-out infinite;
}
.conn-badge.connecting .conn-dot {
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
  animation: blink 0.6s step-end infinite;
}
.conn-badge.error .conn-dot { background: var(--red); box-shadow: 0 0 6px var(--red); }
@keyframes connPulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.state-display {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  border: 1px solid rgba(0,212,255,0.15);
  background: var(--bg-2);
}
.state-label { font-size: 9px; letter-spacing: 2px; color: var(--text-muted); }
#state-value {
  font-size: 11px; letter-spacing: 3px; color: var(--blue);
  font-family: var(--font-display); font-weight: 600;
  transition: color 0.3s;
}
.session-info { display: flex; align-items: center; gap: 6px; }
.session-label { font-size: 9px; color: var(--text-muted); letter-spacing: 2px; }
.session-val { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; }

.status-right { display: flex; align-items: center; gap: 10px; }
.btn-ghost {
  background: none; border: 1px solid rgba(0,212,255,0.15);
  color: var(--text-dim); font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 2px; padding: 5px 12px; cursor: pointer;
  transition: all 0.2s; text-transform: uppercase;
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost.danger:hover { border-color: var(--red); color: var(--red); }

/* ═══════════════════════════════════════════════════════════
   SCENE
   ═══════════════════════════════════════════════════════════ */
#scene {
  flex: 1;
  position: relative; overflow: hidden;
  background: var(--bg);
}

/* ── STARFIELD CANVAS ── */
#starfield {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%;
}

/* ── FLOOR GRID ── */
#floor-grid {
  position: absolute; bottom: -20px; left: 50%;
  transform: translateX(-50%) perspective(400px) rotateX(65deg);
  width: 1200px; height: 600px; z-index: 1;
  background-image:
    linear-gradient(rgba(0,212,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.08) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 80%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 80%, black 30%, transparent 80%);
}

/* ── AMBIENT LIGHT ── */
#ambient-light {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  transition: background 1.5s ease;
  background: radial-gradient(ellipse 50% 60% at 50% 70%, rgba(0,212,255,0.04) 0%, transparent 70%);
}
body[data-state="thinking"] #ambient-light {
  background: radial-gradient(ellipse 50% 60% at 50% 70%, rgba(245,158,11,0.06) 0%, transparent 70%);
}
body[data-state="coding"] #ambient-light {
  background: radial-gradient(ellipse 50% 60% at 50% 70%, rgba(0,212,255,0.08) 0%, transparent 60%);
}
body[data-state="alert"] #ambient-light {
  background: radial-gradient(ellipse 50% 60% at 50% 70%, rgba(239,68,68,0.1) 0%, transparent 60%);
}
body[data-state="calling_agent"] #ambient-light {
  background: radial-gradient(ellipse 60% 70% at 50% 70%, rgba(168,85,247,0.07) 0%, transparent 65%);
}

/* ── BACKGROUND SCREENS ── */
#bg-screens {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 24px; pointer-events: none;
  gap: 12px;
}
.bg-screen {
  flex: 1; min-width: 0; max-width: 220px;
  opacity: 0.75; transition: opacity 0.5s;
}
.bg-screen:hover { opacity: 1; }
.screen-center-top { max-width: 320px; }

.screen-frame {
  border: 1px solid rgba(0,212,255,0.2);
  background: rgba(8,12,24,0.85);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  overflow: hidden;
}
.screen-frame.wide { max-height: 180px; }
.screen-header-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: rgba(0,212,255,0.06);
  border-bottom: 1px solid rgba(0,212,255,0.12);
  font-size: 9px; letter-spacing: 2px; color: var(--text-dim);
}
.scr-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 5px var(--blue);
  animation: connPulse 2s ease-in-out infinite;
}
.scr-dot.amber { background: var(--amber); box-shadow: 0 0 5px var(--amber); }
.scr-dot.green { background: var(--green); box-shadow: 0 0 5px var(--green); }
.scr-status { margin-left: auto; color: var(--green); font-size: 9px; }

.screen-body {
  padding: 8px; height: 130px; overflow: hidden;
  font-size: 9px; line-height: 1.5; color: var(--text-dim);
  position: relative;
}
.screen-frame.wide .screen-body { height: 160px; }

/* LOG SCREEN */
.log-screen { font-family: var(--font-mono); }
.log-line { margin-bottom: 1px; opacity: 0; animation: fadeInLine 0.3s forwards; }
.log-line.info { color: var(--blue); }
.log-line.warn { color: var(--amber); }
.log-line.ok { color: var(--green); }
.log-line.err { color: var(--red); }
@keyframes fadeInLine { from{opacity:0;transform:translateX(-4px)} to{opacity:1;transform:none} }

/* NEURAL SCREEN */
.neural-svg { width: 100%; height: 100%; }
.neural-node { animation: neuralPulse 2s ease-in-out infinite; }
@keyframes neuralPulse { 0%,100%{r:3;opacity:0.8} 50%{r:5;opacity:1} }

/* CODE SCREEN */
.code-screen { font-family: var(--font-mono); color: var(--green); overflow: hidden; }
.code-line { white-space: nowrap; overflow: hidden; animation: typeIn 0.5s steps(30) forwards; opacity: 0.7; }
.code-line.dim { color: var(--green-dim); opacity: 0.4; }
@keyframes typeIn { from{width:0} to{width:100%} }

/* DATA SCREEN */
.data-screen { display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-start; }
.data-block {
  width: 8px; height: 8px;
  background: rgba(0,212,255,0.3);
  animation: dataFlicker 1s ease-in-out infinite;
}
@keyframes dataFlicker { 0%,100%{opacity:0.3} 50%{opacity:1; background:rgba(0,212,255,0.8)} }

/* AGENT SCREEN */
.agent-screen { font-family: var(--font-mono); }

/* ── AGENT ZONES ── */
.agent-zone {
  position: absolute; z-index: 5;
  display: flex; flex-direction: column; align-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s, transform 0.5s;
  transform: translateY(20px);
}
.agent-zone[data-visible="true"] {
  opacity: 1; pointer-events: auto;
  transform: translateY(0);
}
.zone-left {
  left: 180px; bottom: 10px;
  width: 120px;
}
.zone-right {
  right: 180px; bottom: 10px;
  width: 120px;
}
.zone-back {
  left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: 50px; width: 100px;
}
.zone-back[data-visible="true"] {
  transform: translateX(-50%) translateY(0);
}

.zone-desk {
  width: 140px; height: 20px;
  background: linear-gradient(180deg, #1a2a3a 0%, #0d1825 100%);
  border: 1px solid rgba(0,212,255,0.2);
  border-bottom: none; margin-top: auto;
}
.zone-screen {
  position: absolute; top: 20px;
  width: 60px; height: 40px;
  background: rgba(0,212,255,0.05);
  border: 1px solid rgba(0,212,255,0.2);
  left: 5px;
}
.zone-screen::after {
  content: '';
  display: block; width: 100%; height: 100%;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,212,255,0.06) 3px, rgba(0,212,255,0.06) 4px);
}

.agent-sprite-wrap { width: 100%; }
.agent-sprite-wrap.small { transform: scale(0.75); transform-origin: bottom center; }
.agent-svg {
  width: 100%; height: auto;
  filter: drop-shadow(0 0 12px rgba(0,0,0,0.8));
  animation: agentIdle 3s ease-in-out infinite;
}
@keyframes agentIdle {
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(-3px)}
}
.agent-label {
  font-size: 9px; letter-spacing: 3px; color: var(--text-dim);
  margin-top: 4px; text-align: center;
}
.agent-status-light {
  width: 6px; height: 6px; border-radius: 50%; margin-top: 4px;
}
.agent-status-light.blue { background: var(--blue); box-shadow: 0 0 8px var(--blue); animation: connPulse 2s infinite; }
.agent-status-light.violet { background: var(--violet); box-shadow: 0 0 8px var(--violet); animation: connPulse 2s infinite; }
.agent-status-light.green { background: var(--green); box-shadow: 0 0 8px var(--green); animation: connPulse 2s infinite; }

/* ── HOLOGRAM ── */
#hologram-display {
  position: absolute; z-index: 6;
  left: 50%; top: 15%;
  transform: translateX(30px);
  width: 120px; height: 120px;
  animation: holoFloat 3s ease-in-out infinite;
}
.holo-svg { width: 100%; height: 100%; }
.holo-ring-1 { animation: holoSpin 8s linear infinite; transform-origin: 100px 100px; }
.holo-ring-2 { animation: holoSpin 5s linear infinite reverse; transform-origin: 100px 100px; }
.holo-ring-3 { animation: holoSpin 3s linear infinite; transform-origin: 100px 100px; }
.holo-hex { animation: holoSpin 12s linear infinite reverse; transform-origin: 100px 100px; }
.holo-core { animation: holoPulse 1.5s ease-in-out infinite; }
.holo-cross { animation: blink 2s step-end infinite; }
@keyframes holoSpin { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
@keyframes holoPulse { 0%,100%{opacity:0.6;r:8} 50%{opacity:1;r:12} }
@keyframes holoFloat { 0%,100%{transform:translateX(30px) translateY(0)} 50%{transform:translateX(30px) translateY(-8px)} }

/* ═══════════════════════════════════════════════════════════
   MIA SPRITE
   ═══════════════════════════════════════════════════════════ */
#mia-container {
  position: absolute; z-index: 7;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 240px;
  display: flex; flex-direction: column; align-items: center;
}
#mia-glow {
  position: absolute; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  width: 200px; height: 300px;
  background: radial-gradient(ellipse 60% 80% at 50% 100%, rgba(0,212,255,0.15) 0%, transparent 70%);
  pointer-events: none;
  transition: background 0.8s ease;
  z-index: 0;
}
#mia-svg {
  position: relative; z-index: 1;
  width: 100%; height: auto;
  filter: drop-shadow(0 0 20px rgba(0,0,0,0.9));
  transform-origin: bottom center;
}

/* Mia base idle */
[data-state="idle"] #mia-svg {
  animation: miaBreath 4s ease-in-out infinite;
}
/* Mia thinking */
[data-state="thinking"] #mia-svg {
  animation: miaThink 2s ease-in-out infinite;
}
/* Mia talking */
[data-state="talking"] #mia-svg {
  animation: miaTalk 0.8s ease-in-out infinite;
}
/* Mia coding */
[data-state="coding"] #mia-svg {
  animation: miaCoding 0.4s ease-in-out infinite;
}
/* Mia alert */
[data-state="alert"] #mia-svg {
  animation: miaAlert 0.5s ease-in-out infinite;
}

@keyframes miaBreath {
  0%,100%{transform:scaleY(1) scaleX(1)}
  50%{transform:scaleY(1.012) scaleX(0.998)}
}
@keyframes miaThink {
  0%,100%{transform:translateY(0) rotate(0deg)}
  50%{transform:translateY(-3px) rotate(-0.5deg)}
}
@keyframes miaTalk {
  0%,100%{transform:translateY(0) scaleX(1)}
  25%{transform:translateY(-2px) scaleX(1.005)}
  75%{transform:translateY(1px) scaleX(0.998)}
}
@keyframes miaCoding {
  0%,100%{transform:translateX(0)}
  25%{transform:translateX(1px)}
  75%{transform:translateX(-1px)}
}
@keyframes miaAlert {
  0%,100%{transform:translateX(0)}
  25%{transform:translateX(-2px)}
  75%{transform:translateX(2px)}
}

/* Mia hair animation */
.hair-strand {
  animation: hairSway 4s ease-in-out infinite;
  transform-origin: top center;
}
#hs-r1,#hs-r2,#hs-r3 { animation-name: hairSwayR; }
#hs-l1,#hs-l2,#hs-l3 { animation-name: hairSwayL; }
#hs-r2,#hs-l2 { animation-delay: -0.5s; animation-duration: 4.5s; }
#hs-r3,#hs-l3 { animation-delay: -1s; animation-duration: 5s; }
@keyframes hairSwayR {
  0%,100%{transform:rotate(0deg)}
  50%{transform:rotate(2deg)}
}
@keyframes hairSwayL {
  0%,100%{transform:rotate(0deg)}
  50%{transform:rotate(-2deg)}
}

/* Eye blink */
.mia-eye {
  animation: eyeBlink 5s ease-in-out infinite;
  transform-origin: center;
}
#mia-eye-right { animation-delay: 0.05s; }
@keyframes eyeBlink {
  0%,90%,100%{transform:scaleY(1)}
  95%{transform:scaleY(0.08)}
}

/* State-specific glow colors for #mia-glow */
[data-state="idle"] #mia-glow {
  background: radial-gradient(ellipse 60% 80% at 50% 100%, rgba(0,212,255,0.15) 0%, transparent 70%);
}
[data-state="thinking"] #mia-glow {
  background: radial-gradient(ellipse 60% 80% at 50% 100%, rgba(245,158,11,0.2) 0%, transparent 70%);
}
[data-state="talking"] #mia-glow {
  background: radial-gradient(ellipse 60% 80% at 50% 100%, rgba(0,212,255,0.25) 0%, transparent 65%);
}
[data-state="coding"] #mia-glow {
  background: radial-gradient(ellipse 60% 80% at 50% 100%, rgba(0,212,255,0.3) 0%, transparent 60%);
}
[data-state="alert"] #mia-glow {
  background: radial-gradient(ellipse 60% 80% at 50% 100%, rgba(239,68,68,0.35) 0%, transparent 60%);
  animation: alertGlow 0.5s ease-in-out infinite;
}
[data-state="calling_agent"] #mia-glow {
  background: radial-gradient(ellipse 60% 80% at 50% 100%, rgba(168,85,247,0.25) 0%, transparent 65%);
}
@keyframes alertGlow { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* Think/Code/Call arm visibility */
.mia-arm-idle { transition: opacity 0.3s; }
#mia-think-arm { transition: opacity 0.3s; }
#mia-code-arms { transition: opacity 0.3s; }
#mia-call-arm { transition: opacity 0.3s; }

[data-state="thinking"] .mia-arm-idle { opacity: 0; }
[data-state="thinking"] #mia-think-arm { display: block !important; }
[data-state="coding"] .mia-arm-idle { opacity: 0; }
[data-state="coding"] #mia-code-arms { display: block !important; }
[data-state="calling_agent"] #mia-call-arm { display: block !important; }

/* Eye color shifts per state */
[data-state="thinking"] .mia-eye ellipse:nth-child(2) { fill: var(--amber); filter: drop-shadow(0 0 4px var(--amber)); }
[data-state="alert"] .mia-eye ellipse:nth-child(2) { fill: var(--red); filter: drop-shadow(0 0 4px var(--red)); }
[data-state="coding"] .mia-eye ellipse:nth-child(2) { fill: #00ff88; filter: drop-shadow(0 0 4px #00ff88); }

/* State ring under Mia */
#mia-state-ring {
  width: 180px; height: 8px;
  background: radial-gradient(ellipse, rgba(0,212,255,0.5) 0%, transparent 70%);
  margin-top: -4px; transition: background 0.8s;
}
[data-state="thinking"] #mia-state-ring { background: radial-gradient(ellipse, rgba(245,158,11,0.6) 0%, transparent 70%); }
[data-state="alert"] #mia-state-ring { background: radial-gradient(ellipse, rgba(239,68,68,0.7) 0%, transparent 70%); animation: alertGlow 0.5s infinite; }
[data-state="calling_agent"] #mia-state-ring { background: radial-gradient(ellipse, rgba(168,85,247,0.6) 0%, transparent 70%); }

/* ═══════════════════════════════════════════════════════════
   CHAT PANEL
   ═══════════════════════════════════════════════════════════ */
#chat-panel {
  height: var(--chat-panel-h);
  flex-shrink: 0;
  position: relative;
  background: var(--surface);
  border-top: 1px solid rgba(0,212,255,0.15);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.chat-scanline {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,212,255,0.012) 3px, rgba(0,212,255,0.012) 4px);
}

/* Corner decorations */
.corner {
  position: absolute; z-index: 10;
  width: 16px; height: 16px; pointer-events: none;
}
.corner-tl { top: 0; left: 0; border-top: 1px solid var(--blue); border-left: 1px solid var(--blue); }
.corner-tr { top: 0; right: 0; border-top: 1px solid var(--blue); border-right: 1px solid var(--blue); }
.corner-bl { bottom: 0; left: 0; border-bottom: 1px solid var(--blue); border-left: 1px solid var(--blue); }
.corner-br { bottom: 0; right: 0; border-bottom: 1px solid var(--blue); border-right: 1px solid var(--blue); }

/* ── SUBTITLES ── */
#subtitles-area {
  flex: 1; min-height: 0;
  display: flex; align-items: flex-end; gap: 12px;
  padding: 12px 28px 8px;
  position: relative; z-index: 1;
}
#subtitle-speaker {
  display: flex; align-items: center; gap: 6px;
  font-size: 9px; letter-spacing: 3px; color: var(--blue);
  flex-shrink: 0; align-self: flex-end;
  opacity: 0.8;
}
.speaker-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 6px var(--blue);
}
#subtitle-text {
  flex: 1;
  font-family: var(--font-display); font-size: 17px; font-weight: 400;
  color: var(--white); line-height: 1.4;
  max-height: 80px; overflow: hidden;
  letter-spacing: 0.3px;
}
#subtitle-cursor {
  font-size: 18px; color: var(--blue);
  animation: blink 0.6s step-end infinite;
  align-self: flex-end; flex-shrink: 0;
}

/* ── HISTORY PANEL ── */
#history-panel {
  position: absolute; bottom: 56px; left: 0; right: 0;
  max-height: 0; overflow: hidden;
  transition: max-height 0.4s ease;
  background: var(--surface);
  border-top: 1px solid rgba(0,212,255,0.1);
  z-index: 5;
}
#history-panel.open { max-height: 280px; }
#history-messages {
  padding: 12px 28px;
  max-height: 280px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.hist-msg {
  display: flex; flex-direction: column; gap: 3px;
}
.hist-msg.user .hist-role { color: var(--blue); font-size: 9px; letter-spacing: 2px; }
.hist-msg.assistant .hist-role { color: var(--violet); font-size: 9px; letter-spacing: 2px; }
.hist-body {
  font-size: 12px; color: var(--text-main); line-height: 1.5;
  padding-left: 10px; border-left: 2px solid rgba(0,212,255,0.2);
}
.hist-msg.user .hist-body { border-left-color: rgba(0,212,255,0.3); }
.hist-msg.assistant .hist-body { border-left-color: rgba(168,85,247,0.3); }

/* ── TOOL STRIP ── */
#tool-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 28px;
  background: rgba(0,212,255,0.05);
  border-top: 1px solid rgba(0,212,255,0.1);
  font-size: 10px; color: var(--text-dim); letter-spacing: 1px;
  z-index: 2; position: relative;
}
.tool-label { color: var(--blue); letter-spacing: 2px; }
#tool-name-display { color: var(--text-main); flex: 1; }
.tool-progress {
  width: 60px; height: 3px;
  background: var(--bg-2);
  position: relative; overflow: hidden;
}
.tool-progress::after {
  content: '';
  position: absolute; top: 0; left: -60px;
  width: 60px; height: 100%;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  animation: toolProgress 1s linear infinite;
}
@keyframes toolProgress { from{left:-60px} to{left:60px} }

/* ── INPUT ROW ── */
#input-row {
  display: flex; align-items: center; gap: 0;
  padding: 10px 20px;
  border-top: 1px solid rgba(0,212,255,0.1);
  position: relative; z-index: 2;
  flex-shrink: 0;
}
.input-prefix {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.2);
  border-right: none;
  font-size: 9px; letter-spacing: 3px; color: var(--blue);
  white-space: nowrap; flex-shrink: 0;
}
.input-wrap {
  flex: 1; position: relative;
}
#msg-input {
  width: 100%; padding: 10px 16px;
  background: rgba(0,6,20,0.6);
  border: 1px solid rgba(0,212,255,0.2);
  border-right: none;
  color: var(--text-main); font-family: var(--font-mono); font-size: 13px;
  outline: none; transition: border-color 0.2s;
  letter-spacing: 0.5px;
}
#msg-input:focus { border-color: var(--blue); }
#msg-input::placeholder { color: var(--text-muted); }
.input-line {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 1px; background: transparent;
  transition: background 0.3s;
}
#msg-input:focus ~ .input-line { background: var(--blue); box-shadow: var(--glow-blue); }

.btn-transmit {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; flex-shrink: 0;
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.3);
  color: var(--blue); font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 2px; cursor: pointer;
  transition: all 0.2s; text-transform: uppercase;
}
.btn-transmit:hover:not(:disabled) {
  background: rgba(0,212,255,0.2);
  box-shadow: var(--glow-blue);
}
.btn-transmit:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-transmit:active:not(:disabled) { transform: scale(0.98); }

/* ═══════════════════════════════════════════════════════════
   STATE-BASED SCREEN EFFECTS
   ═══════════════════════════════════════════════════════════ */
body[data-state="alert"] #bridge-status { color: var(--red); animation: blink 0.5s step-end infinite; }
body[data-state="thinking"] #bridge-status { color: var(--amber); }
body[data-state="coding"] #bridge-status { color: var(--green); }
body[data-state="idle"] #bridge-status { color: var(--green); }

/* #state-value colors */
body[data-state="idle"] #state-value { color: var(--blue); }
body[data-state="thinking"] #state-value { color: var(--amber); text-shadow: var(--glow-amber); }
body[data-state="talking"] #state-value { color: var(--white); text-shadow: 0 0 10px rgba(255,255,255,0.5); }
body[data-state="coding"] #state-value { color: var(--green); text-shadow: 0 0 8px rgba(34,197,94,0.7); }
body[data-state="alert"] #state-value { color: var(--red); text-shadow: var(--glow-red); animation: blink 0.4s step-end infinite; }
body[data-state="calling_agent"] #state-value { color: var(--violet); text-shadow: var(--glow-violet); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE (minimal - optimized for 1920×1080)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1400px) {
  .bg-screen { opacity: 0.6; }
  .screen-far-left, .screen-far-right { display: none; }
  .zone-left { left: 100px; }
  .zone-right { right: 100px; }
}
@media (max-width: 1100px) {
  .bg-screen { display: none; }
  .zone-left { left: 40px; }
  .zone-right { right: 40px; }
  #mia-container { width: 200px; }
}
@media (max-width: 768px) {
  .agent-zone { display: none; }
  #chat-panel { height: 160px; }
  :root { --chat-panel-h: 160px; }
  #subtitle-text { font-size: 14px; }
  .bg-screen { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   NOTIFICATION / TOAST
   ═══════════════════════════════════════════════════════════ */
#toast {
  position: fixed; bottom: 220px; right: 24px; z-index: 200;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid rgba(0,212,255,0.3);
  color: var(--text-main); font-size: 11px; letter-spacing: 1px;
  opacity: 0; transform: translateX(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }
#toast.error { border-color: rgba(239,68,68,0.4); color: var(--red); }
