:root {
  --bg: #060a0d;
  --bg-glow: radial-gradient(circle at 50% 0%, #0a1a20 0%, #060a0d 60%);
  --panel-bg: rgba(8, 20, 26, 0.6);
  --border: rgba(77, 216, 232, 0.25);
  --border-strong: rgba(77, 216, 232, 0.55);
  --cyan: #4dd8e8;
  --cyan-bright: #8ff2ff;
  --text: #cdeef4;
  --muted: #5f8a92;
  --green: #4be3a0;
  --red: #ff6b6b;
  --mono: "SF Mono", "Courier New", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--mono);
  background: var(--bg-glow);
  color: var(--text);
  min-height: 100vh;
  letter-spacing: 0.02em;
  position: relative;
  overflow-x: hidden;
}

.starfield-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  background: radial-gradient(circle at 50% 35%, #0d1a20 0%, #050809 70%);
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0px,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
}

.glitch-text { position: relative; }
.glitch-text::before, .glitch-text::after {
  content: "JARVIS";
  position: absolute;
  inset: 0;
  opacity: 0;
}
.glitch-text::before { color: #ff6ec7; }
.glitch-text::after { color: #6ec7ff; }
.glitch-text { animation: glitch-main 7s ease-in-out infinite; }
.glitch-text::before { animation: glitch-flicker 7s ease-in-out infinite; left: -2px; }
.glitch-text::after { animation: glitch-flicker 7s ease-in-out infinite reverse; left: 2px; }
@keyframes glitch-main {
  0%, 96%, 100% { text-shadow: 0 0 10px rgba(77,216,232,0.5); }
  97% { text-shadow: 2px 0 var(--cyan), -2px 0 #ff6ec7; }
}
@keyframes glitch-flicker {
  0%, 96%, 100% { opacity: 0; }
  97% { opacity: 0.7; }
  98% { opacity: 0; }
}

.topbar, .hud-grid, .status-pips { position: relative; z-index: 2; }

.status-pips {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  padding: 0.5rem 0 0;
}
.status-pips .pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(77, 216, 232, 0.15);
  transition: background 0.2s, box-shadow 0.2s;
}
.status-pips .pip:hover { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }

.local-date { font-size: 0.7rem; color: #e8a15c; letter-spacing: 0.08em; text-transform: uppercase; }

/* ---------- login ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2.5rem;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
  box-shadow: 0 0 40px rgba(77, 216, 232, 0.08), inset 0 0 40px rgba(77, 216, 232, 0.03);
}

.login-card h1 {
  margin: 0;
  color: var(--cyan-bright);
  letter-spacing: 0.15em;
  text-shadow: 0 0 12px rgba(77, 216, 232, 0.6);
}
.subtitle { color: var(--muted); margin: 0 0 0.5rem; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.1em; }

.login-card input {
  padding: 0.7rem 0.9rem;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.4);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
}
.login-card input:focus { outline: none; border-color: var(--cyan); }

button {
  padding: 0.7rem 1rem;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  background: rgba(77, 216, 232, 0.12);
  color: var(--cyan-bright);
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
button:hover { background: rgba(77, 216, 232, 0.22); box-shadow: 0 0 16px rgba(77, 216, 232, 0.3); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.error { color: var(--red); min-height: 1.2em; margin: 0; font-size: 0.85rem; }

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 0.9rem; }

.brand-icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(77, 216, 232, 0.4);
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  color: var(--cyan-bright);
  text-shadow: 0 0 10px rgba(77, 216, 232, 0.5);
}

.tagline { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

.topbar-right { display: flex; align-items: center; gap: 2rem; }

.system-status { text-align: right; }
.status-label { display: block; font-size: 0.6rem; color: var(--muted); letter-spacing: 0.1em; }
.status-pill { display: flex; align-items: center; gap: 0.4rem; justify-content: flex-end; color: var(--cyan-bright); font-size: 0.8rem; letter-spacing: 0.08em; }

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.local-time { font-size: 0.85rem; color: var(--text); letter-spacing: 0.05em; }

.gauge { position: relative; width: 40px; height: 40px; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--border); stroke-width: 3; }
.gauge-value {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 107;
  stroke-dashoffset: 107;
  transition: stroke-dashoffset 0.6s ease, stroke 0.3s ease;
  filter: drop-shadow(0 0 4px var(--cyan));
}
.gauge-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: var(--cyan-bright);
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- layout ---------- */

.hud-grid {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 1.25rem;
  padding: 1.5rem 2rem 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.col { display: flex; flex-direction: column; gap: 1.25rem; }

.panel {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 1.1rem 1.2rem;
  backdrop-filter: blur(6px);
}

.panel::before, .panel::after,
.panel .corner-tl, .panel .corner-br {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--cyan);
  border-style: solid;
  opacity: 0.8;
}
.panel::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.panel::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.panel-header .label {
  font-size: 0.75rem;
  color: var(--cyan);
  letter-spacing: 0.08em;
}

.panel-header .sublabel {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- status panel ---------- */

.status-row { display: flex; align-items: center; gap: 0.6rem; }
.status-text { font-size: 1.5rem; font-weight: 600; letter-spacing: 0.06em; color: var(--cyan-bright); text-shadow: 0 0 10px rgba(77,216,232,0.4); }
.status-since { color: var(--muted); font-size: 0.8rem; margin-top: 0.5rem; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.online { background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot.offline { background: var(--red); box-shadow: 0 0 10px var(--red); }

/* ---------- market panel ---------- */

.crypto-list { display: flex; flex-direction: column; }

.crypto-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.crypto-row:last-child { border-bottom: none; }
.crypto-row .coin { font-weight: 600; color: var(--muted); letter-spacing: 0.05em; }
.crypto-row .price { font-weight: 600; color: var(--text); }
.crypto-row .change { display: inline-block; min-width: 3.2em; text-align: right; font-size: 0.75rem; }
.crypto-row .change.up { color: var(--green); }
.crypto-row .change.down { color: var(--red); }

.crypto-row .price { transition: background-color 0.3s, color 0.3s; border-radius: 2px; padding: 0 2px; }
.crypto-row .price.flash-up { background-color: rgba(75, 227, 160, 0.25); color: var(--green); }
.crypto-row .price.flash-down { background-color: rgba(255, 107, 107, 0.25); color: var(--red); }

.live-badge { display: flex; align-items: center; gap: 0.4rem; color: var(--cyan-bright) !important; }
.pulse-dot.small { width: 6px; height: 6px; }

.forex-alert { margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }
.forex-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.4rem; }
.forex-headline { font-size: 0.78rem; line-height: 1.5; color: var(--text); }


/* ---------- center HUD ---------- */

.hud-center { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 1.5rem; padding: 1rem 0; }

.pillar {
  position: absolute;
  top: 8%;
  width: 34px;
  height: 68%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(77,216,232,0.08), rgba(77,216,232,0.01));
  opacity: 0.55;
}
.pillar-left { left: 6%; transform: perspective(400px) rotateY(12deg); }
.pillar-right { right: 6%; transform: perspective(400px) rotateY(-12deg); }
.pillar span {
  display: block;
  height: 3px;
  background: var(--cyan);
  opacity: 0.25;
  animation: pillarscan 2.4s ease-in-out infinite;
}
.pillar span:nth-child(1) { animation-delay: 0s; }
.pillar span:nth-child(2) { animation-delay: 0.4s; }
.pillar span:nth-child(3) { animation-delay: 0.8s; }
@keyframes pillarscan { 0%, 100% { opacity: 0.15; transform: scaleX(0.6); } 50% { opacity: 0.7; transform: scaleX(1); } }

@media (max-width: 1300px) {
  .pillar { display: none; }
}

.radar {
  position: relative;
  width: 320px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radar-ring {
  position: absolute;
  border: 1px solid var(--border);
  border-radius: 50%;
}
.radar-ring.r1 { width: 100%; height: 100%; animation: spin 90s linear infinite; }
.radar-ring.r1::before, .radar-ring.r1::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--cyan);
}
.radar-ring.r1::before { top: -3px; left: calc(50% - 3px); }
.radar-ring.r1::after { bottom: -3px; left: calc(50% - 3px); }
.radar-ring.r2 { width: 78%; height: 78%; border-style: dashed; animation: spin 30s linear infinite; }
.radar-ring.r3 { width: 56%; height: 56%; animation: spin 45s linear infinite reverse; }
.radar-ring.r4 { width: 34%; height: 34%; border-style: dotted; animation: spin 20s linear infinite; }

.radar-sweep {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(77,216,232,0.35), transparent 25%);
  animation: spin 4s linear infinite;
  mix-blend-mode: screen;
}

.orbit-dot {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
}
.orbit-dot::before {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  background: var(--cyan-bright);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--cyan-bright);
}
.orbit-dot.od1 { animation: spin 12s linear infinite; }
.orbit-dot.od1::before { top: 2%; left: calc(50% - 2.5px); }
.orbit-dot.od2 { animation: spin 18s linear infinite reverse; }
.orbit-dot.od2::before { top: 14%; left: calc(50% - 2.5px); }

.radar-ping {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50%;
  height: 50%;
  border: 1px solid var(--cyan-bright);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
}
.radar.speaking .radar-ping { animation: sonarping 1.6s ease-out infinite; }
.radar.speaking .radar-ping.p2 { animation-delay: 0.8s; }
@keyframes sonarping {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(1.9); opacity: 0; }
}

.radar { --voice-level: 0; }
.radar.speaking .radar-ring { filter: brightness(calc(1 + var(--voice-level) * 1.8)); }
.radar.speaking .radar-sweep { animation-duration: 1.5s; }

.radar-crosshair {
  position: absolute;
  width: 100%;
  height: 100%;
}
.radar-crosshair::before, .radar-crosshair::after {
  content: "";
  position: absolute;
  background: var(--border);
}
.radar-crosshair::before { top: 50%; left: 0; width: 100%; height: 1px; }
.radar-crosshair::after { top: 0; left: 50%; width: 1px; height: 100%; }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.radar-core {
  position: relative;
  width: 128px;
  height: 128px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  text-align: center;
  background: rgba(77, 216, 232, 0.05);
  box-shadow: 0 0 30px rgba(77, 216, 232, 0.25), inset 0 0 20px rgba(77, 216, 232, 0.1);
  animation: corepulse 3s ease-in-out infinite;
}
@keyframes corepulse {
  0%, 100% { box-shadow: 0 0 30px rgba(77, 216, 232, 0.25), inset 0 0 20px rgba(77, 216, 232, 0.1); }
  50% { box-shadow: 0 0 44px rgba(77, 216, 232, 0.4), inset 0 0 28px rgba(77, 216, 232, 0.18); }
}

.radar-clock { font-size: 1.1rem; font-weight: 600; letter-spacing: 0.05em; color: var(--cyan-bright); text-shadow: 0 0 10px rgba(77,216,232,0.5); transition: opacity 0.2s; }
.radar-core-text { font-size: 0.6rem; letter-spacing: 0.1em; color: var(--muted); line-height: 1.4; transition: opacity 0.2s; }

.core-bars {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
}
.radar-core.speaking .radar-clock,
.radar-core.speaking .radar-core-text { display: none; }
.radar-core.speaking .core-bars { display: flex; }
.radar-core.speaking {
  transform: scale(calc(1 + var(--voice-level, 0) * 0.3));
  box-shadow:
    0 0 calc(30px + var(--voice-level, 0) * 70px) rgba(77, 216, 232, calc(0.35 + var(--voice-level, 0) * 0.5)),
    inset 0 0 calc(20px + var(--voice-level, 0) * 30px) rgba(77, 216, 232, calc(0.15 + var(--voice-level, 0) * 0.25));
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
  border-color: var(--cyan-bright);
}
.core-bars span {
  width: 5px;
  height: 100%;
  background: var(--cyan-bright);
  border-radius: 2px;
  transform: scaleY(0.15);
  transform-origin: center;
  transition: transform 0.06s linear;
  box-shadow: 0 0 8px var(--cyan-bright);
}

#mic-btn { cursor: pointer; transition: background 0.2s, border-color 0.2s; }
#mic-btn.recording {
  background: rgba(255, 107, 107, 0.15);
  border-color: var(--red);
  color: #ffb3b3;
  animation: pulse 1s ease-in-out infinite;
}
#mic-btn.processing { opacity: 0.6; cursor: wait; }

.voice-bar { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; width: 100%; max-width: 420px; }

.waveform { display: flex; align-items: flex-end; gap: 3px; height: 28px; }
.waveform span {
  width: 3px;
  background: var(--cyan);
  opacity: 0.7;
  border-radius: 2px;
  animation: wave 1.2s ease-in-out infinite;
}
.waveform span:nth-child(1) { height: 30%; animation-delay: 0s; }
.waveform span:nth-child(2) { height: 60%; animation-delay: 0.1s; }
.waveform span:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.waveform span:nth-child(4) { height: 50%; animation-delay: 0.3s; }
.waveform span:nth-child(5) { height: 80%; animation-delay: 0.4s; }
.waveform span:nth-child(6) { height: 40%; animation-delay: 0.5s; }
.waveform span:nth-child(7) { height: 65%; animation-delay: 0.6s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1); } }

.command-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan-bright);
  background: rgba(77, 216, 232, 0.06);
}

/* ---------- terminal / chat ---------- */

.terminal-log {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  max-height: 260px;
  overflow-y: auto;
}

.terminal-log .line { line-height: 1.5; }
.terminal-log .line .ts { color: var(--cyan); margin-right: 0.5rem; }

.chat-log {
  min-height: 140px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.chat-msg { line-height: 1.5; }
.chat-msg.user::before { content: "> "; color: var(--cyan); }
.chat-msg.user { color: var(--text); }
.chat-msg.jarvis::before { content: "jarvis :: "; color: var(--cyan); }
.chat-msg.jarvis { color: var(--muted); }

.chat-form { display: flex; gap: 0.5rem; align-items: center; }
.chat-form input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.35);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
}
.chat-form input:focus { outline: none; border-color: var(--cyan); }
.chat-form input::placeholder { color: var(--muted); }
.chat-form button { padding: 0.6rem 1rem; font-size: 0.75rem; }

@media (max-width: 1100px) {
  .hud-grid { grid-template-columns: 1fr; }
  .radar { width: 240px; height: 240px; }
}
