:root {
  --void: #01070d;
  --holo: #5ce1ff;
  --ice: #d8f7ff;
  --steel: #1b3a4b;
  --gold: #e8b04b;
  --granate: #c2334a;
  --accent: var(--holo);
  --font: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --pad: clamp(14px, 3vw, 32px);
  color-scheme: dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }

html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at 50% 42%, #06202d 0%, var(--void) 62%);
  color: var(--ice);
  font: 400 15px/1.45 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  grid-template-columns: minmax(0, 1fr);
}

body[data-state="thinking"], body[data-state="transcribing"] { --accent: var(--gold); }
body[data-state="error"] { --accent: var(--granate); }

#core { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }

.frame { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.frame i {
  position: fixed; width: 34px; height: 34px; z-index: 1; pointer-events: none;
  border: 1px solid var(--steel);
}
.frame i:nth-child(1) { top: calc(env(safe-area-inset-top, 0px) + 10px); left: 10px; border-right: 0; border-bottom: 0; }
.frame i:nth-child(2) { top: calc(env(safe-area-inset-top, 0px) + 10px); right: 10px; border-left: 0; border-bottom: 0; }
.frame i:nth-child(3) { bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); left: 10px; border-right: 0; border-top: 0; }
.frame i:nth-child(4) { bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); right: 10px; border-left: 0; border-top: 0; }

.sub { color: #7fa6b6; font-size: 12px; letter-spacing: .04em; }

.top {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: var(--pad) calc(var(--pad) + 14px) 0;
}
.ident, .link { display: grid; gap: 2px; }
.link { justify-items: end; text-align: right; grid-template-columns: auto auto; column-gap: 8px; align-items: center; }
.link .sub { grid-column: 1 / -1; }
.wordmark { font-weight: 600; font-size: 13px; letter-spacing: .5em; color: var(--holo); }
#clock { font-weight: 300; font-size: clamp(28px, 5vw, 44px); line-height: 1; font-variant-numeric: tabular-nums; }
#linkText { font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--granate); box-shadow: 0 0 10px currentColor; color: var(--granate); }
.dot.on { background: var(--holo); color: var(--holo); }

.status {
  position: relative; z-index: 2; align-self: end; pointer-events: none;
  display: grid; justify-items: center; gap: 4px; text-align: center;
  padding: 0 var(--pad) clamp(10px, 3vh, 28px);
}
#stateLabel {
  font-weight: 500; font-size: clamp(15px, 2.2vw, 18px); letter-spacing: .14em;
  color: var(--accent); transition: color .3s;
}
#hint { min-height: 1.2em; }

.log {
  position: fixed; z-index: 2; left: calc(var(--pad) + 14px); top: 50%; transform: translateY(-50%);
  width: 220px; max-height: 40vh; overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent, #000 30%);
}
.log ol { list-style: none; margin: 0; padding: 0 0 0 10px; border-left: 1px solid var(--steel); display: grid; gap: 6px; }
.log li { font-size: 11.5px; color: #7fa6b6; line-height: 1.3; }
.log li b { color: var(--holo); font-weight: 500; }
@media (max-width: 900px) { .log { display: none; } }

.dialog {
  position: relative; z-index: 2;
  width: min(720px, 100% - 2 * var(--pad)); margin: 0 auto;
  display: grid; gap: 6px; min-height: 3em;
}
.top, .log { pointer-events: none; }
.line { margin: 0; overflow-wrap: anywhere; }
.line:empty { display: none; }
.you { color: #8fb3c2; font-size: 14px; }
.you::before { content: "Tú  "; color: var(--steel); }
.jarvis {
  font-size: clamp(16px, 2.3vw, 19px); color: var(--ice);
  max-height: 7.5em; overflow-y: auto; scrollbar-width: none;
}

.dock {
  position: relative; z-index: 3;
  width: min(720px, 100% - 2 * var(--pad)); margin: 12px auto var(--pad);
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--steel); background: rgba(3, 18, 27, .72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 6px; clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}
.dock:focus-within { border-color: rgba(92, 225, 255, .55); }
.dock input:focus-visible { outline: 0; }
.dock input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0;
  color: var(--ice); font: inherit; padding: 10px 6px;
}
.dock input::placeholder { color: #557885; }
button { font: inherit; color: inherit; cursor: pointer; }
.talk {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.talk svg { width: 22px; height: 22px; fill: currentColor; }
body[data-state="listening"] .talk { background: var(--holo); color: var(--void); }
.ghost {
  flex: none; background: transparent; border: 1px solid transparent; padding: 9px 10px; color: #8fb3c2;
}
.ghost svg { width: 18px; height: 18px; fill: currentColor; display: block; }
#stop { border-color: var(--granate); color: #ffb3bf; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--holo); outline-offset: 2px; }

.menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); display: grid; min-width: 220px;
  background: rgba(3, 18, 27, .96); border: 1px solid var(--steel);
}
.menu button { background: none; border: 0; text-align: left; padding: 12px 14px; color: var(--ice); }
.menu button:hover, .menu button:focus-visible { background: rgba(92, 225, 255, .08); }

/* ── Arranque ── */
.boot {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: rgba(1, 7, 13, .86); transition: opacity .8s ease;
}
.boot.gone { opacity: 0; pointer-events: none; }
.boot-inner { display: grid; justify-items: center; gap: 14px; padding: var(--pad); text-align: center; }
.boot-title { margin: 0; font-weight: 300; font-size: clamp(40px, 9vw, 76px); letter-spacing: .6em; margin-right: -.6em; color: var(--holo); }
.boot-sub { margin: -6px 0 10px; color: #7fa6b6; }
.token { display: grid; gap: 6px; width: min(320px, 80vw); text-align: left; font-size: 13px; color: #8fb3c2; }
.token input {
  background: transparent; border: 1px solid var(--steel); color: var(--ice);
  font: inherit; padding: 12px; outline: 0;
}
.token input:focus { border-color: var(--holo); }
.start {
  margin-top: 6px; padding: 13px 44px; background: transparent; color: var(--holo);
  border: 1px solid var(--holo); letter-spacing: .3em; font-weight: 500;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.start:hover { background: rgba(92, 225, 255, .1); }
.boot-error { min-height: 1.3em; margin: 0; color: #ff8fa0; font-size: 13px; max-width: 34ch; }

@media (prefers-reduced-motion: reduce) {
  .boot { transition: none; }
}
