:root {
  color-scheme: light;
  --bg: #edf0ed;
  --surface: #ffffff;
  --surface-muted: #f5f7f5;
  --ink: #17201d;
  --ink-soft: #66716d;
  --line: #dce2de;
  --header: #202624;
  --accent: #087f6b;
  --accent-dark: #066755;
  --accent-soft: #dcf2ec;
  --amber: #c97a16;
  --danger: #c74343;
  --shadow: 0 1px 2px rgba(16, 28, 24, 0.08), 0 8px 24px rgba(16, 28, 24, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button, select { cursor: pointer; }
button:disabled, input:disabled { cursor: not-allowed; }

.app-header {
  min-height: 76px;
  padding: 14px clamp(18px, 3vw, 40px);
  background: var(--header);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #76dbc7;
  background: #303936;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-block h1 { margin: 0; font-size: 18px; line-height: 1.2; font-weight: 700; text-wrap: balance; }
.brand-block p { margin: 3px 0 0; color: #aab4b0; font-size: 12px; }

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #cbd2cf;
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #7b8581; box-shadow: 0 0 0 3px rgba(123,133,129,.14); }
.status-dot.connecting { background: var(--amber); box-shadow: 0 0 0 3px rgba(201,122,22,.18); }
.status-dot.connected { background: #54d5b8; box-shadow: 0 0 0 3px rgba(84,213,184,.18); }
.status-dot.error { background: #ed6d6d; box-shadow: 0 0 0 3px rgba(237,109,109,.18); }
.session-time { color: #8f9995; padding-left: 8px; margin-left: 4px; border-left: 1px solid #3d4643; min-width: 48px; }

.workspace {
  width: min(1480px, 100%);
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.config-panel {
  padding: 28px 26px 32px;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
  z-index: 1;
}
.panel-heading, .stage-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading { margin-bottom: 24px; }
.section-kicker { display: block; margin-bottom: 3px; color: var(--accent); font-size: 10px; line-height: 1.4; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h2 { margin: 0; font-size: 19px; line-height: 1.3; letter-spacing: 0; }

.icon-button, .input-icon, .round-control, .clear-button, .send-button {
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  transition-property: background-color, color, transform, opacity;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(.2,0,0,1);
}
.icon-button:active, .input-icon:active, .round-control:active, .clear-button:active, .send-button:active, .primary-button:active, .talk-control:active { transform: scale(.96); }
.icon-button { width: 40px; height: 40px; border-radius: 5px; color: var(--ink-soft); }
.icon-button:hover { background: var(--surface-muted); color: var(--ink); }
.icon-button svg, .input-icon svg, .clear-button svg, .send-button svg { width: 17px; height: 17px; }

.field-group { display: grid; gap: 7px; margin-bottom: 18px; min-width: 0; }
.field-group > span:first-child { color: #34403c; font-size: 12px; font-weight: 700; }
.field-group small { color: var(--ink-soft); font-size: 11px; line-height: 1.35; text-wrap: pretty; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfd7d2;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  transition-property: border-color, box-shadow, background-color;
  transition-duration: 150ms;
}
input, select { height: 42px; padding: 0 11px; }
textarea { padding: 10px 11px; resize: vertical; min-height: 88px; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #98a29e; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,127,107,.12); }
input:disabled { background: #eef1ef; }

.input-with-action { display: grid; grid-template-columns: minmax(0, 1fr) 42px; position: relative; }
.input-with-action input { grid-column: 1 / -1; grid-row: 1; padding-right: 45px; }
.input-icon { grid-column: 2; grid-row: 1; z-index: 1; width: 42px; height: 42px; color: var(--ink-soft); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 6px; background: #edf1ee; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { height: 36px; display: grid; place-items: center; border-radius: 4px; color: var(--ink-soft); font-size: 12px; font-weight: 700; cursor: pointer; transition-property: background-color, color, box-shadow; transition-duration: 150ms; }
.segmented input:checked + span { color: var(--ink); background: #fff; box-shadow: 0 1px 2px rgba(20,32,28,.12); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.two-column-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.primary-button {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 1px 2px rgba(3,77,63,.24), 0 7px 16px rgba(3,77,63,.13);
  transition-property: background-color, transform, box-shadow;
  transition-duration: 160ms;
}
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { opacity: .65; }
.button-icon { display: grid; place-items: center; }
.button-icon svg, .primary-button svg { width: 17px; height: 17px; }
.icon-disconnect, .is-connected .icon-connect { display: none; }
.is-connected .icon-disconnect { display: grid; }
.is-connected.primary-button { background: #37413e; box-shadow: none; }

.connection-meta { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; gap: 9px; }
.connection-meta[hidden] { display: none; }
.connection-meta div { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11px; }
.connection-meta span { color: var(--ink-soft); }
.connection-meta strong { font-weight: 650; }

.console-panel { min-width: 0; display: grid; grid-template-rows: 292px 48px minmax(260px, 1fr) 68px; min-height: calc(100vh - 76px); }
.voice-stage { position: relative; overflow: hidden; background: #f8faf8; padding: 28px 34px 20px; box-shadow: inset 0 -1px 0 var(--line); }
.voice-stage::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; opacity: 0; background: var(--accent); transition-property: opacity; transition-duration: 180ms; }
.voice-stage.listening::after { opacity: 1; }
.latency-stat { display: flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; }
.latency-stat svg { width: 16px; }
.level-canvas { display: block; width: 100%; height: 112px; margin: 18px 0 12px; }
.voice-controls { display: flex; justify-content: center; align-items: center; gap: 13px; }
.round-control { width: 44px; height: 44px; border-radius: 50%; background: #fff; color: #56615d; box-shadow: 0 1px 2px rgba(16,28,24,.1), 0 5px 16px rgba(16,28,24,.08); }
.round-control:hover:not(:disabled) { color: var(--ink); background: #f2f5f3; }
.round-control:disabled { opacity: .42; }
.round-control svg { width: 18px; }
.round-control.danger:hover:not(:disabled) { color: var(--danger); background: #fff3f3; }
.round-control .icon-muted, .round-control.is-muted .icon-mic { display: none; }
.round-control.is-muted .icon-muted { display: grid; color: var(--danger); }
.talk-control { min-width: 194px; height: 46px; padding: 0 18px; border: 0; border-radius: 5px; display: flex; align-items: center; justify-content: center; gap: 9px; background: #dde4e0; color: #4c5853; font-size: 12px; font-weight: 750; transition-property: color, background-color, transform, box-shadow; transition-duration: 150ms; }
.talk-control svg { width: 18px; }
.talk-control:disabled { opacity: .58; cursor: not-allowed; }
.talk-control.manual { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(3,77,63,.2), 0 6px 16px rgba(3,77,63,.12); }
.talk-control.manual.talking { background: var(--danger); box-shadow: 0 0 0 4px rgba(199,67,67,.14); }

.console-tabs { background: var(--surface); padding: 0 26px; display: flex; align-items: stretch; gap: 4px; box-shadow: inset 0 -1px 0 var(--line); }
.tab-button { min-width: 118px; min-height: 48px; padding: 0 10px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--ink-soft); display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 12px; font-weight: 700; }
.tab-button svg { width: 16px; }
.tab-button:hover { color: var(--ink); }
.tab-button.active { color: var(--accent); border-bottom-color: var(--accent); }
.event-count { min-width: 20px; padding: 2px 5px; border-radius: 9px; background: #e9eeeb; color: #65706c; font-size: 10px; font-variant-numeric: tabular-nums; }
.clear-button { width: 44px; height: 44px; margin: 2px 0 2px auto; border-radius: 5px; color: var(--ink-soft); }
.clear-button:hover { color: var(--danger); background: #fff3f3; }

.tab-content { min-height: 0; overflow: hidden; background: var(--surface); }
.tab-content > section { height: 100%; overflow-y: auto; }
.empty-state { min-height: 100%; padding: 48px 24px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--ink-soft); }
.empty-state[hidden] { display: none; }
.empty-state svg { width: 28px; height: 28px; color: #8a9691; margin-bottom: 10px; }
.empty-state h3 { margin: 0 0 5px; color: #3c4743; font-size: 14px; }
.empty-state p { margin: 0; font-size: 12px; text-wrap: pretty; }
.transcript-list { max-width: 860px; margin: 0 auto; padding: 26px 30px 34px; display: grid; gap: 20px; }
.transcript-entry { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 14px; animation: entry-in 180ms cubic-bezier(.2,0,0,1) both; }
@keyframes entry-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.transcript-role { padding-top: 2px; color: var(--ink-soft); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.transcript-entry.assistant .transcript-role { color: var(--accent); }
.transcript-copy { margin: 0; font-size: 14px; line-height: 1.58; white-space: pre-wrap; text-wrap: pretty; overflow-wrap: anywhere; }
.transcript-copy.streaming::after { content: ""; display: inline-block; width: 5px; height: 14px; margin-left: 3px; background: var(--accent); vertical-align: -2px; opacity: .7; }

.events-toolbar { position: sticky; top: 0; z-index: 2; min-height: 54px; padding: 8px 24px; background: rgba(255,255,255,.96); display: flex; align-items: center; justify-content: space-between; gap: 14px; box-shadow: 0 1px 0 var(--line); }
.filter-input { width: min(340px, 62%); position: relative; }
.filter-input svg { position: absolute; left: 11px; top: 12px; width: 16px; color: var(--ink-soft); }
.filter-input input { height: 38px; padding-left: 35px; }
.toggle-row { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 11px; white-space: nowrap; }
.toggle-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.event-list { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 11px; }
.event-row { display: grid; grid-template-columns: 76px minmax(180px, 280px) minmax(0, 1fr); gap: 14px; padding: 9px 24px; box-shadow: inset 0 -1px 0 #edf0ee; }
.event-row:hover { background: #f8faf8; }
.event-time { color: #8a9490; font-variant-numeric: tabular-nums; }
.event-type { color: #155f52; font-weight: 700; overflow-wrap: anywhere; }
.event-detail { color: #66716d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-row.outbound .event-type { color: #8b5b15; }
.event-row.error .event-type { color: var(--danger); }

.text-composer { padding: 12px 24px; background: #f8faf8; display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; align-items: center; box-shadow: inset 0 1px 0 var(--line); }
.text-composer input { height: 44px; }
.send-button { width: 44px; height: 44px; border-radius: 5px; background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(3,77,63,.2); }
.send-button:hover:not(:disabled) { background: var(--accent-dark); }
.send-button:disabled { opacity: .4; }

.toast { position: fixed; z-index: 10; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(520px, calc(100vw - 32px)); min-height: 44px; padding: 10px 14px; border-radius: 6px; background: #242a28; color: #fff; display: flex; align-items: center; gap: 9px; box-shadow: 0 12px 40px rgba(0,0,0,.24); font-size: 12px; }
.toast[hidden] { display: none; }
.toast svg { width: 17px; flex: 0 0 auto; color: #f1ab52; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 320px minmax(0, 1fr); }
  .config-panel { padding-inline: 20px; }
  .voice-stage { padding-inline: 24px; }
  .event-row { grid-template-columns: 68px minmax(150px, 220px) minmax(0, 1fr); padding-inline: 18px; }
}

@media (max-width: 720px) {
  .app-header { min-height: 68px; padding: 11px 16px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand-block h1 { font-size: 15px; }
  .brand-block p { display: none; }
  .header-status { font-size: 11px; }
  .session-time { display: none; }
  .workspace { display: block; min-height: 0; }
  .config-panel { padding: 22px 18px 24px; box-shadow: 0 1px 0 var(--line); }
  .console-panel { grid-template-rows: 264px 48px minmax(320px, 55vh) 68px; min-height: auto; }
  .voice-stage { padding: 22px 18px 16px; }
  .level-canvas { height: 94px; margin-block: 13px 10px; }
  .talk-control { min-width: 180px; }
  .console-tabs { padding-inline: 10px; }
  .tab-button { min-width: 108px; }
  .transcript-list { padding: 22px 18px 28px; }
  .transcript-entry { grid-template-columns: 56px minmax(0, 1fr); gap: 10px; }
  .events-toolbar { padding-inline: 12px; }
  .event-row { grid-template-columns: 60px minmax(0, 1fr); gap: 8px; padding: 9px 12px; }
  .event-detail { grid-column: 2; }
  .text-composer { padding-inline: 12px; }
}

@media (max-width: 420px) {
  .header-status #statusText { max-width: 88px; overflow: hidden; text-overflow: ellipsis; }
  .two-column-fields { grid-template-columns: 1fr; gap: 0; }
  .voice-controls { gap: 9px; }
  .talk-control { min-width: 0; flex: 1; padding-inline: 10px; }
  .round-control { flex: 0 0 42px; width: 42px; height: 42px; }
  .tab-button { min-width: 0; flex: 1; }
  .events-toolbar { align-items: stretch; flex-direction: column; }
  .filter-input { width: 100%; }
}

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