:root {
  color-scheme: dark;
  --ink: #090b0a;
  --ink-soft: #101311;
  --panel: rgba(17, 20, 18, 0.86);
  --panel-deep: rgba(8, 10, 9, 0.94);
  --line: rgba(217, 224, 217, 0.14);
  --line-bright: rgba(217, 224, 217, 0.25);
  --paper: #e8e9df;
  --muted: #8b918a;
  --amber: #f3b45d;
  --amber-hot: #ffd18f;
  --green: #5df2a0;
  --green-dim: rgba(93, 242, 160, 0.13);
  --red: #ff6d57;
  --display: "Bahnschrift Condensed", "Aptos Display", "Arial Narrow", sans-serif;
  --body: "Aptos", "Yu Gothic UI", sans-serif;
  --mono: "Cascadia Mono", "IBM Plex Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--ink);
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--paper);
  font-family: var(--body);
  background:
    radial-gradient(circle at 50% 42%, rgba(47, 67, 55, 0.22), transparent 32rem),
    linear-gradient(135deg, rgba(243, 180, 93, 0.025), transparent 35%),
    #090b0a;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--amber-hot);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  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: 1rem;
  left: 1rem;
  padding: 0.7rem 1rem;
  transform: translateY(-200%);
  color: var(--ink);
  background: var(--amber-hot);
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

.noise {
  position: fixed;
  z-index: -1;
  inset: 0;
  opacity: 0.16;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.018) 3px 4px),
    linear-gradient(90deg, transparent 49.9%, rgba(255, 255, 255, 0.025) 50%, transparent 50.1%);
  background-size: auto, 6rem 100%;
}

.shell {
  width: min(1600px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 1.35rem 1rem;
}

.masthead {
  min-height: 5.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-bright);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 2.7rem;
  height: 2.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid var(--amber);
  border-radius: 50%;
  box-shadow: inset 0 0 1rem rgba(243, 180, 93, 0.11);
}

.brand-mark i {
  width: 2px;
  height: 0.75rem;
  background: var(--amber);
}

.brand-mark i:nth-child(2) {
  height: 1.25rem;
}

.brand > span:last-child {
  display: grid;
  line-height: 1;
}

.brand b {
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: 0.18em;
}

.brand > span:last-child > span {
  margin-top: 0.35rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.59rem;
  letter-spacing: 0.22em;
}

.header-readout {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.14em;
}

.readout-label {
  color: var(--muted);
}

.status-chip {
  min-width: 7.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.62rem 0.8rem;
  border: 1px solid var(--line-bright);
  background: rgba(0, 0, 0, 0.28);
}

.status-chip i {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--muted);
}

body[data-state="ready"] .status-chip i,
body[data-state="listening"] .status-chip i {
  background: var(--green);
  box-shadow: 0 0 0.8rem var(--green);
}

.studio {
  min-height: calc(100vh - 18rem);
  display: grid;
  grid-template-columns: minmax(16rem, 0.82fr) minmax(24rem, 1.38fr) minmax(16rem, 0.82fr);
  grid-template-areas: "transcript focus telemetry";
  border-bottom: 1px solid var(--line-bright);
}

.panel {
  min-width: 0;
  padding: 1.35rem 1.25rem;
  background: linear-gradient(180deg, var(--panel), var(--panel-deep));
}

.transcript-panel {
  grid-area: transcript;
  border-right: 1px solid var(--line);
}

.telemetry-panel {
  grid-area: telemetry;
  border-left: 1px solid var(--line);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.state-kicker,
.primary-metric span,
.strategy-block > span,
.evidence-block > span {
  display: block;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.59rem;
  letter-spacing: 0.16em;
}

h1,
h2 {
  margin: 0.35rem 0 0;
  font-family: var(--display);
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  font-stretch: condensed;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.turn-counter {
  color: rgba(232, 233, 223, 0.22);
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1;
}

.turns {
  height: clamp(25rem, calc(100vh - 25rem), 48rem);
  min-height: 22rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-bright) transparent;
}

.empty-state {
  min-height: 15rem;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-index {
  color: var(--line-bright);
  font-family: var(--display);
  font-size: 3.8rem;
}

.empty-state p {
  margin: 0.3rem 0;
  color: var(--paper);
  font-family: var(--display);
  font-size: 1.25rem;
}

.empty-state small {
  max-width: 15rem;
  line-height: 1.6;
}

.turn {
  position: relative;
  padding: 1rem 0 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  animation: turn-in 260ms ease-out both;
}

.turn::before {
  content: "";
  position: absolute;
  top: 1.25rem;
  left: 0;
  width: 0.45rem;
  height: 0.45rem;
  border: 1px solid currentColor;
  transform: rotate(45deg);
}

.turn[data-role="user"] {
  color: var(--amber);
}

.turn[data-role="assistant"] {
  color: var(--green);
}

.turn-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
}

.turn-time {
  color: var(--muted);
}

.turn p {
  margin: 0;
  color: var(--paper);
  font-size: 0.94rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.turn.is-interim p::after {
  content: "▋";
  margin-left: 0.2rem;
  color: var(--amber);
  animation: blink 800ms steps(1) infinite;
}

.focus-stage {
  grid-area: focus;
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  padding: 1.2rem clamp(1rem, 3vw, 3.5rem) 1.5rem;
  background:
    linear-gradient(90deg, transparent 49.85%, rgba(232, 233, 223, 0.06) 50%, transparent 50.15%),
    radial-gradient(circle at center, rgba(93, 242, 160, 0.08), transparent 47%);
}

.frequency-rule {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.55rem;
}

.frequency-rule i {
  flex: 1;
  height: 0.5rem;
  border-left: 1px solid var(--line-bright);
}

.aperture-wrap {
  min-height: 24rem;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
}

.aperture {
  position: relative;
  width: min(31vw, 25rem);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(93, 242, 160, 0.32);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(10, 15, 12, 0.4) 0 47%, rgba(93, 242, 160, 0.035) 48% 64%, transparent 65%),
    repeating-radial-gradient(circle, transparent 0 1.7rem, rgba(232, 233, 223, 0.045) 1.75rem 1.8rem);
  box-shadow:
    0 0 4rem rgba(93, 242, 160, 0.045),
    inset 0 0 4rem rgba(0, 0, 0, 0.58);
}

.aperture::before,
.aperture::after {
  content: "";
  position: absolute;
  background: var(--line-bright);
}

.aperture::before {
  width: calc(100% + 4rem);
  height: 1px;
}

.aperture::after {
  width: 1px;
  height: calc(100% + 4rem);
}

.aperture-ring {
  position: absolute;
  border: 1px dashed rgba(232, 233, 223, 0.17);
  border-radius: 50%;
}

.ring-outer {
  inset: -1.25rem;
  animation: slow-spin 26s linear infinite;
}

.ring-inner {
  inset: 12%;
  border-style: solid;
  border-color: rgba(243, 180, 93, 0.15);
}

#waveform {
  z-index: 1;
  width: 74%;
  height: 38%;
}

.aperture-copy {
  z-index: 2;
  position: absolute;
  display: grid;
  place-items: center;
  width: 54%;
  padding: 1.5rem 0.6rem;
  text-align: center;
  background: radial-gradient(circle, rgba(9, 11, 10, 0.96) 0 52%, transparent 76%);
}

.aperture-copy strong {
  margin: 0.4rem 0;
  font-family: var(--display);
  font-size: clamp(2.05rem, 4vw, 3.4rem);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.aperture-copy > span:last-child {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
}

.orbit-label {
  z-index: 3;
  padding: 0.35rem 0.7rem;
  color: var(--muted);
  background: var(--ink);
  font-family: var(--mono);
  font-size: 0.52rem;
  letter-spacing: 0.14em;
}

body[data-state="listening"] .aperture {
  border-color: var(--green);
  box-shadow: 0 0 5rem rgba(93, 242, 160, 0.16), inset 0 0 4rem rgba(0, 0, 0, 0.55);
  animation: listen-pulse 1.35s ease-in-out infinite;
}

body[data-state="thinking"] .ring-inner {
  border-color: var(--amber);
  animation: slow-spin 3s linear infinite reverse;
}

body[data-state="speaking"] .aperture-copy strong {
  color: var(--green);
}

.signal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
}

.signal-stats > div {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem;
  text-align: center;
  border-right: 1px solid var(--line);
}

.signal-stats > div:last-child {
  border-right: 0;
}

.signal-stats span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.52rem;
}

.signal-stats b {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
}

.signal-stats .engine-chain {
  font-size: clamp(0.55rem, 0.72vw, 0.68rem);
  white-space: nowrap;
}

.telemetry-pulse {
  width: 0.55rem;
  height: 0.55rem;
  margin-top: 0.45rem;
  border: 1px solid var(--muted);
  border-radius: 50%;
}

body[data-classified="true"] .telemetry-pulse {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 0.9rem var(--green);
}

.primary-metric {
  padding: 1.45rem 0;
}

.primary-metric strong {
  display: block;
  margin-top: 0.55rem;
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(1.65rem, 2.3vw, 2.35rem);
  font-weight: 500;
  line-height: 1;
  overflow-wrap: anywhere;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.metric-grid div {
  min-width: 0;
  padding: 0.85rem 0.75rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-grid dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.53rem;
  letter-spacing: 0.12em;
}

.metric-grid dd {
  margin: 0.4rem 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.metric-grid dd[data-alert="true"] {
  color: var(--red);
}

.meter {
  height: 3px;
  margin: 1rem 0 1.35rem;
  overflow: hidden;
  background: var(--line);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  box-shadow: 0 0 0.6rem var(--green);
  transition: width 400ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.meter span[data-level="1"] { width: 10%; }
.meter span[data-level="2"] { width: 20%; }
.meter span[data-level="3"] { width: 30%; }
.meter span[data-level="4"] { width: 40%; }
.meter span[data-level="5"] { width: 50%; }
.meter span[data-level="6"] { width: 60%; }
.meter span[data-level="7"] { width: 70%; }
.meter span[data-level="8"] { width: 80%; }
.meter span[data-level="9"] { width: 90%; }
.meter span[data-level="10"] { width: 100%; }

.strategy-block,
.evidence-block {
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.strategy-block b {
  display: block;
  margin-top: 0.55rem;
  color: var(--amber-hot);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.evidence-block ul {
  display: grid;
  gap: 0.55rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
}

.evidence-block li {
  position: relative;
  padding-left: 1rem;
  color: #b6bbb4;
  font-size: 0.78rem;
  line-height: 1.45;
}

.evidence-block li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--green);
}

.loop-monitor {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(15rem, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 0.8rem;
  border-block: 1px solid var(--line);
  background: rgba(8, 10, 9, 0.72);
  font-family: var(--mono);
}

.loop-monitor > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.loop-monitor b {
  min-width: 0;
  color: var(--muted);
  font-size: 0.54rem;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.loop-monitor ol {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.loop-monitor li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #5f665f;
  font-size: 0.51rem;
  letter-spacing: 0.08em;
}

.loop-monitor li:not(:last-child)::after {
  content: "→";
  color: #3d423e;
}

.loop-monitor li[data-complete="true"] {
  color: var(--green);
}

.loop-monitor li[data-current="true"] {
  color: var(--amber-hot);
  text-shadow: 0 0 0.7rem rgba(243, 180, 93, 0.38);
}

.control-deck {
  min-width: 0;
  display: grid;
  grid-template-columns: 9rem minmax(18rem, 1fr) auto;
  align-items: end;
  gap: 1.4rem;
  padding: 1.2rem 0;
}

.deck-label {
  align-self: center;
  display: grid;
  gap: 0.3rem;
  font-family: var(--mono);
}

.deck-label span {
  color: var(--amber);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
}

.deck-label small {
  color: var(--muted);
  font-size: 0.55rem;
}

.text-console {
  min-width: 0;
}

.text-console label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.53rem;
  letter-spacing: 0.13em;
}

.input-wrap {
  min-width: 0;
  display: flex;
  border-bottom: 1px solid var(--line-bright);
  background: rgba(0, 0, 0, 0.32);
}

.input-wrap:focus-within {
  border-color: var(--amber);
  box-shadow: 0 0.7rem 1.5rem -1.2rem var(--amber);
}

.input-wrap input {
  min-width: 0;
  flex: 1;
  padding: 0.85rem 0.95rem;
  border: 0;
  outline: 0;
  color: var(--paper);
  background: transparent;
}

.input-wrap input::placeholder {
  color: #686d68;
}

.input-wrap input:disabled {
  cursor: not-allowed;
}

.input-wrap button {
  border: 0;
  padding: 0.7rem 1rem;
  color: var(--amber);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.input-wrap button:disabled {
  color: #555b56;
  cursor: not-allowed;
}

.permission-notice {
  min-height: 1.1rem;
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.52rem;
  line-height: 1.5;
  letter-spacing: 0.035em;
}

.permission-notice[data-status="requesting"] {
  color: var(--amber-hot);
}

.permission-notice[data-status="granted"] {
  color: var(--green);
}

.permission-notice[data-status="error"] {
  color: #ff9b8c;
}

.transport {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.transport-button {
  border: 1px solid var(--line-bright);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.transport-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.transport-button.secondary {
  width: 4.5rem;
  height: 4.5rem;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.25rem;
}

.button-icon {
  display: grid;
  width: 1.2rem;
  height: 1.2rem;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.52rem;
}

.transport-button.secondary.is-on {
  color: var(--green);
  border-color: rgba(93, 242, 160, 0.34);
}

.transport-button.secondary.is-unavailable {
  color: var(--red);
  border-color: rgba(255, 109, 87, 0.3);
}

.connect-button {
  position: relative;
  width: 5.75rem;
  height: 5.75rem;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.4rem;
  border-radius: 50%;
  color: var(--ink);
  border-color: var(--amber);
  background: var(--amber);
  box-shadow: 0 0 0 0.45rem rgba(243, 180, 93, 0.08);
  font-weight: 800;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.connect-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 0 0.55rem rgba(243, 180, 93, 0.12), 0 0.8rem 2rem rgba(0, 0, 0, 0.35);
}

.connect-core {
  width: 0.65rem;
  height: 0.65rem;
  border: 2px solid currentColor;
  border-radius: 50%;
}

body[data-state="connecting"] .connect-button {
  animation: connect-pulse 1s ease-in-out infinite;
}

body[data-state="ready"] .connect-button,
body[data-state="listening"] .connect-button,
body[data-state="thinking"] .connect-button,
body[data-state="speaking"] .connect-button {
  color: var(--green);
  border-color: rgba(93, 242, 160, 0.45);
  background: var(--green-dim);
  box-shadow: 0 0 0 0.45rem rgba(93, 242, 160, 0.04);
}

.voice-lab,
.prompt-lab {
  min-width: 0;
  border-block: 1px solid var(--line-bright);
  background:
    linear-gradient(90deg, rgba(243, 180, 93, 0.035), transparent 32%),
    rgba(8, 10, 9, 0.78);
}

:is(.voice-lab, .prompt-lab) summary {
  min-height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  list-style: none;
  cursor: pointer;
}

:is(.voice-lab, .prompt-lab) summary::-webkit-details-marker {
  display: none;
}

:is(.voice-lab, .prompt-lab) summary:focus-visible {
  outline: 2px solid var(--amber-hot);
  outline-offset: -2px;
}

.voice-lab-title {
  display: grid;
  gap: 0.35rem;
}

.voice-lab-title strong {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 500;
}

.voice-lab-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.09em;
}

.voice-lab-summary b {
  color: var(--green);
  font-weight: 500;
}

.voice-lab-summary i {
  display: inline-block;
  margin-left: 0.3rem;
  color: var(--amber);
  font-style: normal;
  transition: transform 180ms ease;
}

:is(.voice-lab, .prompt-lab)[open] .voice-lab-summary i {
  transform: rotate(180deg);
}

.voice-lab-body {
  min-width: 0;
  display: grid;
  grid-template-columns: 11.5rem minmax(0, 1fr);
  gap: 1rem 1.25rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.voice-current {
  grid-row: 1 / span 2;
  display: grid;
  align-content: start;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid rgba(93, 242, 160, 0.24);
  background: var(--green-dim);
  font-family: var(--mono);
}

.voice-current span,
.voice-field > span,
.voice-preview-field > span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.12em;
}

.voice-current b {
  color: var(--green);
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.voice-current small {
  color: var(--amber-hot);
  font-size: 0.53rem;
}

.voice-fields {
  min-width: 0;
  display: grid;
  grid-template-columns:
    minmax(10rem, 1.25fr)
    minmax(12rem, 1.5fr)
    repeat(3, minmax(7rem, 0.8fr))
    minmax(7rem, auto);
  gap: 0.7rem;
  align-items: end;
}

.voice-field {
  min-width: 0;
  display: grid;
  gap: 0.4rem;
}

.voice-field > span {
  display: flex;
  justify-content: space-between;
}

.voice-field output {
  color: var(--amber-hot);
}

.voice-field select,
.voice-field input[type="text"],
.voice-preview-field input {
  width: 100%;
  min-width: 0;
  height: 2.35rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line-bright);
  border-radius: 0;
  outline: 0;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.34);
  font-family: var(--mono);
  font-size: 0.61rem;
}

.voice-field select:focus,
.voice-field input[type="text"]:focus,
.voice-preview-field input:focus {
  border-color: var(--amber);
}

.voice-id-field input[aria-invalid="true"] {
  border-color: var(--red);
  color: #ff9b8c;
}

.range-field input[type="range"] {
  width: 100%;
  height: 2.35rem;
  margin: 0;
  accent-color: var(--green);
}

.voice-boost {
  min-height: 2.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem;
  border: 1px solid var(--line-bright);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.52rem;
  cursor: pointer;
}

.voice-boost input {
  position: absolute;
  opacity: 0;
}

.voice-boost span {
  width: 1.4rem;
  height: 0.7rem;
  position: relative;
  border: 1px solid var(--muted);
}

.voice-boost span::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 0.38rem;
  height: 0.38rem;
  background: var(--muted);
  transition: transform 150ms ease, background 150ms ease;
}

.voice-boost input:checked + span {
  border-color: var(--green);
}

.voice-boost input:checked + span::after {
  transform: translateX(0.66rem);
  background: var(--green);
}

.voice-preview-field {
  min-width: 0;
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
}

.voice-actions {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.voice-actions button {
  min-height: 2.25rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line-bright);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.3);
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.voice-actions button:first-child {
  color: var(--ink);
  border-color: var(--amber);
  background: var(--amber);
  font-weight: 800;
}

.voice-actions button:disabled {
  opacity: 0.45;
  cursor: wait;
}

#voiceLabStatus {
  min-width: 0;
  margin-left: 0.4rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.53rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

#voiceLabStatus[data-status="testing"] {
  color: var(--amber-hot);
}

#voiceLabStatus[data-status="ready"] {
  color: var(--green);
}

#voiceLabStatus[data-status="error"] {
  color: #ff9b8c;
}

.prompt-lab {
  border-top: 0;
  background:
    linear-gradient(90deg, rgba(93, 242, 160, 0.035), transparent 38%),
    rgba(8, 10, 9, 0.78);
}

.prompt-lab-body {
  min-width: 0;
  display: grid;
  grid-template-columns: 11.5rem minmax(0, 1fr) 12rem;
  gap: 0.8rem 1.25rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.prompt-current {
  grid-row: 1 / span 2;
  display: grid;
  align-content: start;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid rgba(243, 180, 93, 0.28);
  background: rgba(243, 180, 93, 0.07);
  font-family: var(--mono);
}

.prompt-current span,
.prompt-field > span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.1em;
}

.prompt-current b {
  color: var(--amber-hot);
  font-size: 0.64rem;
  font-weight: 500;
  line-height: 1.45;
}

.prompt-current small {
  color: var(--muted);
  font-size: 0.51rem;
  line-height: 1.45;
}

.prompt-field {
  min-width: 0;
  display: grid;
  gap: 0.4rem;
}

.prompt-field > span {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.prompt-field output {
  color: var(--green);
  white-space: nowrap;
}

.prompt-field textarea {
  width: 100%;
  min-width: 0;
  min-height: 5.5rem;
  resize: vertical;
  padding: 0.65rem;
  border: 1px solid var(--line-bright);
  border-radius: 0;
  outline: 0;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.34);
  font-family: var(--body);
  font-size: 0.72rem;
  line-height: 1.55;
}

.prompt-field textarea:focus {
  border-color: var(--amber);
}

.prompt-reasoning {
  align-self: start;
}

.prompt-actions {
  grid-column: 2 / -1;
}

#promptLabStatus {
  min-width: 0;
  margin-left: 0.4rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.53rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

#promptLabStatus[data-status="ready"] {
  color: var(--green);
}

#promptLabStatus[data-status="warning"] {
  color: var(--amber-hot);
}

#promptLabStatus[data-status="error"] {
  color: #ff9b8c;
}

footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding-top: 0.15rem;
  color: #626761;
  font-family: var(--mono);
  font-size: 0.49rem;
  letter-spacing: 0.11em;
}

.tts-latency {
  padding-inline: 0.45rem;
  color: var(--muted);
  border-left: 1px solid var(--line-bright);
  white-space: nowrap;
}

.tts-latency[data-active="true"] {
  color: var(--green);
  border-color: var(--green);
}

.build-label {
  margin-left: auto;
}

@keyframes slow-spin {
  to { transform: rotate(360deg); }
}

@keyframes listen-pulse {
  50% { transform: scale(1.012); }
}

@keyframes connect-pulse {
  50% { opacity: 0.6; }
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes turn-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

@media (max-width: 1050px) {
  .studio {
    grid-template-columns: minmax(15rem, 0.75fr) minmax(22rem, 1.25fr);
    grid-template-areas:
      "transcript focus"
      "telemetry telemetry";
  }

  .telemetry-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .classification {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.4rem;
  }

  .primary-metric,
  .metric-grid,
  .meter {
    grid-column: 1;
  }

  .strategy-block,
  .evidence-block {
    grid-column: 2;
  }

  .strategy-block {
    grid-row: 1 / span 2;
    padding-top: 1.45rem;
    border-top: 0;
  }

  .aperture {
    width: min(44vw, 24rem);
  }

  .control-deck {
    grid-template-columns: minmax(14rem, 1fr) auto;
  }

  .deck-label {
    display: none;
  }

  .voice-fields {
    grid-template-columns: repeat(3, minmax(8rem, 1fr));
  }

  .voice-id-field {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .shell {
    padding-inline: 0.8rem;
  }

  .masthead {
    min-height: 4.8rem;
  }

  .readout-label {
    display: none;
  }

  .studio {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "focus"
      "transcript"
      "telemetry";
  }

  .focus-stage {
    min-height: 31rem;
    border-bottom: 1px solid var(--line);
  }

  .aperture {
    width: min(74vw, 22rem);
  }

  .transcript-panel {
    border-right: 0;
  }

  .turns {
    height: auto;
    min-height: 18rem;
    max-height: 32rem;
  }

  .classification {
    display: block;
  }

  .control-deck {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .loop-monitor {
    grid-template-columns: 1fr;
  }

  .loop-monitor > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.3rem;
  }

  .loop-monitor ol {
    justify-content: space-between;
  }

  .transport {
    grid-row: 1;
    justify-content: center;
  }

  .text-console {
    grid-row: 2;
  }

  .voice-lab-body {
    grid-template-columns: 1fr;
  }

  .prompt-lab-body {
    grid-template-columns: 1fr;
  }

  .prompt-current {
    grid-row: auto;
  }

  .prompt-actions {
    grid-column: 1;
  }

  .voice-current {
    grid-row: auto;
  }

  .voice-actions {
    grid-column: 1;
  }
}

@media (max-width: 420px) {
  .shell {
    width: 100%;
    padding-inline: 0.55rem;
  }

  .brand-mark {
    width: 2.25rem;
    height: 2.25rem;
  }

  .brand b {
    font-size: 1.05rem;
  }

  .brand > span:last-child > span {
    letter-spacing: 0.12em;
  }

  .status-chip {
    min-width: 6rem;
    padding-inline: 0.55rem;
    font-size: 0.58rem;
  }

  .panel,
  .focus-stage {
    padding-inline: 0.85rem;
  }

  .focus-stage {
    min-height: 28rem;
  }

  .aperture-wrap {
    min-height: 21rem;
  }

  .aperture {
    width: min(79vw, 19rem);
  }

  .aperture::before {
    width: calc(100% + 1rem);
  }

  .aperture::after {
    height: calc(100% + 1rem);
  }

  .aperture-copy {
    width: 66%;
  }

  .aperture-copy strong {
    font-size: 1.85rem;
  }

  .transport {
    gap: 0.5rem;
  }

  .transport-button.secondary {
    width: 4rem;
    height: 4rem;
  }

  .connect-button {
    width: 5.1rem;
    height: 5.1rem;
  }

  :is(.voice-lab, .prompt-lab) summary {
    align-items: flex-start;
    padding-inline: 0.75rem;
  }

  .voice-lab-summary {
    display: grid;
    justify-items: end;
    gap: 0.3rem;
    text-align: right;
  }

  .voice-lab-body,
  .prompt-lab-body {
    padding: 0.75rem;
  }

  .voice-fields {
    grid-template-columns: 1fr 1fr;
  }

  .voice-id-field,
  .voice-field:first-child {
    grid-column: 1 / -1;
  }

  .voice-preview-field {
    grid-template-columns: 1fr;
  }

  .voice-actions {
    flex-wrap: wrap;
  }

  #voiceLabStatus {
    width: 100%;
    margin: 0.25rem 0 0;
  }

  #promptLabStatus {
    width: 100%;
    margin: 0.25rem 0 0;
  }

  .loop-monitor {
    padding-inline: 0.55rem;
  }

  .loop-monitor ol {
    gap: 0.18rem;
  }

  .loop-monitor li {
    gap: 0.18rem;
    font-size: 0.44rem;
    letter-spacing: 0.025em;
  }

  footer {
    gap: 0.6rem;
    letter-spacing: 0.03em;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
