/* Jarvis HUD — tech-noir aesthetic.
   Dark void background, cyan arc-reactor accents, scan-lines, monospace numerics. */

:root {
  --jv-bg: #050a10;
  --jv-bg-panel: #0a141d;
  --jv-bg-soft: #0d1a25;
  --jv-fg: #e8f4ff;
  --jv-fg-dim: #6f8aa0;
  --jv-fg-faint: #3a566c;
  --jv-cyan: #5cf2ff;
  --jv-cyan-dim: #2cb5c9;
  --jv-amber: #ffb454;
  --jv-red: #ff5577;
  --jv-grid: rgba(92, 242, 255, 0.05);
  --jv-grid-strong: rgba(92, 242, 255, 0.10);
  --font-display: "Orbitron", "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@300;400;500&family=Orbitron:wght@500;600;700&display=swap");

* { box-sizing: border-box; }

html, body {
  background: var(--jv-bg);
  color: var(--jv-fg);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

/* Subtle animated grid background */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--jv-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--jv-grid) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* Faint scan-line overlay */
body::after {
  content: "";
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(92, 242, 255, 0.02) 0px,
    rgba(92, 242, 255, 0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: screen;
}

main, .jv-z { position: relative; z-index: 2; }

/* Display fonts */
.jv-display { font-family: var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; }
.jv-mono    { font-family: var(--font-mono); }

/* Panels — corners cut at 8px */
.jv-panel {
  background: linear-gradient(180deg, var(--jv-bg-panel), var(--jv-bg-soft));
  border: 1px solid rgba(92, 242, 255, 0.18);
  border-radius: 6px;
  position: relative;
  box-shadow:
    inset 0 0 24px rgba(92, 242, 255, 0.04),
    0 1px 0 rgba(255, 255, 255, 0.02);
}
.jv-panel::before, .jv-panel::after {
  content: ""; position: absolute; width: 12px; height: 12px;
  border-color: var(--jv-cyan); border-style: solid; border-width: 0;
}
.jv-panel::before { top: -1px; left: -1px;  border-top-width: 1px; border-left-width: 1px; }
.jv-panel::after  { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

/* Glow utility */
.jv-glow      { box-shadow: 0 0 18px rgba(92, 242, 255, 0.20), 0 0 60px rgba(92, 242, 255, 0.06); }
.jv-glow-soft { box-shadow: 0 0 8px rgba(92, 242, 255, 0.18); }
.jv-text-glow { text-shadow: 0 0 12px rgba(92, 242, 255, 0.55); }

/* Inputs */
.jv-input {
  background: rgba(8, 18, 28, 0.7);
  border: 1px solid rgba(92, 242, 255, 0.22);
  color: var(--jv-fg);
  border-radius: 4px;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.jv-input::placeholder { color: var(--jv-fg-faint); }
.jv-input:focus {
  border-color: var(--jv-cyan);
  box-shadow: 0 0 0 3px rgba(92, 242, 255, 0.10), 0 0 20px rgba(92, 242, 255, 0.18);
  background: rgba(12, 26, 38, 0.9);
}

/* Buttons */
.jv-btn {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.7rem 1.2rem;
  border: 1px solid var(--jv-cyan);
  background: linear-gradient(180deg, rgba(92, 242, 255, 0.12), rgba(92, 242, 255, 0.04));
  color: var(--jv-cyan);
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s ease;
  position: relative;
}
.jv-btn:hover { background: rgba(92, 242, 255, 0.18); box-shadow: 0 0 24px rgba(92, 242, 255, 0.35); color: #fff; }
.jv-btn:active { transform: translateY(1px); }
.jv-btn-ghost {
  border-color: rgba(92, 242, 255, 0.25);
  background: transparent;
  color: var(--jv-fg-dim);
}
.jv-btn-ghost:hover { color: var(--jv-cyan); border-color: var(--jv-cyan); box-shadow: 0 0 12px rgba(92, 242, 255, 0.20); }
.jv-btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border-radius: 4px;
}

/* Arc reactor — used on login + as loading indicator */
.arc-reactor {
  --size: 220px;
  width: var(--size); height: var(--size);
  position: relative;
  filter: drop-shadow(0 0 30px rgba(92, 242, 255, 0.55));
}
.arc-reactor svg { width: 100%; height: 100%; }
.arc-spin     { transform-origin: center; animation: arc-spin 12s linear infinite; }
.arc-spin-rev { transform-origin: center; animation: arc-spin 18s linear infinite reverse; }
.arc-pulse    { transform-origin: center; animation: arc-pulse 2.4s ease-in-out infinite; }
.arc-breathe  { transform-origin: center; animation: arc-breathe 4.2s ease-in-out infinite; }
@keyframes arc-spin  { to { transform: rotate(360deg); } }
@keyframes arc-pulse { 0%,100% { opacity: 0.85; } 50% { opacity: 1; transform: scale(1.04); } }
@keyframes arc-breathe {
  0%,100% { filter: drop-shadow(0 0 18px rgba(92,242,255,0.45)); }
  50%     { filter: drop-shadow(0 0 38px rgba(92,242,255,0.85)); }
}

/* Status pill */
.jv-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0.18rem 0.55rem;
  border: 1px solid rgba(92, 242, 255, 0.25);
  border-radius: 999px;
  color: var(--jv-cyan-dim);
}
.jv-pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--jv-cyan); box-shadow: 0 0 8px var(--jv-cyan);
  animation: dot-pulse 1.6s ease-in-out infinite;
}
@keyframes dot-pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

/* Sidebar list items */
.jv-conv-item {
  display: block; padding: 0.55rem 0.75rem; margin: 0.15rem 0;
  border-left: 2px solid transparent;
  color: var(--jv-fg-dim);
  font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-radius: 0 4px 4px 0;
  transition: all .12s ease;
}
.jv-conv-item:hover  { color: var(--jv-fg); background: rgba(92, 242, 255, 0.04); border-left-color: var(--jv-cyan-dim); }
.jv-conv-active      { color: var(--jv-cyan); background: rgba(92, 242, 255, 0.08); border-left-color: var(--jv-cyan); }

/* Chat message bubbles */
.jv-msg-user {
  align-self: flex-end;
  background: linear-gradient(180deg, rgba(92, 242, 255, 0.10), rgba(92, 242, 255, 0.04));
  border: 1px solid rgba(92, 242, 255, 0.25);
  padding: 0.7rem 1rem;
  border-radius: 4px 4px 4px 12px;
  max-width: 85%;
  white-space: pre-wrap;
}
.jv-msg-assistant {
  align-self: flex-start;
  border-left: 2px solid var(--jv-cyan-dim);
  padding: 0.2rem 0 0.2rem 1rem;
  max-width: 90%;
  white-space: pre-wrap;
  color: var(--jv-fg);
}
.jv-msg-label {
  font-family: var(--font-display);
  font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--jv-fg-faint);
  margin-bottom: 0.3rem;
}

/* Typing cursor */
.jv-cursor::after {
  content: "▋";
  color: var(--jv-cyan);
  margin-left: 2px;
  animation: cursor-blink 1s steps(2) infinite;
}
@keyframes cursor-blink { to { opacity: 0; } }

/* Voice waveform */
.jv-wave { display: inline-flex; gap: 2px; align-items: center; height: 14px; }
.jv-wave span {
  display: inline-block; width: 2px; background: var(--jv-cyan);
  animation: wave 0.9s ease-in-out infinite;
}
.jv-wave span:nth-child(1) { animation-delay: 0.0s; }
.jv-wave span:nth-child(2) { animation-delay: 0.1s; }
.jv-wave span:nth-child(3) { animation-delay: 0.2s; }
.jv-wave span:nth-child(4) { animation-delay: 0.3s; }
.jv-wave span:nth-child(5) { animation-delay: 0.4s; }
@keyframes wave { 0%,100% { height: 4px; } 50% { height: 14px; } }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(92, 242, 255, 0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(92, 242, 255, 0.30); }

/* Selection */
::selection { background: rgba(92, 242, 255, 0.30); color: #fff; }

/* HUD corner brackets */
.jv-corner {
  position: absolute; width: 16px; height: 16px;
  border: 1px solid var(--jv-cyan); opacity: 0.5;
}
.jv-corner-tl { top: 8px; left: 8px;     border-right: 0; border-bottom: 0; }
.jv-corner-tr { top: 8px; right: 8px;    border-left: 0;  border-bottom: 0; }
.jv-corner-bl { bottom: 8px; left: 8px;  border-right: 0; border-top: 0;    }
.jv-corner-br { bottom: 8px; right: 8px; border-left: 0;  border-top: 0;    }

/* ====================== Markdown in chat replies ====================== */
.jv-msg-assistant p { margin: 0 0 0.6em 0; }
.jv-msg-assistant p:last-child { margin-bottom: 0; }
.jv-msg-assistant ul, .jv-msg-assistant ol { padding-left: 1.4em; margin: 0.4em 0; }
.jv-msg-assistant li { margin: 0.2em 0; }
.jv-msg-assistant h1, .jv-msg-assistant h2, .jv-msg-assistant h3 {
  font-family: var(--font-display); letter-spacing: 0.06em;
  color: var(--jv-cyan); margin: 0.8em 0 0.4em 0;
}
.jv-msg-assistant h1 { font-size: 1.15rem; }
.jv-msg-assistant h2 { font-size: 1.05rem; }
.jv-msg-assistant h3 { font-size: 0.95rem; }
.jv-msg-assistant code {
  background: rgba(92,242,255,0.10);
  border: 1px solid rgba(92,242,255,0.20);
  padding: 1px 5px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 0.85em;
  color: var(--jv-cyan);
}
.jv-msg-assistant pre {
  background: var(--jv-bg-soft);
  border: 1px solid rgba(92,242,255,0.15);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 0.6em 0;
}
.jv-msg-assistant pre code {
  background: transparent; border: 0; padding: 0; color: var(--jv-fg);
  font-size: 0.82rem; line-height: 1.55;
}
.jv-msg-assistant a { color: var(--jv-cyan); text-decoration: underline; text-decoration-color: rgba(92,242,255,0.4); }
.jv-msg-assistant a:hover { text-decoration-color: var(--jv-cyan); }
.jv-msg-assistant strong { color: #fff; }
.jv-msg-assistant blockquote {
  border-left: 2px solid var(--jv-cyan-dim);
  padding-left: 0.9em; color: var(--jv-fg-dim);
  margin: 0.6em 0;
}
.jv-msg-assistant table {
  border-collapse: collapse; margin: 0.6em 0;
  font-family: var(--font-mono); font-size: 0.85em;
}
.jv-msg-assistant th, .jv-msg-assistant td {
  border: 1px solid rgba(92,242,255,0.20);
  padding: 0.35em 0.6em;
  text-align: left;
}
.jv-msg-assistant th { background: rgba(92,242,255,0.06); color: var(--jv-cyan); }
.jv-msg-assistant hr { border: 0; border-top: 1px solid rgba(92,242,255,0.20); margin: 1em 0; }

/* ====================== Eclipse Treatment Plan visualization ====================== */
/* Real-Eclipse-style 4-quadrant layout with structure sidebar + DVH/fields footer. */
.jv-eclipse-shell {
  display: flex; flex-direction: column;
  background: rgba(5,10,16,0.85);
  border: 1px solid rgba(92,242,255,0.18);
  border-radius: 4px;
  overflow: hidden;
  font-family: var(--font-mono);
  width: 100%;
  height: 100%;
  min-height: 0;
}
.jv-eclipse-toolbar {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.4rem 0.7rem;
  background: linear-gradient(180deg, rgba(92,242,255,0.08), rgba(92,242,255,0.02));
  border-bottom: 1px solid rgba(92,242,255,0.18);
}
.jv-eclipse-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  /* Explicit height so the 2x2 quad grid below has rows to fill. Without this,
     each quadrant collapses to its min-height and Plotly can't auto-size.
     Sized to roughly 70% of viewport so the diagnostic detail is readable. */
  height: clamp(520px, 72vh, 1050px);
  flex: 1 1 auto;
  min-height: 0;
}
.jv-eclipse-side {
  padding: 0.6rem 0.8rem;
  border-right: 1px solid rgba(92,242,255,0.10);
  background: rgba(8,18,28,0.6);
  font-size: 0.78rem;
  overflow-y: auto;
}
.jv-eclipse-side-h {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--jv-cyan-dim);
  padding-bottom: 0.3rem;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid rgba(92,242,255,0.10);
}
.jv-eclipse-structs {
  display: flex; flex-direction: column; gap: 0.3rem;
  font-size: 0.7rem; color: var(--jv-fg-dim);
}
.jv-eclipse-structs li:first-child { color: var(--jv-cyan); font-weight: 500; }
.jv-eclipse-side .jv-k {
  display: inline-block; min-width: 38px; margin-right: 0.4rem;
  padding: 0 0.3rem; font-size: 0.5rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--jv-cyan); border: 1px solid rgba(92,242,255,0.25); border-radius: 2px;
}

/* Quadrant grid (axial / BEV / coronal / sagittal) */
.jv-eclipse-quad {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  background: rgba(92,242,255,0.12);
  height: 100%;
  min-height: 0;  /* allow rows to shrink to fit container */
}
.jv-eclipse-q {
  position: relative;
  background: #050a10;
  min-height: 0;
  overflow: hidden;
}
/* Plotly hosts fill the quadrant absolutely so they have a real size to size to. */
.jv-eclipse-q > div {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

.jv-eclipse-bottom {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 0;
  border-top: 1px solid rgba(92,242,255,0.18);
}
.jv-eclipse-dvh-wrap {
  padding: 0.45rem 0.7rem 0.6rem;
  border-right: 1px solid rgba(92,242,255,0.10);
  background: rgba(8,18,28,0.55);
}
.jv-eclipse-dvh-wrap .jv-eclipse-dvh {
  width: 100%; height: clamp(220px, 26vh, 320px);
}
.jv-eclipse-fields {
  padding: 0.45rem 0.7rem 0.6rem;
  background: rgba(8,18,28,0.55);
}
.jv-eclipse-fields-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--jv-fg-dim);
}
.jv-eclipse-fields-table thead th {
  text-align: left;
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--jv-cyan-dim);
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid rgba(92,242,255,0.18);
}
.jv-eclipse-fields-table tbody td {
  padding: 0.22rem 0.4rem;
  border-bottom: 1px dashed rgba(92,242,255,0.06);
  font-size: 0.65rem;
}
.jv-eclipse-fields-table tbody tr:hover { background: rgba(92,242,255,0.04); }

/* Quadrant labels (drawn as Plotly annotations inside each chart) */
.jv-eclipse-q { font-size: 0.55rem; }

/* 2D / 3D mode toggle inside the toolbar */
.jv-eclipse-mode-btn {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.20em;
  padding: 2px 8px;
  background: rgba(5,10,16,0.6);
  border: 1px solid rgba(92,242,255,0.30);
  border-radius: 3px;
  color: var(--jv-cyan-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}
.jv-eclipse-mode-btn:hover {
  background: rgba(92,242,255,0.10);
  color: var(--jv-cyan);
}
.jv-eclipse-mode-btn.active {
  background: rgba(92,242,255,0.20);
  color: #fff;
  border-color: rgba(92,242,255,0.7);
  box-shadow: 0 0 8px rgba(92,242,255,0.35);
}

/* Mobile collapse */
@media (max-width: 820px) {
  .jv-eclipse-body { grid-template-columns: 1fr; }
  .jv-eclipse-side { border-right: 0; border-bottom: 1px solid rgba(92,242,255,0.10); }
  .jv-eclipse-bottom { grid-template-columns: 1fr; }
  .jv-eclipse-dvh-wrap { border-right: 0; border-bottom: 1px solid rgba(92,242,255,0.10); }
}

/* Mobile tweaks */
@media (max-width: 768px) {
  body::before { background-size: 40px 40px; }
}

/* ====================== Listening overlay ====================== */
.jv-listen {
  position: fixed; inset: 0; z-index: 9999;
  background: radial-gradient(ellipse at center, rgba(5,10,16,0.92) 0%, rgba(5,10,16,0.985) 75%);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
  padding: 1.5rem 1.75rem 1rem;
}
.jv-listen.active {
  display: flex; opacity: 1; pointer-events: auto;
}

/* HUD top bar */
.jv-hud-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.25rem 0.5rem 0.5rem;
  border-bottom: 1px solid rgba(92,242,255,0.18);
  z-index: 4;
}
.jv-hud-title {
  font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.4em;
  color: var(--jv-cyan); text-shadow: 0 0 14px rgba(92,242,255,0.6);
}
.jv-hud-meta {
  display: flex; align-items: center; gap: 1rem;
  font-size: 0.78rem; color: var(--jv-fg-dim);
}
.jv-hud-meta .jv-mono { letter-spacing: 0.18em; }

/* Three-column grid */
.jv-hud-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: 1rem;
  margin: 1rem 0;
  z-index: 4;
  min-height: 0;
}

/* Side panels (chat + log) */
.jv-hud-panel {
  position: relative;
  background: linear-gradient(180deg, rgba(10,20,29,0.65), rgba(13,26,37,0.55));
  border: 1px solid rgba(92,242,255,0.20);
  border-radius: 6px;
  padding: 0.6rem 0.75rem 0.5rem;
  display: flex; flex-direction: column;
  min-height: 0;
  box-shadow: inset 0 0 24px rgba(92,242,255,0.04);
}
.jv-hud-panel-title {
  font-family: var(--font-display); font-size: 0.62rem;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--jv-cyan-dim);
  padding-bottom: 0.4rem; margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(92,242,255,0.10);
}
.jv-hud-stream {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.4rem;
  font-size: 0.82rem;
  line-height: 1.5;
}
.jv-hud-stream.jv-hud-mono { font-family: var(--font-mono); font-size: 0.74rem; color: var(--jv-fg-dim); }

/* Conversation stream rows */
.jv-listen-msg {
  margin: 0.5rem 0;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  border-left: 2px solid transparent;
  white-space: pre-wrap;
  word-break: break-word;
}
.jv-listen-msg-user {
  border-left-color: var(--jv-cyan);
  background: rgba(92,242,255,0.06);
  color: var(--jv-fg);
}
.jv-listen-msg-assistant {
  border-left-color: rgba(92,242,255,0.45);
  color: var(--jv-fg);
}
.jv-listen-msg::before {
  content: attr(data-role);
  display: block;
  font-family: var(--font-display); font-size: 0.55rem;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--jv-fg-faint);
  margin-bottom: 0.15rem;
}

/* Trace log rows */
.jv-log-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 0.4rem;
  padding: 0.18rem 0;
  border-bottom: 1px dashed rgba(92,242,255,0.06);
  font-size: 0.72rem;
}
.jv-log-time { color: var(--jv-fg-faint); }
.jv-log-msg  { color: var(--jv-fg-dim); word-break: break-word; }
.jv-log-msg .jv-log-tag {
  display: inline-block;
  padding: 0 0.3rem;
  margin-right: 0.35rem;
  font-family: var(--font-display); font-size: 0.55rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--jv-cyan);
  border: 1px solid rgba(92,242,255,0.30);
  border-radius: 2px;
}

/* Center stage (reactor + visualizer) */
.jv-hud-stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  overflow: hidden;
}
.jv-hud-stage > .jv-listen-canvas,
.jv-hud-stage > #jv-listen-3d {
  position: absolute;
  width: min(72vmin, 540px); height: min(72vmin, 540px);
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
}
.jv-hud-stage .jv-listen-core {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* Stage takeover — charts / images render here while voice mode is active */
.jv-hud-takeover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  background: radial-gradient(ellipse at center, rgba(5,10,16,0.85) 0%, rgba(5,10,16,0.96) 75%);
  backdrop-filter: blur(2px);
  animation: takeover-fade .25s ease;
}
.jv-hud-takeover.hidden { display: none; }
@keyframes takeover-fade { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

.jv-takeover-card {
  width: min(98%, 1700px);
  max-height: 98%;
  height: 96vh;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  background: linear-gradient(180deg, rgba(10,20,29,0.85), rgba(13,26,37,0.75));
  border: 1px solid rgba(92,242,255,0.30);
  border-radius: 6px;
  box-shadow: 0 0 32px rgba(92,242,255,0.20);
  position: relative;
  overflow-y: auto;
}
.jv-takeover-card .jv-corner { opacity: 0.85; }
.jv-takeover-title {
  font-family: var(--font-display); font-size: 0.7rem; letter-spacing: 0.2em;
  color: var(--jv-cyan); text-shadow: 0 0 10px rgba(92,242,255,0.5);
  text-align: center; margin-bottom: 0.4rem;
}
.jv-takeover-plot { width: 100%; flex: 1; min-height: 50vh; }
.jv-takeover-card .jv-takeover-host { width: 100%; flex: 1; min-height: 0; }
.jv-takeover-image {
  width: 100%; max-height: 70vh; object-fit: contain;
  border-radius: 4px;
}
.jv-takeover-hint {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.22em;
  color: var(--jv-fg-faint); text-transform: uppercase;
  text-align: center; margin-top: 0.4rem;
}
.jv-takeover-close {
  position: absolute; top: 6px; right: 8px;
  width: 26px; height: 26px;
  background: rgba(5,10,16,0.7);
  border: 1px solid rgba(92,242,255,0.35);
  border-radius: 4px;
  color: var(--jv-cyan);
  font-family: var(--font-display); font-size: 18px; line-height: 1;
  cursor: pointer; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
}
.jv-takeover-close:hover {
  background: rgba(92,242,255,0.18);
  border-color: rgba(92,242,255,0.7);
  color: #fff;
  box-shadow: 0 0 12px rgba(92,242,255,0.4);
}
/* Make sure Plotly's modebar shows on hover and is interactable inside the takeover */
.jv-takeover-host .modebar { z-index: 4; }
.jv-takeover-host .js-plotly-plot,
.jv-takeover-host .plot-container { pointer-events: auto !important; }

/* Glow border around the screen edges */
.jv-listen::before {
  content: ""; position: absolute; inset: 0;
  pointer-events: none;
  box-shadow:
    inset 0 0 80px rgba(92,242,255,0.20),
    inset 0 0 200px rgba(92,242,255,0.08);
  animation: edge-pulse 2.4s ease-in-out infinite;
}
@keyframes edge-pulse {
  0%,100% { box-shadow: inset 0 0 80px rgba(92,242,255,0.18), inset 0 0 200px rgba(92,242,255,0.06); }
  50%     { box-shadow: inset 0 0 120px rgba(92,242,255,0.36), inset 0 0 320px rgba(92,242,255,0.14); }
}

/* HUD scan-line in overlay (denser) */
.jv-listen::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(92,242,255,0.04) 0px,
    rgba(92,242,255,0.04) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none; mix-blend-mode: screen;
}

.jv-listen-title {
  font-family: var(--font-display); font-size: 0.75rem; letter-spacing: 0.4em;
  color: var(--jv-cyan); text-shadow: 0 0 14px rgba(92,242,255,0.6);
  position: relative; z-index: 2;
}
.jv-listen-title::before, .jv-listen-title::after {
  content: ""; display: inline-block; width: 36px; height: 1px;
  background: var(--jv-cyan); vertical-align: middle; margin: 0 14px; opacity: 0.6;
}

.jv-listen-stage {
  position: relative;
  width: min(78vmin, 540px); height: min(78vmin, 540px);
  z-index: 2;
}

/* ---- Calendar strip ---- */
.jv-listen .jv-hud-cal {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 0.15rem;
  padding: 0.3rem 0.5rem 0.5rem;
  border-bottom: 1px solid rgba(92,242,255,0.10);
  font-family: var(--font-mono); font-size: 0.62rem;
  overflow-x: auto;
  z-index: 4;
  width: 100%;
}
.jv-hud-cal::-webkit-scrollbar { display: none; }
.jv-cal-day {
  flex: 0 0 auto;
  min-width: 22px;
  text-align: center;
  padding: 2px 4px;
  color: var(--jv-fg-faint);
  border: 1px solid transparent;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.jv-cal-day.is-today {
  color: var(--jv-cyan);
  border-color: var(--jv-cyan);
  box-shadow: 0 0 10px rgba(92,242,255,0.35);
  background: rgba(92,242,255,0.08);
}
.jv-cal-day.is-past { color: var(--jv-fg-dim); }

/* ---- Corner gauges ---- */
.jv-hud-stage .jv-gauge {
  position: absolute !important;
  width: 78px !important;
  height: 78px !important;
  filter: drop-shadow(0 0 6px rgba(92,242,255,0.25));
  pointer-events: none;
  opacity: 0.85;
  z-index: 3;
}
.jv-hud-stage .jv-gauge-tl { top: 8px;    left: 8px;    right: auto; bottom: auto; }
.jv-hud-stage .jv-gauge-tr { top: 8px;    right: 8px;   left: auto;  bottom: auto; }
.jv-hud-stage .jv-gauge-bl { bottom: 8px; left: 8px;    right: auto; top: auto;    }
.jv-hud-stage .jv-gauge-br { bottom: 8px; right: 8px;   left: auto;  top: auto;    }
.jv-gauge circle[id^="jv-gauge-"] {
  transition: stroke-dasharray .8s cubic-bezier(.2,.7,.2,1), stroke .25s ease;
}

/* ---- Connector status row ---- */
.jv-listen .jv-hud-status {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  padding: 0.4rem 0.75rem 0;
  z-index: 4;
  width: 100%;
}
.jv-hud-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  font-family: var(--font-mono); font-size: 0.62rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  border: 1px solid rgba(92,242,255,0.22);
  border-radius: 3px;
  color: var(--jv-fg-dim);
  background: rgba(10,20,29,0.45);
}
.jv-hud-chip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--jv-fg-faint); box-shadow: 0 0 4px var(--jv-fg-faint);
}
.jv-hud-chip.is-on::before { background: var(--jv-cyan); box-shadow: 0 0 8px var(--jv-cyan); animation: dot-pulse 1.6s ease-in-out infinite; }
.jv-hud-chip.is-on { color: var(--jv-cyan-dim); border-color: rgba(92,242,255,0.40); }
.jv-hud-chip.is-warn { color: var(--jv-amber); border-color: rgba(255,180,84,0.35); }
.jv-hud-chip.is-warn::before { background: var(--jv-amber); box-shadow: 0 0 6px var(--jv-amber); }

/* ---- Scrolling activity ticker ---- */
.jv-listen .jv-hud-ticker {
  position: relative;
  margin-top: 0.4rem;
  height: 20px;
  border-top: 1px solid rgba(92,242,255,0.10);
  border-bottom: 1px solid rgba(92,242,255,0.10);
  overflow: hidden !important;
  white-space: nowrap;
  z-index: 4;
  mask-image: linear-gradient(90deg, transparent 0, #000 8%, #000 92%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 8%, #000 92%, transparent 100%);
  width: 100%;
  flex: 0 0 auto;
}
.jv-hud-ticker-track {
  position: absolute; top: 0; left: 0;
  display: inline-flex; gap: 2.4rem;
  font-family: var(--font-mono); font-size: 0.65rem;
  white-space: nowrap;
  line-height: 20px;
  color: var(--jv-fg-dim);
  animation: ticker-scroll 60s linear infinite;
  will-change: transform;
}
.jv-hud-ticker-track .jv-tk-tag {
  color: var(--jv-cyan);
  margin-right: 0.4rem;
}
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* Live telemetry strip — sits between connector chips and transcript */
.jv-listen .jv-hud-telemetry {
  display: flex !important;
  flex-wrap: wrap;
  gap: 0.55rem 1.05rem;
  justify-content: center;
  padding: 0.45rem 0.75rem 0;
  font-family: var(--font-mono);
  font-size: 0.70rem;
  color: var(--jv-fg-dim);
  z-index: 4;
}
.jv-listen .jv-hud-telemetry span { white-space: nowrap; }
.jv-listen .jv-hud-telemetry .t-k {
  display: inline-block;
  padding: 0 0.3rem;
  margin-right: 0.25rem;
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--jv-cyan);
  border: 1px solid rgba(92,242,255,0.30);
  border-radius: 2px;
}

/* Bottom transcript inside the HUD */
.jv-listen-hud .jv-listen-transcript {
  text-align: center;
  padding: 0.4rem 1rem 0;
  z-index: 4;
}
.jv-listen-hud .jv-listen-hint {
  position: relative;
  bottom: auto;
  text-align: center;
  padding: 0.4rem 0 0.2rem;
  z-index: 4;
}

/* Project file tree (inline + HUD takeover) */
.jv-tree {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--jv-fg-dim);
  border: 1px solid rgba(92,242,255,0.10);
  border-radius: 4px;
  padding: 0.45rem 0.6rem;
  background: rgba(8,18,28,0.55);
  max-height: 320px;
  overflow-y: auto;
}
.jv-tree-row {
  padding: 1px 4px;
  border-left: 2px solid transparent;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.jv-tree-row:hover {
  border-left-color: var(--jv-cyan);
  color: var(--jv-fg);
  background: rgba(92,242,255,0.05);
}

/* Mobile: collapse HUD to single column */
@media (max-width: 900px) {
  .jv-hud-grid { grid-template-columns: 1fr; grid-template-rows: 1fr 1.2fr 1fr; }
  .jv-hud-side { max-height: 22vh; }
  .jv-hud-stage > .jv-listen-canvas,
  .jv-hud-stage > #jv-listen-3d { width: min(50vmin, 360px); height: min(50vmin, 360px); }
}
.jv-listen-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.jv-listen-core {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.jv-listen-reactor {
  width: 36%; height: 36%; border-radius: 50%;
  background: radial-gradient(circle at center, #ffffff 0%, #e7feff 25%, #5cf2ff 55%, #1a6f80 90%, transparent 100%);
  filter: drop-shadow(0 0 32px rgba(92,242,255,0.7));
  transform: scale(var(--jv-scale, 1));
  transition: transform .08s ease-out;
}

.jv-listen-transcript {
  font-family: var(--font-mono); font-size: clamp(1.15rem, 2.6vw, 1.65rem);
  color: var(--jv-fg); text-align: center; max-width: 80vw;
  min-height: 1.5em;
  text-shadow: 0 0 12px rgba(92,242,255,0.45);
  line-height: 1.4;
  position: relative; z-index: 2;
}
.jv-listen-transcript .jv-listen-cursor {
  display: inline-block; width: 0.55em; height: 1.05em; vertical-align: -0.15em;
  background: var(--jv-cyan); margin-left: 4px;
  animation: cursor-blink 0.85s steps(2) infinite;
}

.jv-listen-hint {
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 0.3em;
  color: var(--jv-fg-faint); text-transform: uppercase;
  position: absolute; bottom: 2.5rem; z-index: 2;
}

/* Wake-word armed pill on the chat header */
.jv-armed { color: var(--jv-cyan) !important; border-color: var(--jv-cyan) !important; box-shadow: 0 0 12px rgba(92,242,255,0.4); }

/* Hands-free consent gate (first visit) */
.jv-consent {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(5,10,16,0.92); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.jv-consent.hidden { display: none; }
.jv-consent-card {
  max-width: 460px; padding: 2rem;
  text-align: center;
}
