:root {
  --bg: #05080d;
  --cyan: #3DDBFF;
  --cyan-soft: rgba(61, 219, 255, 0.35);
  --cyan-faint: rgba(61, 219, 255, 0.08);
  --text: #e6f9ff;
  --muted: #7fa9b8;
  --danger: #ff6b6b;
  --ok: #4dffb5;
  --panel: rgba(8, 20, 30, 0.55);
  --title: 'Orbitron', 'Rajdhani', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.75) 100%),
    linear-gradient(var(--cyan-faint) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, var(--cyan-faint) 1px, transparent 1px) 0 0 / 40px 40px,
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button {
  font: 500 14px var(--body);
  color: var(--bg);
  background: var(--cyan);
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 0 12px var(--cyan-soft);
}
button:hover { filter: brightness(1.1); }
button:focus-visible, input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
button.ghost { background: transparent; color: var(--cyan); border: 1px solid var(--cyan-soft); box-shadow: none; }
button.small { padding: 6px 12px; font-size: 13px; }
input {
  font: 15px var(--body);
  color: var(--text);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--cyan-soft);
  border-radius: 8px;
  padding: 11px 14px;
  min-width: 0;
}
.brand { font-family: var(--title); letter-spacing: 0.45em; color: var(--cyan); text-shadow: 0 0 12px var(--cyan-soft); font-weight: 700; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }

/* ---------- login ---------- */
.login-body { align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: min(380px, 100%);
  text-align: center;
  padding: 32px 24px;
  background: var(--panel);
  border: 1px solid var(--cyan-soft);
  border-radius: 16px;
  backdrop-filter: blur(6px);
}
.login-card h1 { font-size: 22px; margin: 16px 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.login-ring { position: relative; width: 96px; height: 96px; margin: 0 auto; }
.login-ring span { position: absolute; inset: 0; border-radius: 50%; border: 2px dashed var(--cyan); animation: spin 18s linear infinite; }
.login-ring span:nth-child(2) { inset: 16px; border-style: solid; border-color: var(--cyan-soft); animation-direction: reverse; animation-duration: 10s; }
.login-ring span:nth-child(3) { inset: 36px; border: 0; background: radial-gradient(circle, #bff3ff, var(--cyan) 60%, transparent 70%); animation: pulse 3s ease-in-out infinite; }

/* ---------- layout ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--cyan-faint);
}
.top .brand { font-size: 18px; }
.clock { display: flex; flex-direction: column; align-items: center; font-family: var(--title); color: var(--cyan); font-size: 15px; }
.clock #date { font-family: var(--body); color: var(--muted); font-size: 12px; letter-spacing: 0.05em; }
.tabs { display: none; }
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr minmax(280px, 380px);
  gap: 20px;
  padding: 20px;
  min-height: 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--cyan-soft);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column; min-height: 0;
}
.panel h2 { font-family: var(--title); font-size: 13px; letter-spacing: 0.3em; color: var(--cyan); margin: 0 0 14px; text-transform: uppercase; }
.status dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; margin: 0 0 18px; font-size: 14px; }
.status dt { color: var(--muted); }
.status dd { margin: 0; text-align: right; }
.pill { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--cyan-soft); justify-self: end; }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.down { color: var(--danger); border-color: var(--danger); }
.messages { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; max-height: calc(100dvh - 260px); }
.msg { padding: 10px 12px; border-radius: 12px; line-height: 1.5; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: rgba(61, 219, 255, 0.16); border: 1px solid var(--cyan-soft); max-width: 90%; }
.msg.assistant { align-self: flex-start; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08); max-width: 95%; }
.msg.error { color: var(--danger); border-color: var(--danger); }

/* ---------- reactor ---------- */
.core { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.reactor { width: min(440px, 80vw, 58vh); height: auto; overflow: visible; }
.ring circle, .ticks circle { fill: none; stroke: var(--cyan); }
.ring { transform-origin: 200px 200px; transform-box: view-box; transition: transform 0.6s ease, opacity 0.6s ease; }
.r1 circle { stroke-width: 1.5; stroke-dasharray: 4 10; opacity: 0.6; }
.r2 circle { stroke-width: 3; stroke-dasharray: 120 30 20 30; opacity: 0.85; filter: drop-shadow(0 0 6px var(--cyan)); }
.r3 circle { stroke-width: 1.5; stroke-dasharray: 60 12; opacity: 0.7; }
.r4 circle { stroke-width: 6; stroke-dasharray: 30 16; opacity: 0.9; filter: drop-shadow(0 0 8px var(--cyan)); }
.ticks circle { stroke-width: 10; stroke-dasharray: 1 8; opacity: 0.35; }
.ticks { transform-origin: 200px 200px; transform-box: view-box; }
.r1 { animation: spin 60s linear infinite; }
.r2 { animation: spin 40s linear infinite reverse; }
.r3 { animation: spin 28s linear infinite; }
.r4 { animation: spin 18s linear infinite reverse; }
.ticks { animation: spin 90s linear infinite reverse; }
.core-group { transform-origin: 200px 200px; transform-box: view-box; }
.core-dot { fill: #bff3ff; filter: drop-shadow(0 0 18px var(--cyan)) drop-shadow(0 0 40px var(--cyan)); }
.state-idle .core-group { animation: pulse 4s ease-in-out infinite; }
.state-listening .ring { transform: scale(0.88); }
.state-listening .r2 circle, .state-listening .r4 circle { filter: drop-shadow(0 0 14px #fff); }
.state-listening .core-group { animation: pulse 1s ease-in-out infinite; }
.state-thinking .r1 { animation-duration: 6s; }
.state-thinking .r2 { animation-duration: 4s; }
.state-thinking .r3 { animation-duration: 3s; }
.state-thinking .r4 { animation-duration: 2s; }
.state-speaking .core-group { transform: scale(var(--level, 1)); transition: transform 0.08s linear; }
.caption { color: var(--muted); font-size: 15px; text-align: center; max-width: 520px; min-height: 1.5em; margin: 8px 16px 0; }

/* ---------- composer ---------- */
.composer { padding: 12px 20px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; justify-content: center; }
.input-row { display: flex; gap: 10px; flex: 1; max-width: 760px; }
.input-row input { flex: 1; }
.mic {
  width: 64px; height: 64px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  background: radial-gradient(circle, rgba(61, 219, 255, 0.25), rgba(61, 219, 255, 0.05));
  border: 2px solid var(--cyan);
}
.mic svg { width: 28px; height: 28px; fill: var(--cyan); }
.state-listening .mic { background: var(--cyan); box-shadow: 0 0 28px var(--cyan); }
.state-listening .mic svg { fill: var(--bg); }
.notice { flex-basis: 100%; text-align: center; color: var(--muted); font-size: 13px; margin: 0; min-height: 1em; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.08); opacity: 1; } }

/* ---------- móvil: pestañas ---------- */
@media (max-width: 900px) {
  .top { padding: 10px 16px; }
  .top .brand { font-size: 14px; letter-spacing: 0.3em; }
  .tabs { display: flex; gap: 6px; padding: 10px 16px 0; }
  .tab { flex: 1; background: transparent; color: var(--muted); border: 1px solid var(--cyan-faint); box-shadow: none; padding: 8px; font-size: 13px; }
  .tab.active { color: var(--cyan); border-color: var(--cyan-soft); }
  .grid { grid-template-columns: 1fr; padding: 12px 16px; }
  [data-pane] { display: none; }
  [data-pane].active { display: flex; }
  .messages { max-height: calc(100dvh - 300px); }
  .composer { padding: 10px 16px 16px; }
  .input-row { flex: 1 1 100%; max-width: 100%; gap: 8px; }
  .input-row button { padding: 10px 12px; }
  .clock #date { display: none; }
  .mic { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
