/* ==========================================================================
   JARVIS — holographic HUD
   Dark-only interface. Layout: 3-column HUD >=1100px, 2-column tablet,
   single column + dock on phones (<700px).
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #01050b;
  --panel-bg: linear-gradient(180deg, rgba(7, 30, 52, 0.62), rgba(3, 15, 29, 0.58));
  --panel-solid: rgba(3, 15, 28, 0.95);
  --line: rgba(0, 217, 255, 0.26);
  --line-soft: rgba(0, 217, 255, 0.14);
  --line-strong: rgba(0, 217, 255, 0.55);

  --cyan: #00d9ff;
  --cyan-soft: #6fe8ff;
  --cyan-deep: #0a8fb8;
  --ink: #021220; /* text on cyan fills */
  --text: #daf6ff;
  --text-bright: #effcff;
  --text-dim: #8fb9cb;
  --text-faint: #6a91a3;
  --amber: #ffbe55;
  --red: #ff6b85;
  --green: #4cf2b4;
  --mint: #6dffd6;

  --glow-s: 0 0 8px rgba(0, 217, 255, 0.45);
  --glow-m: 0 0 18px rgba(0, 217, 255, 0.4);

  --font-display: "Orbitron", "Eurostile", "Segoe UI", system-ui, sans-serif;
  --font-body: "Exo 2", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --gutter: 16px;
  --app-h: 100vh;
}
@supports (height: 100dvh) {
  :root { --app-h: 100dvh; }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
* { scrollbar-width: thin; scrollbar-color: rgba(0, 217, 255, 0.35) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0, 217, 255, 0.3); }
::-webkit-scrollbar-track { background: transparent; }
::selection { background: rgba(0, 217, 255, 0.35); color: #fff; }

button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); }
.dim { color: var(--text-dim); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico {
  width: 1em; height: 1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; z-index: 100; top: 8px; left: 8px; padding: 8px 14px;
  background: var(--cyan); color: var(--ink); font-weight: 700; transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--cyan-soft); outline-offset: 2px; }

/* ------------------------------------------------------------- backdrop */
.backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(0, 120, 170, 0.18), transparent 70%),
    radial-gradient(ellipse 130% 70% at 50% 108%, #08304a 0%, #041626 42%, #01060d 100%);
}
.bd-sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 40% 30% at 82% 18%, rgba(120, 70, 200, 0.12), transparent 70%),
    radial-gradient(ellipse 35% 25% at 12% 30%, rgba(0, 160, 220, 0.1), transparent 70%);
}
.bd-city {
  position: absolute; left: -3%; right: -3%; bottom: -2%; height: 64%;
  background: url("assets/skyline.svg") center bottom / cover no-repeat;
  filter: blur(3px) saturate(1.15);
  opacity: 0.6;
}
.bd-bokeh {
  position: absolute; inset: 0; filter: blur(7px); opacity: 0.75;
  background:
    radial-gradient(circle at 8% 78%, rgba(255, 184, 92, 0.45) 0 7px, transparent 9px),
    radial-gradient(circle at 15% 64%, rgba(0, 217, 255, 0.35) 0 11px, transparent 13px),
    radial-gradient(circle at 23% 83%, rgba(255, 220, 160, 0.3) 0 5px, transparent 7px),
    radial-gradient(circle at 31% 71%, rgba(255, 120, 160, 0.25) 0 9px, transparent 11px),
    radial-gradient(circle at 38% 90%, rgba(0, 217, 255, 0.3) 0 6px, transparent 8px),
    radial-gradient(circle at 46% 76%, rgba(255, 190, 110, 0.3) 0 13px, transparent 15px),
    radial-gradient(circle at 54% 86%, rgba(160, 230, 255, 0.3) 0 7px, transparent 9px),
    radial-gradient(circle at 61% 68%, rgba(255, 184, 92, 0.3) 0 5px, transparent 7px),
    radial-gradient(circle at 68% 80%, rgba(0, 217, 255, 0.35) 0 10px, transparent 12px),
    radial-gradient(circle at 76% 92%, rgba(255, 210, 150, 0.35) 0 8px, transparent 10px),
    radial-gradient(circle at 83% 72%, rgba(255, 120, 160, 0.22) 0 12px, transparent 14px),
    radial-gradient(circle at 90% 84%, rgba(0, 217, 255, 0.3) 0 6px, transparent 8px),
    radial-gradient(circle at 96% 66%, rgba(255, 184, 92, 0.35) 0 9px, transparent 11px),
    radial-gradient(circle at 4% 92%, rgba(160, 230, 255, 0.25) 0 10px, transparent 12px);
}
.bd-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(0, 217, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 217, 255, 0.05) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 42%, #000 25%, transparent 85%);
          mask-image: radial-gradient(ellipse 80% 70% at 50% 42%, #000 25%, transparent 85%);
}
.bd-scan {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 3px);
}
.bd-scan::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 160px;
  background: linear-gradient(180deg, transparent, rgba(0, 217, 255, 0.045), transparent);
  transform: translateY(-160px);
  animation: sweepDown 11s linear infinite;
}
.bd-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 40%, rgba(0, 0, 0, 0.7) 100%);
}

/* --------------------------------------------------------------- layout */
.hud {
  position: relative; z-index: 1;
  height: var(--app-h);
  display: grid;
  grid-template-columns: minmax(260px, 310px) minmax(0, 1fr) minmax(260px, 310px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top top top"
    "left center right"
    "bottom bottom bottom";
  gap: 14px 16px;
  padding: 0 calc(var(--gutter) + var(--sar)) calc(12px + var(--sab)) calc(var(--gutter) + var(--sal));
}
@media (min-width: 1500px) {
  .hud { grid-template-columns: 330px minmax(0, 1fr) 330px; gap: 16px 20px; }
}
.side { display: contents; }
.topbar { grid-area: top; }
.col-left { grid-area: left; }
.col-center { grid-area: center; }
.col-right { grid-area: right; }
.bottombar { grid-area: bottom; }

.col {
  display: flex; flex-direction: column; gap: 14px;
  min-height: 0; min-width: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
}
.col-left, .col-right { padding: 2px 4px 2px 2px; margin: -2px -4px -2px -2px; }
.col-center { overflow: hidden; gap: 10px; }

/* ---------------------------------------------------------------- panel */
.panel {
  position: relative;
  flex: none;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 0 0 1px rgba(0, 217, 255, 0.04),
    inset 0 0 28px rgba(0, 217, 255, 0.05),
    0 0 22px rgba(0, 217, 255, 0.06),
    0 10px 30px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
          backdrop-filter: blur(12px) saturate(140%);
  animation: panelIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
/* corner brackets */
.panel::before, .drawer::before, .dialog-card::before {
  content: ""; position: absolute; inset: -1px; pointer-events: none; z-index: 2;
  --b: var(--cyan);
  background:
    linear-gradient(var(--b), var(--b)) top left / 14px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) top left / 2px 14px no-repeat,
    linear-gradient(var(--b), var(--b)) top right / 14px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) top right / 2px 14px no-repeat,
    linear-gradient(var(--b), var(--b)) bottom left / 14px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) bottom left / 2px 14px no-repeat,
    linear-gradient(var(--b), var(--b)) bottom right / 14px 2px no-repeat,
    linear-gradient(var(--b), var(--b)) bottom right / 2px 14px no-repeat;
  filter: drop-shadow(0 0 4px rgba(0, 217, 255, 0.9));
}
.col-left .panel:nth-child(2), .col-right .panel:nth-child(2) { animation-delay: 0.08s; }
.col-left .panel:nth-child(3), .col-right .panel:nth-child(3) { animation-delay: 0.16s; }
.panel.pulse { animation: panelPulse 1.3s ease-out; }

.panel-head {
  display: flex; align-items: center; gap: 8px;
  min-height: 38px;
  padding: 9px 12px 8px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(90deg, rgba(0, 217, 255, 0.1), transparent 70%);
}
.panel-head h2 {
  display: flex; align-items: center; gap: 9px;
  margin: 0;
  font: 700 11px/1 var(--font-display);
  letter-spacing: 0.22em;
  color: var(--cyan);
  text-shadow: var(--glow-s);
  white-space: nowrap;
}
.panel-head h2::before {
  content: ""; width: 6px; height: 6px; flex: none;
  background: var(--cyan); transform: rotate(45deg);
  box-shadow: 0 0 8px var(--cyan);
}
.panel-head .meta {
  margin-left: auto;
  font: 500 10.5px/1 var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.panel-head .meta:empty { flex: 1; }
.panel-body { padding: 12px 14px 14px; }
.panel-msg { margin: 0; font-size: 13px; color: var(--text-dim); list-style: none; }
.panel-msg.bad { color: var(--red); }
.is-loading .panel-head h2::after {
  content: ""; width: 22px; height: 2px; margin-left: 4px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  animation: blink 0.8s ease-in-out infinite alternate;
}

/* small buttons */
.head-btn {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  min-height: 24px; padding: 4px 7px;
  background: transparent; color: var(--text-dim);
  border: 1px solid rgba(0, 217, 255, 0.28);
  font: 600 9px/1 var(--font-display); letter-spacing: 0.14em;
  cursor: pointer; transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.head-btn .ico { width: 13px; height: 13px; }
.head-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.head-btn[aria-pressed="true"] { background: var(--cyan); color: var(--ink); border-color: var(--cyan); }
.head-btn.icon-only { padding: 4px 5px; }

.mini-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 8px; min-height: 26px;
  background: transparent; color: var(--text-dim);
  border: 1px solid rgba(0, 217, 255, 0.22);
  font: 600 9.5px/1 var(--font-display); letter-spacing: 0.14em;
  cursor: pointer; transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.mini-btn .ico { width: 13px; height: 13px; }
.mini-btn:hover { color: var(--cyan); border-color: var(--cyan); background: rgba(0, 217, 255, 0.08); }
.mini-btn.accent { color: var(--cyan); border-color: rgba(0, 217, 255, 0.5); }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px;
  background: transparent; color: var(--text-dim);
  border: 1px solid rgba(0, 217, 255, 0.22);
  cursor: pointer; transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn .ico { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.icon-btn.danger:hover, .icon-btn.is-armed { color: #fff; border-color: var(--red); background: rgba(255, 107, 133, 0.22); }
.arm-tip {
  position: absolute; right: calc(100% + 6px); top: 50%; transform: translateY(-50%);
  padding: 4px 7px; white-space: nowrap;
  background: var(--red); color: #1a0007;
  font: 700 9.5px/1 var(--font-display); letter-spacing: 0.12em;
}
.link-btn {
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--cyan); font: 600 9.5px/1 var(--font-display); letter-spacing: 0.16em;
}
.primary-btn, .ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 9px 16px;
  font: 700 11px/1 var(--font-display); letter-spacing: 0.18em;
  cursor: pointer; transition: background 0.15s, box-shadow 0.15s, color 0.15s, border-color 0.15s;
}
.primary-btn {
  background: var(--cyan); color: var(--ink); border: 1px solid var(--cyan);
  box-shadow: 0 0 16px rgba(0, 217, 255, 0.45);
}
.primary-btn:hover { background: var(--cyan-soft); box-shadow: 0 0 24px rgba(0, 217, 255, 0.7); }
.primary-btn .ico { width: 16px; height: 16px; }
.ghost-btn { background: rgba(0, 217, 255, 0.05); color: var(--cyan); border: 1px solid rgba(0, 217, 255, 0.4); }
.ghost-btn:hover { background: rgba(0, 217, 255, 0.14); border-color: var(--cyan); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* --------------------------------------------------------------- topbar */
.topbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding-top: calc(8px + var(--sat));
  padding-bottom: 4px;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line) 12%, var(--line) 35%, transparent 42%, transparent 58%, var(--line) 65%, var(--line) 88%, transparent);
}
.tb-left { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.voice-ind, .uplink {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 10px;
  font: 600 10px/1 var(--font-display); letter-spacing: 0.18em;
  color: var(--text-dim);
  border: 1px solid var(--line-soft);
  background: linear-gradient(90deg, rgba(0, 217, 255, 0.1), rgba(0, 217, 255, 0.02));
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
  white-space: nowrap; max-width: 100%;
}
.voice-ind .dot, .uplink .dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan);
}
.vi-state, .ul-state { color: var(--cyan); }
.voice-ind[data-state="active"] { color: var(--text); border-color: rgba(255, 107, 133, 0.5); }
.voice-ind[data-state="active"] .dot { background: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 0.9s ease-in-out infinite alternate; }
.voice-ind[data-state="active"] .vi-state { color: var(--red); }
.voice-ind[data-state="off"] .dot { background: var(--text-faint); box-shadow: none; }
.voice-ind[data-state="off"] .vi-state { color: var(--text-faint); }
.uplink { font-size: 9px; padding: 4px 12px 4px 10px; }
.uplink .dot { width: 6px; height: 6px; }
.uplink[data-state="online"] .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.uplink[data-state="online"] .ul-state { color: var(--green); }
.uplink[data-state="offline"] .dot, .uplink[data-state="degraded"] .dot { background: var(--red); box-shadow: 0 0 8px var(--red); }
.uplink[data-state="offline"] .ul-state, .uplink[data-state="degraded"] .ul-state { color: var(--red); }
.uplink[data-state="auth"] .dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.uplink[data-state="auth"] .ul-state { color: var(--amber); }
.uplink[data-state="unknown"] .dot { animation: blink 0.8s ease-in-out infinite alternate; }
.ul-lat { font-family: var(--font-mono); letter-spacing: 0; color: var(--text-faint); font-weight: 400; }

.tb-center {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 56px 9px;
}
.tb-center::before {
  content: ""; position: absolute; inset: calc(-8px - var(--sat)) 0 0; z-index: -1;
  background: linear-gradient(180deg, rgba(0, 217, 255, 0.04), rgba(0, 217, 255, 0.14));
  clip-path: polygon(0 0, 100% 0, calc(100% - 34px) 100%, 34px 100%);
}
.tb-center::after {
  content: ""; position: absolute; left: 34px; right: 34px; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan) 20%, var(--cyan) 80%, transparent);
  box-shadow: 0 0 12px var(--cyan);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-emblem {
  width: 26px; height: 26px; fill: none; stroke: var(--cyan); stroke-width: 2.4;
  filter: drop-shadow(0 0 6px var(--cyan));
}
.wordmark {
  margin: 0;
  font: 800 22px/1 var(--font-display);
  letter-spacing: 0.5em; padding-left: 0.5em;
  color: var(--text-bright);
  background: linear-gradient(180deg, #ffffff 0%, #b9f3ff 55%, #42dcff 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(0, 217, 255, 0.55));
}
.clock { display: flex; align-items: baseline; gap: 12px; margin-top: 7px; }
.clock-time {
  font: 600 28px/1 var(--font-mono);
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(0, 217, 255, 0.7);
  font-variant-numeric: tabular-nums;
}
.clock-sec { font-size: 15px; color: var(--cyan-soft); opacity: 0.75; }
.clock-date { font: 600 10.5px/1 var(--font-display); letter-spacing: 0.22em; color: var(--text-dim); white-space: nowrap; }

.tb-right { display: flex; justify-content: flex-end; gap: 8px; }
.hud-btn {
  position: relative;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: rgba(0, 217, 255, 0.05);
  color: var(--cyan);
  border: 1px solid rgba(0, 217, 255, 0.32);
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  cursor: pointer; transition: background 0.15s, box-shadow 0.15s;
}
.hud-btn .ico { width: 19px; height: 19px; }
.hud-btn:hover { background: rgba(0, 217, 255, 0.18); box-shadow: inset 0 0 14px rgba(0, 217, 255, 0.4); }
.hud-btn:focus-visible { outline-offset: -5px; }

/* ----------------------------------------------------------------- core */
.core-wrap { flex: none; display: flex; justify-content: center; padding-top: 4px; }
.core {
  --core-size: clamp(190px, 36vh, 380px);
  --c: var(--cyan);
  --level: 0;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}
.hud.has-messages .core { --core-size: clamp(104px, 16vh, 150px); }
.core-stage {
  position: relative;
  width: var(--core-size); height: var(--core-size);
  transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.core-readout { min-width: 0; }
.cr-left { text-align: right; justify-self: end; }
.cr-right { justify-self: start; }
.cr-title {
  font: 700 10.5px/1 var(--font-display); letter-spacing: 0.3em; color: var(--cyan);
  text-shadow: var(--glow-s);
  padding-bottom: 8px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  display: inline-block;
}
.cr-state {
  font: 700 20px/1.1 var(--font-display); letter-spacing: 0.12em;
  color: var(--text-bright);
  text-shadow: 0 0 16px rgba(0, 217, 255, 0.6);
}
.cr-detail {
  margin-top: 6px; font-size: 13px; color: var(--text-dim); line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.cr-stats { margin: 0; display: grid; gap: 8px; }
.cr-stats > div { border-left: 2px solid var(--line-strong); padding-left: 10px; }
.cr-stats dt { font: 600 9px/1 var(--font-display); letter-spacing: 0.22em; color: var(--text-dim); }
.cr-stats dd { margin: 4px 0 0; font: 600 14px/1.1 var(--font-mono); color: var(--text-bright); overflow-wrap: anywhere; }
.hud.has-messages .cr-state { font-size: 15px; }
.hud.has-messages .cr-title { padding-bottom: 5px; margin-bottom: 5px; }
.hud.has-messages .cr-stats { grid-template-columns: repeat(3, auto); gap: 14px; }
.hud.has-messages .cr-stats dd { font-size: 13px; }

.core[data-state="listening"] { --c: var(--mint); }
.core[data-state="error"] { --c: var(--red); }
.core[data-state="offline"] { --c: #5d8193; }
.core[data-state="listening"] .cr-state { color: var(--mint); }
.core[data-state="error"] .cr-state { color: var(--red); }

.reticle {
  position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible;
  filter: drop-shadow(0 0 5px rgba(0, 217, 255, 0.35));
}
.reticle circle, .reticle path, .reticle ellipse { fill: none; stroke: var(--c); transition: stroke 0.4s; }
.reticle .glow-disc { stroke: none; transition: opacity 0.4s; }
.reticle .st-a { stop-color: var(--c); }
.reticle .ticks { stroke-width: 6; opacity: 0.5; }
.reticle .ticks-major { stroke-width: 12; opacity: 0.9; }
.reticle .seg { stroke-width: 7; opacity: 0.72; }
.reticle .thin { stroke-width: 1; opacity: 0.45; }
.reticle .arc { stroke-width: 3.5; opacity: 0.95; }
.reticle .arc-thin { stroke-width: 1.5; opacity: 0.6; }
.reticle .dash { stroke-width: 2; opacity: 0.5; }
.reticle .cross path { stroke-width: 1.5; opacity: 0.8; }
.reticle .cross .cross-fine { opacity: 0.45; }
.reticle .box path { stroke-width: 2; opacity: 0.5; }
.reticle .inner { stroke-width: 1.2; opacity: 0.55; }
.reticle .orbit { stroke-width: 1.4; opacity: 0.65; }
.reticle .hex { stroke-width: 2.6; fill: rgba(0, 217, 255, 0.07); }
.reticle .hex-in { stroke-width: 1.5; opacity: 0.85; }
.reticle .nucleus { fill: var(--c); stroke: none; filter: drop-shadow(0 0 10px var(--c)); }
.reticle .labels text { fill: var(--c); font: 600 11px var(--font-mono); letter-spacing: 0.08em; opacity: 0.6; }
.reticle .ripple { opacity: 0; stroke-width: 2; }
.hud.has-messages .reticle .labels { display: none; }

.spin, .boost, .emblem-core, .ripple, .nucleus {
  transform-box: view-box;
  transform-origin: 50% 50%;
}
.spin { animation: spin var(--dur, 60s) linear infinite; }
.s1 { --dur: 140s; } .s2 { --dur: 90s; } .s3 { --dur: 55s; } .s4 { --dur: 38s; } .s5 { --dur: 26s; }
.spin.rev { animation-direction: reverse; }
.boost { animation: spin 2.8s linear infinite; animation-play-state: paused; }
.boost.rev { animation-direction: reverse; }
.core[data-state="thinking"] .boost, .core[data-state="tool"] .boost { animation-play-state: running; }

.emblem-core {
  transform: scale(calc(1 + var(--level) * 0.3));
  transition: transform 0.08s linear;
}
.sweep {
  position: absolute; inset: 7%; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 280deg, rgba(0, 217, 255, 0.04) 290deg, rgba(0, 217, 255, 0.42) 359deg, transparent 360deg);
  -webkit-mask: radial-gradient(circle, transparent 0 27%, #000 28%);
          mask: radial-gradient(circle, transparent 0 27%, #000 28%);
  opacity: 0; transition: opacity 0.4s;
  animation: spin 1.9s linear infinite; animation-play-state: paused;
}
.core[data-state="thinking"] .sweep, .core[data-state="tool"] .sweep { opacity: 1; animation-play-state: running; }
.core[data-state="tool"] .sweep { background: conic-gradient(from 0deg, transparent 0 280deg, rgba(255, 190, 85, 0.04) 290deg, rgba(255, 190, 85, 0.4) 359deg, transparent 360deg); }
.core[data-state="speaking"] .glow-disc { animation: breathe 1.1s ease-in-out infinite; }
.core[data-state="speaking"] .nucleus { animation: nucleus 0.9s ease-in-out infinite; }
.core[data-state="speaking"] .reticle { filter: drop-shadow(0 0 12px rgba(0, 217, 255, 0.7)); }
.core[data-state="listening"] .ripple { animation: ripple 1.7s ease-out infinite; }
.core[data-state="listening"] .ripple.r2 { animation-delay: 0.85s; }
.core[data-state="idle"] .glow-disc { opacity: 0.7; }
.core[data-state="offline"] .spin { animation-duration: 400s; }

/* ----------------------------------------------------------- transcript */
.transcript-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.session-label { text-transform: none; }
.transcript {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px 18px 18px;
  display: flex; flex-direction: column; gap: 18px;
}
.transcript:focus-visible { outline-offset: -3px; }
.loading-line { color: var(--text-dim); font-size: 13px; margin: auto; }

.empty { margin: auto; max-width: 620px; text-align: center; padding: 8px 0; animation: msgIn 0.6s ease-out both; }
.empty-kicker { font: 600 10.5px/1 var(--font-display); letter-spacing: 0.34em; color: var(--cyan); text-shadow: var(--glow-s); }
.empty-title {
  margin: 12px 0 6px;
  font: 700 26px/1.15 var(--font-display); letter-spacing: 0.05em;
  color: var(--text-bright); text-shadow: 0 0 20px rgba(0, 217, 255, 0.35);
}
.empty-sub { margin: 0 auto 18px; color: var(--text-dim); max-width: 440px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px 9px 10px; min-height: 40px;
  background: rgba(0, 217, 255, 0.06);
  border: 1px solid rgba(0, 217, 255, 0.3);
  color: var(--text);
  font: 500 14px/1.25 var(--font-body);
  text-align: left; cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip-ico { color: var(--cyan); width: 14px; height: 14px; }
.chip:hover { background: rgba(0, 217, 255, 0.16); border-color: var(--cyan); color: #fff; }
.chip:focus-visible { outline-offset: -4px; }

.msg { min-width: 0; animation: msgIn 0.35s ease-out both; }
.msg-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px;
  font: 700 10px/1 var(--font-display); letter-spacing: 0.2em;
  color: var(--text-dim);
}
.msg-head time { font: 400 10.5px/1 var(--font-mono); letter-spacing: 0; color: var(--text-faint); }
.msg-user { align-self: flex-end; max-width: min(84%, 660px); }
.msg-user .msg-head { justify-content: flex-end; }
.msg-user .msg-body {
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(0, 150, 205, 0.28), rgba(0, 70, 120, 0.22));
  border: 1px solid rgba(0, 217, 255, 0.38);
  color: var(--text-bright);
  white-space: pre-wrap; overflow-wrap: anywhere;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}
.msg-ai { position: relative; padding-left: 16px; }
.msg-ai::before {
  content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 2px;
  background: linear-gradient(180deg, var(--cyan), rgba(0, 217, 255, 0.08));
  box-shadow: 0 0 8px rgba(0, 217, 255, 0.7);
}
.msg-ai .msg-who { color: var(--cyan); text-shadow: var(--glow-s); }
.brain-badge {
  padding: 3px 7px;
  font: 700 9px/1 var(--font-display); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--cyan-soft); border: 1px solid currentColor;
}
.brain-badge[data-provider="claude"] { color: #ffc27a; }
.brain-badge[data-provider="cloud"] { color: #7cc4ff; }
.brain-badge[data-provider="local"] { color: var(--green); }
.live-tag { display: inline-flex; align-items: center; gap: 5px; color: var(--red); font-size: 9px; }
.live-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); animation: blink 0.9s ease-in-out infinite alternate; }

.msg-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px;
  font: 400 11px/1.3 var(--font-mono); color: var(--text-faint);
}
.foot-actions { margin-left: auto; display: flex; gap: 6px; opacity: 0.8; transition: opacity 0.15s; }
.msg:hover .foot-actions, .msg:focus-within .foot-actions { opacity: 1; }
.msg-error {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 8px; padding: 9px 12px;
  background: rgba(255, 107, 133, 0.1); border: 1px solid rgba(255, 107, 133, 0.5);
  color: #ffd0d8; font-size: 14px;
}
.msg-error .ico { color: var(--red); width: 18px; height: 18px; margin-top: 1px; }

/* streaming affordances */
.msg-ai.is-streaming .md:empty {
  height: 22px;
  background: linear-gradient(90deg, transparent, rgba(0, 217, 255, 0.7), transparent) no-repeat;
  background-size: 34% 2px;
  animation: scanBar 1.3s linear infinite;
}
.msg-ai.is-streaming .md:empty::before {
  content: "ESTABLISHING RESPONSE";
  font: 600 9.5px/1 var(--font-display); letter-spacing: 0.24em; color: var(--text-dim);
}
.msg-ai.is-streaming .md > :last-child::after {
  content: ""; display: inline-block;
  width: 8px; height: 1.05em; margin-left: 3px; vertical-align: -0.18em;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan);
  animation: blink 0.9s steps(2, jump-none) infinite;
}

/* markdown */
.md { font-size: 15px; line-height: 1.62; color: var(--text); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.75em; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 1.15em 0 0.45em; line-height: 1.25;
  font-family: var(--font-body); font-weight: 700; color: var(--text-bright);
}
.md h1 { font-size: 1.32em; }
.md h2 { font-size: 1.18em; }
.md h1, .md h2 { padding-bottom: 0.28em; border-bottom: 1px solid var(--line-soft); }
.md h3 { font-size: 1.06em; color: var(--cyan-soft); }
.md h4, .md h5, .md h6 { font-size: 0.82em; font-family: var(--font-display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--cyan); }
.md ul, .md ol { margin: 0 0 0.8em; padding-left: 1.4em; }
.md li { margin: 0.22em 0; }
.md li > ul, .md li > ol { margin: 0.2em 0 0.3em; }
.md li::marker { color: var(--cyan); }
.md strong { color: var(--text-bright); font-weight: 700; }
.md em { color: #c6efff; }
.md a {
  color: var(--cyan-soft);
  text-decoration: underline; text-decoration-color: rgba(0, 217, 255, 0.45);
  text-underline-offset: 2px;
}
.md a:hover { color: #fff; text-decoration-color: var(--cyan); }
.md code {
  font-family: var(--font-mono); font-size: 0.86em;
  padding: 0.08em 0.38em;
  background: rgba(0, 217, 255, 0.08); border: 1px solid rgba(0, 217, 255, 0.18);
  border-radius: 3px;
}
.md pre {
  position: relative;
  margin: 0.25em 0 0.9em;
  padding: 30px 14px 12px;
  background: rgba(1, 7, 15, 0.82);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow-x: auto;
}
.md pre code {
  display: block; padding: 0; background: none; border: 0;
  font-size: 12.5px; line-height: 1.55; white-space: pre; overflow-wrap: normal;
}
.code-lang {
  position: absolute; top: 9px; left: 13px;
  font: 600 9.5px/1 var(--font-display); letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-dim);
}
.code-copy {
  position: absolute; top: 4px; right: 4px;
  display: grid; place-items: center; width: 28px; height: 24px;
  background: transparent; border: 1px solid transparent; color: var(--text-dim); cursor: pointer;
}
.code-copy .ico { width: 14px; height: 14px; }
.code-copy:hover { color: var(--cyan); border-color: var(--line); }
.code-copy.is-done { color: var(--green); }
.md blockquote {
  margin: 0 0 0.8em; padding: 0.35em 0 0.35em 13px;
  border-left: 2px solid var(--amber); color: var(--text-dim);
  background: linear-gradient(90deg, rgba(255, 190, 85, 0.06), transparent 60%);
}
.md hr { border: 0; height: 1px; margin: 1.1em 0; background: linear-gradient(90deg, var(--line-strong), transparent); }
.md .md-check { color: var(--cyan); }
.table-wrap { overflow-x: auto; margin: 0 0 0.9em; border: 1px solid var(--line); }
.md table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md th, .md td { padding: 7px 11px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.md th {
  background: rgba(0, 217, 255, 0.08);
  font: 700 10px/1.3 var(--font-display); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--cyan); white-space: nowrap;
}
.md tr:last-child td { border-bottom: 0; }
.md tbody tr:hover td { background: rgba(0, 217, 255, 0.04); }

/* analysis */
.analysis {
  margin: 2px 0 10px;
  border: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(0, 32, 54, 0.55), rgba(0, 16, 30, 0.45));
}
.analysis > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  list-style: none; cursor: pointer;
  font: 700 9.5px/1 var(--font-display); letter-spacing: 0.22em; color: var(--cyan);
}
.analysis > summary::-webkit-details-marker { display: none; }
.analysis > summary:hover { background: rgba(0, 217, 255, 0.06); }
.analysis > summary:focus-visible { outline-offset: -2px; }
.an-chev { width: 12px; height: 12px; transition: transform 0.2s; }
.analysis[open] > summary .an-chev, .lead-draft[open] > summary .an-chev { transform: rotate(90deg); }
.an-meta { margin-left: auto; font: 400 10.5px/1 var(--font-mono); letter-spacing: 0; color: var(--text-dim); }
.is-streaming .analysis .an-title::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; vertical-align: 1px;
  background: var(--cyan); transform: rotate(45deg); box-shadow: 0 0 8px var(--cyan);
  animation: blink 0.7s ease-in-out infinite alternate;
}
.an-body { padding: 2px 12px 12px; }
.an-thinking { margin: 6px 0 10px; }
.an-label { font: 700 9px/1 var(--font-display); letter-spacing: 0.22em; color: var(--text-dim); margin-bottom: 6px; }
.an-think-text {
  max-height: 220px; overflow-y: auto;
  padding: 2px 0 2px 11px;
  border-left: 1px dashed var(--line);
  font-size: 13px; line-height: 1.55; color: var(--text-dim);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.an-steps { list-style: none; margin: 0; padding: 0; }
.step { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; padding: 6px 0; }
.step::before {
  content: ""; position: absolute; left: 8px; top: 25px; bottom: -6px; width: 1px;
  background: var(--line);
}
.step:last-child::before { display: none; }
.step-node {
  width: 14px; height: 14px; margin: 3px 2px 0;
  border: 1.5px solid var(--cyan); border-radius: 50%;
}
.step[data-status="running"] .step-node { border-color: var(--cyan) transparent var(--cyan) transparent; animation: spin 0.8s linear infinite; }
.step[data-status="ok"] .step-node { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.step[data-status="fail"] .step-node { border-color: var(--red); background: rgba(255, 107, 133, 0.35); box-shadow: 0 0 8px var(--red); }
.step[data-status="notice"] .step-node, .step[data-status="reset"] .step-node {
  width: 10px; height: 10px; margin: 5px 4px 0; border-radius: 1px; transform: rotate(45deg);
  border-color: var(--amber);
}
.step[data-status="reset"] .step-node { border-style: dashed; }
.step[data-status="cancelled"] .step-node { border-color: var(--text-faint); }
.step-label { font-size: 13.5px; line-height: 1.4; color: var(--text); overflow-wrap: anywhere; }
.step[data-status="notice"] .step-label, .step[data-status="reset"] .step-label { color: #ffd9a0; }
.step-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: 2px; }
.step-tool { font: 400 11px/1.3 var(--font-mono); color: var(--cyan-soft); }
.step-input { font: 400 11px/1.4 var(--font-mono); color: var(--text-faint); overflow-wrap: anywhere; }
.step-summary { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; overflow-wrap: anywhere; }
.step-summary:empty { display: none; }
.step[data-status="fail"] .step-summary { color: var(--red); }
.step-time { font: 400 11px/1.3 var(--font-mono); color: var(--text-faint); padding-top: 2px; }

/* composer */
.composer {
  position: relative;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(0, 20, 36, 0.4), rgba(0, 10, 20, 0.6));
}
.composer textarea {
  flex: 1; min-width: 0;
  min-height: 44px; max-height: 168px;
  padding: 11px 70px 11px 13px;
  resize: none;
  background: rgba(0, 4, 10, 0.55);
  border: 1px solid rgba(0, 217, 255, 0.3);
  border-radius: 2px;
  color: var(--text-bright);
  font: 400 15px/1.45 var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 18px rgba(0, 217, 255, 0.25); }
.kbd-hint {
  position: absolute; right: 70px; bottom: 23px;
  padding: 3px 6px;
  font: 400 10px/1 var(--font-mono); color: var(--text-faint);
  border: 1px solid var(--line-soft); pointer-events: none;
}
.composer:focus-within .kbd-hint { opacity: 0; }
.send-btn {
  flex: none; display: grid; place-items: center;
  width: 46px; height: 44px;
  background: var(--cyan); color: var(--ink);
  border: 0; cursor: pointer;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  box-shadow: 0 0 18px rgba(0, 217, 255, 0.5);
  transition: background 0.15s, transform 0.1s;
}
.send-btn .ico { width: 20px; height: 20px; stroke-width: 2.2; }
.send-btn:hover { background: var(--cyan-soft); }
.send-btn:active { transform: scale(0.95); }
.send-btn:focus-visible { outline: 2px solid #fff; outline-offset: -6px; }
.send-btn.is-stop { background: var(--red); color: #1a0007; animation: blink 1.2s ease-in-out infinite alternate; }
.mic-inline { display: none; }
.composer-wave { display: none; }

/* ------------------------------------------------------------ side panels */
.stat { margin: 0 0 11px; }
.stat:last-child { margin-bottom: 0; }
.stat-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.stat-k { font: 600 9.5px/1.2 var(--font-display); letter-spacing: 0.16em; color: var(--text-dim); }
.stat-v { font: 600 12px/1 var(--font-mono); color: var(--text-bright); white-space: nowrap; }
.bar {
  position: relative; height: 8px; overflow: hidden;
  background: rgba(0, 217, 255, 0.06);
  border: 1px solid rgba(0, 217, 255, 0.2);
}
.bar > i {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--p, 0%);
  background: linear-gradient(90deg, rgba(0, 217, 255, 0.45), var(--cyan));
  box-shadow: 0 0 10px rgba(0, 217, 255, 0.7);
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px);
          mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px);
  transition: width 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar[data-tone="warn"] > i { background: linear-gradient(90deg, rgba(255, 190, 85, 0.4), var(--amber)); box-shadow: 0 0 10px rgba(255, 190, 85, 0.6); }
.bar[data-tone="bad"] > i { background: linear-gradient(90deg, rgba(255, 107, 133, 0.4), var(--red)); box-shadow: 0 0 10px rgba(255, 107, 133, 0.6); }

.brains { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.brain-line { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.brain-rank { font: 400 10px/1 var(--font-mono); color: var(--text-faint); }
.brain-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brain-state {
  padding: 3px 6px;
  font: 700 8.5px/1 var(--font-display); letter-spacing: 0.16em;
  border: 1px solid currentColor;
}
.brain[data-state="online"] .brain-state { color: var(--green); }
.brain[data-state="standby"] .brain-state { color: var(--amber); }
.brain[data-state="offline"] .brain-state { color: var(--text-faint); }
.brain[data-active="1"] .brain-state { color: var(--ink); background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.brain[data-active="1"] .brain-name { color: var(--text-bright); }
.brain-bar { height: 6px; }
.brain-bar[data-state="online"] > i { width: 100%; }
.brain-bar[data-state="standby"] > i {
  width: 100%; box-shadow: none;
  background: repeating-linear-gradient(-45deg, rgba(255, 190, 85, 0.55) 0 4px, transparent 4px 8px);
  -webkit-mask: none; mask: none;
}
.brain-bar[data-state="offline"] > i { width: 0; }
.brain-sub { margin-top: 4px; font: 400 10.5px/1.3 var(--font-mono); color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.svc { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 7px 8px; border: 1px solid var(--line-soft); background: rgba(0, 217, 255, 0.04); }
.svc-k { font: 600 8.5px/1 var(--font-display); letter-spacing: 0.16em; color: var(--text-dim); }
.svc-v { font: 600 11px/1 var(--font-mono); color: var(--green); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc[data-ok="0"] .svc-v { color: var(--text-faint); }

/* environment */
.wx { display: flex; align-items: center; gap: 14px; }
.wx-icon-wrap {
  flex: none; display: grid; place-items: center;
  width: 66px; height: 66px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 217, 255, 0.2), transparent 70%);
  border: 1px solid rgba(0, 217, 255, 0.28);
  box-shadow: inset 0 0 14px rgba(0, 217, 255, 0.2);
}
.wx-icon { width: 40px; height: 40px; fill: none; stroke: var(--cyan); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 6px var(--cyan)); }
.wx-icon-wrap[data-icon="sun"] .wx-icon, .wx-icon-wrap[data-icon="cloud-sun"] .wx-icon { stroke: #ffd27a; filter: drop-shadow(0 0 8px rgba(255, 200, 100, 0.7)); }
.wx-icon-wrap[data-icon="sun"] .wx-icon { animation: spin 50s linear infinite; }
.wx-icon-wrap[data-icon="storm"] .wx-icon { stroke: #c9b8ff; }
.wx-main { min-width: 0; }
.wx-temp { display: flex; align-items: flex-start; }
.wx-temp .num { font: 600 40px/1 var(--font-mono); color: var(--text-bright); text-shadow: 0 0 14px rgba(0, 217, 255, 0.45); }
.wx-temp .unit { font: 600 15px/1 var(--font-mono); color: var(--cyan); margin: 3px 0 0 3px; }
.wx-desc { margin-top: 4px; font-size: 14px; color: var(--text); }
.wx-city { font: 600 9.5px/1.2 var(--font-display); letter-spacing: 0.18em; color: var(--text-dim); margin-top: 3px; }
.wx-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 13px 0 12px; }
.wx-stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 7px 8px; border: 1px solid var(--line-soft); background: rgba(0, 217, 255, 0.04); }
.wx-stat .k { font: 600 8.5px/1 var(--font-display); letter-spacing: 0.16em; color: var(--text-dim); }
.wx-stat .v { font: 600 13px/1 var(--font-mono); color: var(--text-bright); white-space: nowrap; }

/* communications */
.mail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mail {
  width: 100%; display: flex; flex-direction: column; gap: 3px;
  padding: 8px 10px;
  text-align: left; cursor: pointer;
  background: rgba(0, 217, 255, 0.035);
  border: 1px solid var(--line-soft); border-left: 2px solid rgba(0, 217, 255, 0.55);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.mail:hover { background: rgba(0, 217, 255, 0.1); border-color: rgba(0, 217, 255, 0.45); }
.mail:focus-visible { outline-offset: -2px; }
.mail-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.mail-from { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-time { flex: none; font: 400 10.5px/1 var(--font-mono); color: var(--text-faint); }
.mail-subj, .mail-prev { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-subj { font-size: 13px; color: var(--text-dim); }
.mail-prev { font-size: 12px; color: var(--text-faint); }

/* location */
.loc { display: grid; grid-template-columns: minmax(96px, 120px) minmax(0, 1fr); gap: 12px; align-items: center; }
.holo-map { width: 100%; height: auto; overflow: visible; }
.hm-plane ellipse, .hm-plane path { fill: none; stroke: var(--cyan); stroke-width: 1; opacity: 0.42; }
.hm-plane ellipse:first-child { fill: rgba(0, 217, 255, 0.07); opacity: 0.75; }
.hm-nodes circle { fill: var(--cyan); opacity: 0.8; }
.hm-pulse { fill: none; stroke: var(--cyan); stroke-width: 1.4; transform-box: fill-box; transform-origin: center; animation: hmPulse 2.6s ease-out infinite; }
.hm-pulse.p2 { animation-delay: 1.3s; }
.hm-beam { fill: none; stroke: var(--cyan); stroke-width: 2; stroke-dasharray: 2 3; opacity: 0.55; }
.hm-pin { animation: bob 3.2s ease-in-out infinite; filter: drop-shadow(0 0 6px var(--cyan)); }
.hm-pin path { fill: rgba(0, 217, 255, 0.22); stroke: var(--cyan); stroke-width: 1.8; }
.hm-pin circle { fill: var(--cyan); }
.loc-info { min-width: 0; }
.loc-city { font: 700 16px/1.15 var(--font-display); letter-spacing: 0.12em; color: var(--text-bright); text-shadow: var(--glow-s); overflow-wrap: anywhere; }
.loc-tz { margin-top: 4px; font-size: 11px; color: var(--text-dim); overflow-wrap: anywhere; }
.loc-time { margin-top: 6px; font-size: 24px; font-weight: 600; line-height: 1; color: var(--cyan); text-shadow: 0 0 12px rgba(0, 217, 255, 0.6); font-variant-numeric: tabular-nums; }
.loc-sec { font-size: 13px; opacity: 0.7; }
.loc-date { margin-top: 5px; font: 600 9.5px/1.2 var(--font-display); letter-spacing: 0.16em; color: var(--text-dim); }

/* mission */
.task-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.task {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--line-soft);
  transition: opacity 0.5s, transform 0.5s;
}
.task:last-child { border-bottom: 0; }
.task.is-done { opacity: 0.35; transform: translateX(6px); }
.task.is-done .task-title { text-decoration: line-through; }
.task-check { position: relative; flex: none; width: 22px; height: 22px; margin-top: 1px; cursor: pointer; }
.task-check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.task-check .box {
  position: absolute; inset: 3px;
  display: grid; place-items: center;
  border: 1.5px solid var(--cyan);
  transform: rotate(45deg);
  transition: background 0.15s, box-shadow 0.15s;
}
.task-check .box .ico { width: 13px; height: 13px; stroke-width: 3; color: var(--ink); transform: rotate(-45deg); opacity: 0; }
.task-check:hover .box { box-shadow: 0 0 10px rgba(0, 217, 255, 0.6); }
.task-check input:checked + .box { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.task-check input:checked + .box .ico { opacity: 1; }
.task-check input:focus-visible + .box { outline: 2px solid #fff; outline-offset: 3px; }
.task-main { min-width: 0; flex: 1; }
.task-title { font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.task-due { margin-top: 3px; font: 400 11px/1.2 var(--font-mono); color: var(--text-dim); }
.task[data-overdue="1"] .task-due { color: var(--red); }
.task[data-soon="1"] .task-due { color: var(--amber); }
.task-form { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 6px; }
.task-form #taskTitle { grid-column: 1 / -1; }
.task-form input, .field input, .search input {
  width: 100%; min-width: 0; min-height: 38px;
  padding: 8px 10px;
  background: rgba(0, 4, 10, 0.55);
  border: 1px solid rgba(0, 217, 255, 0.28);
  border-radius: 2px;
  color: var(--text-bright);
  font: 400 14px/1.3 var(--font-body);
  color-scheme: dark;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.task-form input::placeholder, .field input::placeholder, .search input::placeholder { color: var(--text-faint); }
.task-form input:focus, .field input:focus, .search input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.task-form #taskDue { font: 400 12.5px/1.2 var(--font-mono); color: var(--text-dim); }
.add-btn {
  display: grid; place-items: center;
  background: rgba(0, 217, 255, 0.12); color: var(--cyan);
  border: 1px solid rgba(0, 217, 255, 0.45);
  cursor: pointer; transition: background 0.15s;
}
.add-btn .ico { width: 18px; height: 18px; stroke-width: 2; }
.add-btn:hover { background: var(--cyan); color: var(--ink); }

/* gauge */
.gauge-body { display: flex; flex-direction: column; align-items: center; }
.gauge { position: relative; width: min(188px, 74%); aspect-ratio: 1; }
.gauge-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.g-ticks { fill: none; stroke: var(--cyan); stroke-width: 5; opacity: 0.32; }
.g-orbit { fill: none; stroke: var(--cyan); stroke-width: 2; opacity: 0.7; }
.g-spin { --dur: 16s; }
.g-track { fill: none; stroke: rgba(0, 217, 255, 0.12); stroke-width: 12; }
.g-value {
  fill: none; stroke: var(--gc, var(--cyan)); stroke-width: 12;
  stroke-dasharray: 477.52; stroke-dashoffset: 477.52;
  filter: drop-shadow(0 0 6px var(--gc, var(--cyan)));
  transition: stroke-dashoffset 1.4s cubic-bezier(0.2, 0.8, 0.2, 1), stroke 0.4s;
}
.g-inner { fill: rgba(0, 217, 255, 0.05); stroke: rgba(0, 217, 255, 0.3); stroke-width: 1; }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.g-pct { font: 600 32px/1 var(--font-mono); color: var(--text-bright); text-shadow: 0 0 14px rgba(0, 217, 255, 0.6); }
.g-lbl { margin-top: 6px; max-width: 104px; font: 700 8.5px/1.35 var(--font-display); letter-spacing: 0.16em; color: var(--gc, var(--cyan)); }
.g-sub { margin: 10px 0 0; text-align: center; font-size: 12.5px; color: var(--text-dim); }
.gauge-panel[data-mode="free"] { --gc: var(--green); }
.gauge-panel[data-mode="low"] { --gc: var(--amber); }

/* ------------------------------------------------------------ bottom bar */
.bottombar { display: flex; gap: 16px; align-items: stretch; min-width: 0; }
.voicebar {
  position: relative; flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 9px 18px 9px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
.mic-btn {
  position: relative; flex: none;
  display: grid; place-items: center;
  width: 54px; height: 54px; border-radius: 50%;
  margin: 4px;
  background: radial-gradient(circle, rgba(0, 217, 255, 0.3), rgba(0, 217, 255, 0.05) 70%);
  border: 1.5px solid var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 18px rgba(0, 217, 255, 0.35), inset 0 0 12px rgba(0, 217, 255, 0.3);
  cursor: pointer; transition: background 0.2s, box-shadow 0.2s, color 0.2s, border-color 0.2s;
}
.mic-btn .ico { width: 24px; height: 24px; stroke-width: 1.8; }
.mic-btn:hover { box-shadow: 0 0 26px rgba(0, 217, 255, 0.6), inset 0 0 14px rgba(0, 217, 255, 0.45); }
.mic-ring { position: absolute; inset: -6px; border-radius: 50%; border: 1px dashed rgba(0, 217, 255, 0.55); animation: spin 16s linear infinite; }
.mic-btn[aria-pressed="true"], .mic-inline[aria-pressed="true"] {
  background: radial-gradient(circle, rgba(255, 90, 120, 0.5), rgba(255, 90, 120, 0.08) 70%);
  border-color: var(--red); color: #fff;
  box-shadow: 0 0 26px rgba(255, 90, 120, 0.6);
}
.mic-btn[aria-pressed="true"] .mic-ring { border-color: rgba(255, 107, 133, 0.8); animation: micPulse 1.2s ease-out infinite; }
.vb-text { flex: none; width: 200px; min-width: 0; }
.vb-title { font: 700 11px/1 var(--font-display); letter-spacing: 0.26em; color: var(--cyan); text-shadow: var(--glow-s); }
.vb-status {
  margin-top: 5px; font-size: 12.5px; line-height: 1.3; color: var(--text-dim);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.hud.is-listening .vb-status { color: var(--mint); }
.vb-wave { flex: 1; min-width: 0; height: 48px; display: block; }

.dock {
  flex: none;
  display: flex; align-items: center; gap: 4px;
  padding: 7px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
}
.dock-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 66px; padding: 3px 2px;
  background: none; border: 0; cursor: pointer;
  color: var(--text-dim);
  transition: color 0.15s;
}
.dock-ico {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(0, 217, 255, 0.4);
  background: radial-gradient(circle, rgba(0, 217, 255, 0.12), transparent 70%);
  color: var(--cyan-soft);
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s, color 0.2s;
}
.dock-ico .ico { width: 19px; height: 19px; }
.dock-lbl { font: 700 8.5px/1 var(--font-display); letter-spacing: 0.16em; }
.dock-btn:hover { color: var(--text); }
.dock-btn:hover .dock-ico { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0, 217, 255, 0.45); }
.dock-btn.is-active { color: var(--cyan); }
.dock-btn.is-active .dock-ico {
  background: radial-gradient(circle, rgba(0, 217, 255, 0.45), rgba(0, 217, 255, 0.08) 70%);
  border-color: var(--cyan); color: #fff;
  box-shadow: 0 0 18px rgba(0, 217, 255, 0.55), inset 0 0 10px rgba(0, 217, 255, 0.45);
}
.dock-btn:focus-visible { outline: none; }
.dock-btn:focus-visible .dock-ico { outline: 2px solid #fff; outline-offset: 3px; }

/* ---------------------------------------------------------------- drawers */
.scrim {
  position: fixed; inset: 0; z-index: 39;
  background: rgba(0, 4, 10, 0.55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 40;
  top: calc(12px + var(--sat)); bottom: calc(12px + var(--sab)); right: calc(12px + var(--sar));
  width: min(500px, calc(100vw - 24px));
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(5, 24, 42, 0.96), rgba(2, 12, 23, 0.97));
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 40px rgba(0, 217, 255, 0.16), 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: translateX(calc(100% + 40px));
  visibility: hidden;
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.38s;
}
.drawer.open { transform: none; visibility: visible; transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1); }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(0, 217, 255, 0.12), transparent 70%);
  color: var(--cyan);
}
.drawer-head > .ico { width: 18px; height: 18px; filter: drop-shadow(0 0 4px var(--cyan)); }
.drawer-head h2 { margin: 0; font: 700 12px/1 var(--font-display); letter-spacing: 0.24em; color: var(--cyan); text-shadow: var(--glow-s); }
.drawer-head .meta { font: 400 10.5px/1 var(--font-mono); color: var(--text-dim); }
.drawer-close { margin-left: auto; }
.drawer-intro { margin: 12px 16px 0; font-size: 13px; color: var(--text-dim); }
.drawer-tools { padding: 12px 16px 0; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px 18px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 9px; min-height: 30px;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--line-soft);
  font: 700 9px/1 var(--font-display); letter-spacing: 0.14em;
  cursor: pointer;
}
.filter:hover { color: var(--cyan); border-color: var(--cyan); }
.filter[aria-pressed="true"] { background: rgba(0, 217, 255, 0.16); color: var(--cyan); border-color: var(--cyan); }
.filter-n { font: 400 10px/1 var(--font-mono); color: var(--text-faint); }
.filter[aria-pressed="true"] .filter-n { color: var(--text); }

.lead {
  position: relative;
  margin-bottom: 10px; padding: 12px 14px;
  border: 1px solid var(--line-soft); border-left: 3px solid var(--lc, var(--cyan));
  background: rgba(0, 217, 255, 0.035);
}
.lead[data-status="new"] { --lc: var(--cyan); }
.lead[data-status="contacted"] { --lc: #7cc4ff; }
.lead[data-status="replied"] { --lc: var(--amber); }
.lead[data-status="won"] { --lc: var(--green); }
.lead[data-status="dead"] { --lc: var(--text-faint); opacity: 0.75; }
.lead-head { display: flex; align-items: flex-start; gap: 10px; }
.lead-name { flex: 1; min-width: 0; margin: 2px 0 0; font-size: 15.5px; font-weight: 700; color: var(--text-bright); overflow-wrap: anywhere; }
.lead-status {
  flex: none; min-height: 30px; padding: 4px 8px;
  background: rgba(0, 4, 10, 0.7); color: var(--lc, var(--cyan));
  border: 1px solid var(--lc, var(--cyan));
  font: 700 9.5px/1 var(--font-display); letter-spacing: 0.12em;
  color-scheme: dark; cursor: pointer;
}
.lead-meta { margin-top: 4px; font-size: 12.5px; color: var(--text-dim); }
.lead-contact { display: inline-block; margin-top: 6px; font: 400 12.5px/1.3 var(--font-mono); color: var(--cyan-soft); overflow-wrap: anywhere; }
a.lead-contact { text-decoration: underline; text-decoration-color: rgba(0, 217, 255, 0.4); text-underline-offset: 2px; }
.lead-notes { margin: 8px 0 0; font-size: 13.5px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.lead-draft { margin-top: 10px; border: 1px solid var(--line-soft); background: rgba(0, 0, 0, 0.25); }
.lead-draft > summary { display: flex; align-items: center; gap: 7px; padding: 7px 10px; list-style: none; cursor: pointer; font: 700 9px/1 var(--font-display); letter-spacing: 0.18em; color: var(--cyan); }
.lead-draft > summary::-webkit-details-marker { display: none; }
.draft-text { padding: 2px 12px 10px; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.lead-draft .mini-btn { margin: 0 12px 10px; }
.lead-actions { display: flex; justify-content: flex-end; margin-top: 10px; }

.memory-list, .session-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.memory {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--line-soft); border-left: 2px solid var(--cyan);
  background: rgba(0, 217, 255, 0.035);
  transition: opacity 0.25s, transform 0.25s;
}
.memory.is-removing { opacity: 0; transform: translateX(20px); }
.memory-main { flex: 1; min-width: 0; }
.memory-fact { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.memory-time { display: block; margin-top: 4px; font: 400 10.5px/1 var(--font-mono); color: var(--text-faint); }

.search { position: relative; display: block; }
.search > .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-dim); width: 16px; height: 16px; }
.search input { padding-left: 34px; }
.note { margin-bottom: 10px; padding: 12px 14px; border: 1px solid var(--line-soft); background: rgba(0, 217, 255, 0.035); }
.note-title { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: var(--text-bright); overflow-wrap: anywhere; }
.note-body {
  margin: 0; font-size: 13.5px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
}
.note-body.is-open { display: block; -webkit-line-clamp: unset; }
.note .link-btn { margin-top: 6px; }

.session { display: flex; align-items: stretch; gap: 6px; }
.session-open {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px; text-align: left; cursor: pointer;
  background: rgba(0, 217, 255, 0.035);
  border: 1px solid var(--line-soft); border-left: 2px solid rgba(0, 217, 255, 0.4);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.session-open:hover { background: rgba(0, 217, 255, 0.1); border-color: rgba(0, 217, 255, 0.45); }
.session-open[aria-current="true"] { border-left-color: var(--cyan); background: rgba(0, 217, 255, 0.12); }
.session-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-meta { font: 400 10.5px/1 var(--font-mono); color: var(--text-faint); }
.session .icon-btn { height: auto; min-height: 34px; }

/* ---------------------------------------------------------------- dialog */
.dialog {
  width: min(540px, calc(100vw - 32px));
  max-width: none; max-height: calc(var(--app-h) - 32px);
  padding: 0; border: 0; background: transparent; color: var(--text);
  overflow: visible;
}
.dialog::backdrop { background: rgba(0, 3, 8, 0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog[open] { animation: dialogIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.dialog-card {
  position: relative;
  display: flex; flex-direction: column;
  max-height: calc(var(--app-h) - 32px);
  background: linear-gradient(180deg, rgba(6, 26, 46, 0.97), rgba(2, 12, 23, 0.98));
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 50px rgba(0, 217, 255, 0.18), 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dialog-body { overflow-y: auto; padding: 16px 18px 6px; }
.first-run {
  margin-bottom: 16px; padding: 12px 14px;
  border: 1px solid rgba(0, 217, 255, 0.4);
  background: linear-gradient(90deg, rgba(0, 217, 255, 0.12), rgba(0, 217, 255, 0.03));
  font-size: 14px;
}
.first-run p { margin: 0; }
.first-run .fr-title { font: 700 13px/1.3 var(--font-display); letter-spacing: 0.06em; color: var(--cyan); margin-bottom: 6px; }
.first-run code { font-family: var(--font-mono); font-size: 0.88em; color: var(--cyan-soft); }
.field { margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field > label, .field legend {
  display: block; margin-bottom: 6px; padding: 0;
  font: 700 9.5px/1 var(--font-display); letter-spacing: 0.2em; color: var(--text-dim);
}
.field .opt { letter-spacing: 0.06em; color: var(--text-faint); font-weight: 500; text-transform: none; }
.field small { display: block; margin-top: 6px; font-size: 12px; color: var(--text-faint); }
.field-row { display: flex; gap: 6px; }
.field-row input { flex: 1; font-family: var(--font-mono); font-size: 13.5px; }
.field-row .ghost-btn { min-height: 38px; padding: 6px 12px; font-size: 9.5px; }
.toggle { display: flex; align-items: center; gap: 11px; padding: 7px 0; cursor: pointer; font-size: 14px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  position: relative; flex: none; width: 40px; height: 21px;
  border: 1px solid rgba(0, 217, 255, 0.4); background: rgba(0, 0, 0, 0.4);
  transition: background 0.2s, border-color 0.2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 13px; height: 13px;
  background: var(--text-faint); transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}
.toggle input:checked + .switch { border-color: var(--cyan); background: rgba(0, 217, 255, 0.18); }
.toggle input:checked + .switch::after { transform: translateX(19px); background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--cyan-soft); outline-offset: 2px; }
.toggle input:disabled + .switch { opacity: 0.4; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--text-faint); }
.test-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 4px 0 14px; }
#testResult { font-size: 13px; color: var(--text-dim); }
#testResult[data-kind="ok"] { color: var(--green); }
#testResult[data-kind="bad"] { color: var(--red); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line-soft); }

/* ---------------------------------------------------------------- toasts */
.toasts {
  position: fixed; z-index: 60;
  top: calc(var(--tb-h, 90px) + 8px); right: calc(16px + var(--sar));
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(4, 30, 52, 0.97), rgba(2, 14, 26, 0.97));
  border: 1px solid var(--line-strong); border-left: 3px solid var(--cyan);
  box-shadow: 0 0 24px rgba(0, 217, 255, 0.2), 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 13.5px; color: var(--text-bright);
  opacity: 0; transform: translateX(16px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}
.toast .ico { width: 16px; height: 16px; margin-top: 2px; color: var(--cyan); }
.toast[data-kind="error"] { border-left-color: var(--red); }
.toast[data-kind="error"] .ico { color: var(--red); }
.toast.in { opacity: 1; transform: none; }

/* ------------------------------------------------------------- keyframes */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { from { opacity: 1; } to { opacity: 0.25; } }
@keyframes breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes nucleus { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
@keyframes ripple { from { transform: scale(1); opacity: 0.75; } to { transform: scale(2); opacity: 0; } }
@keyframes hmPulse { from { transform: scale(1); opacity: 0.9; } to { transform: scale(5.5); opacity: 0; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes micPulse { from { transform: scale(1); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
@keyframes scanBar { from { background-position: -40% 100%; } to { background-position: 140% 100%; } }
@keyframes sweepDown { from { transform: translateY(-160px); } to { transform: translateY(110vh); } }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes dialogIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes panelPulse {
  0% { box-shadow: 0 0 0 1px var(--cyan), 0 0 40px rgba(0, 217, 255, 0.6); }
  100% { box-shadow: inset 0 0 0 1px rgba(0, 217, 255, 0.04), 0 0 22px rgba(0, 217, 255, 0.06); }
}

/* Background tab: freeze every animation (JS also stops the canvas loop). */
body.is-hidden *, body.is-hidden *::before, body.is-hidden *::after { animation-play-state: paused !important; }

/* =========================================================== TABLET 700-1099 */
@media (min-width: 700px) and (max-width: 1099px) {
  .hud {
    grid-template-columns: minmax(0, 1fr) minmax(270px, 320px);
    grid-template-areas:
      "top top"
      "center side"
      "bottom bottom";
  }
  .side {
    grid-area: side;
    display: flex; flex-direction: column; gap: 14px;
    min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 2px 4px 2px 2px; margin: -2px -4px -2px -2px;
  }
  .side .col { overflow: visible; padding: 0; margin: 0; }
  .vb-text { width: 160px; }
  .dock-btn { min-width: 56px; }
  .dock-ico { width: 40px; height: 40px; }
  .wordmark { font-size: 19px; }
  .clock-time { font-size: 24px; }
  .cr-stats { display: none; }
  .hud.has-messages .cr-stats { display: none; }
  .core { grid-template-columns: minmax(0, 1fr) auto minmax(0, 0.35fr); }
}

/* ================================================================ PHONE <700 */
@media (max-width: 699px) {
  body { font-size: 15px; }
  .hud {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "top" "main" "bottom";
    gap: 10px;
    padding: 0 calc(var(--gutter) + var(--sar)) 0 calc(var(--gutter) + var(--sal));
  }
  .side { display: contents; }
  .col { grid-area: main; display: none; overflow-y: auto; padding: 2px; margin: -2px; }
  .hud[data-view="core"] .col-center,
  .hud[data-view="leads"] .col-center,
  .hud[data-view="memory"] .col-center,
  .hud[data-view="missions"] .col-right,
  .hud[data-view="system"] .col-left,
  .hud[data-view="inbox"] .col-left { display: flex; }
  .hud[data-view="system"] #panelComms,
  .hud[data-view="inbox"] #panelSystem,
  .hud[data-view="inbox"] #panelEnv { display: none; }
  .col-center { overflow: hidden; }

  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding-top: calc(8px + var(--sat)); padding-bottom: 6px; }
  .topbar::after { bottom: -5px; background: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent); }
  .tb-left { display: none; }
  .tb-center { flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; padding: 0; }
  .tb-center::before, .tb-center::after { display: none; }
  .brand { gap: 8px; }
  .brand-emblem { width: 22px; height: 22px; }
  .wordmark { font-size: 15px; letter-spacing: 0.34em; padding-left: 0; }
  .clock { margin: 0; gap: 0; }
  .clock-time { font-size: 15px; text-shadow: 0 0 8px rgba(0, 217, 255, 0.6); }
  .clock-sec, .clock-date { display: none; }
  .tb-right { gap: 6px; }
  .hud-btn { width: 38px; height: 38px; }

  .core { --core-size: clamp(130px, 27vh, 210px); gap: 12px; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .hud.has-messages .core { --core-size: 76px; grid-template-columns: auto minmax(0, 1fr); }
  .hud.has-messages .core-stage { order: -1; }
  .hud.has-messages .cr-left { text-align: left; justify-self: start; }
  .hud.has-messages .cr-right { display: none; }
  .hud.has-messages .cr-title { display: none; }
  .hud.has-messages .cr-detail { -webkit-line-clamp: 1; font-size: 12px; margin-top: 3px; }
  .cr-stats { display: grid; }
  .cr-title { font-size: 9px; letter-spacing: 0.22em; }
  .cr-state { font-size: 15px; }
  .cr-detail { font-size: 12px; }
  .cr-stats dd { font-size: 12px; }
  .core-wrap { padding-top: 0; }
  body.kb-open .core-wrap { display: none; }

  .transcript { padding: 12px 12px 14px; gap: 14px; }
  .msg-user { max-width: 90%; }
  .msg-ai { padding-left: 12px; }
  .md { font-size: 15px; }
  .empty-title { font-size: 21px; }
  .chip { font-size: 13.5px; }
  .kbd-hint { display: none; }
  .composer { padding: 8px; gap: 6px; }
  .composer textarea { padding-right: 12px; font-size: 16px; } /* 16px stops iOS zoom-on-focus */
  .mic-inline {
    display: grid; place-items: center; flex: none;
    width: 44px; height: 44px; border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 217, 255, 0.25), rgba(0, 217, 255, 0.04) 70%);
    border: 1.5px solid var(--cyan); color: var(--cyan); cursor: pointer;
    box-shadow: 0 0 12px rgba(0, 217, 255, 0.35);
  }
  .mic-inline .ico { width: 20px; height: 20px; }
  .hud.is-listening .composer-wave {
    display: block; position: absolute; left: 8px; right: 8px; bottom: 100%;
    height: 44px; width: calc(100% - 16px);
    background: linear-gradient(180deg, transparent, rgba(2, 10, 20, 0.92));
    pointer-events: none;
  }

  .bottombar { padding-bottom: calc(8px + var(--sab)); }
  .voicebar { display: none; }
  .dock { flex: 1; justify-content: space-between; gap: 0; padding: 6px 4px; clip-path: none; }
  .dock-btn { flex: 1; min-width: 0; gap: 5px; }
  .dock-ico { width: 38px; height: 38px; }
  .dock-ico .ico { width: 17px; height: 17px; }
  .dock-lbl { font-size: 7.5px; letter-spacing: 0.1em; }
  body.kb-open .bottombar { display: none; }

  .drawer {
    top: calc(var(--tb-h, 64px) + 8px); bottom: calc(var(--bb-h, 76px) + 6px);
    left: calc(var(--gutter) + var(--sal)); right: calc(var(--gutter) + var(--sar));
    width: auto;
    transform: translateY(16px); opacity: 0;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s, visibility 0s linear 0.3s;
  }
  .drawer.open { transform: none; opacity: 1; transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s; }
  .scrim { display: none; }
  .toasts { left: 16px; right: 16px; max-width: none; align-items: stretch; top: calc(var(--tb-h, 64px) + 8px); }
  .loc { grid-template-columns: 110px minmax(0, 1fr); }
  .task-list { max-height: none; }
  .panel { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
}

@media (max-width: 380px) {
  .wordmark { letter-spacing: 0.22em; }
  .tb-right .hud-btn { width: 34px; height: 34px; }
  .dock-lbl { font-size: 7px; letter-spacing: 0.06em; }
}

/* short desktop screens */
@media (min-width: 700px) and (max-height: 760px) {
  .core { --core-size: clamp(150px, 30vh, 250px); }
  .hud.has-messages .core { --core-size: clamp(90px, 14vh, 120px); }
  .clock { margin-top: 4px; }
  .clock-time { font-size: 22px; }
}

/* ======================================================== reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .bd-scan::after { display: none; }
  .ripple { display: none; }
  .core[data-state="thinking"] .sweep, .core[data-state="tool"] .sweep { opacity: 0.6; }
}

@media (forced-colors: active) {
  .panel, .drawer, .dialog-card { border: 1px solid CanvasText; }
  .send-btn, .mic-btn { forced-color-adjust: none; }
}

/* --- small additions: reply footer usage line + flex overflow guards --- */
.msg-foot .usage { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11px; letter-spacing: .04em; color: var(--dim, #6f93ad); }
.step-main { min-width: 0; flex: 1 1 auto; }
.step-main .step-input { overflow-wrap: anywhere; }

/* --- layout fixes: inbox fills the rest of the left column and scrolls inside;
       welcome block never hides its first line when the chat panel is short --- */
@media (min-width: 1100px) {
  .col-left #panelComms { flex: 1 1 auto; min-height: 170px; display: flex; flex-direction: column; }
  .col-left #panelComms > .panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
}
.transcript > .empty { margin-block: auto; flex: none; }

/* --- v4: login, settings, studio, action cards, phone/tablet layouts --- */
.auth-screen { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 30%, rgba(6, 36, 60, .96), rgba(2, 8, 18, .99)); overflow-y: auto; }
.auth-screen[hidden] { display: none; }
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 26px 22px;
  border: 1px solid rgba(0, 217, 255, .35); background: rgba(4, 18, 32, .9); box-shadow: 0 0 40px rgba(0, 217, 255, .14); }
.auth-card h2 { margin: 0; text-align: center; font: 700 18px/1.3 var(--font-display); letter-spacing: .06em; }
.auth-emblem { width: 56px; height: 56px; align-self: center; color: #00d9ff; fill: none; stroke: currentColor; stroke-width: 2; }
.auth-error { min-height: 18px; margin: 0; color: #ff8b8b; font-size: 13px; }
.mini-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim, #8fb4c9); margin: 8px 0; }
.mini-field input, .mini-field select, .study-form input { width: 100%; min-width: 0; padding: 10px 11px; font: inherit; font-size: 16px;
  color: var(--text-bright, #e8f8ff); background: rgba(0, 20, 36, .85); border: 1px solid rgba(0, 217, 255, .3); }
.set-section { border-top: 1px solid rgba(0, 217, 255, .18); padding: 12px 0 14px; }
.set-section:first-child { border-top: 0; padding-top: 0; }
.set-section h3, .studio-h { margin: 0 0 8px; font: 600 11px/1 var(--font-display); letter-spacing: .2em; color: #00d9ff; text-transform: uppercase; }
.row-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; }
.row-main { overflow-wrap: anywhere; min-width: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions.wrap { margin-top: 10px; }
.set-section .toggle { margin: 8px 0; }
.set-section a { color: #67e8f9; }
.dialog-card { max-height: min(88dvh, 780px); display: flex; flex-direction: column; }
.dialog-body { overflow-y: auto; min-height: 0; }
.action-card { margin: 8px 0; padding: 11px 13px; border: 1px solid rgba(0, 217, 255, .35); background: rgba(0, 60, 90, .25); }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; overflow-wrap: anywhere; }
.card-title .ico { width: 18px; height: 18px; flex: none; }
.card-sub { font-size: 12px; color: var(--text-dim, #8fb4c9); margin: 3px 0; }
.card-caption { white-space: pre-wrap; font-size: 13px; max-height: 120px; overflow-y: auto; margin: 6px 0; overflow-wrap: anywhere; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.card-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 7px 14px; cursor: pointer;
  font: 600 13px/1.2 inherit; color: #d9f6ff; text-decoration: none; background: rgba(0, 217, 255, .08); border: 1px solid rgba(0, 217, 255, .4); }
.card-btn.primary { background: #00d9ff; color: #00141d; }
.card-btn.danger { border-color: rgba(255, 120, 120, .5); color: #ffb4b4; }
@media (min-width: 700px) { .drawer.drawer-wide { width: min(620px, calc(100vw - 24px)); } }
.studio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 20px; }
.studio-item { padding: 10px; border: 1px solid rgba(0, 217, 255, .25); background: rgba(0, 24, 40, .7); min-width: 0; }
.studio-item h3 { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.studio-video { width: 100%; max-height: 340px; background: #000; margin-top: 6px; }
.studio-wait { padding: 18px 8px; font-size: 12px; text-align: center; color: #ffd27d; overflow-wrap: anywhere; }
.study-form { display: flex; gap: 8px; margin-bottom: 10px; }
.playbook { border: 1px solid rgba(0, 217, 255, .2); padding: 8px 10px; margin-bottom: 8px; }
.playbook summary { cursor: pointer; font-weight: 600; }
.playbook-text { white-space: pre-wrap; font-size: 13px; margin: 8px 0; overflow-wrap: anywhere; }
.is-guest #panelGauge, .is-guest #panelLocation { display: none; }
body.is-locked .toasts { z-index: 90; }

/* phones */
@media (max-width: 699px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  #app, .hud { max-width: 100vw; min-width: 0; }
  #app > *, .col, .panel, .topbar, .bottombar, .core-wrap, .transcript-panel, .composer { min-width: 0; max-width: 100%; box-sizing: border-box; }
  .dock { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  .dock-btn { flex: 1 0 52px; }
  .core-readout.cr-right { display: none; }
  .chip { max-width: 100%; text-align: left; }
}

/* --- v4 layout fixes (found by device screenshots) --- */
@media (min-width: 700px) and (max-width: 1099px) {
  .side .col { flex: none; min-height: auto; }
  .voice-ind, .uplink { letter-spacing: 0.04em; font-size: 10px; }
}
@media (max-width: 699px) {
  .hud:not(.has-messages) .core { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .hud:not(.has-messages) .cr-left { display: none; }
  .dock { overflow: visible; }
  .dock-btn { flex: 1 1 0; min-width: 0; padding-left: 0; padding-right: 0; }
  .dock-ico { width: 36px; height: 36px; }
  .dock-lbl { font-size: 7.5px; letter-spacing: 0.02em; }
}

.auth-gmail { margin: 0; padding: 8px 12px 6px; border: 1px solid rgba(0, 217, 255, .25); min-width: 0; }
.auth-gmail[hidden] { display: none; }
.auth-gmail legend { padding: 0 6px; font: 600 11px/1 var(--font-display); letter-spacing: .12em; color: #00d9ff; }
.auth-gmail a { color: #67e8f9; }
.auth-screen { align-items: safe center; }
.auth-card { margin: auto 0; }
