:root {
  color-scheme: dark;
  --bg: #05070c;
  --surface: #0a0e16;
  --surface-raised: #0d121c;
  --text: #f3f7ff;
  --muted: #768196;
  --muted-bright: #a7b1c3;
  --line: rgba(141, 165, 203, 0.16);
  --line-bright: rgba(87, 225, 255, 0.34);
  --cyan: #32e6ff;
  --blue: #3974ff;
  --magenta: #ff3cc7;
  --danger: #ff537b;
  --amber: #ffc45b;
  --orb-rms: 0;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(rgba(75, 105, 160, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 105, 160, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 50% 30%, rgba(30, 67, 112, 0.12), transparent 38%),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto, auto;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, transparent 0%, rgba(5, 7, 12, 0.72) 58%, var(--bg) 100%);
  content: "";
  pointer-events: none;
}

button, input, textarea { font: inherit; letter-spacing: 0; }
h1, h2, p { margin: 0; }

.app {
  width: min(1180px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 13px; }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 3px);
  align-items: end;
  gap: 3px;
  width: 24px;
  height: 24px;
  padding: 4px;
  border: 1px solid rgba(50, 230, 255, 0.32);
  box-shadow: inset 0 0 12px rgba(50, 230, 255, 0.12);
}

.brand-mark i { display: block; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.brand-mark i:nth-child(1) { height: 7px; }
.brand-mark i:nth-child(2) { height: 14px; }
.brand-mark i:nth-child(3) { height: 10px; }

h1 { font-size: 17px; line-height: 1.2; font-weight: 650; }
.brand p { margin-top: 3px; color: var(--muted); font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }

.status-stack { display: flex; align-items: center; gap: 8px; }
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(10, 14, 22, 0.72);
  color: var(--muted-bright);
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.status.connection::before {
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 9px var(--danger);
  content: "";
}

.status.connection.is-connected { color: #c6fff3; border-color: rgba(64, 238, 193, 0.25); }
.status.connection.is-connected::before { background: #40eec1; box-shadow: 0 0 9px #40eec1; }
.status.state { color: var(--cyan); border-color: rgba(50, 230, 255, 0.22); }

.voice-stage {
  display: grid;
  place-items: center;
  min-height: 570px;
  padding: 38px 0 20px;
  overflow: hidden;
}

.orb-shell {
  position: relative;
  width: min(420px, 84vw);
  aspect-ratio: 1;
  contain: layout paint size;
}

.voice-orb { display: block; width: 100%; height: 100%; }

.orb-reticle { position: absolute; inset: 8%; border: 1px solid rgba(75, 186, 255, 0.09); border-radius: 50%; pointer-events: none; }
.orb-reticle::before, .orb-reticle::after { position: absolute; inset: 12%; border: 1px dashed rgba(89, 221, 255, 0.1); border-radius: 50%; content: ""; animation: reticle-spin 28s linear infinite; }
.orb-reticle::after { inset: 30%; border-style: solid; border-color: rgba(255, 60, 199, 0.08); animation-direction: reverse; animation-duration: 18s; }
.orb-reticle i { position: absolute; width: 18px; height: 1px; background: rgba(50, 230, 255, 0.45); }
.orb-reticle i:nth-child(1) { top: 50%; left: -9px; }
.orb-reticle i:nth-child(2) { top: 50%; right: -9px; }
.orb-reticle i:nth-child(3) { top: -1px; left: calc(50% - 9px); transform: rotate(90deg); }
.orb-reticle i:nth-child(4) { bottom: -1px; left: calc(50% - 9px); transform: rotate(90deg); }

.orb-readout {
  position: absolute;
  right: 4%;
  bottom: 18%;
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: rgba(179, 240, 255, 0.78);
  font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.orb-readout small { color: var(--muted); font-size: 8px; }

.voice-state { width: min(780px, 100%); margin-top: -34px; text-align: center; }
.state-line { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--cyan); font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.state-line i { width: 42px; height: 1px; background: linear-gradient(90deg, transparent, currentColor); opacity: 0.6; }
.state-line i:last-child { transform: scaleX(-1); }

.caption { min-height: 96px; padding: 18px 20px 0; }
.partial { min-height: 23px; color: #88a6b7; font-size: 14px; line-height: 1.55; }
.final { margin-top: 6px; color: #f4f8ff; font-size: clamp(20px, 2.4vw, 30px); line-height: 1.42; font-weight: 450; text-wrap: balance; }

.controls { display: flex; justify-content: center; gap: 10px; padding: 10px 0 42px; }
.control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 136px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(50, 230, 255, 0.26);
  border-radius: 4px;
  background: rgba(11, 19, 29, 0.82);
  color: #dffaff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.control-button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--cyan); box-shadow: 0 0 22px rgba(50, 230, 255, 0.14); }
.control-button.primary { background: linear-gradient(135deg, rgba(32, 133, 177, 0.32), rgba(35, 52, 114, 0.32)); }
.control-button.ghost { color: var(--muted-bright); border-color: var(--line); background: rgba(9, 13, 20, 0.68); }
.control-button.danger:hover:not(:disabled) { color: #ffdce5; border-color: rgba(255, 83, 123, 0.7); box-shadow: 0 0 22px rgba(255, 83, 123, 0.12); }
.control-button:disabled { cursor: not-allowed; opacity: 0.34; }
.control-button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.button-icon { position: relative; display: inline-block; flex: 0 0 16px; width: 16px; height: 16px; }
.mic-icon { width: 9px; height: 13px; border: 1.5px solid currentColor; border-radius: 7px; }
.mic-icon::before { position: absolute; left: -4px; bottom: -4px; width: 13px; height: 8px; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 8px 8px; content: ""; }
.mic-icon::after { position: absolute; left: 3px; bottom: -7px; width: 1.5px; height: 4px; background: currentColor; content: ""; }
.stop-icon { width: 11px; height: 11px; margin: 2px; border: 1px solid currentColor; background: currentColor; }
.interrupt-icon::before, .interrupt-icon::after { position: absolute; top: 2px; width: 4px; height: 12px; background: currentColor; content: ""; }
.interrupt-icon::before { left: 3px; }.interrupt-icon::after { right: 3px; }
.link-icon::before, .link-icon::after { position: absolute; width: 9px; height: 6px; border: 1.5px solid currentColor; border-radius: 6px; content: ""; transform: rotate(-38deg); }
.link-icon::before { top: 2px; left: 1px; }.link-icon::after { right: 1px; bottom: 2px; }

.telemetry, .diagnostics { border-top: 1px solid var(--line); }
.telemetry { padding: 32px 0 42px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-heading > div { display: flex; align-items: baseline; gap: 10px; }
.section-index { color: var(--cyan); font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
h2 { font-size: 15px; line-height: 1.2; font-weight: 600; }
.section-note { color: var(--muted); font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }

.metrics-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric { position: relative; min-width: 0; min-height: 90px; padding: 17px 14px; border-right: 1px solid var(--line); background: rgba(8, 12, 19, 0.34); }
.metric:last-child { border-right: 0; }
.metric.featured::before { position: absolute; top: -1px; left: 0; right: 0; height: 1px; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); content: ""; }
.metric-label { display: block; overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.metric strong { display: block; margin-top: 10px; overflow: hidden; color: #dce8f7; font: 21px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; text-overflow: ellipsis; }
.metric.featured strong { color: var(--cyan); }

.table-wrap { overflow-x: auto; margin-top: 18px; }
.metrics-table { width: 100%; border-collapse: collapse; color: var(--muted-bright); font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.metrics-table th, .metrics-table td { padding: 10px 12px; border-bottom: 1px solid rgba(141, 165, 203, 0.09); text-align: left; white-space: nowrap; }
.metrics-table th { color: var(--muted); font-size: 9px; font-weight: 500; text-transform: uppercase; }
.metrics-table tbody tr:hover { background: rgba(50, 230, 255, 0.025); }

.diagnostics { display: grid; grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr); gap: 0; }
.session-panel, .event-panel { min-width: 0; padding: 30px 0; }
.session-panel { padding-right: 32px; border-right: 1px solid var(--line); }
.event-panel { padding-left: 32px; }
.section-heading.compact { margin-bottom: 18px; }
.meta { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 12px; margin: 0; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.meta dt { color: var(--muted); }.meta dd { margin: 0; overflow-wrap: anywhere; color: var(--muted-bright); }
.live-indicator { display: flex; align-items: center; gap: 6px; color: var(--muted); font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.live-indicator i { width: 5px; height: 5px; border-radius: 50%; background: #40eec1; box-shadow: 0 0 8px #40eec1; animation: live-pulse 1.6s ease-in-out infinite; }
.log { max-height: 220px; overflow: auto; margin: 0; padding: 0; list-style: none; color: #708096; font: 10px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; scrollbar-color: #28354a transparent; }
.log li { padding: 5px 0; border-bottom: 1px solid rgba(141, 165, 203, 0.07); overflow-wrap: anywhere; }

@keyframes reticle-spin { to { transform: rotate(360deg); } }
@keyframes live-pulse { 50% { opacity: 0.35; } }

@media (max-width: 900px) {
  .voice-stage { min-height: 520px; }
  .metrics-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .metric:nth-child(4) { border-right: 0; }
  .metric:nth-child(-n + 4) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 680px) {
  .app { width: min(100% - 28px, 1180px); padding-top: 14px; }
  .topbar { align-items: flex-start; }
  .brand p { display: none; }
  h1 { max-width: 170px; font-size: 15px; }
  .status-stack { flex-direction: column; align-items: stretch; }
  .status { min-width: 78px; min-height: 26px; font-size: 9px; }
  .voice-stage { min-height: 470px; padding-top: 24px; }
  .orb-shell { width: min(360px, 96vw); }
  .voice-state { margin-top: -26px; }
  .caption { min-height: 106px; padding-inline: 6px; }
  .final { font-size: 20px; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; padding-bottom: 34px; }
  .control-button { min-width: 0; width: 100%; padding: 0 10px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric, .metric:nth-child(4) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .metric:nth-child(even) { border-right: 0; }
  .metric:last-child { border-bottom: 0; }
  .diagnostics { grid-template-columns: 1fr; }
  .session-panel { padding-right: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .event-panel { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .orb-reticle::before, .orb-reticle::after, .live-indicator i { animation: none; }
}
