:root {
  --bg: #04070d;
  --panel: rgba(10, 20, 32, 0.72);
  --cyan: #33e1ff;
  --cyan-dim: #1a6b7d;
  --gold: #ffb648;
  --text: #cfeff7;
  --muted: #6c8b98;
}

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

body {
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.grid-bg {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(51, 225, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(51, 225, 255, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 30%, transparent 80%);
  z-index: 0;
  animation: drift 40s linear infinite;
}
@keyframes drift { to { background-position: 440px 440px; } }

/* ---------- HUD header ---------- */
.hud {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(51, 225, 255, 0.18);
  background: linear-gradient(180deg, rgba(51, 225, 255, 0.05), transparent);
}
.hud-text h1 {
  font-size: 22px;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 0 14px var(--cyan);
}
.hud-text p { font-size: 11px; color: var(--muted); letter-spacing: 2px; margin-top: 4px; }
.online { color: var(--cyan); }

.reactor {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
}
.reactor-core {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan), 0 0 26px var(--cyan);
  animation: pulse 2.4s ease-in-out infinite;
}
.reactor-ring { position: absolute; border-radius: 50%; border: 2px solid var(--cyan-dim); }
.r1 { width: 30px; height: 30px; border-top-color: var(--cyan); animation: spin 3s linear infinite; }
.r2 { width: 44px; height: 44px; border-bottom-color: var(--cyan); animation: spin 6s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.45; transform: scale(0.82); } }

/* ---------- main ---------- */
main {
  position: relative;
  z-index: 2;
  flex: 1;
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 24px 18px 0;
  display: flex;
  flex-direction: column;
}

.feed { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding-bottom: 20px; }

.msg { display: flex; flex-direction: column; gap: 6px; animation: rise 0.35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.msg .tag { font-size: 10px; letter-spacing: 3px; color: var(--muted); }
.msg.user { align-items: flex-end; }
.msg.user .tag { color: var(--gold); }

.bubble {
  max-width: 90%;
  padding: 14px 16px;
  border: 1px solid rgba(51, 225, 255, 0.22);
  background: var(--panel);
  border-radius: 4px;
  line-height: 1.6;
  font-size: 14px;
  white-space: pre-wrap;
  backdrop-filter: blur(6px);
}
.msg.user .bubble { border-color: rgba(255, 182, 72, 0.35); background: rgba(32, 24, 8, 0.6); }
.msg.jarvis .bubble { box-shadow: inset 0 0 30px rgba(51, 225, 255, 0.06); }

.sources { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.sources a {
  display: block;
  padding: 8px 10px;
  border-left: 2px solid var(--cyan);
  background: rgba(51, 225, 255, 0.05);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
}
.sources a:hover { background: rgba(51, 225, 255, 0.12); }
.sources a small { color: var(--muted); display: block; margin-top: 3px; }

.thinking { color: var(--cyan); font-size: 13px; letter-spacing: 2px; }
.thinking::after { content: "▮"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- input ---------- */
.ask {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 16px 0 20px;
  background: linear-gradient(0deg, var(--bg) 60%, transparent);
}
.ask input {
  flex: 1;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid rgba(51, 225, 255, 0.3);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}
.ask input:focus { border-color: var(--cyan); box-shadow: 0 0 16px rgba(51, 225, 255, 0.25); }
.ask button {
  width: 52px;
  border: 1px solid var(--cyan);
  background: rgba(51, 225, 255, 0.12);
  color: var(--cyan);
  font-size: 18px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
.ask button:hover { background: rgba(51, 225, 255, 0.28); }
.ask button:disabled { opacity: 0.4; cursor: wait; }

.ver {
  position: relative;
  z-index: 2;
  text-align: center;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  padding: 10px;
}
