:root {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-elevated: rgba(16, 26, 43, 0.82);
  --bg-soft: rgba(22, 36, 58, 0.62);
  --line: rgba(164, 184, 209, 0.16);
  --line-strong: rgba(164, 184, 209, 0.26);
  --text: #edf4ff;
  --muted: #91a4bf;
  --primary: #7dd3fc;
  --primary-strong: #38bdf8;
  --accent: #c4b5fd;
  --success: #86efac;
  --shadow: 0 24px 80px rgba(2, 8, 23, 0.45);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(125, 211, 252, 0.08), transparent 32%),
    linear-gradient(135deg, #09111d 0%, #0c1526 42%, #111d31 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

body::before {
  top: -12rem;
  left: -10rem;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.18), transparent 68%);
}

body::after {
  right: -14rem;
  bottom: -12rem;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 181, 253, 0.14), transparent 70%);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  margin-bottom: 22px;
  padding: 8px 6px 0;
}

.hero-copy {
  max-width: none;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero .eyebrow {
  margin: 0;
  flex: 0 0 auto;
  font-size: 0.68rem;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  flex: 0 0 auto;
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.config-panel {
  flex: 1 1 720px;
  min-width: 320px;
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr)) minmax(260px, 1.6fr);
  gap: 10px;
  align-items: end;
}

.config-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.config-field span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.config-field select {
  width: 100%;
  min-height: 38px;
  padding: 0 32px 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: rgba(12, 20, 34, 0.92);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.config-checkbox {
  align-content: end;
}

.config-checkbox input {
  width: 22px;
  height: 22px;
  margin: 0 0 8px;
  accent-color: var(--primary);
}

.config-current {
  grid-column: 1 / -1;
  min-height: 20px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(23, 35, 56, 0.92), rgba(14, 23, 38, 0.86));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.65), transparent);
  pointer-events: none;
}

.panel-avatar,
.panel-control,
.panel-log {
  padding: 22px;
}

.panel-log {
  grid-column: 1 / -1;
}

.panel-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.avatar-stage {
  position: relative;
  z-index: 1;
  min-height: 100%;
  padding: 18px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at top, rgba(125, 211, 252, 0.16), transparent 40%),
    linear-gradient(180deg, rgba(12, 20, 33, 0.88), rgba(10, 16, 27, 0.98));
  border: 1px solid var(--line);
}

.control-bar {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

button {
  appearance: none;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease, background 140ms ease;
}

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

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  flex: 1 1 0;
  color: #03111b;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 16px 36px rgba(56, 189, 248, 0.28);
}

.btn-secondary {
  flex: 0 0 auto;
  min-width: 126px;
  color: var(--text);
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid var(--line-strong);
}

.status-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.badge {
  min-height: 68px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.4;
  display: flex;
  align-items: center;
}

.audio-viz-mount {
  position: relative;
  z-index: 1;
  width: 100%;
}

.log {
  position: relative;
  z-index: 1;
  margin: 0;
  min-height: 260px;
  max-height: 44vh;
  padding: 14px 16px;
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(7, 13, 22, 0.96), rgba(10, 18, 29, 0.9));
  color: #cfdef3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.48;
}

.log-line {
  min-height: 1.48em;
  padding: 2px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #cfdef3;
}

.log-break,
.log-kind-break {
  height: 10px;
  min-height: 10px;
  padding: 0;
}

.log-debug {
  color: #91a4bf;
}

.log-plain {
  color: #dbeafe;
}

.log-info {
  color: #7dd3fc;
}

.log-success {
  color: #86efac;
}

.log-error {
  color: #fca5a5;
}

.log-kind-create-response {
  color: #60a5fa;
  font-weight: 800;
}

.log-kind-speech-started,
.log-kind-speech-stopped {
  color: #fde047;
  font-weight: 700;
}

.log-kind-committed {
  color: #c084fc;
  font-weight: 800;
}

.log-kind-semantic-vad {
  color: #fb923c;
  font-weight: 700;
}

.log-kind-audio-level-drop {
  color: #d8b4fe;
  font-weight: 900;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

@media (max-width: 980px) {
  .hero-copy {
    gap: 10px;
  }

  .hero .eyebrow {
    font-size: 0.62rem;
  }

  h1 {
    font-size: 1.55rem;
  }

  .config-panel {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    flex-basis: 100%;
  }

  .app-grid {
    grid-template-columns: 1fr;
  }

  .log { max-height: 48vh; }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 100%);
    padding-top: 18px;
    padding-bottom: 24px;
  }

  .hero {
    margin-bottom: 16px;
    padding-inline: 2px;
  }

  .hero-copy {
    display: grid;
    grid-template-columns: 1fr;
    max-width: 760px;
  }

  .hero .eyebrow {
    margin: 0 0 8px;
    font-size: 0.78rem;
  }

  h1 {
    font-size: 2.2rem;
    letter-spacing: -0.04em;
  }

  .config-panel {
    min-width: 0;
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .config-current {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .panel-avatar,
  .panel-control,
  .panel-log {
    padding: 16px;
  }

  .avatar-stage {
    padding: 12px;
  }

  .control-bar,
  .status-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .btn-secondary,
  .btn-primary {
    width: 100%;
  }

  .badge {
    min-height: 60px;
  }

  .log {
    min-height: 260px;
    padding: 14px;
  }
}
