:root {
  --bg: #0b0810;
  --ink: #f3e9f2;
  --muted: #a493a8;
  --line: rgba(255, 255, 255, 0.09);
  --card: rgba(255, 255, 255, 0.035);
  --accent: #f0a6c8;
  --accent-2: #a98bf5;
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  overflow-x: hidden;
}

/* breathing glow */
.aura {
  position: fixed;
  inset: -30vmax;
  z-index: 0;
  background:
    radial-gradient(38vmax 38vmax at 28% 18%, rgba(240, 166, 200, 0.22), transparent 62%),
    radial-gradient(42vmax 42vmax at 76% 72%, rgba(169, 139, 245, 0.2), transparent 62%),
    radial-gradient(30vmax 30vmax at 55% 48%, rgba(120, 220, 200, 0.1), transparent 60%);
  filter: blur(20px);
  animation: breathe 14s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1) translate3d(0, 0, 0); opacity: 0.85; }
  50% { transform: scale(1.08) translate3d(1.5%, -1.5%, 0); opacity: 1; }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  padding: 10vh 22px 14vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* masthead */
.masthead { text-align: center; margin-bottom: 10px; }

.kicker {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 300;
  font-size: clamp(42px, 10vw, 76px);
  letter-spacing: -0.02em;
  margin: 0;
  background: linear-gradient(100deg, #fff 10%, var(--accent) 50%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  margin: 12px auto 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 15px;
}

/* cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 24px 60px -32px rgba(0, 0, 0, 0.9);
}

.section-label {
  margin: 0 0 16px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* drop zone */
.drop {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.25s;
  color: var(--ink);
}

.drop:hover, .drop:focus-visible, .drop.over {
  border-color: var(--accent);
  background: rgba(240, 166, 200, 0.07);
  outline: none;
  transform: translateY(-1px);
}

.drop.loaded { border-style: solid; border-color: rgba(169, 139, 245, 0.55); }

.drop-icon { width: 30px; height: 30px; opacity: 0.65; margin-bottom: 6px; }
.drop-title { margin: 0; font-size: 15px; }
.drop-hint { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

.or {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.or::before, .or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* fields */
.field { display: block; }
.field-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  resize: vertical;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  padding: 14px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea::placeholder { color: rgba(164, 147, 168, 0.65); font-style: italic; }

textarea:focus {
  outline: none;
  border-color: rgba(240, 166, 200, 0.5);
  box-shadow: 0 0 0 4px rgba(240, 166, 200, 0.1);
}

.meter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 12px;
}

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

/* backend toggle */
.backend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  margin-bottom: 22px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.backend-opt {
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font: inherit;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
}

.backend-opt:hover:not([disabled]) { color: var(--ink); }

.backend-opt[aria-checked="true"] {
  background: linear-gradient(120deg, rgba(240, 166, 200, 0.18), rgba(169, 139, 245, 0.18));
  border-color: rgba(240, 166, 200, 0.4);
  color: var(--ink);
}

.backend-opt[disabled] { opacity: 0.4; cursor: not-allowed; }

.backend-name {
  display: block;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.backend-note {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* voice picker */
.voices { margin-bottom: 22px; }

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.voice-opt {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font: inherit;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}

.voice-opt:hover:not([disabled]) { color: var(--ink); transform: translateY(-1px); }

.voice-opt[aria-checked="true"] {
  background: linear-gradient(120deg, rgba(240, 166, 200, 0.18), rgba(169, 139, 245, 0.18));
  border-color: rgba(240, 166, 200, 0.45);
  color: var(--ink);
}

.voice-name {
  display: block;
  font-family: Fraunces, Georgia, serif;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.voice-blurb {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

/* sliders */
.sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 22px;
}

@media (max-width: 560px) { .sliders { grid-template-columns: 1fr; } }

.slider span {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.slider b { color: var(--ink); font-weight: 400; letter-spacing: 0; }
.slider small { display: block; margin-top: 8px; font-size: 11.5px; color: rgba(164, 147, 168, 0.8); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 5px rgba(240, 166, 200, 0.18);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 5px rgba(240, 166, 200, 0.18); cursor: pointer;
}

/* buttons */
.primary {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 15px 20px;
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: #1a0d16;
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s, opacity 0.18s;
  box-shadow: 0 14px 34px -14px rgba(240, 166, 200, 0.6);
}

.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 18px 40px -14px rgba(240, 166, 200, 0.7); }
.primary:disabled { opacity: 0.5; cursor: progress; }

.ghost {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}

.ghost:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.3); }
.ghost.icon { padding: 6px 10px; font-size: 14px; letter-spacing: -0.05em; }

.status {
  min-height: 20px;
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.status.error { color: #ff9ab0; }

/* player */
.player-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.play {
  flex: none;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #1a0d16;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 0 rgba(240, 166, 200, 0.45);
  transition: transform 0.18s;
}

.play:hover { transform: scale(1.04); }
.play svg { width: 24px; height: 24px; }
.play.playing { animation: pulse 2.6s ease-out infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(240, 166, 200, 0.4); }
  100% { box-shadow: 0 0 0 26px rgba(240, 166, 200, 0); }
}

.player-body { flex: 1; min-width: 0; }

.now {
  margin: 0 0 8px;
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  font-size: 14px;
  color: rgba(243, 233, 242, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seek { height: 4px; }

.times {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

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

.player-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}

.loop { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.loop input { accent-color: var(--accent); }

.passages {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  max-height: 190px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.passages li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.passages li:hover { color: var(--ink); background: rgba(255, 255, 255, 0.03); }
.passages li.active { color: var(--accent); }
.passages li.pending { opacity: 0.45; cursor: default; }
.passages .n { font-variant-numeric: tabular-nums; opacity: 0.6; flex: none; }
.passages .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.foot { text-align: center; font-size: 11.5px; color: rgba(164, 147, 168, 0.65); }

@media (prefers-reduced-motion: reduce) {
  .aura, .play.playing { animation: none; }
}
