:root {
  --bg: #02070d;
  --bg-2: #061420;
  --line: rgba(62, 232, 255, 0.18);
  --line-strong: rgba(62, 232, 255, 0.45);
  --cyan: #3ee8ff;
  --cyan-soft: #7ff1ff;
  --text: #c9f6ff;
  --muted: #5f8a96;
  --amber: #ffb347;
  --red: #ff5a6a;
  --glow: 0 0 18px rgba(62, 232, 255, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: radial-gradient(ellipse at 50% 45%, #07202e 0%, var(--bg) 62%);
  color: var(--text);
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  overflow: hidden;
  user-select: none;
}

body::before {
  /* rejilla holográfica de fondo */
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.18;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  pointer-events: none;
}

body::after {
  /* líneas de escaneo */
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

/* ---------- barra superior ---------- */
.titlebar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 0 18px;
  border-bottom: 1px solid var(--line);
  -webkit-app-region: drag;
  position: relative;
  z-index: 2;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--cyan);
  box-shadow: var(--glow);
}
.brand-name { font-family: 'Orbitron', sans-serif; font-weight: 700; letter-spacing: 6px; color: var(--cyan); }
.brand-sub { font-size: 12px; letter-spacing: 3px; color: var(--muted); }

.status-pill {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Orbitron', sans-serif; font-size: 11px; letter-spacing: 3px;
  padding: 5px 14px; border: 1px solid var(--line-strong); border-radius: 20px;
  color: var(--muted);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
body[data-state="connecting"] .status-pill .dot { background: var(--amber); animation: blink 0.8s infinite; }
body[data-state="listening"] .status-pill .dot,
body[data-state="speaking"] .status-pill .dot { background: var(--cyan); box-shadow: var(--glow); }
body[data-state="listening"] .status-pill,
body[data-state="speaking"] .status-pill { color: var(--cyan); }
body[data-state="error"] .status-pill .dot { background: var(--red); }

.win-buttons { display: flex; height: 100%; -webkit-app-region: no-drag; }
.win-buttons button {
  width: 46px; height: 100%; border: 0; background: transparent; color: var(--muted);
  font-size: 14px; cursor: pointer;
}
.win-buttons button:hover { background: rgba(62,232,255,0.08); color: var(--cyan); }
.win-buttons .close:hover { background: var(--red); color: #fff; }

/* ---------- distribución ---------- */
.layout {
  height: calc(100% - 44px - 46px);
  display: grid;
  grid-template-columns: 280px 1fr 340px;
  gap: 16px;
  padding: 16px;
  position: relative;
  z-index: 1;
}

.panel { display: flex; flex-direction: column; gap: 14px; min-height: 0; }

.card {
  position: relative;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6, 26, 38, 0.65), rgba(2, 10, 16, 0.55));
  padding: 14px 16px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 40px; height: 2px; background: var(--cyan); box-shadow: var(--glow);
}
.card h3 {
  font-family: 'Orbitron', sans-serif; font-weight: 500; font-size: 11px;
  letter-spacing: 3px; color: var(--muted); margin-bottom: 10px;
}

.clock { font-family: 'Orbitron', sans-serif; font-size: 40px; color: var(--cyan); text-shadow: var(--glow); }
.date { font-size: 16px; margin-top: 2px; }
.date::first-letter { text-transform: uppercase; }
.sub { font-size: 12px; color: var(--muted); letter-spacing: 2px; margin-top: 6px; }

.systems { list-style: none; display: flex; flex-direction: column; gap: 9px; font-size: 14px; letter-spacing: 1px; }
.systems li { display: flex; align-items: center; gap: 10px; }
.systems em { margin-left: auto; font-style: normal; color: var(--muted); font-size: 13px; }
.led { width: 8px; height: 8px; border-radius: 50%; background: #23404a; flex: none; }
.led.on { background: var(--cyan); box-shadow: var(--glow); }
.led.pending { background: transparent; border: 1px solid var(--amber); }
.led.err { background: var(--red); }
.led.busy { animation: led-pulse 0.8s ease-in-out infinite; }
@keyframes led-pulse { 50% { opacity: 0.3; } }

.kv { display: flex; justify-content: space-between; font-size: 15px; padding: 3px 0; }
.kv span { color: var(--muted); }
.kv b { font-family: 'Orbitron', sans-serif; font-weight: 500; color: var(--cyan-soft); }

/* ---------- núcleo ---------- */
.core { position: relative; min-height: 0; }
#hud { position: absolute; inset: 0; width: 100%; height: 100%; }
.core-ui {
  position: absolute; left: 0; right: 0; bottom: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.mode { font-family: 'Orbitron', sans-serif; letter-spacing: 6px; font-size: 14px; color: var(--cyan); text-shadow: var(--glow); }
.activate {
  font-family: 'Orbitron', sans-serif; font-size: 14px; letter-spacing: 5px;
  color: var(--cyan); background: rgba(62,232,255,0.06);
  border: 1px solid var(--line-strong); padding: 12px 38px; cursor: pointer;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  transition: background 0.2s, color 0.2s;
}
.activate:hover { background: rgba(62,232,255,0.16); }
body[data-state="listening"] .activate,
body[data-state="speaking"] .activate { color: var(--amber); border-color: rgba(255,179,71,0.5); }
.activate:disabled { opacity: 0.5; cursor: wait; }
.hint { font-size: 12px; color: var(--muted); letter-spacing: 1px; }

/* ---------- registro ---------- */
.log-card { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; user-select: text; }
.log p { font-size: 15px; line-height: 1.35; padding: 8px 10px; border-left: 2px solid var(--line-strong); background: rgba(62,232,255,0.03); }
.log p .who { display: block; font-family: 'Orbitron', sans-serif; font-size: 10px; letter-spacing: 3px; margin-bottom: 3px; }
.log p.user { border-color: var(--amber); }
.log p.user .who { color: var(--amber); }
.log p.agent .who { color: var(--cyan); }
.log p.sys { color: var(--muted); font-size: 13px; border-color: var(--line); }
.log p.err { color: var(--red); border-color: var(--red); font-size: 13px; }
.log::-webkit-scrollbar { width: 4px; }
.log::-webkit-scrollbar-thumb { background: var(--line-strong); }

/* ---------- pie ---------- */
.footer {
  height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 18px;
  border-top: 1px solid var(--line); position: relative; z-index: 1;
}
.meter-label { font-family: 'Orbitron', sans-serif; font-size: 10px; letter-spacing: 3px; color: var(--muted); }
.meter { width: 180px; height: 6px; background: rgba(62,232,255,0.08); position: relative; overflow: hidden; }
.meter div { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--cyan); box-shadow: var(--glow); transition: width 0.08s linear; }
#micBar { background: var(--amber); }
.version { margin-left: auto; font-size: 12px; color: var(--muted); letter-spacing: 2px; }

@keyframes blink { 50% { opacity: 0.3; } }

@media (max-width: 1150px) {
  .layout { grid-template-columns: 230px 1fr 280px; }
}
