:root {
  --bg: #07101d;
  --panel: rgba(16, 27, 45, 0.82);
  --panel-border: rgba(151, 190, 255, 0.16);
  --text: #f2f7ff;
  --muted: #9cacc4;
  --blue: #7ab8ff;
  --cyan: #65e8d2;
  --red: #ff8e9a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 8%, rgba(52, 133, 255, 0.24), transparent 34rem),
    radial-gradient(circle at 86% 30%, rgba(49, 220, 190, 0.14), transparent 30rem),
    linear-gradient(145deg, #07101d 0%, #0a1424 50%, #08101b 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.shell {
  position: relative;
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.hero { margin-bottom: 28px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 0 rgba(101, 232, 210, 0.55);
  animation: pulse 2.2s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 9px rgba(101, 232, 210, 0); }
  100% { box-shadow: 0 0 0 0 rgba(101, 232, 210, 0); }
}

h1 {
  max-width: 720px;
  margin: 14px 0 12px;
  font-size: clamp(2.5rem, 7vw, 5.3rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.lede {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.7;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.control-panel,
.transcript-panel,
.audio-panel,
.debug-panel {
  margin-top: 18px;
  padding: 24px;
}

.status-row,
.meter-heading,
.section-heading,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
}

.badge {
  padding: 7px 11px;
  border: 1px solid rgba(122, 184, 255, 0.24);
  border-radius: 999px;
  color: var(--blue);
  background: rgba(122, 184, 255, 0.08);
  font-size: 0.78rem;
  white-space: nowrap;
}

.badge.ready {
  border-color: rgba(101, 232, 210, 0.3);
  color: var(--cyan);
  background: rgba(101, 232, 210, 0.09);
}

.badge.error {
  border-color: rgba(255, 142, 154, 0.35);
  color: var(--red);
  background: rgba(255, 142, 154, 0.09);
}

.token-field {
  display: grid;
  gap: 9px;
  margin: 24px 0 20px;
  font-size: 0.9rem;
  font-weight: 650;
}

.token-field input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(151, 190, 255, 0.2);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: rgba(4, 10, 20, 0.7);
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.token-field input:focus {
  border-color: rgba(122, 184, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(122, 184, 255, 0.11);
}

.token-field small,
.hint {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.55;
}

.meter { margin: 18px 0 24px; }

.meter-heading {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.meter-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

#meterFill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  box-shadow: 0 0 18px rgba(101, 232, 210, 0.38);
  transition: width 80ms linear;
}

.actions { justify-content: flex-start; flex-wrap: wrap; }

.button {
  min-width: 126px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.42; }
.button.primary { color: #07121e; background: linear-gradient(135deg, #a8d2ff, #65e8d2); }
.button.secondary { background: rgba(122, 184, 255, 0.1); border-color: rgba(122, 184, 255, 0.25); }
.button.danger { background: rgba(255, 142, 154, 0.1); border-color: rgba(255, 142, 154, 0.3); color: #ffd0d5; }

.hint { min-height: 1.55em; margin: 14px 0 0; }
.hint.warning { color: #ffd28b; }

.section-heading h2 {
  margin: 0;
  font-size: 1.06rem;
  letter-spacing: -0.01em;
}

.text-button {
  border: 0;
  padding: 4px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.text-button:hover { color: var(--text); }

.transcript {
  display: grid;
  gap: 12px;
  min-height: 180px;
  max-height: 420px;
  margin-top: 18px;
  padding-right: 4px;
  overflow-y: auto;
  align-content: start;
}

.empty {
  margin: 36px 0;
  color: var(--muted);
  text-align: center;
}

.bubble {
  width: min(78%, 620px);
  padding: 12px 15px;
  border: 1px solid rgba(151, 190, 255, 0.14);
  border-radius: 16px 16px 16px 5px;
  background: rgba(122, 184, 255, 0.08);
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.bubble.user { justify-self: end; border-radius: 16px 16px 5px 16px; background: rgba(101, 232, 210, 0.09); }
.bubble.assistant { justify-self: start; }
.bubble .speaker { display: block; margin-bottom: 4px; color: var(--muted); font-size: 0.72rem; font-weight: 750; letter-spacing: 0.08em; }

.audio-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.audio-panel audio { width: min(440px, 60%); }

.debug-panel { padding-top: 18px; padding-bottom: 18px; }
.debug-panel summary { cursor: pointer; font-weight: 700; }
.debug-panel pre {
  max-height: 220px;
  margin: 16px 0 0;
  padding: 14px;
  overflow: auto;
  border-radius: 13px;
  color: #bac8dd;
  background: rgba(3, 8, 16, 0.65);
  font: 0.77rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 920px); padding: 36px 0 48px; }
  .control-panel, .transcript-panel, .audio-panel, .debug-panel { padding: 18px; border-radius: 19px; }
  .status-row { align-items: flex-start; }
  .button { flex: 1 1 calc(50% - 8px); min-width: 0; }
  .button.primary { flex-basis: 100%; }
  .audio-panel { align-items: stretch; flex-direction: column; }
  .audio-panel audio { width: 100%; }
  .bubble { width: 88%; }
}
