:root {
  color-scheme: light;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f4f6fb;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.56);
  --text: #101828;
  --text-soft: #475467;
  --muted: #667085;
  --border: rgba(16, 24, 40, 0.09);
  --border-strong: rgba(16, 24, 40, 0.17);
  --accent: #5b5bd6;
  --accent-2: #0891b2;
  --accent-soft: rgba(91, 91, 214, 0.1);
  --success: #067647;
  --warning: #b54708;
  --warning-soft: rgba(247, 144, 9, 0.11);
  --danger: #b42318;
  --danger-soft: rgba(240, 68, 56, 0.1);
  --shadow-lg: 0 26px 70px -34px rgba(16, 24, 40, 0.38);
  --shadow-sm: 0 12px 28px -20px rgba(16, 24, 40, 0.4);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --gradient: linear-gradient(120deg, #6366f1 0%, #8b5cf6 38%, #06b6d4 100%);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #080b14;
    --surface: rgba(17, 24, 39, 0.74);
    --surface-strong: #111827;
    --surface-soft: rgba(17, 24, 39, 0.52);
    --text: #f2f5fb;
    --text-soft: #c4ccda;
    --muted: #98a2b3;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.19);
    --accent: #9aa0ff;
    --accent-2: #22d3ee;
    --accent-soft: rgba(129, 140, 248, 0.17);
    --success: #75e0a7;
    --warning: #fdb022;
    --warning-soft: rgba(253, 176, 34, 0.11);
    --danger: #fda29b;
    --danger-soft: rgba(253, 162, 155, 0.12);
    --shadow-lg: 0 32px 90px -42px rgba(0, 0, 0, 0.95);
    --shadow-sm: 0 14px 34px -22px rgba(0, 0, 0, 0.95);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(820px 520px at 6% -8%, rgba(99, 102, 241, 0.2), transparent 62%),
    radial-gradient(720px 520px at 102% 4%, rgba(6, 182, 212, 0.15), transparent 60%),
    radial-gradient(640px 520px at 45% 108%, rgba(139, 92, 246, 0.1), transparent 62%),
    var(--bg);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(to right, rgba(16, 24, 40, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(16, 24, 40, 0.035) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at 50% 20%, #000 0%, transparent 72%);
}

@media (prefers-color-scheme: dark) {
  body::after {
    background-image:
      linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  }
}

::selection {
  background: rgba(99, 102, 241, 0.28);
}

img,
svg {
  display: block;
}

a {
  color: var(--accent);
}

button,
input,
textarea,
select {
  font: inherit;
}

:where(a, button, input, textarea, select, summary):focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.45);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border-strong);
  text-decoration: none;
  font-weight: 700;
}

.skip-link:focus {
  top: 12px;
}

/* ---------- Layout ---------- */

.site-header {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 5;
}

.app-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 44px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 16px 28px -16px rgba(99, 102, 241, 0.85);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-text strong {
  font-size: 1.06rem;
  letter-spacing: -0.015em;
}

.brand-sub {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* ---------- Buttons ---------- */

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.1;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.button svg {
  width: 18px;
  height: 18px;
}

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

.button:active {
  transform: translateY(0);
}

.button.primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 16px 32px -18px rgba(99, 102, 241, 0.85);
}

.button.primary:hover {
  filter: brightness(1.06);
}

.button.secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

.button.secondary:hover {
  background: rgba(91, 91, 214, 0.15);
}

.button.ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-soft);
  backdrop-filter: blur(12px);
}

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

.button.small {
  padding: 7px 12px;
  font-size: 0.78rem;
  border-radius: 999px;
}

.button.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.icon-button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  color: var(--text);
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(250px, 0.65fr);
  gap: 36px;
  align-items: center;
  padding: 26px 0 36px;
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(2.5rem, 5.4vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero h1 {
    color: var(--text);
  }
}

.hero-subtitle {
  margin: 0;
  max-width: 58ch;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.68;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.badge {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 0.74rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.badge.accent {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.hero-visual {
  display: grid;
  place-items: center;
}

.studio-tile {
  position: relative;
  width: 100%;
  max-width: 330px;
  aspect-ratio: 1.08;
  border-radius: 34px;
  border: 1px solid var(--border);
  background:
    linear-gradient(150deg, rgba(99, 102, 241, 0.16), rgba(6, 182, 212, 0.1)),
    var(--surface);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  overflow: hidden;
}

.studio-tile::before {
  content: "";
  position: absolute;
  width: 140%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(from 180deg, transparent 0deg, rgba(99, 102, 241, 0.2) 90deg, transparent 190deg);
  animation: spin 18s linear infinite;
}

.studio-tile > * {
  position: relative;
  z-index: 1;
}

.free-pill {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.studio-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  text-align: center;
}

.studio-caption span {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.studio-caption strong {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--text-soft);
}

/* ---------- Waveform ---------- */

.wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 58px;
}

.wave span {
  display: block;
  width: 5px;
  border-radius: 999px;
  background: var(--gradient);
  opacity: 0.92;
  transform-origin: center;
}

.wave.large {
  height: 86px;
  gap: 5px;
}

.wave.large span {
  width: 7px;
}

.wave span:nth-child(1) { height: 28%; }
.wave span:nth-child(2) { height: 52%; }
.wave span:nth-child(3) { height: 74%; }
.wave span:nth-child(4) { height: 44%; }
.wave span:nth-child(5) { height: 92%; }
.wave span:nth-child(6) { height: 62%; }
.wave span:nth-child(7) { height: 100%; }
.wave span:nth-child(8) { height: 56%; }
.wave span:nth-child(9) { height: 84%; }
.wave span:nth-child(10) { height: 42%; }
.wave span:nth-child(11) { height: 68%; }
.wave span:nth-child(12) { height: 50%; }
.wave span:nth-child(13) { height: 32%; }
.wave span:nth-child(14) { height: 46%; }

.equalizer span {
  animation: eq 1.1s ease-in-out infinite alternate;
  animation-play-state: paused;
}

.equalizer span:nth-child(2n) {
  animation-duration: 0.82s;
}

.equalizer span:nth-child(3n) {
  animation-duration: 1.35s;
}

.equalizer.is-playing span {
  animation-play-state: running;
}

/* ---------- Workspace & cards ---------- */

.proxy-notice {
  margin-bottom: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  padding: 26px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.card-head h2 {
  margin: 0;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}

.card-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.result-card {
  position: sticky;
  top: 20px;
}

/* ---------- Fields ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 20px;
}

.field:last-child {
  margin-bottom: 0;
}

label,
.field-label,
.label-row {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-soft);
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.count {
  font-size: 0.76rem;
  font-weight: 550;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.count.is-over {
  color: var(--warning);
}

textarea,
input[type="text"],
input[type="password"],
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--text);
  padding: 13px 15px;
  font-size: 0.94rem;
  line-height: 1.5;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

textarea {
  min-height: 158px;
  resize: vertical;
  line-height: 1.62;
}

textarea::placeholder,
input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

textarea:hover,
input[type="text"]:hover,
input[type="password"]:hover,
select:hover {
  border-color: var(--border-strong);
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-strong);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 19px) calc(50% - 2px),
    calc(100% - 14px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.help {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--muted);
}

.inline-help {
  font-weight: 500;
  text-align: right;
}

.inline-link {
  color: var(--accent);
  font-size: 0.77rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.inline-link:hover {
  text-decoration: underline;
}

.link-button {
  appearance: none;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 650;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.link-button:hover {
  text-decoration: underline;
}

/* ---------- Engine selector ---------- */

.engine-fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
  min-width: 0;
}

.engine-fieldset legend {
  padding: 0;
  margin-bottom: 9px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-soft);
}

.engine-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.engine-tab {
  appearance: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  padding: 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  min-width: 0;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.engine-tab:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.engine-tab[aria-pressed="true"] {
  border-color: transparent;
  background:
    linear-gradient(140deg, rgba(99, 102, 241, 0.14), rgba(6, 182, 212, 0.09)),
    var(--surface-strong);
  box-shadow: inset 0 0 0 1.5px rgba(99, 102, 241, 0.45);
}

.engine-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.engine-icon svg {
  width: 21px;
  height: 21px;
}

.fish-icon {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.12);
}

.mimo-icon {
  color: #ea580c;
  background: rgba(234, 88, 12, 0.12);
}

.engine-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.engine-text strong {
  font-size: 0.88rem;
  letter-spacing: -0.01em;
}

.engine-text small {
  font-size: 0.68rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.engine-check {
  margin-left: auto;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--gradient);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 160ms ease, transform 160ms ease;
}

.engine-check svg {
  width: 12px;
  height: 12px;
}

.engine-tab[aria-pressed="true"] .engine-check {
  opacity: 1;
  transform: scale(1);
}

/* ---------- Chips ---------- */

.preset-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background-color 150ms ease,
    color 150ms ease;
}

.chip:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.chip.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(99, 102, 241, 0.4);
}

.chip-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.65;
}

.chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-official {
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
}

/* ---------- Controls ---------- */

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  margin-bottom: 20px;
}

.controls-grid .field {
  margin: 0;
}

.format-field {
  grid-column: 1 / -1;
}

.format-field .help {
  margin-top: 1px;
}

.range-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-soft);
}

.range-row output {
  color: var(--accent);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.55;
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.55;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
}

/* ---------- Notices ---------- */

.notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 0.8rem;
  line-height: 1.55;
}

.notice.warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: rgba(247, 144, 9, 0.22);
}

.notice.error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(240, 68, 56, 0.23);
}

.notice.info {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(99, 102, 241, 0.2);
}

.notice .inline-link {
  color: inherit;
  text-decoration: underline;
  flex: 0 0 auto;
}

#keyNotice {
  margin-bottom: 16px;
}

.error-copy {
  min-width: 0;
}

.error-copy p {
  margin: 0;
}

.error-copy details {
  margin-top: 8px;
}

.error-copy summary {
  cursor: pointer;
  font-weight: 650;
}

.error-copy pre {
  margin: 8px 0 0;
  padding: 10px;
  max-height: 180px;
  overflow: auto;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (prefers-color-scheme: dark) {
  .error-copy pre {
    background: rgba(255, 255, 255, 0.07);
  }
}

/* ---------- Synthesize ---------- */

.synth-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.synth-button {
  flex: 1;
  padding: 15px 20px;
  font-size: 0.98rem;
  border-radius: 18px;
}

.button-icon {
  display: grid;
  place-items: center;
}

.button-icon svg {
  width: 20px;
  height: 20px;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

.synth-button.is-loading {
  cursor: progress;
  filter: saturate(0.85);
}

.cancel-button {
  flex: 0 0 auto;
}

/* ---------- Result ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 28px 14px 22px;
  color: var(--muted);
}

.empty-wave {
  height: 72px;
  opacity: 0.55;
  margin-bottom: 8px;
}

.empty-wave span {
  width: 4px;
}

.empty-state h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.empty-state p {
  margin: 0;
  max-width: 32ch;
  font-size: 0.82rem;
  line-height: 1.65;
}

#resultError {
  margin-bottom: 16px;
}

.player-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background:
    linear-gradient(150deg, rgba(99, 102, 241, 0.12), rgba(6, 182, 212, 0.07)),
    var(--surface-soft);
}

.player-shell .equalizer {
  height: 46px;
  opacity: 0.85;
}

.player-shell audio {
  width: 100%;
  height: 42px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0 0 16px;
}

.meta-grid > div {
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.meta-grid dt {
  margin-bottom: 3px;
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-grid dd {
  margin: 0;
  font-size: 0.83rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.download-button {
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
}

/* ---------- History ---------- */

.history-section {
  margin-top: 20px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}

.section-head p {
  margin: 4px 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  transition: border-color 150ms ease, background-color 150ms ease;
}

.history-item:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.history-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.history-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 0.7rem;
  color: var(--muted);
}

.engine-pill {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: var(--accent-soft);
}

.engine-pill.mimo {
  color: #c2410c;
  background: rgba(234, 88, 12, 0.12);
}

@media (prefers-color-scheme: dark) {
  .engine-pill.mimo {
    color: #fdba74;
  }
}

.history-voice {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 24ch;
}

.history-text {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.85rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.history-actions .button {
  padding: 6px 10px;
  font-size: 0.72rem;
}

.history-missing {
  font-size: 0.68rem;
  color: var(--warning);
}

.empty-inline {
  margin: 4px 0 0;
  padding: 18px 0 6px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- Footer ---------- */

.site-footer {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.74rem;
}

.site-footer p {
  margin: 0;
}

.footer-proxy {
  opacity: 0.8;
}

/* ---------- Toasts ---------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 60;
  width: min(92vw, 430px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  animation: toast-in 220ms ease both;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

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

.toast.is-leaving {
  animation: toast-out 200ms ease both;
}

/* ---------- Settings page ---------- */

.settings-shell {
  max-width: 980px;
  padding-bottom: 36px;
}

.settings-hero {
  padding: 24px 0 22px;
}

.settings-hero h1 {
  margin: 8px 0 10px;
  font-size: clamp(2rem, 4.5vw, 2.9rem);
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.settings-hero > p {
  margin: 0;
  max-width: 72ch;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.65;
}

.security-note {
  justify-content: flex-start;
  align-items: flex-start;
  margin-bottom: 18px;
}

.security-note svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.security-copy {
  min-width: 0;
}

.security-copy strong {
  display: block;
  margin-bottom: 2px;
  color: inherit;
}

.security-copy p {
  margin: 0;
  opacity: 0.9;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.settings-card {
  padding: 22px;
}

.settings-card.full {
  grid-column: 1 / -1;
}

.settings-card h2 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: -0.015em;
}

.card-subtitle {
  margin: 5px 0 18px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.settings-card .field {
  margin-bottom: 16px;
}

.settings-card .field:last-child {
  margin-bottom: 0;
}

.settings-card .inline-link {
  display: inline-block;
  margin-top: 2px;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 82px;
}

.reveal-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.7rem;
  font-weight: 750;
  color: var(--accent);
  background: var(--accent-soft);
  cursor: pointer;
}

.reveal-btn:hover {
  background: rgba(91, 91, 214, 0.17);
}

.model-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.model-row input {
  flex: 1;
}

.model-row .button {
  flex: 0 0 auto;
  padding: 9px 13px;
  font-size: 0.75rem;
}

.readonly-input {
  color: var(--muted);
  background: var(--surface-soft);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  cursor: default;
}

.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 2px;
}

.settings-actions .button.primary {
  padding: 12px 26px;
  border-radius: 14px;
}

.voice-form {
  display: grid;
  grid-template-columns: 1fr 1.5fr auto;
  gap: 10px;
  align-items: end;
  margin: 16px 0;
}

.voice-form .field {
  margin: 0;
}

.voice-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

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

.voice-row-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 650;
}

.voice-row-id {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.voice-row .button {
  flex: 0 0 auto;
}

.voice-empty {
  margin: 0;
  padding: 12px 0 2px;
  font-size: 0.8rem;
  color: var(--muted);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.data-stat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
}

.settings-footer {
  margin-top: 20px;
  padding: 16px 2px 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.back-link svg {
  width: 17px;
  height: 17px;
}

/* ---------- Keyframes ---------- */

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

@keyframes eq {
  from {
    transform: scaleY(0.38);
  }
  to {
    transform: scaleY(1.14);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-bottom: 28px;
  }

  .hero-visual {
    display: none;
  }

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

  .result-card {
    position: static;
  }

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

  .settings-card.full {
    grid-column: auto;
  }

  .settings-actions {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .site-header {
    padding: 16px 16px 10px;
  }

  .app-shell {
    padding: 0 16px 34px;
  }

  .brand-sub {
    display: none;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .settings-link {
    padding: 9px 13px;
  }

  .settings-link span {
    display: none;
  }

  .settings-link svg {
    width: 20px;
    height: 20px;
  }

  .hero {
    padding-top: 18px;
  }

  .hero-subtitle {
    font-size: 0.94rem;
  }

  .card {
    padding: 18px;
    border-radius: 20px;
  }

  .engine-tabs {
    grid-template-columns: 1fr;
  }

  .controls-grid {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .format-field {
    grid-column: auto;
  }

  .history-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .history-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .history-actions .button {
    flex: 1;
    justify-content: center;
  }

  .synth-row {
    flex-direction: column;
  }

  .section-head {
    align-items: center;
  }

  .site-footer {
    padding: 18px 16px 30px;
    flex-direction: column;
    align-items: flex-start;
  }

  .voice-form {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    justify-content: stretch;
  }

  .settings-actions .button {
    flex: 1;
  }

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

@media (max-width: 420px) {
  .label-row {
    flex-wrap: wrap;
    gap: 4px 12px;
  }

  .toast-host {
    bottom: 14px;
  }
}

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

  .studio-tile::before {
    animation: none;
  }
}

/* Fish voice picker: browse the Fish Audio library instead of pasting IDs. */
.voice-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.picker-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.picker-tab {
  appearance: none;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
}

.picker-tab.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(99, 102, 241, 0.4);
}

.picker-refresh {
  margin-left: auto;
}

#fishVoiceSearch {
  width: 100%;
}

.voice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

.voice-row {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background-color 150ms ease;
}

.voice-row:hover {
  border-color: var(--border-strong);
}

.voice-row.is-active {
  border-color: transparent;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px rgba(99, 102, 241, 0.4);
}

.voice-row-name {
  font-size: 0.88rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.voice-row-meta {
  font-size: 0.74rem;
  color: var(--text-soft);
}

.voice-row-desc {
  font-size: 0.78rem;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.picker-manual-label {
  margin-top: 2px;
}
