:root {
  color-scheme: dark;
  --bg: #090a0a;
  --panel: rgba(18, 21, 21, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.24);
  --text: #f5f7f1;
  --muted: #aeb7ad;
  --soft: #d8ddd5;
  --teal: #28d7c2;
  --amber: #f8b84a;
  --coral: #ff6b57;
  --violet: #9c7dff;
  --green: #8be36c;
  --danger: #ff5b7a;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(40, 215, 194, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(255, 107, 87, 0.12), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 10, 10, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(40, 215, 194, 0.45);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(40, 215, 194, 0.22), rgba(255, 184, 74, 0.16));
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.nav-tabs {
  display: grid;
  grid-auto-flow: column;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.nav-tab {
  min-width: 96px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.nav-tab.active {
  border-color: rgba(40, 215, 194, 0.36);
  background: rgba(40, 215, 194, 0.14);
  color: var(--text);
}

.primary-button:hover,
.secondary-button:hover,
.nav-tab:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 0 14px;
  border-color: rgba(40, 215, 194, 0.42);
  background: linear-gradient(135deg, rgba(40, 215, 194, 0.94), rgba(14, 143, 133, 0.9));
  color: #03100e;
  font-weight: 900;
}

.secondary-button {
  padding: 0 14px;
  border-color: rgba(248, 184, 74, 0.32);
  background: rgba(248, 184, 74, 0.14);
}

.wide {
  width: 100%;
}

.lucide {
  width: 18px;
  height: 18px;
}

main {
  padding-top: 18px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-stage {
  position: relative;
  min-height: 380px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(9, 10, 10, 0.94), rgba(9, 10, 10, 0.52) 44%, rgba(9, 10, 10, 0.08)),
    linear-gradient(0deg, rgba(9, 10, 10, 0.62), transparent 62%);
}

.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: end;
  max-width: 820px;
  min-height: 380px;
  padding: clamp(24px, 5vw, 56px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 12ch;
  margin-bottom: 24px;
  font-size: clamp(42px, 7vw, 88px);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.1;
}

h3 {
  margin-bottom: 6px;
  font-size: 15px;
}

.hero-metrics,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-metrics[hidden],
.hero-metrics span[hidden] {
  display: none;
}

.hero-metrics span,
.signal-chip,
.status-pill {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--soft);
}

.hero-metrics span {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
}

.hero-metrics strong.ready {
  color: var(--green);
}

.signal-chip {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  backdrop-filter: blur(12px);
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(139, 227, 108, 0.75);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 12px rgba(139, 227, 108, 0);
  }
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(380px, 1.25fr) minmax(300px, 0.9fr);
  gap: 16px;
  margin-top: 16px;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.control-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.field-label,
.split-fields span,
legend {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topic-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.relaxed-row {
  margin-bottom: 6px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  outline: none;
}

select {
  appearance: none;
}

select option {
  background: #121515;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: rgba(40, 215, 194, 0.78);
  box-shadow: 0 0 0 3px rgba(40, 215, 194, 0.12);
}

.topic-chip {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.topic-chip.active {
  border-color: rgba(255, 107, 87, 0.44);
  background: rgba(255, 107, 87, 0.15);
  color: var(--text);
}

.action-row {
  display: flex;
  gap: 10px;
  padding-top: 2px;
}

.source-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.toggle input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

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

.split-fields label {
  display: grid;
  gap: 8px;
}

.pipeline {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.pipeline-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.pipeline-step .icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: rgba(40, 215, 194, 0.14);
  color: var(--teal);
}

.pipeline-step strong,
.pipeline-step small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-step small {
  color: var(--muted);
}

.pipeline-step.done .state {
  color: var(--green);
}

.pipeline-step.active .state {
  color: var(--amber);
}

.pipeline-step.waiting .state {
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 0 10px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.alt {
  color: var(--amber);
}

.player-surface {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 128px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(40, 215, 194, 0.12), rgba(255, 107, 87, 0.08)),
    rgba(255, 255, 255, 0.04);
}

.play-button {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(248, 184, 74, 0.52);
  border-radius: 50%;
  background: var(--amber);
  color: #1b1102;
}

.waveform {
  display: grid;
  grid-template-columns: repeat(42, 1fr);
  align-items: center;
  gap: 3px;
  height: 56px;
  overflow: hidden;
}

.bar {
  width: 100%;
  min-width: 3px;
  height: var(--h);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--teal), var(--amber), var(--coral));
  opacity: 0.72;
}

.waveform.playing .bar {
  animation: bounce 720ms ease-in-out infinite alternate;
  animation-delay: var(--d);
}

@keyframes bounce {
  from {
    transform: scaleY(0.38);
  }
  to {
    transform: scaleY(1.05);
  }
}

audio {
  grid-column: 1 / -1;
  width: 100%;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  margin-top: 12px;
  padding: 0 14px;
  border: 1px solid rgba(248, 184, 74, 0.32);
  border-radius: 8px;
  background: rgba(248, 184, 74, 0.14);
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.download-button.disabled {
  opacity: 0.48;
  pointer-events: none;
}

.episode-summary {
  margin: 14px 0 0;
  color: var(--soft);
  line-height: 1.5;
}

.script-list,
.source-list,
.premium-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  margin-top: 14px;
  overflow: auto;
  padding-right: 4px;
}

.script-line,
.source-row,
.premium-row,
.setup-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.script-meta,
.source-meta,
.premium-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.script-line p,
.source-row p,
.premium-row p {
  margin: 0;
  color: var(--soft);
  line-height: 1.45;
}

.source-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.source-row p,
.source-row h3 {
  grid-column: 1 / -1;
}

.source-type {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.heat-score {
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
}

.vault-grid,
.premium-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.8fr);
  gap: 16px;
}

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

.warehouse-stats,
.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.warehouse-stats span,
.setup-card {
  min-height: 74px;
  align-content: center;
  color: var(--muted);
}

.warehouse-stats strong {
  color: var(--text);
  font-size: 26px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: var(--soft);
}

.pass-visual {
  display: grid;
  gap: 10px;
  min-height: 280px;
  align-content: end;
  padding: 20px;
  border: 1px solid rgba(255, 184, 74, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(248, 184, 74, 0.24), transparent 38%),
    linear-gradient(225deg, rgba(156, 125, 255, 0.22), transparent 38%),
    url("/assets/studio-hero.png") center / cover;
  box-shadow: inset 0 0 0 999px rgba(9, 10, 10, 0.34);
}

.pass-visual span {
  width: max-content;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  font-size: 12px;
  font-weight: 900;
}

.pass-visual strong {
  max-width: 12ch;
  font-size: clamp(28px, 5vw, 52px);
  line-height: 0.98;
}

.pass-visual small {
  color: var(--amber);
  font-size: 18px;
  font-weight: 900;
}

.premium-row.locked {
  opacity: 0.62;
}

.setup-card strong {
  color: var(--text);
}

.setup-card.ready strong {
  color: var(--green);
}

.setup-card.pending strong {
  color: var(--danger);
}

.profile-note,
.env-box {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--soft);
}

.profile-note p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(460px, calc(100vw - 36px));
  padding: 14px 16px;
  border: 1px solid rgba(40, 215, 194, 0.4);
  border-radius: 8px;
  background: rgba(18, 21, 21, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .studio-grid,
  .premium-grid {
    grid-template-columns: 1fr 1fr;
  }

  .source-panel {
    grid-column: span 2;
  }
}

@media (max-width: 840px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .studio-grid,
  .premium-grid,
  .warehouse-stats,
  .setup-grid,
  .source-panel {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .nav-tabs {
    grid-auto-flow: row;
    grid-template-columns: 1fr;
  }

  .nav-tab {
    width: 100%;
  }

  .hero-stage,
  .hero-content {
    min-height: 430px;
  }

  .hero-shade {
    background: linear-gradient(0deg, rgba(9, 10, 10, 0.94), rgba(9, 10, 10, 0.46));
  }
}

@media (max-width: 560px) {
  html,
  body {
    overflow-x: hidden;
  }

  .topic-row,
  .player-surface,
  .source-row,
  .split-fields {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .hero-content {
    padding: 22px;
  }

  .signal-chip {
    left: 12px;
    right: auto;
    top: 12px;
  }
}
