:root {
  --bg: #100f0c;
  --bg-2: #181611;
  --ink: #f3ece1;
  --muted: #9a9083;
  --line: rgba(243, 236, 225, 0.1);
  --brass: #d4a056;
  --brass-2: #e8c48a;
  --andrei: #7eb8c4;
  --elena: #e39b86;
  --danger: #e07a6c;
  --ok: #8fbf88;
  --radius: 22px;
  --font-serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-sans: "Outfit", "Avenir Next", system-ui, sans-serif;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0.01em;
}

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

.grain,
.glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.grain {
  z-index: 0;
  opacity: 0.18;
  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='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

.glow {
  z-index: 0;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(212, 160, 86, 0.16), transparent 55%),
    radial-gradient(700px 360px at 100% 10%, rgba(126, 184, 196, 0.08), transparent 50%);
}

.topbar,
.studio,
.drawer {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--brass);
  border-radius: 50%;
  box-shadow: inset 0 0 0 6px var(--bg), inset 0 0 0 8px var(--brass);
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(143, 191, 136, 0.15);
}

.live-label {
  color: var(--muted);
  font-size: 13px;
  text-transform: lowercase;
}

.ghost-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}

.ghost-btn.sm {
  padding: 6px 12px;
  font-size: 13px;
}

.ghost-btn:hover {
  border-color: rgba(212, 160, 86, 0.45);
  color: var(--brass-2);
}

.studio {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
  gap: 28px;
  padding: 12px 32px 40px;
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 80px);
}

.console {
  padding: 28px 8px 40px;
}

.kicker {
  margin: 0 0 12px;
  color: var(--brass);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 14px;
  font-family: var(--font-serif);
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 480;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.lede {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  max-width: 38ch;
  font-weight: 320;
}

.topic-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
}

.topic-wrap {
  position: relative;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 112px;
  padding: 16px 56px 28px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(24, 22, 17, 0.85);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  outline: none;
}

textarea:focus {
  border-color: rgba(212, 160, 86, 0.7);
  box-shadow: 0 0 0 4px rgba(212, 160, 86, 0.12);
}

.mic-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(16, 15, 12, 0.7);
  color: var(--brass-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.mic-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  position: relative;
  z-index: 1;
}

.mic-btn:hover {
  border-color: rgba(212, 160, 86, 0.5);
  color: var(--brass);
}

.mic-btn.is-recording {
  color: #1a140c;
  background: var(--brass);
  border-color: var(--brass);
}

.mic-btn.is-busy {
  opacity: 0.6;
  cursor: wait;
}

.mic-pulse {
  display: none;
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(212, 160, 86, 0.55);
  animation: pulse 1.2s ease-out infinite;
}

.mic-btn.is-recording .mic-pulse {
  display: block;
}

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

#mic-status:empty {
  display: none;
}

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

.chips button {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
}

.chips button:hover {
  color: var(--ink);
  border-color: rgba(243, 236, 225, 0.28);
}

.primary-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--brass-2), var(--brass));
  color: #1a140c;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
}

.primary-btn:hover {
  filter: brightness(1.05);
}

.primary-btn:disabled {
  cursor: wait;
  filter: saturate(0.7);
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(26, 20, 12, 0.25);
  border-top-color: #1a140c;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.primary-btn.is-busy .btn-spinner {
  display: block;
}

.hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.stage {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 620px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.empty-state,
.loading-state {
  margin: auto;
  text-align: center;
  max-width: 320px;
  color: var(--muted);
}

.vinyl {
  width: 120px;
  height: 120px;
  margin: 0 auto 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--brass) 0 7px, #1c1a16 8px 18px, #0e0d0b 19px 38px, #2a261f 39px 52px, #0e0d0b 53px 60px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  position: relative;
}

.vinyl span {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(212, 160, 86, 0.18);
  border-radius: 50%;
}

.hidden {
  display: none !important;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: grid;
  gap: 10px;
  text-align: left;
}

.steps li {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  position: relative;
}

.steps li.is-active {
  color: var(--ink);
  border-color: rgba(212, 160, 86, 0.45);
  background: rgba(212, 160, 86, 0.06);
}

.steps li.is-done {
  color: var(--ok);
}

.loading-note,
.elapsed {
  margin: 8px 0 0;
  font-size: 13px;
}

.episode-head {
  margin-bottom: 22px;
}

.episode-meta {
  display: flex;
  gap: 14px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  text-transform: lowercase;
}

.episode h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 480;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.player {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  margin-bottom: 28px;
  background: rgba(16, 15, 12, 0.45);
}

.play-btn {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.play-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.play-btn .icon-pause,
.play-btn.is-playing .icon-play {
  display: none;
}

.play-btn.is-playing .icon-pause {
  display: block;
}

.progress-wrap input[type="range"] {
  width: 100%;
  accent-color: var(--brass);
}

.player-times {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.download-btn {
  color: var(--brass-2);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 4px;
}

.transcript-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.transcript-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.transcript {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding-right: 4px;
  max-height: min(48vh, 520px);
}

.transcript.prose {
  gap: 0;
}

.transcript.prose p {
  margin: 0 0 1em;
  line-height: 1.65;
  font-weight: 320;
  color: var(--ink);
}

.transcript.prose p:last-child {
  margin-bottom: 0;
}

.turn {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(16, 15, 12, 0.35);
  border: 1px solid var(--line);
}

.turn .who {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.turn.andrei .who {
  color: var(--andrei);
}

.turn.elena .who {
  color: var(--elena);
}

.turn p {
  margin: 0;
  line-height: 1.55;
  font-weight: 320;
}

.error-banner {
  margin-top: auto;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(224, 122, 108, 0.1);
  border: 1px solid rgba(224, 122, 108, 0.35);
  color: #f0c4bd;
}

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 6, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drawer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(420px, 100%);
  background: #16140f;
  border-left: 1px solid var(--line);
  padding: 24px;
  overflow: auto;
}

.drawer-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.drawer-panel h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 480;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.history-list li {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
}

.history-list li:hover {
  border-color: rgba(212, 160, 86, 0.4);
}

.history-list small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.history-list .empty {
  color: var(--muted);
  cursor: default;
}

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

@keyframes pulse {
  from {
    transform: scale(0.92);
    opacity: 0.9;
  }
  to {
    transform: scale(1.35);
    opacity: 0;
  }
}

@media (max-width: 920px) {
  .studio {
    grid-template-columns: 1fr;
    padding: 8px 18px 32px;
  }

  .topbar {
    padding: 18px 18px 0;
  }

  .stage {
    min-height: 480px;
    padding: 20px;
  }

  .player {
    grid-template-columns: 52px 1fr;
  }

  .download-btn {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-spinner,
  .drawer {
    animation: none;
    transition: none;
  }
}
