:root {
  --ink: #e8eef6;
  --muted: #9aabbf;
  --deep: #0f1620;
  --panel: rgba(26, 35, 50, 0.72);
  --line: rgba(232, 238, 246, 0.12);
  --accent: #3ecf8e;
  --accent-2: #f0a35e;
  --danger: #ff6b6b;
  --doubao: #3d8bfd;
  --qwen: #5ec8c0;
  --stepfun: #e0a45a;
  --font: "Noto Sans SC", "PingFang SC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--deep);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 10% -10%, rgba(62, 207, 142, 0.18), transparent 55%),
    radial-gradient(90% 70% at 100% 0%, rgba(61, 139, 253, 0.2), transparent 50%),
    radial-gradient(70% 50% at 50% 100%, rgba(240, 163, 94, 0.12), transparent 55%),
    linear-gradient(165deg, #121a26 0%, #0f1620 45%, #152032 100%);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100dvh;
}

.brand-name {
  margin: 0;
  font-size: clamp(2.4rem, 10vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.05;
}

.brand-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.vendor-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.vendor {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.vendor .v-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.vendor .v-key {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}

.vendor.active[data-vendor="doubao"] {
  border-color: var(--doubao);
  box-shadow: inset 0 0 0 1px rgba(61, 139, 253, 0.35);
}
.vendor.active[data-vendor="qwen"] {
  border-color: var(--qwen);
  box-shadow: inset 0 0 0 1px rgba(94, 200, 192, 0.35);
}
.vendor.active[data-vendor="stepfun"] {
  border-color: var(--stepfun);
  box-shadow: inset 0 0 0 1px rgba(224, 164, 90, 0.35);
}

.vendor:active {
  transform: scale(0.98);
}

.v-key.ok {
  color: var(--accent);
}
.v-key.missing {
  color: var(--accent-2);
}

.voice-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
}

.voice-label {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.voice-select,
.voice-custom {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 36px 11px 12px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.3;
}

.voice-select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.voice-custom {
  grid-column: 1 / -1;
  padding-right: 12px;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.voice-select:disabled,
.voice-custom:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.voice-select:focus,
.voice-custom:focus {
  outline: none;
  border-color: rgba(62, 207, 142, 0.55);
  box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.15);
}

.prompt-panel {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 0 12px;
}

.prompt-summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 0;
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  user-select: none;
}

.prompt-summary::-webkit-details-marker {
  display: none;
}

.prompt-summary::after {
  content: "▸";
  float: right;
  color: var(--muted);
  transition: transform 160ms ease;
}

.prompt-panel[open] .prompt-summary::after {
  transform: rotate(90deg);
}

.prompt-textarea {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(15, 22, 32, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 10px 12px;
  resize: vertical;
  min-height: 5.5em;
}

.prompt-textarea:focus {
  outline: none;
  border-color: rgba(62, 207, 142, 0.55);
  box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.15);
}

.prompt-textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.prompt-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.talk-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.talk-btn {
  width: min(220px, 70vw);
  height: min(220px, 70vw);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #0b121a;
  background:
    radial-gradient(circle at 35% 30%, #7dffc0 0%, var(--accent) 42%, #1f9d66 100%);
  box-shadow:
    0 18px 40px rgba(62, 207, 142, 0.28),
    inset 0 -8px 18px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.talk-btn .talk-label {
  font-size: 1.35rem;
  font-weight: 700;
}

.talk-btn .talk-hint {
  font-size: 0.78rem;
  opacity: 0.75;
}

.talk-btn[aria-pressed="true"] {
  transform: scale(0.96);
  filter: saturate(1.15);
  background:
    radial-gradient(circle at 35% 30%, #ffd29a 0%, var(--accent-2) 45%, #c06a2a 100%);
  box-shadow:
    0 18px 40px rgba(240, 163, 94, 0.32),
    inset 0 -8px 18px rgba(0, 0, 0, 0.18);
}

.talk-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.metrics-section {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 8px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.m-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.m-value {
  font-size: 1rem;
  font-weight: 600;
}

.m-value.mono,
.mono {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  word-break: break-all;
}

.transcripts {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.lane h2 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.bubble {
  margin: 0;
  min-height: 3.2em;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffb4b4;
  font-size: 0.9rem;
}

@media (min-width: 720px) {
  .app {
    padding-top: 36px;
  }
}
