:root {
  color-scheme: dark;
  --bg: #07090c;
  --panel: #10141a;
  --panel-2: #0c1015;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eef2f5;
  --muted: #9aa6b2;
  --faint: #66717d;
  --teal: #42d6bc;
  --cyan: #66b9ff;
  --amber: #f3b351;
  --rose: #ff6f8f;
  --green: #68d391;
  --red: #ff6b6b;
  --shadow: 0 20px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(102, 185, 255, 0.08), transparent 330px),
    radial-gradient(circle at top left, rgba(66, 214, 188, 0.09), transparent 320px),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1720px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.lede {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 560px;
}

.status-pill,
.voice-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.status-pill.ok,
.voice-state.ok {
  border-color: rgba(104, 211, 145, 0.35);
  background: rgba(104, 211, 145, 0.12);
  color: #a6f2c2;
}

.status-pill.warn,
.voice-state.warn {
  border-color: rgba(243, 179, 81, 0.36);
  background: rgba(243, 179, 81, 0.12);
  color: #ffd796;
}

.status-pill.error,
.voice-state.error {
  border-color: rgba(255, 107, 107, 0.36);
  background: rgba(255, 107, 107, 0.12);
  color: #ffb1b1;
}

.connection-panel,
.model-strip,
.studio-grid,
.workspace,
.diagnostics {
  display: grid;
  gap: 14px;
}

.connection-panel {
  grid-template-columns: minmax(240px, 1.4fr) minmax(220px, 1fr) minmax(150px, 0.45fr) auto;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 20, 26, 0.82);
  box-shadow: var(--shadow);
  padding: 14px;
}

label,
.full-width {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b10;
  color: var(--text);
  outline: none;
  padding: 10px 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  resize: vertical;
  min-height: 86px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(66, 214, 188, 0.68);
  box-shadow: 0 0 0 3px rgba(66, 214, 188, 0.13);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
  transition: transform 120ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.button.primary {
  background: linear-gradient(135deg, #0f8f7e, #1d5f92);
  border-color: rgba(66, 214, 188, 0.38);
}

.button.secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-strong);
}

.button.ghost {
  min-height: 32px;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  padding: 6px 10px;
}

.button.compact {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.connection-note {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.connection-note strong {
  color: var(--text);
}

.model-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 14px 0;
}

.studio-grid {
  grid-template-columns: minmax(260px, 0.95fr) minmax(280px, 1fr) minmax(280px, 1fr) minmax(260px, 0.9fr);
  margin: 14px 0;
}

.studio-panel {
  min-height: 250px;
}

.scope-list,
.connector-grid,
.eval-board,
.drill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
}

.scope-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(102, 185, 255, 0.24);
  border-radius: 8px;
  background: rgba(102, 185, 255, 0.08);
  color: #d8ebff;
  padding: 6px 9px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 750;
}

.connector {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
}

.connector-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(243, 179, 81, 0.11);
}

.connector.ready .connector-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(104, 211, 145, 0.11);
}

.connector strong,
.drill-item strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.connector span:last-child,
.drill-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.eval-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
}

.metric-row {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b10;
  padding: 10px;
}

.metric-row span {
  display: block;
  margin-bottom: 8px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-row strong {
  font-size: 18px;
}

.category-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.category-grid span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--muted);
  padding: 5px 0;
  font-size: 11px;
}

.drill-actions {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.drill-actions .button {
  width: 100%;
}

.drill-list {
  display: grid;
}

.drill-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b10;
  padding: 10px;
}

.model-lane {
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  padding: 14px;
}

.lane-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.model-lane strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.model-lane span:last-child {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.workspace {
  grid-template-columns: minmax(0, 1.1fr) minmax(390px, 0.9fr);
  align-items: stretch;
}

.diagnostics {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.75fr);
  margin-top: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 20, 26, 0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 480px;
  overflow: auto;
  padding: 16px;
  background: rgba(0, 0, 0, 0.12);
}

.message {
  max-width: 86%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
  line-height: 1.48;
}

.timestamp {
  display: inline-block;
  margin-right: 7px;
  color: var(--faint);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.message.user {
  align-self: flex-end;
  border-color: rgba(102, 185, 255, 0.3);
  background: rgba(102, 185, 255, 0.11);
}

.message.assistant {
  align-self: flex-start;
  border-color: rgba(66, 214, 188, 0.25);
  background: rgba(66, 214, 188, 0.08);
}

.message.system {
  align-self: stretch;
  max-width: 100%;
  border-style: dashed;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.voice-controls,
.inline-composer {
  display: flex;
  gap: 10px;
}

.voice-panel {
  padding-bottom: 16px;
}

.voice-panel > label,
.voice-panel > .voice-controls,
.voice-panel > .transcript {
  margin: 16px 16px 0;
}

.inline-composer {
  align-items: stretch;
}

.inline-composer input {
  flex: 1;
}

.transcript {
  height: 292px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b10;
  padding: 12px;
}

.transcript-line {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 0;
  color: var(--muted);
  line-height: 1.42;
}

.transcript-line strong {
  color: var(--text);
}

.stage-list {
  display: grid;
  gap: 10px;
  max-height: 540px;
  overflow: auto;
  padding: 14px;
}

.stage {
  border: 1px solid var(--line);
  border-left: 3px solid var(--faint);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 12px;
}

.stage.ok {
  border-left-color: var(--green);
}

.stage.error {
  border-left-color: var(--red);
}

.stage.skipped {
  border-left-color: var(--amber);
}

.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.stage-title {
  font-weight: 800;
}

.stage-meta {
  color: var(--faint);
  font-size: 12px;
  white-space: nowrap;
}

.stage-output,
.raw-log {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #d9e4ec;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.48;
}

.raw-log {
  min-height: 540px;
  max-height: 540px;
  overflow: auto;
  padding: 14px;
  background: #070b10;
}

@media (max-width: 1180px) {
  .connection-panel,
  .model-strip,
  .studio-grid,
  .workspace,
  .diagnostics {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .composer,
  .inline-composer,
  .voice-controls,
  .connection-note {
    flex-direction: column;
    align-items: stretch;
    display: flex;
  }

  .message {
    max-width: 100%;
  }
}
