:root {
  --cyan: #00e5ff;
  --cyan-dim: #00b8d4;
  --cyan-glow: rgba(0, 229, 255, 0.45);
  --bg: #02060c;
  --panel: rgba(4, 18, 32, 0.72);
  --border: rgba(0, 229, 255, 0.22);
  --text: #e8f7ff;
  --muted: #7eb8cc;
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.hud-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.hud-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 35% 45%, black 10%, transparent 70%);
}

.hud-glow {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  left: 10%;
  top: 20%;
  transform: translate(-10%, -10%);
  background: radial-gradient(circle, rgba(0, 180, 220, 0.18) 0%, transparent 65%);
  animation: breathe 4s ease-in-out infinite;
}

.hud-scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 229, 255, 0.015) 3px,
    transparent 4px
  );
  opacity: 0.5;
}

@keyframes breathe {
  0%, 100% { opacity: 0.55; transform: translate(-10%, -10%) scale(1); }
  50% { opacity: 1; transform: translate(-10%, -10%) scale(1.05); }
}

body.state-thinking .hud-glow,
body.state-speaking .hud-glow {
  animation: breathe-fast 1.2s ease-in-out infinite;
}

body.state-listening .hud-glow {
  animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe-fast {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; transform: translate(-10%, -10%) scale(1.12); }
}

.hud-header,
main {
  position: relative;
  z-index: 1;
}

.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  background: rgba(2, 8, 16, 0.65);
}

.brand { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.35em;
  font-weight: 600;
  color: var(--cyan);
  text-shadow: 0 0 18px var(--cyan-glow);
}
.brand-sub {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

main { padding: 1rem 1.25rem 2rem; max-width: 1400px; margin: 0 auto; }

.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 0 40px rgba(0, 120, 160, 0.08);
}

.panel { max-width: 420px; margin: 2rem auto; padding: 1.5rem; }
.auth-core-wrap { display: flex; justify-content: center; margin-bottom: 1rem; }

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
  min-height: calc(100vh - 120px);
}

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
}

.stage-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 2rem;
  min-height: 420px;
}

.chat-column {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1rem;
  min-height: 420px;
}

@media (max-width: 760px) {
  .chat-column { grid-template-columns: 1fr; }
}

.sidebar { padding: 1rem; }
.sidebar ul { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.sidebar li { margin-bottom: 0.35rem; }
.sidebar button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
}
.sidebar button:hover {
  border-color: var(--border);
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.06);
}

#chat-panel {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  min-height: 420px;
}

.messages {
  flex: 1;
  min-height: 280px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 0.25rem;
  margin-bottom: 0.75rem;
}

.msg {
  margin: 0.55rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  max-width: 92%;
  line-height: 1.45;
  animation: msg-in 0.35s ease-out;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  margin-left: auto;
  background: rgba(0, 100, 140, 0.35);
  border: 1px solid rgba(0, 229, 255, 0.15);
}
.msg.assistant {
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.28);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.06);
}
.msg.pending {
  color: var(--muted);
  font-style: italic;
  border: 1px dashed var(--border);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  align-items: end;
}

.voice-controls {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.btn-voice {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 229, 255, 0.35);
  background: rgba(0, 60, 90, 0.5);
  color: var(--cyan);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.btn-voice.active {
  border-color: var(--cyan);
  background: rgba(0, 229, 255, 0.15);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.25);
  animation: mic-pulse 1.5s ease-in-out infinite;
}

.btn-voice.active .mic-icon {
  filter: drop-shadow(0 0 6px var(--cyan));
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 16px rgba(0, 229, 255, 0.2); }
  50% { box-shadow: 0 0 28px rgba(0, 229, 255, 0.45); }
}

.btn-mic {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
}

.btn-mic.listening {
  border-color: var(--cyan);
  background: rgba(0, 229, 255, 0.2);
  animation: mic-pulse 1s ease-in-out infinite;
}

.voice-status {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  max-width: 260px;
  line-height: 1.4;
}

.voice-status.ok { color: #6ee7b7; }
.voice-status.warn { color: #fbbf24; }

textarea, input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 10, 20, 0.8);
  color: var(--text);
  resize: vertical;
}

textarea:focus, input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.15);
}

button {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 40, 60, 0.8);
  color: var(--text);
  cursor: pointer;
  transition: 0.2s;
}
button:hover:not(:disabled) {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.2);
}
.btn-accent {
  background: linear-gradient(180deg, rgba(0, 200, 230, 0.35), rgba(0, 120, 160, 0.25));
  border-color: rgba(0, 229, 255, 0.45);
  color: var(--cyan);
}
.btn-ghost { background: transparent; }
.full { width: 100%; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
button:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }

.error { color: #ff7b7b; font-size: 0.9rem; }
.location-label, .jarvis-status {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin: 0.5rem 0 0;
}
.jarvis-status {
  color: var(--cyan);
  text-transform: uppercase;
  min-height: 1.2em;
}

/* JARVIS core HUD */
.jarvis-core {
  position: relative;
  width: min(280px, 70vw);
  height: min(280px, 70vw);
  display: grid;
  place-items: center;
}

.jarvis-core-sm { width: 160px; height: 160px; }

.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1.2;
  opacity: 0.55;
}

.ring-outer { animation: spin 24s linear infinite; stroke-dasharray: 8 14; }
.ring-mid { animation: spin-rev 16s linear infinite; stroke-dasharray: 4 10; opacity: 0.7; }
.ring-inner { animation: spin 10s linear infinite; opacity: 0.9; stroke-width: 1.5; }
.ring-ticks { opacity: 0.35; animation: spin 40s linear infinite; color: var(--cyan); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }

.core-glow {
  position: absolute;
  width: 55%;
  height: 55%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.25) 0%, transparent 70%);
  animation: core-pulse 3s ease-in-out infinite;
}

@keyframes core-pulse {
  0%, 100% { transform: scale(0.92); opacity: 0.6; }
  50% { transform: scale(1.05); opacity: 1; }
}

.core-title {
  position: relative;
  z-index: 2;
  font-size: clamp(0.85rem, 3vw, 1.15rem);
  letter-spacing: 0.28em;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 20px var(--cyan-glow), 0 0 40px rgba(0, 229, 255, 0.3);
}

.equalizer-ring {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.eq-bar {
  position: absolute;
  width: 3px;
  height: 12px;
  top: 50%;
  left: 50%;
  margin-left: -1.5px;
  margin-top: -6px;
  transform-origin: center center;
  background: linear-gradient(to top, transparent, var(--cyan));
  border-radius: 2px;
  opacity: 0.35;
}

body.state-idle .eq-bar { animation: eq-idle 2.5s ease-in-out infinite; }
body.state-listening .eq-bar { animation: eq-active 0.5s ease-in-out infinite; opacity: 0.7; }
body.state-thinking .eq-bar { animation: eq-active 0.35s ease-in-out infinite; opacity: 0.85; }
body.state-speaking .eq-bar { animation: eq-speak 0.22s ease-in-out infinite; opacity: 1; }

@keyframes eq-idle {
  0%, 100% { height: 8px; }
  50% { height: 16px; }
}
@keyframes eq-active {
  0%, 100% { height: 10px; }
  50% { height: 28px; }
}
@keyframes eq-speak {
  0%, 100% { height: 14px; }
  25% { height: 36px; }
  75% { height: 22px; }
}

body.state-thinking .ring-outer { animation-duration: 6s; }
body.state-thinking .ring-mid { animation-duration: 4s; }
body.state-speaking .ring-outer { animation-duration: 3s; }
body.state-speaking .ring-mid { animation-duration: 2s; }
body.state-speaking .core-glow { animation: core-pulse 0.6s ease-in-out infinite; }

body.state-listening .core-title,
body.state-speaking .core-title {
  text-shadow: 0 0 28px var(--cyan-glow), 0 0 60px rgba(0, 229, 255, 0.5);
}
