/* JARVIS — Holographic HUD */
:root {
  --bg-0: #0a0806;
  --bg-1: #120c08;
  --bg-2: #1a1108;
  --ink-0: #fff4e0;
  --ink-1: #ffd9a8;
  --ink-2: #c89464;
  --ink-3: #6e4f30;
  --primary: #ffb347;
  --primary-soft: #ffb34733;
  --primary-line: #ffb34755;
  --hot: #ff5e3a;
  --hot-soft: #ff5e3a33;
  --good: #7cffb0;
  --warn: #ffb347;
  --crit: #ff5e3a;
  --glass: rgba(28, 18, 10, 0.55);
  --glass-line: rgba(255, 179, 71, 0.18);
  --glass-line-strong: rgba(255, 179, 71, 0.4);
  --grid: rgba(255, 179, 71, 0.06);
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-ui: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--ink-0);
  font-family: var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(255, 94, 58, 0.06), transparent 70%),
    radial-gradient(ellipse 60% 80% at 50% 100%, rgba(255, 179, 71, 0.04), transparent 70%),
    var(--bg-0);
}

/* ------------ Subtle scanline + grid overlay ------------ */
.scanlines {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255, 179, 71, 0.015) 50%, transparent 50%);
  background-size: 100% 3px;
  pointer-events: none;
  z-index: 100;
  mix-blend-mode: screen;
}
.vignette {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
  z-index: 99;
}
.bg-grid {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* ------------ Glass card ------------ */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 2px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 180, 0.04),
    0 24px 60px -12px rgba(0, 0, 0, 0.6);
  position: relative;
}
.glass::before, .glass::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border: 1px solid var(--primary);
  pointer-events: none;
}
.glass::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.glass::after { bottom: -1px; right: -1px; border-left: none; border-top: none; }

.glass-corner-tl, .glass-corner-tr, .glass-corner-bl, .glass-corner-br {
  position: absolute;
  width: 8px; height: 8px;
  border: 1px solid var(--primary);
  pointer-events: none;
}
.glass-corner-tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
.glass-corner-bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }

/* ------------ Type ------------ */
.mono { font-family: var(--font-mono); }
.label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.label-hot { color: var(--hot); }
.label-primary { color: var(--primary); }

/* ------------ HUD panel chrome ------------ */
.panel {
  display: flex; flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--glass-line);
}
.panel-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--primary);
  display: flex; align-items: center; gap: 8px;
}
.panel-title-id {
  color: var(--ink-3);
  font-size: 9px;
  letter-spacing: 0.16em;
}
.panel-status {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--good);
  display: inline-flex; align-items: center; gap: 6px;
}
.panel-status::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.interface-header {
  min-height: 56px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background:
    linear-gradient(90deg, rgba(74, 211, 255, 0.045), transparent 42%, rgba(255, 0, 221, 0.035)),
    rgba(5, 12, 20, 0.24);
}
.interface-id {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-cluster {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.status-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid rgba(74, 211, 255, 0.18);
  background: rgba(4, 15, 26, 0.56);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: inset 0 0 16px rgba(74, 211, 255, 0.04);
}
.status-pill strong {
  color: var(--primary);
  font-size: 10px;
  letter-spacing: 0.08em;
}
.status-pill.dim {
  color: var(--ink-3);
}
.status-pill.secure {
  color: var(--good);
  border-color: rgba(112, 255, 173, 0.18);
}
.status-pill.voice-toggle {
  cursor: pointer;
  border-color: rgba(74, 211, 255, 0.22);
  color: var(--primary);
  appearance: none;
}
.status-pill.signout-pill {
  cursor: pointer;
  color: var(--ink-3);
  border-color: rgba(255, 179, 71, 0.18);
  background: rgba(255, 179, 71, 0.035);
}
.status-pill.signout-pill:hover {
  color: var(--hot);
  border-color: rgba(255, 94, 58, 0.4);
  background: rgba(255, 94, 58, 0.07);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--good);
  box-shadow: 0 0 12px rgba(112, 255, 173, 0.65);
  animation: pulse-dot 2.4s ease-in-out infinite;
}

/* ------------ Floating positions ------------ */
.hud-root {
  position: fixed; inset: 0;
  z-index: 10;
  pointer-events: none;
}
.hud-root > * { pointer-events: auto; }

/* ------------ Buttons ------------ */
.btn {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--glass-line);
  color: var(--ink-1);
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 0;
}
.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.btn-hot:hover {
  border-color: var(--hot);
  color: var(--hot);
  background: var(--hot-soft);
}
.voice-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
.voice-toggle:hover {
  border-color: var(--primary);
  color: var(--primary-2);
  background: rgba(74, 211, 255, 0.13);
}
.voice-toggle.wake-listening {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(74, 211, 255, 0.14);
  box-shadow: 0 0 16px rgba(74, 211, 255, 0.18), inset 0 0 18px rgba(74, 211, 255, 0.1);
}
.voice-pulse {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(74, 211, 255, 0.45), 0 0 12px rgba(74, 211, 255, 0.7);
  animation: voicePulse 1.8s ease-out infinite;
}
.voice-toggle:not(.wake-listening) .voice-pulse {
  animation-duration: 2.8s;
  opacity: 0.72;
}
.voice-toggle.wake-listening .voice-pulse {
  animation-duration: 1.15s;
}
@keyframes voicePulse {
  0% { transform: scale(0.86); box-shadow: 0 0 0 0 rgba(74, 211, 255, 0.46), 0 0 10px rgba(74, 211, 255, 0.65); }
  70% { transform: scale(1); box-shadow: 0 0 0 9px rgba(74, 211, 255, 0), 0 0 16px rgba(74, 211, 255, 0.8); }
  100% { transform: scale(0.86); box-shadow: 0 0 0 0 rgba(74, 211, 255, 0), 0 0 10px rgba(74, 211, 255, 0.65); }
}

/* ------------ Streaming caret ------------ */
.caret {
  display: inline-block;
  width: 7px; height: 14px;
  background: var(--primary);
  vertical-align: -2px;
  margin-left: 2px;
  animation: caret-blink 0.9s steps(2) infinite;
  box-shadow: 0 0 8px var(--primary);
}
@keyframes caret-blink {
  50% { opacity: 0; }
}

/* ------------ Input ------------ */
.composer-form {
  position: relative;
  min-height: 64px;
  padding: 8px 68px;
  border-top: 1px solid var(--glass-line);
  display: flex;
  align-items: flex-end;
  background:
    linear-gradient(90deg, rgba(74, 211, 255, 0.04), rgba(255, 179, 71, 0.03) 50%, rgba(255, 0, 221, 0.035)),
    rgba(255, 179, 71, 0.03);
}

.chat-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  max-height: 160px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink-0);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  padding: 13px 0;
  caret-color: var(--primary);
  resize: none;
  overflow-y: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-input::placeholder {
  color: var(--ink-3);
  font-style: italic;
}

/* ------------ Scrollbar ------------ */
.scroll {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-line) transparent;
}
.scroll::-webkit-scrollbar { width: 4px; }
.scroll::-webkit-scrollbar-thumb {
  background: var(--primary-line);
}
.scroll::-webkit-scrollbar-track { background: transparent; }

/* ------------ Telemetry bar ------------ */
.tele-bar {
  height: 4px;
  background: rgba(255, 179, 71, 0.08);
  position: relative;
  overflow: hidden;
}
.tele-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--primary), var(--hot));
  box-shadow: 0 0 8px var(--primary);
  transition: width 0.6s ease;
}

/* ------------ Marquee scanner line ------------ */
.scanner {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.6;
  animation: scan 4s linear infinite;
  pointer-events: none;
}
@keyframes scan {
  0% { top: 0; }
  100% { top: 100%; }
}

/* ------------ Chat bubbles ------------ */
.msg {
  margin-bottom: 18px;
  font-size: 15px;
  line-height: 1.6;
}
.msg-meta {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
  display: flex; gap: 10px; align-items: center;
}
.msg-user .msg-meta { color: var(--ink-2); }
.msg-ai .msg-meta { color: var(--primary); }
.msg-body {
  color: var(--ink-0);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.msg-user .msg-body {
  color: var(--ink-1);
  border-left: 2px solid var(--ink-3);
  padding-left: 14px;
}
.msg-ai .msg-body {
  border-left: 2px solid var(--primary);
  padding-left: 14px;
  text-shadow: 0 0 12px rgba(255, 179, 71, 0.15);
}
.msg-error .msg-body {
  border-left: 2px solid var(--hot);
  padding-left: 14px;
  color: var(--hot);
}

/* ------------ Tool invocation ------------ */
.tool-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-line);
  padding: 4px 8px;
  margin-right: 6px;
}

/* ------------ Density variants ------------ */
[data-density="sparse"] .panel { padding: 18px 20px; gap: 14px; }
[data-density="dense"] .panel { padding: 10px 12px; gap: 6px; font-size: 12px; }
[data-density="dense"] .msg { font-size: 13px; margin-bottom: 12px; }

/* ------------ Motion off ------------ */
[data-motion="off"] *,
[data-motion="off"] *::before,
[data-motion="off"] *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition: none !important;
}

/* ------------ Layout variants ------------ */
[data-layout="centered"] .hud-side { opacity: 0.55; }
[data-layout="focus"] .hud-side { display: none; }
[data-layout="focus"] .chat-shell { width: min(900px, 92vw); }

/* ------------ Misc ------------ */
.kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid var(--glass-line);
  padding: 1px 5px;
  color: var(--ink-2);
  letter-spacing: 0.06em;
}

.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-sm { gap: 6px; }
.gap-md { gap: 10px; }
.gap-lg { gap: 16px; }
.between { justify-content: space-between; }

/* tabular numbers for telemetry */
.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============== MOBILE ============== */
.mobile-only { display: none; }

.control-icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice-icon-button {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--primary-line);
  border-radius: 999px;
  background: rgba(74, 211, 255, 0.08);
  color: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 18px rgba(74, 211, 255, 0.16), inset 0 0 18px rgba(74, 211, 255, 0.08);
}

.voice-icon-button.active {
  border-color: var(--hot);
  color: var(--hot);
  background: rgba(255, 94, 58, 0.12);
  box-shadow: 0 0 14px rgba(255, 94, 58, 0.28), inset 0 0 18px rgba(255, 94, 58, 0.12);
}

.send-icon-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  flex: 0 0 48px;
  width: 48px;
  height: 44px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(74, 211, 255, 0.05);
  color: var(--ink-3);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.send-icon-button.ready {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(74, 211, 255, 0.12);
  box-shadow: 0 0 18px rgba(74, 211, 255, 0.2), inset 0 0 18px rgba(74, 211, 255, 0.08);
}

.send-icon-button.ready:hover,
.voice-icon-button:hover {
  transform: translateY(-1px);
}

.send-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  box-shadow: none;
}

.send-icon {
  transform: translateX(-1px);
}

.mobile-dictation-status {
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding-right: 4px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex; }
  .mobile-dictation-status { display: none !important; }
  .interface-header {
    min-height: auto;
    padding: 10px 12px;
    gap: 10px;
  }
  .interface-id {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .interface-id .panel-title {
    font-size: 9px;
    letter-spacing: 0.16em;
  }
  .status-cluster {
    gap: 5px;
  }
  .status-pill {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 8px;
    letter-spacing: 0.08em;
  }
  .status-pill.dim,
  .status-pill.secure {
    display: none;
  }
  .composer-form {
    min-height: 62px;
    padding: 8px 62px;
  }

  .chat-shell {
    position: fixed !important;
    inset: 56px 0 56px 0 !important;
    transform: none !important;
    width: 100% !important;
    height: auto !important;
    top: 56px !important;
    left: 0 !important;
    padding: 8px;
  }
  .chat-shell .glass {
    border-radius: 0 !important;
  }

  /* Mobile top bar */
  .mob-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 48px;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: rgba(10, 8, 6, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--glass-line);
  }
  .mob-topbar-title {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.32em;
    color: var(--primary);
    font-weight: 500;
  }
  .mob-icon-btn {
    background: transparent;
    border: 1px solid var(--glass-line);
    color: var(--ink-1);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 14px;
    padding: 0;
  }
  .mob-icon-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
  }

  /* Mobile bottom tab bar */
  .mob-tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 52px;
    z-index: 50;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background: rgba(10, 8, 6, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--glass-line);
  }
  .mob-tabbar button {
    flex: 1;
    background: transparent;
    border: none;
    border-top: 2px solid transparent;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px;
  }
  .mob-tabbar button.active {
    color: var(--primary);
    border-top-color: var(--primary);
    background: var(--primary-soft);
  }
  .mob-tabbar .ic {
    font-size: 16px;
    line-height: 1;
  }

  /* Mobile drawer panel */
  .mob-drawer {
    position: fixed;
    top: 48px; left: 0; right: 0; bottom: 52px;
    z-index: 40;
    background: rgba(10, 8, 6, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: drawerSlide 0.25s ease;
  }
  @keyframes drawerSlide {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
  .mob-drawer .glass.panel { width: 100% !important; max-width: 100%; }

  /* Sign-in console mobile */
  .signin-card {
    grid-template-columns: 1fr !important;
    height: auto !important;
    width: 92vw !important;
    max-height: 90vh;
    overflow-y: auto;
  }
  .signin-card > div:first-child {
    border-right: none !important;
    border-bottom: 1px solid var(--glass-line);
    padding: 24px 22px !important;
  }
  .signin-card > div:last-child {
    padding: 18px 22px !important;
  }
  .signin-card h1 {
    font-size: 20px !important;
  }
  .signin-scanner {
    height: 200px !important;
    flex: 0 0 200px !important;
  }

  /* Hide scanlines on mobile - too noisy */
  .scanlines { opacity: 0.5; }

  /* Smaller chat input */
  .chat-input {
    font-size: 16px;
    line-height: 1.4;
    min-height: 44px;
    max-height: 132px;
    padding: 11px 0;
  }
  .voice-icon-button {
    left: 8px;
    bottom: 8px;
  }
  .send-icon-button {
    right: 8px;
    bottom: 8px;
    width: 44px;
    height: 44px;
  }
  .msg { font-size: 14px; }
}

/* Even tighter on small phones */
@media (max-width: 380px) {
  .mob-topbar-title { font-size: 11px; letter-spacing: 0.24em; }
  .mob-tabbar button { font-size: 8px; }
  .composer-form { padding-left: 58px; padding-right: 56px; }
  .voice-icon-button,
  .send-icon-button {
    width: 42px;
    height: 42px;
  }
}
