:root {
  --bg-0: #07070c;
  --bg-1: #0d0e16;
  --bg-2: #14151f;
  --fg-0: #f3f3fa;
  --fg-1: #c2c4d4;
  --fg-2: #8588a0;
  --fg-3: #5a5d75;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #7c5cff;
  --accent-2: #19e3c2;
  --accent-3: #ff5c8a;
  --warn: #ffb84d;
  --err: #ff6470;
  --ok: #2ee59d;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-card: 0 30px 80px -30px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--fg-1);
}

.muted {
  color: var(--fg-2);
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
textarea,
button {
  font-family: inherit;
  color: inherit;
}

/* Background */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(1200px 800px at 20% -10%, #1a1340 0%, transparent 60%),
    radial-gradient(900px 700px at 110% 10%, #0b3a3a 0%, transparent 55%),
    radial-gradient(900px 600px at 50% 120%, #2a0f3c 0%, transparent 50%), var(--bg-0);
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  mix-blend-mode: screen;
  animation: drift 24s ease-in-out infinite;
}

.orb-1 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, #7c5cff, transparent 65%);
  top: -120px;
  left: -120px;
}

.orb-2 {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, #19e3c2, transparent 65%);
  top: 30%;
  right: -120px;
  animation-delay: -8s;
}

.orb-3 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #ff5c8a, transparent 65%);
  bottom: -120px;
  left: 30%;
  animation-delay: -16s;
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(40px, -30px, 0) scale(1.08);
  }
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Layout */
.shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 56px 32px 80px;
}

.hero {
  margin-bottom: 36px;
}

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 14px 20px;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: nowrap;
  min-width: 0;
}

.brand-logo {
  height: clamp(28px, 3.6vw, 46px);
  width: auto;
  opacity: 0.9;
  filter: drop-shadow(0 6px 22px rgba(124, 92, 255, 0.3));
}

.title {
  margin: 0;
  font-weight: 800;
  font-size: clamp(22px, 3vw, 40px);
  letter-spacing: 0.02em;
  background: linear-gradient(120deg, #fff 0%, #c9b9ff 40%, #88ffe5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.title-bracket {
  color: var(--accent);
  opacity: 0.5;
  margin: 0 0.15em;
}

.subtitle {
  margin: 14px 0 0;
  color: var(--fg-2);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.subtitle .sep {
  color: var(--fg-3);
}

.hero-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  justify-self: end;
  min-width: 0;
  max-width: min(100%, 560px);
}

/* Token box + theme/lang toggles share one wrapping row; the status pill always sits
   on its own line below so its variable-length text (e.g. "token required or rejected")
   can't push the controls into a ragged second column. */
.hero-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.lang-toggle,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  padding: 2px;
  gap: 1px;
  backdrop-filter: blur(6px);
}

.lang-btn,
.theme-btn {
  background: transparent;
  border: none;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-btn {
  font-size: 13px;
  line-height: 1;
}

.lang-btn:hover:not(.active),
.theme-btn:hover:not(.active) {
  color: var(--fg-0);
}

.lang-btn.active,
.theme-btn.active {
  background: rgba(124, 92, 255, 0.22);
  color: var(--fg-0);
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.4) inset;
}

/* Token box — sits in the hero controls next to the toggles. */
.token-box {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  padding: 2px 2px 2px 4px;
  gap: 4px;
  backdrop-filter: blur(6px);
}

.token-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg-1);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 4px 6px;
  width: 112px;
}

.token-input::placeholder {
  color: var(--fg-3);
}

.token-apply {
  background: rgba(124, 92, 255, 0.18);
  border: none;
  color: var(--fg-0);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}

.token-apply:hover:not(:disabled) {
  background: rgba(124, 92, 255, 0.32);
}

.token-apply:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Logo variants — dark theme shows the white-text logo, light theme the dark-text one. */
.logo-light {
  display: none;
}

html[data-theme="light"] .logo-dark {
  display: none;
}

html[data-theme="light"] .logo-light {
  display: inline-block;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-1);
  backdrop-filter: blur(6px);
  white-space: nowrap;
  max-width: 280px;
}

.status-label {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--fg-3);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

.status[data-state="ok"] .status-dot {
  background: var(--ok);
  box-shadow: 0 0 12px var(--ok);
}

.status[data-state="err"] .status-dot {
  background: var(--err);
  box-shadow: 0 0 12px var(--err);
}

.status[data-state="warn"] .status-dot {
  background: var(--warn);
  box-shadow: 0 0 12px var(--warn);
}

@media (max-width: 1020px) {
  .hero-row {
    grid-template-columns: 1fr;
  }

  .hero-controls {
    justify-self: end;
    max-width: min(100%, 620px);
  }
}

@media (max-width: 760px) {
  .hero-brand {
    flex-wrap: wrap;
  }

  .title {
    white-space: normal;
  }

  .hero-controls {
    justify-self: stretch;
    align-items: stretch;
  }

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

  .token-box {
    flex: 1 1 220px;
  }

  .token-input {
    flex: 1 1 90px;
    min-width: 0;
    width: auto;
  }

  .status {
    justify-content: center;
    max-width: none;
  }
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
}

.card {
  grid-column: span 4;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 40px 90px -28px rgba(0, 0, 0, 0.7),
    0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

@media (max-width: 1100px) {
  .card {
    grid-column: span 6;
  }
}

@media (max-width: 760px) {
  .card {
    grid-column: span 12;
  }
}

.card-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 12px;
}

.num {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  /* Color set per-card below for visual rhythm. */
  color: var(--accent-2);
  background: rgba(25, 227, 194, 0.1);
  border: 1px solid rgba(25, 227, 194, 0.25);
}

#card-clone .num {
  color: var(--accent);
  background: rgba(124, 92, 255, 0.1);
  border-color: rgba(124, 92, 255, 0.3);
}

#card-library .num {
  color: var(--accent-2);
  background: rgba(25, 227, 194, 0.1);
  border-color: rgba(25, 227, 194, 0.3);
}

#card-synth .num {
  color: var(--accent-3);
  background: rgba(255, 92, 138, 0.1);
  border-color: rgba(255, 92, 138, 0.3);
}

.card-sub {
  margin: 6px 0 0;
  color: var(--fg-2);
  font-size: 13px;
}

/* Form fields */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.field-row .field-label {
  flex: 1 1 170px;
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-2);
  font-family: var(--font-mono);
}

input[type="text"],
textarea {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--fg-0);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
  width: 100%;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

.advanced {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-left: 2px solid rgba(25, 227, 194, 0.45);
  border-radius: var(--radius-sm);
  padding: 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.012));
}

.advanced summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-2);
  line-height: 1.45;
  user-select: none;
}

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

.advanced summary::before {
  content: "▸ ";
  color: var(--accent-2);
  display: inline-block;
  transition: transform 0.15s;
}

.advanced[open] summary::before {
  content: "▾ ";
}

.advanced[open] {
  padding-bottom: 16px;
}

.advanced .field {
  padding: 0 14px;
}

.advanced .field + .field {
  margin-top: 13px;
}

#clone-ref-text {
  min-height: 116px;
  line-height: 1.45;
}

.field-status {
  min-height: 16px;
  font-size: 11px;
  color: var(--fg-3);
}

.field-status[hidden] {
  display: none;
}

/* Buttons */
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5a3eff);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  transition: transform 0.08s, box-shadow 0.2s, opacity 0.15s;
  box-shadow: 0 10px 28px -10px rgba(124, 92, 255, 0.7);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px -10px rgba(124, 92, 255, 0.9);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-ghost {
  background: transparent;
  color: var(--fg-1);
  border: 1px solid var(--line-strong);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-mini {
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  min-height: 34px;
}

#btn-transcribe-ref {
  color: var(--warn);
  border-color: rgba(255, 184, 77, 0.4);
  background: rgba(255, 184, 77, 0.07);
}

#btn-transcribe-ref:hover:not(:disabled) {
  color: #ffd58a;
  border-color: rgba(255, 184, 77, 0.72);
  background: rgba(255, 184, 77, 0.12);
}

#btn-transcribe-ref:disabled {
  color: rgba(255, 184, 77, 0.55);
  border-color: rgba(255, 184, 77, 0.22);
  background: rgba(255, 184, 77, 0.04);
}

/* Record */
.rec-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#waveform {
  width: 100%;
  height: 100px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: block;
}

.rec-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-rec {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 92, 138, 0.08);
  display: grid;
  place-items: center;
  position: relative;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  flex-shrink: 0;
}

.btn-rec:hover {
  background: rgba(255, 92, 138, 0.15);
  border-color: var(--accent-3);
}

.btn-rec-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-3);
  box-shadow: 0 0 0 0 rgba(255, 92, 138, 0.6);
}

.btn-rec[data-recording="true"] .btn-rec-dot {
  border-radius: 4px;
  width: 16px;
  height: 16px;
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 92, 138, 0.55);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(255, 92, 138, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 92, 138, 0);
  }
}

.rec-meta {
  display: flex;
  flex-direction: column;
}

.rec-timer {
  font-size: 22px;
  color: var(--fg-0);
  letter-spacing: 0.05em;
}

.rec-hint {
  font-size: 12px;
  color: var(--fg-2);
}

/* Custom audio player */
.audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.audio-player[hidden] {
  display: none;
}

.ap-play {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.25), rgba(124, 92, 255, 0.1));
  color: var(--fg-0);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}

.ap-play:hover {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.45), rgba(124, 92, 255, 0.2));
  border-color: var(--accent);
}

.ap-play:active {
  transform: scale(0.95);
}

.ap-icon {
  font-size: 12px;
  line-height: 1;
}

.ap-progress {
  flex: 1;
  height: 14px;
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
  touch-action: none;
}

.ap-progress::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

.ap-progress-fill {
  position: relative;
  height: 6px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  pointer-events: none;
}

.ap-progress-fill::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--fg-0);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.35), 0 4px 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease-out;
}

.ap-progress:hover .ap-progress-fill::after,
.ap-progress:active .ap-progress-fill::after {
  transform: translateY(-50%) scale(1);
}

.ap-time {
  font-size: 11px;
  color: var(--fg-2);
  flex-shrink: 0;
  min-width: 70px;
  text-align: right;
}

/* Clone progress */
.clone-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
}

.clone-progress .step {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.clone-progress .step.active {
  color: var(--accent-2);
  border-color: var(--accent-2);
  background: rgba(25, 227, 194, 0.08);
}

.clone-progress .step.done {
  color: var(--ok);
  border-color: rgba(46, 229, 157, 0.4);
}

.clone-progress .step.err {
  color: var(--err);
  border-color: rgba(255, 100, 112, 0.4);
}

/* Library */
.lib-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lib-count {
  font-size: 11px;
  color: var(--fg-3);
}

.voice-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.voice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.voice-row:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
}

.voice-row.selected {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.12), transparent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.voice-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.voice-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-meta {
  font-size: 10px;
  color: var(--fg-3);
  letter-spacing: 0.04em;
}

.voice-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}

.voice-tag.builtin {
  color: var(--accent-2);
  background: rgba(25, 227, 194, 0.1);
  border: 1px solid rgba(25, 227, 194, 0.25);
}

.voice-tag.uploaded {
  color: var(--accent);
  background: rgba(124, 92, 255, 0.1);
  border: 1px solid rgba(124, 92, 255, 0.3);
}

.btn-del {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  transition: color 0.15s, border-color 0.15s;
}

.btn-del:hover {
  color: var(--err);
  border-color: rgba(255, 100, 112, 0.4);
}

.lib-empty {
  color: var(--fg-3);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
  font-style: italic;
}

/* Synth */
.selected-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s, background 0.2s;
}

.lang-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(0, 0, 0, 0.3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%238588a0' stroke-width='1.6'><path d='M1.5 2 6 6.5 10.5 2'/></svg>") no-repeat right 12px center;
  background-size: 11px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 32px 7px 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  flex: 1;
  min-width: 0;
}

.lang-select:hover {
  border-color: var(--line-strong);
}

.lang-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

.lang-select option {
  background: var(--bg-2);
  color: var(--fg-0);
}

.selected-voice[data-empty="true"] {
  border-color: rgba(255, 184, 77, 0.4);
  background: rgba(255, 184, 77, 0.06);
  animation: subtle-pulse 2.6s ease-in-out infinite;
}

.selected-voice[data-empty="true"] .mono {
  color: var(--warn);
}

.selected-voice[data-empty="false"] {
  border-color: rgba(124, 92, 255, 0.45);
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.12), transparent);
}

.selected-voice[data-empty="false"] .mono {
  color: var(--accent-2);
  font-weight: 500;
}

@keyframes subtle-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 184, 77, 0);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(255, 184, 77, 0.08);
  }
}

#eq {
  width: 100%;
  height: 80px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: block;
}

/* Shared slot so generating ↔ latency swap in place with no layout shift.
   Reserve the worst-case width up front so the badge never grows or wraps. */
.status-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  min-height: 38px;
}

.status-slot > * {
  width: 100%;
  justify-content: center;
}

/* Status pills in the actions row — match button height for visual alignment. */
.latency,
.generating {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  line-height: 1;
}

.latency {
  color: var(--accent-2);
  border-color: rgba(25, 227, 194, 0.3);
  background: rgba(25, 227, 194, 0.08);
}

.generating {
  color: var(--accent);
  border-color: rgba(124, 92, 255, 0.4);
  background: rgba(124, 92, 255, 0.1);
}

/* The [hidden] attribute must beat our custom display rules above. */
.latency[hidden],
.generating[hidden] {
  display: none;
}

.spinner {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(124, 92, 255, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Mode toggle */
.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  background: rgba(0, 0, 0, 0.3);
  gap: 2px;
  width: fit-content;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.mode-btn:hover:not(.active) {
  color: var(--fg-1);
  background: rgba(255, 255, 255, 0.03);
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.25), rgba(124, 92, 255, 0.1));
  color: var(--fg-0);
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.4) inset;
}

.mode-hint {
  color: var(--fg-3);
  font-weight: 400;
}

.mode-btn.active .mode-hint {
  color: var(--fg-2);
}

/* Footer */
.site-footer {
  margin-top: 60px;
  padding: 24px 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: var(--fg-3);
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-logo {
  height: 18px;
  width: auto;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.footer-logo:hover {
  opacity: 0.85;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modal-fade 0.15s ease-out;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(14px);
  animation: modal-scale 0.2s ease-out;
}

.modal-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.modal-msg {
  margin: 0 0 24px;
  color: var(--fg-1);
  line-height: 1.55;
  font-size: 13px;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-primary.danger {
  background: linear-gradient(135deg, #ff5468, #c0394f);
  box-shadow: 0 10px 28px -10px rgba(255, 100, 112, 0.6);
}

.btn-primary.danger:hover:not(:disabled) {
  box-shadow: 0 14px 32px -10px rgba(255, 100, 112, 0.85);
}

@keyframes modal-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-scale {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Toasts */
.toasts {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(20, 21, 31, 0.95);
  border: 1px solid var(--line-strong);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  max-width: 360px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.25s ease-out;
  backdrop-filter: blur(10px);
}

.toast.ok {
  border-left: 3px solid var(--ok);
}

.toast.err {
  border-left: 3px solid var(--err);
}

.toast.info {
  border-left: 3px solid var(--accent);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===========================================================================
   Light theme — scoped under html[data-theme="light"]. The dark theme is the
   default (no attribute / data-theme="dark") and is left completely untouched.
   This block (a) flips the palette tokens and (b) re-skins the few surfaces
   that hardcode white/black-alpha or dark gradients so they read on a light bg.
   The two visualizer canvases (#waveform, #eq) intentionally stay dark.
   =========================================================================== */
html[data-theme="light"] {
  --bg-0: #eef0f6;
  --bg-1: #ffffff;
  --bg-2: #f4f5fa;
  --fg-0: #181a26;
  --fg-1: #3c3f52;
  --fg-2: #61647a;
  --fg-3: #9296ab;
  --line: rgba(20, 22, 40, 0.12);
  --line-strong: rgba(20, 22, 40, 0.22);
  --shadow-card: 0 20px 50px -28px rgba(20, 22, 40, 0.25),
    0 1px 0 rgba(255, 255, 255, 0.7) inset;
  color-scheme: light;
}

html[data-theme="light"] .backdrop {
  background: radial-gradient(1200px 800px at 20% -10%, rgba(124, 92, 255, 0.1) 0%, transparent 60%),
    radial-gradient(900px 700px at 110% 10%, rgba(25, 227, 194, 0.1) 0%, transparent 55%),
    radial-gradient(900px 600px at 50% 120%, rgba(255, 92, 138, 0.08) 0%, transparent 50%),
    var(--bg-0);
}

html[data-theme="light"] .orb {
  mix-blend-mode: multiply;
  opacity: 0.12;
}

html[data-theme="light"] .title {
  background: linear-gradient(120deg, #1b1340 0%, #5a3eff 45%, #0c9c86 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

html[data-theme="light"] .brand-logo {
  opacity: 1;
  filter: drop-shadow(0 4px 14px rgba(124, 92, 255, 0.18));
}

html[data-theme="light"] .lang-toggle,
html[data-theme="light"] .theme-toggle,
html[data-theme="light"] .token-box,
html[data-theme="light"] .status {
  background: rgba(20, 22, 40, 0.04);
}

html[data-theme="light"] .card {
  background: linear-gradient(180deg, #ffffff, #f7f8fc);
}

html[data-theme="light"] input[type="text"],
html[data-theme="light"] textarea {
  background: #ffffff;
}

html[data-theme="light"] .lang-select {
  background-color: #ffffff;
}

html[data-theme="light"] .advanced {
  border-color: rgba(20, 22, 40, 0.1);
  background: linear-gradient(180deg, #f7f8fc, #fdfdff);
}

html[data-theme="light"] .btn-ghost:hover:not(:disabled) {
  background: rgba(20, 22, 40, 0.04);
}

html[data-theme="light"] .audio-player {
  background: #ffffff;
}

html[data-theme="light"] .ap-progress::before {
  background: rgba(20, 22, 40, 0.12);
}

html[data-theme="light"] .voice-row,
html[data-theme="light"] .selected-voice {
  background: #ffffff;
}

html[data-theme="light"] .voice-row:hover {
  background: rgba(20, 22, 40, 0.035);
}

html[data-theme="light"] .mode-toggle {
  background: rgba(20, 22, 40, 0.05);
}

html[data-theme="light"] .mode-btn:hover:not(.active) {
  background: rgba(20, 22, 40, 0.04);
}

html[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.97);
}

html[data-theme="light"] .modal-card {
  background: linear-gradient(180deg, #ffffff, #f7f8fc);
}

/* Visualizer screens: lighter grey panel in light theme (the live waveform uses a
   vivid accent gradient, so it stays readable on a light background). */
html[data-theme="light"] #waveform,
html[data-theme="light"] #eq {
  background: #dfe2ec;
}
