/* === TOKENS === */
:root {
  --bg: #f5efe6;
  --panel: rgba(255, 250, 244, 0.94);
  --panel-strong: #fffdf9;
  --ink: #1d252f;
  --muted: #6e7886;
  --line: rgba(96, 80, 54, 0.16);
  --accent: #9b4a28;
  --accent-strong: #7c3013;
  --accent-soft: #f4dfd4;
  --studio-teal: rgba(91, 128, 126, 0.18);
  --studio-gold: rgba(233, 187, 123, 0.24);
  --success: #2d6a4f;
  --success-soft: rgba(45, 106, 79, 0.12);
  --danger: #9f2f28;
  --danger-soft: rgba(159, 47, 40, 0.12);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: clamp(1.75rem, 4vw, 2.5rem);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 3px rgba(78, 56, 34, 0.08);
  --shadow-md: 0 4px 16px rgba(78, 56, 34, 0.1);
  --shadow-lg: 0 24px 60px rgba(78, 56, 34, 0.12);
  --shadow: var(--shadow-lg);

  --tab-bar-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --player-height: 64px;
  --touch-target: 48px;
  --content-max: 960px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1e;
    --panel: rgba(38, 36, 33, 0.94);
    --panel-strong: #2a2825;
    --ink: #e8e4df;
    --muted: #9a958e;
    --line: rgba(200, 180, 150, 0.16);
    --accent: #d4845c;
    --accent-strong: #efb08a;
    --accent-soft: rgba(212, 132, 92, 0.15);
    --studio-teal: rgba(103, 151, 148, 0.18);
    --studio-gold: rgba(218, 174, 103, 0.2);
    --success: #5ba67c;
    --success-soft: rgba(91, 166, 124, 0.15);
    --danger: #d45a52;
    --danger-soft: rgba(212, 90, 82, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.3);
    --shadow: var(--shadow-lg);
  }
}

/* === RESET === */
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Helvetica Neue", sans-serif;
  color: var(--ink);
  font-size: var(--text-base);
  line-height: 1.55;
  background:
    radial-gradient(circle at top left, rgba(255, 244, 218, 0.95), transparent 36%),
    radial-gradient(circle at top right, rgba(207, 224, 224, 0.75), transparent 34%),
    linear-gradient(180deg, #fff8f0 0%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  body {
    background: var(--bg);
  }
}

h1, h2, h3 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  line-height: 1.1;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); margin-bottom: var(--space-sm); }
h3 { font-size: var(--text-lg); }

p, li, label, input, textarea, button, a, code, dt, dd {
  font-size: var(--text-base);
  line-height: 1.55;
}

code {
  font-family: ui-monospace, "SFMono-Regular", monospace;
}

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

/* === LAYOUT === */

/* Default main for non-app pages */
main {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

/* App shell layout */
.page-app main {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-content {
  padding: var(--space-md);
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + var(--space-xl));
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Tab bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-bar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  z-index: 100;
}

.tab-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  min-width: 64px;
  text-decoration: none;
  color: var(--muted);
  transition: color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

.tab-bar__item--active {
  color: var(--accent);
}

.tab-bar__icon {
  width: 24px;
  height: 24px;
}

.tab-bar__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Top navigation bar (desktop only) */
.top-nav {
  display: none;
}

/* Audio player (above tab bar, hidden by default) */
.audio-player {
  position: fixed;
  bottom: calc(var(--tab-bar-height) + var(--safe-bottom));
  left: 0;
  right: 0;
  height: var(--player-height);
  background: var(--panel-strong);
  border-top: 1px solid var(--line);
  z-index: 99;
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  gap: var(--space-sm);
}

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

.app-content--player {
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + var(--player-height) + var(--space-xl)) !important;
}

.player__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.player__btn:active { opacity: 0.6; }

.player__btn--play {
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: #fff;
}

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

.player__title {
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player__track {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.player__progress {
  flex: 1;
  height: 4px;
  border: 0;
  border-radius: 2px;
  background: var(--line);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.player__progress::-webkit-progress-bar {
  background: var(--line);
  border-radius: 2px;
}

.player__progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 2px;
}

.player__progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 2px;
}

.player__time {
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* === COMPONENTS === */

/* Eyebrow */
.eyebrow {
  margin: 0 0 var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--accent);
}

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

/* Panels */
.panel {
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.page-app .panel {
  position: relative;
  border-radius: 22px;
  margin-left: 0;
  margin-right: 0;
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.page-app .panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background:
    linear-gradient(90deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 35%, transparent) 55%, transparent 100%);
  opacity: 0.8;
  pointer-events: none;
}

.page-public .panel,
.page-admin .panel {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.panel--wide { min-height: 100%; }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 22px;
  padding: 30px;
  border-radius: 32px;
  margin-bottom: 22px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero--compact { grid-template-columns: 1fr; }

.hero--landing {
  grid-template-columns: 1fr;
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
}

.hero--landing .lede {
  max-width: 540px;
  margin: var(--space-md) auto;
}

.hero--landing .hero-actions {
  justify-content: center;
}

.hero-card {
  background: var(--panel-strong);
  border-radius: 22px;
  border: 1px solid rgba(115, 91, 54, 0.12);
  padding: 20px;
}

.hero-card__label {
  font-weight: 700;
  margin-bottom: 10px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

/* Metric cards */
.metric-card {
  background: var(--panel-strong);
  border-radius: 22px;
  border: 1px solid rgba(115, 91, 54, 0.12);
  padding: 20px;
  box-shadow: var(--shadow);
}

.metric-card__value {
  font-family: "Fraunces", Georgia, serif;
  font-size: 2rem;
  margin-bottom: 6px;
}

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

.feed-box {
  background: var(--panel-strong);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(115, 91, 54, 0.12);
  padding: 14px;
  margin: 14px 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}

.feed-box code {
  display: block;
  word-break: break-all;
  flex: 1;
  min-width: 0;
}

.feed-box__row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.feed-artwork-card {
  border: 1px solid rgba(124, 76, 33, 0.14);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 88%, white) 0%, color-mix(in srgb, var(--studio-teal) 22%, var(--panel)) 100%);
  margin: var(--space-md) 0;
}

.feed-artwork-preview {
  width: min(220px, 100%);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid rgba(124, 76, 33, 0.16);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-sm);
}

/* Subscribe buttons */
.subscribe-buttons { margin: var(--space-md) 0; }
.subscribe-buttons__label { font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-sm); }
.subscribe-buttons__row { display: flex; flex-wrap: wrap; gap: var(--space-sm); }

/* Copy button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 150ms ease, border-color 150ms ease;
  padding: 0;
}

.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

.copy-btn--done {
  color: var(--success) !important;
  border-color: var(--success) !important;
}

/* Character count */
.char-count-wrap {
  position: relative;
}

.char-count {
  display: block;
  font-size: var(--text-xs);
  text-align: right;
  margin-top: var(--space-xs);
}

/* URL domain hint */
.url-hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: var(--space-xs);
  min-height: 1.2em;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--touch-target);
  padding: 0 var(--space-lg);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: var(--text-base);
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
  -webkit-tap-highlight-color: transparent;
}

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

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

.button--ghost {
  background: transparent;
  border: 1px solid rgba(155, 74, 40, 0.25);
}

.button--full {
  width: 100%;
}

.button--icon {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
}

.button--lg {
  min-height: 54px;
  padding: 0 var(--space-xl);
  font-size: var(--text-lg);
}

.button--sm {
  min-height: 36px;
  padding: 0 var(--space-md);
  font-size: var(--text-sm);
}

.button--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

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

/* Grids */
.panel-grid,
.content-grid,
.metrics-grid {
  display: grid;
  gap: var(--space-md);
}

.panel-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.content-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-bottom: var(--space-md);
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: var(--space-lg);
}

.page-app .metrics-grid {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: var(--space-sm);
  padding-bottom: var(--space-xs);
}

.page-app .metric-card {
  min-width: 140px;
  flex-shrink: 0;
  scroll-snap-align: start;
}

/* Forms */
.stack {
  display: grid;
  gap: 14px;
}

.stack--inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

label {
  display: grid;
  gap: var(--space-sm);
  font-weight: 600;
}

input, textarea, select {
  width: 100%;
  min-height: var(--touch-target);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  font-size: var(--text-base);
  font-family: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  min-height: 180px;
  resize: vertical;
}

.inline-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-toggle input {
  width: auto;
  min-height: auto;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-weight: 600;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  min-height: 0;
}

.toggle__track {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--line);
  transition: background 200ms ease;
  flex-shrink: 0;
}

.toggle__track::after {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  margin: 3px;
  transition: transform 200ms ease;
}

.toggle input:checked + .toggle__track {
  background: var(--accent);
}

.toggle input:checked + .toggle__track::after {
  transform: translateX(18px);
}

/* Segmented control */
.seg-control {
  display: flex;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 70%, var(--studio-gold)) 0%, color-mix(in srgb, var(--panel) 92%, var(--studio-teal)) 100%);
  border-radius: var(--radius-full);
  padding: 4px;
  gap: 2px;
  overflow-x: auto;
  margin-bottom: 0;
  width: 100%;
  border: 1px solid rgba(124, 76, 33, 0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}

.seg-control__item {
  flex: 1;
  min-height: 36px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-full);
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease;
}

.seg-control__item--active {
  background: color-mix(in srgb, var(--panel-strong) 86%, white);
  color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
}

/* Drama mode toggle (isolated from global seg-control tab system) */
.drama-toggle {
  display: flex;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 70%, var(--studio-gold)) 0%, color-mix(in srgb, var(--panel) 92%, var(--studio-teal)) 100%);
  border-radius: var(--radius-full);
  padding: 4px;
  gap: 2px;
  margin-bottom: var(--space-md);
  border: 1px solid rgba(124, 76, 33, 0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}
.drama-toggle__item {
  flex: 1;
  min-height: 36px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-full);
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease;
  cursor: pointer;
}
.drama-toggle__item--active {
  background: color-mix(in srgb, var(--panel-strong) 86%, white);
  color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
}

/* Inline radio/checkbox labels (prevent global label grid + input sizing) */
.inline-radio label {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-weight: 500;
  cursor: pointer;
}
.inline-radio input[type="radio"],
.inline-radio input[type="checkbox"] {
  width: auto;
  min-height: auto;
  padding: 0;
  border: revert;
  background: revert;
  border-radius: revert;
  accent-color: var(--accent);
}

/* Search */
.library-top {
  max-width: 760px;
  margin: 0 auto var(--space-lg);
}

.library-top__controls {
  display: grid;
  gap: var(--space-md);
}

.library-top__control--feed {
  order: -1;
}

.library-top__control {
  width: 100%;
}

.library-feed-button {
  width: 100%;
  justify-content: center;
  min-height: 58px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 70%, white) 0%, color-mix(in srgb, var(--studio-gold) 55%, var(--panel-strong)) 100%);
  border-color: rgba(124, 76, 33, 0.18);
}

.search-form {
  display: flex;
  align-items: stretch;
  margin: 0;
  width: 100%;
  max-width: none;
}

.search-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-base);
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: var(--radius-full) 0 0 var(--radius-full);
  background: var(--panel-strong);
  color: var(--ink);
  outline: none;
  box-sizing: border-box;
  min-width: 0;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.search-submit {
  width: 52px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  background: var(--panel-strong);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.search-submit:hover,
.search-submit:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* Item lists */
.item-list, .check-list, .number-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.number-list {
  list-style: decimal;
  padding-left: 18px;
}

/* List cells (new unified pattern) */
.list-cell {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--line);
  min-height: var(--touch-target);
}

.list-cell:last-child { border-bottom: 0; }

.list-cell__body {
  flex: 1;
  min-width: 0;
}

.list-cell__body strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-cell__detail {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.list-cell__meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}
.list-cell__meta span { white-space: nowrap; }

.list-cell__detail--danger { color: var(--danger); }

.list-cell__link {
  color: inherit;
  text-decoration: none;
}
.list-cell__link:hover strong { text-decoration: underline; }

.list-cell__actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
  align-items: center;
}

/* Legacy item-card (kept for admin) */
.item-card {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  align-items: start;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--line);
}

.item-card:last-child { border-bottom: 0; }
.item-card__body { min-width: 0; }
.item-card__actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); justify-content: end; }

.item-detail { margin: 6px 0 0; color: var(--muted); }
.item-detail--danger { color: var(--danger); }
.item-empty { padding: 14px 0; color: var(--muted); }

/* Preview segments (composition preview items) */
.preview-segment {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--line);
}

.preview-segment:last-child { border-bottom: 0; }

.preview-segment__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
}

.preview-segment__number {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.preview-segment__title {
  display: block;
  line-height: 1.35;
}

.preview-segment__excerpt {
  margin-top: var(--space-sm);
  padding-left: var(--space-md);
  border-left: 3px solid var(--accent-soft);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.preview-segment__excerpt p {
  margin: 4px 0;
}

/* Disclosure (styled <details>) */
.disclosure {
  margin-top: var(--space-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.disclosure summary {
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::before {
  content: '\25B8';
  display: inline-block;
  margin-right: var(--space-sm);
  transition: transform 150ms ease;
}

.disclosure[open] > summary::before {
  transform: rotate(90deg);
}

.disclosure__body {
  padding: var(--space-sm) var(--space-md) var(--space-md);
}

/* Readable preview content (turns in read-only view) */
.preview-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.preview-content__turn {
  padding: var(--space-xs) 0;
}

.preview-content__speaker {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.preview-content__text {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--ink);
}

/* Turn editor (inline editing of script lines) */
.turn-editor {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--line);
}

.turn-editor:last-child { border-bottom: 0; }

.turn-editor__speaker {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: var(--space-xs);
}

.turn-editor__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.turn-editor__text {
  width: 100%;
  min-height: 80px;
  padding: var(--space-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--ink);
  background: var(--panel-strong);
  resize: vertical;
}

.turn-editor__text:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.turn-editor__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.turn-editor__hint {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.4;
}

/* Status chips */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  height: 28px;
  border-radius: var(--radius-full);
  background: rgba(49, 82, 124, 0.12);
  color: #29435f;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: lowercase;
}

.status-chip--failed,
.status-chip--needs_manual {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-chip--ready,
.status-chip--completed,
.status-chip--published {
  background: var(--success-soft);
  color: var(--success);
}

.status-chip--processing,
.status-chip--queued {
  position: relative;
}

.status-chip--processing::before,
.status-chip--queued::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Checklist (legacy for admin/landing) */
.check-list__item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.check-list__item:last-child { border-bottom: 0; }

.check-list__item strong {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.check-list__item--done strong {
  background: var(--success-soft);
  color: var(--success);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Toast */
.toast {
  position: fixed;
  top: var(--space-md);
  left: var(--space-md);
  right: var(--space-md);
  max-width: 520px;
  margin: 0 auto;
  padding: 14px var(--space-md);
  border-radius: var(--radius-lg);
  font-weight: 600;
  z-index: 200;
  animation: toast-in 300ms ease, toast-out 300ms ease 4s forwards;
  pointer-events: auto;
}

.toast--notice {
  background: rgba(199, 225, 217, 0.95);
  color: #174d3b;
}

.toast--error {
  background: rgba(243, 207, 204, 0.95);
  color: #7d201a;
}

/* Banner (legacy for non-app pages) */
.banner, .verification-banner {
  margin-bottom: var(--space-md);
  border-radius: var(--radius-lg);
  padding: 14px var(--space-md);
  font-weight: 600;
}

.banner--notice, .verification-banner {
  background: rgba(199, 225, 217, 0.7);
  color: #174d3b;
}

.banner--error {
  background: rgba(243, 207, 204, 0.9);
  color: #7d201a;
}

.verification-banner {
  border-radius: var(--radius-md);
}

/* Disclosure (details/summary) */
.disclosure {
  border-bottom: 1px solid var(--line);
}

.disclosure[data-settings-section="connect-feed"][open] {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 35%, transparent) 0%, transparent 100%);
  border-radius: 18px;
  padding: 0 var(--space-md);
  margin: 0 calc(-1 * var(--space-md));
}

.disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  min-height: var(--touch-target);
  cursor: pointer;
  font-weight: 700;
  font-size: var(--text-lg);
  list-style: none;
}

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

.disclosure summary::after {
  content: '';
  width: 20px;
  height: 20px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9' fill='none' stroke='currentColor' stroke-width='2'/%3E%3C/svg%3E");
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9' fill='none' stroke='currentColor' stroke-width='2'/%3E%3C/svg%3E");
  transition: transform 200ms ease;
  color: var(--muted);
  flex-shrink: 0;
}

.disclosure[open] summary::after {
  transform: rotate(180deg);
}

.disclosure__body {
  padding-bottom: var(--space-lg);
}

/* Article page */
.article-back {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--muted);
  text-decoration: none;
  margin-bottom: var(--space-md);
}
.article-back:hover { color: var(--accent); }
.article-header {
  margin-bottom: 2rem;
}
.article-header h1 {
  font-size: var(--text-2xl);
  line-height: 1.3;
  margin: 0 0 0.5rem;
  max-width: 640px;
}
.article-meta {
  font-size: var(--text-sm);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em 0.6em;
  align-items: center;
}
.article-meta a { color: var(--muted); text-decoration: underline; }
.article-meta a:hover { color: var(--accent); }
.article-body { max-width: 700px; }
.article-summary {
  max-width: 640px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 2rem;
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink);
}
.article-section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--ink);
}
.article-source {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
}
.article-source a { color: var(--muted); text-decoration: none; }
.article-source a:hover { color: var(--accent); text-decoration: underline; }

/* Article text typography */
.article-text {
  max-width: 640px;
  line-height: 1.8;
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.article-text p {
  margin: 0 0 1.2em;
}
.article-text .speaker {
  display: block;
  font-weight: 600;
  color: var(--accent);
  margin-top: 1.5em;
  margin-bottom: 0.3em;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Pacing sliders */
.slider-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
}
.slider-group label {
  min-width: 110px;
  font-size: var(--text-sm);
  color: var(--fg);
  flex-shrink: 0;
}
.slider-group input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 6px;
}
.slider-group output {
  min-width: 3.5ch;
  text-align: right;
  font-size: var(--text-sm);
  color: var(--muted);
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--muted);
}

.empty-state__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-md);
  color: var(--muted);
  opacity: 0.5;
}

.empty-state__text {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-sm);
  margin: 0;
  max-width: none;
}

.quick-actions .button {
  width: 100%;
  min-height: 76px;
  padding: 0.95rem 1.5rem;
  text-align: center;
  line-height: 1.25;
  white-space: normal;
  text-wrap: balance;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 94%, white) 0%, color-mix(in srgb, var(--accent-strong) 88%, black) 100%);
}

.add-grid {
  display: grid;
  gap: var(--space-md);
}

.podcast-input-panels {
  display: grid;
  gap: var(--space-md);
}

.host-grid {
  display: grid;
  gap: var(--space-sm);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.host-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 86%, white) 0%, color-mix(in srgb, var(--studio-teal) 42%, var(--panel)) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.42);
}

.host-card h4 {
  margin-bottom: var(--space-xs);
  color: var(--accent-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: var(--text-xs);
}

.create-broadcast-console {
  border: 1px solid rgba(124, 76, 33, 0.16);
  border-radius: 20px;
  padding: clamp(1rem, 1.4vw, 1.25rem);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 90%, var(--studio-gold)) 0%, color-mix(in srgb, var(--panel) 94%, var(--studio-teal)) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.45),
    0 16px 28px rgba(78, 56, 34, 0.08);
}

.create-broadcast-console::before {
  content: "Broadcast Console";
  display: inline-flex;
  align-items: center;
  margin-bottom: var(--space-xs);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.08);
  color: var(--accent-strong);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Per-tab description (Create page) */
.create-desc {
  margin-bottom: var(--space-md);
  min-height: 1.6em;
}

.create-desc__item {
  display: none;
  margin: 0;
}

.create-desc__item.desc--active {
  display: block;
}

/* Card deck transitions (JS-enhanced mode) */
.create-cards {
  position: relative;
}

.create-cards--enhanced [data-create-panel] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  pointer-events: none;
  transition: transform 280ms ease, opacity 280ms ease;
  will-change: transform, opacity;
}

.create-cards--enhanced [data-create-panel].card--active {
  position: relative;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.create-cards--enhanced [data-create-panel].card--enter-right {
  transform: translateX(30px);
}

.create-cards--enhanced [data-create-panel].card--enter-left {
  transform: translateX(-30px);
}

.create-cards--enhanced [data-create-panel].card--exit-left {
  transform: translateX(-30px);
}

.create-cards--enhanced [data-create-panel].card--exit-right {
  transform: translateX(30px);
}

@media (prefers-reduced-motion: reduce) {
  .create-cards--enhanced [data-create-panel] {
    transition: none;
  }
}

.page-header-actions {
  margin-bottom: var(--space-md);
}

.create-chooser {
  display: grid;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.create-option {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: var(--space-lg);
}

.create-option--highlighted {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.create-option__eyebrow {
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--accent);
}

.create-option__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* Page header */
.page-header {
  margin-bottom: var(--space-lg);
}

.page-header h1 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-xs);
}

.page-header .greeting {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

/* Onboarding card */
.onboarding {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 72%, white) 0%, color-mix(in srgb, var(--studio-gold) 44%, var(--panel-strong)) 100%);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  border: 1px solid rgba(124, 76, 33, 0.14);
  box-shadow: var(--shadow-sm);
}

.onboarding__title {
  font-weight: 700;
  margin-bottom: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.onboarding__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-weight: 500;
}

.onboarding__item--done {
  color: var(--muted);
  text-decoration: line-through;
}

.onboarding__check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding__item--done .onboarding__check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* Steps section (landing) */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.step-card {
  text-align: center;
  padding: var(--space-lg);
}

.step-card__number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: var(--text-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
}

/* Meta list */
.meta-list {
  margin: 0 0 var(--space-lg);
}

.meta-list div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--line);
}

.meta-list div:last-child { border-bottom: 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; }

/* Text utilities */
.text-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.text-center { text-align: center; }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }

/* === PAGE-SPECIFIC === */

/* Auth pages */
.auth-shell {
  min-height: calc(100vh - 84px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(520px, 100%);
  padding: var(--space-xl);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.auth-brand__name {
  font-family: "Fraunces", Georgia, serif;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--accent);
}

.auth-links {
  color: var(--muted);
  margin-bottom: 0;
  text-align: center;
}

/* App navigation header (used on app pages, above content) */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.app-nav {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.app-nav__link {
  padding: 10px 14px;
  border-radius: var(--radius-full);
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
}

.app-nav__link--active {
  color: var(--accent);
  background: rgba(255, 250, 244, 0.9);
  border-color: rgba(155, 74, 40, 0.14);
}

/* Admin shell */
.shell-admin {
  max-width: 1120px;
}

/* === DESKTOP === */
@media (min-width: 820px) {
  .page-app .panel {
    border-radius: var(--radius-xl);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    margin-left: 0;
    margin-right: 0;
    padding: var(--space-lg);
  }

  .app-content {
    padding: var(--space-xl) var(--space-lg);
    padding-bottom: var(--space-2xl);
  }

  .page-header h1 {
    font-size: var(--text-3xl);
  }

  .auth-card {
    padding: var(--space-2xl);
  }

  .create-chooser {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .quick-actions .button {
    white-space: nowrap;
  }

  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .add-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-nav {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: 0 var(--space-lg);
    height: 48px;
    background: var(--panel);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .top-nav__brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: "Fraunces", Georgia, serif;
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--accent);
    text-decoration: none;
    margin-right: auto;
  }

  .top-nav__brand svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .top-nav__links {
    display: flex;
    gap: var(--space-sm);
  }

  .top-nav__link {
    position: relative;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: var(--text-sm);
    transition: color 150ms ease, background 150ms ease;
  }

  .top-nav__link:hover {
    color: var(--ink);
    background: var(--accent-soft);
  }

  .top-nav__link--active {
    color: var(--accent);
    background: var(--accent-soft);
  }

  .top-nav__link--active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 3px;
    border-radius: 2px;
    background: var(--accent);
  }

  .tab-bar {
    display: none;
  }

  .audio-player {
    bottom: 0;
  }
}

@media (max-width: 819px) {
  main {
    width: min(100vw - 20px, 1120px);
    padding-top: 18px;
  }

  .hero, .content-grid, .panel-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .item-card {
    flex-direction: column;
  }

  .auth-card {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    width: 100%;
    max-width: 100%;
  }
}

/* === ANIMATIONS === */
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@keyframes toast-in {
  from { transform: translateY(-100%); opacity: 0; }
}

@keyframes toast-out {
  to { transform: translateY(-100%); opacity: 0; pointer-events: none; }
}

/* === VIEW TRANSITIONS === */
@view-transition {
  navigation: auto;
}
