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

:root {
  --bg:       #04080f;
  --mid:      #07152a;
  --accent:   #00eeff;
  --accent-2: #0099aa;
  --dim:      #0d3040;
  --text:     #b0dce8;
  --text-dim: #1e5060;
  --red:      #ff2d55;
  --ok:       #00ffa3;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Scanline ambient — muy sutil */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(0, 238, 255, 0.014) 1px, transparent 1px);
  background-size: 100% 28px;
  pointer-events: none;
  z-index: -1;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 16px);
  gap: 36px;
}

/* ── Auth modal ─────────────────────────────── */
#auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 15, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
#auth-modal.hidden { display: none; }

.auth-box {
  background: var(--mid);
  border: 1px solid var(--dim);
  border-radius: 4px;
  padding: 28px 24px;
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.auth-tag {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.1em;
}
.auth-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.12em;
}
.auth-sub {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  line-height: 1.6;
}

.auth-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--dim);
  padding-bottom: 6px;
}
.auth-prompt {
  font-size: 13px;
  color: var(--accent);
}
.auth-input-wrap input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  flex: 1;
  letter-spacing: 0.1em;
}
.auth-input-wrap input::placeholder {
  color: var(--text-dim);
  letter-spacing: 0.3em;
}

#token-save {
  background: transparent;
  border: 1px solid var(--accent-2);
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.15em;
  padding: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  border-radius: 2px;
}
#token-save:active { background: var(--dim); }

/* ── Status ─────────────────────────────────── */
#status {
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  height: 14px;
  transition: color 0.2s;
}
#status.recording { color: var(--red); }
#status.processing { color: var(--accent); }
#status.playing    { color: var(--ok); }

/* ── Button — sonar ─────────────────────────── */
#btn {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-touch-callout: none;
}

/* Radar sweep overlay (recording) */
#btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
#btn.recording::before {
  opacity: 1;
  background: conic-gradient(
    from 0deg,
    rgba(255, 45, 85, 0.0) 0%,
    rgba(255, 45, 85, 0.18) 15%,
    rgba(255, 45, 85, 0.04) 35%,
    rgba(255, 45, 85, 0.0) 50%,
    rgba(255, 45, 85, 0.0) 100%
  );
  animation: radar-sweep 2.4s linear infinite;
}

/* Sonar ping (playing) */
#btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--ok);
  opacity: 0;
  pointer-events: none;
}
#btn.playing::after {
  animation: sonar-ping 1.8s ease-out infinite;
}

/* Rings */
.ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--accent);
  transition: border-color 0.3s, opacity 0.3s;
}
.ring.r1 {
  inset: 0;
  opacity: 0.5;
}
.ring.r2 {
  inset: 22px;
  opacity: 0.25;
}

/* Ring states */
#btn.recording .ring {
  border-color: var(--red);
}
#btn.playing .ring {
  border-color: var(--ok);
}
#btn.processing .ring.r1 {
  border-style: dashed;
  animation: spin 1.4s linear infinite;
  opacity: 0.7;
}

/* Ambient breathing — idle only */
#btn:not(.recording):not(.processing):not(.playing) {
  animation: breathe 4s ease-in-out infinite;
}

/* Core dot */
.core {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transition: background 0.2s, transform 0.2s;
  box-shadow: 0 0 12px var(--accent);
}
#btn.recording .core {
  background: var(--red);
  box-shadow: 0 0 16px var(--red);
  animation: core-pulse 0.8s ease-in-out infinite;
}
#btn.processing .core {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  opacity: 0.5;
}
#btn.playing .core {
  background: var(--ok);
  box-shadow: 0 0 16px var(--ok);
}

/* ── Hint ───────────────────────────────────── */
#hint {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.18em;
  transition: opacity 0.2s;
}

/* ── Transcript — comms log ─────────────────── */
#transcript {
  width: 100%;
  max-width: 380px;
  max-height: 32dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 16px;
  scrollbar-width: none;
}
#transcript::-webkit-scrollbar { display: none; }

.log-entry {
  display: grid;
  grid-template-columns: 14px 52px 1fr;
  gap: 0 8px;
  font-size: 11px;
  line-height: 1.6;
  align-items: baseline;
}
.log-dir   { color: var(--text-dim); font-size: 10px; }
.log-label { letter-spacing: 0.08em; font-size: 9px; color: var(--text-dim); }
.log-text  { color: var(--text); word-break: break-word; }

.log-entry.jarvis .log-dir   { color: var(--accent); }
.log-entry.jarvis .log-label { color: var(--accent-2); }
.log-entry.jarvis .log-text  { color: var(--accent); }

/* ── Keyframes ──────────────────────────────── */
@keyframes radar-sweep {
  to { transform: rotate(360deg); }
}
@keyframes sonar-ping {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.012); }
}
@keyframes core-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.5); }
}

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