/* YouCast — "Warm paper" (1a). Values taken directly from the design spec. */

:root {
  --bg: #faf6ee;          /* page cream */
  --ink: #2a2118;         /* ink */
  --muted: #6f6252;
  --muted2: #8a7b6a;
  --muted3: #a4937d;
  --accent: #cf5b25;      /* burnt orange */
  --card: #fff;
  --border: #e4dccd;
  --chip: #f1ebdf;        /* chip / track bg */
  --tint: #fdf0e7;        /* selected host tint */
  --error: #cf3b25;       /* warm red */

  --serif: "Newsreader", Georgia, serif;
  --sans: system-ui, -apple-system, "Space Grotesk", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --shadow-btn: 0 2px 6px rgba(207, 91, 37, .35);
  --shadow-card: 0 1px 2px rgba(42, 33, 24, .04);
  --shadow-pill: 0 1px 2px rgba(42, 33, 24, .12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { padding: 0; }

.wrap {
  max-width: 440px;
  margin: 0 auto;
  padding: 18px 20px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 500px) {
  .wrap { padding: 26px 24px 48px; }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: -.01em;
}
.brand-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted2);
}
.wave {
  display: inline-flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 20px;
}
.wave i {
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  animation: bar 1.1s ease-in-out infinite;
}
.wave i:nth-child(1) { height: 8px;  animation-delay: 0s; }
.wave i:nth-child(2) { height: 16px; animation-delay: .12s; }
.wave i:nth-child(3) { height: 20px; animation-delay: .24s; }
.wave i:nth-child(4) { height: 13px; animation-delay: .36s; }
.wave i:nth-child(5) { height: 7px;  animation-delay: .48s; }
@keyframes bar { 0%, 100% { transform: scaleY(.55); } 50% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .wave i { animation: none; } }

/* ---------- Hero ---------- */
.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: -.015em;
  margin: 2px 0 12px;
}
.hero .sub {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  margin: 0 0 22px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-card);
}

/* ---------- Composer ---------- */
.mono-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted2);
}

.mode-toggle {
  display: inline-flex;
  gap: 14px;
  margin-bottom: 10px;
}
.mode-toggle button {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted2);
  cursor: pointer;
}
.mode-toggle button.active {
  color: var(--accent);
  border-bottom: 1.5px solid var(--accent);
  padding-bottom: 2px;
}

.composer textarea,
.composer input.url-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}
.composer textarea { min-height: 82px; }
.composer input.url-input { padding: 2px 0; }
.composer textarea::placeholder,
.composer input.url-input::placeholder { color: var(--muted3); }

.counter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.counter {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted3);
}
.counter.over { color: var(--error); }

.field-error {
  color: var(--error);
  font-size: 13px;
  margin: 8px 0 0;
  display: none;
}
.field-error.show { display: block; }

.divide { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* Hosts grid */
.hosts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.host {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.host:hover { border-color: var(--muted3); }
.host[aria-pressed="true"] {
  border: 1.5px solid var(--accent);
  background: var(--tint);
  padding: 9.5px;   /* keep size stable when border grows */
}
.host .avatar {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  display: grid;
  place-items: center;
}
.host .avatar svg { width: 9px; height: 9px; display: block; }
.host .h-name { font-size: 13px; font-weight: 600; line-height: 1.15; }
.host .h-persona { font-size: 11px; color: var(--muted2); line-height: 1.2; }

/* Length segmented toggle */
.seg {
  display: flex;
  background: var(--chip);
  border-radius: 9px;
  padding: 3px;
  margin-top: 8px;
  gap: 3px;
}
.seg button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 9px 6px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-pill);
}

/* Generate button */
.btn-primary {
  width: 100%;
  margin-top: 16px;
  border: none;
  border-radius: 11px;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-size: 15.5px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary .wave-mini { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; }
.btn-primary .wave-mini i { width: 2.5px; background: #fff; border-radius: 2px; }
.btn-primary .wave-mini i:nth-child(1){height:6px}
.btn-primary .wave-mini i:nth-child(2){height:11px}
.btn-primary .wave-mini i:nth-child(3){height:13px}
.btn-primary .wave-mini i:nth-child(4){height:8px}

.turnstile-holder { margin-top: 12px; display: flex; justify-content: center; }

/* ---------- Progress card ---------- */
.progress-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.progress-head h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  margin: 0;
}
.progress-head .eta { font-family: var(--mono); font-size: 11.5px; color: var(--muted2); }
.track {
  height: 5px;
  background: var(--chip);
  border-radius: 3px;
  overflow: hidden;
  margin: 14px 0 4px;
}
.track .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width .5s ease;
}
.track.indeterminate .fill {
  width: 34%;
  animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide { 0%{margin-left:-34%} 100%{margin-left:100%} }

.stages { list-style: none; margin: 14px 0 0; padding: 0; }
.stages li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted2);
  padding: 3px 0;
}
.stages li .dot { width: 15px; text-align: center; color: var(--muted3); }
.stages li.done { color: var(--ink); }
.stages li.done .dot { color: var(--accent); }
.stages li.active { color: var(--ink); font-weight: 600; }
.stages li.active .dot { color: var(--accent); }

.progress-note { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 14px 0 0; }
.copy-link {
  margin-top: 10px;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

/* Dashed callouts (queue-busy) */
.callout {
  border: 1.5px dashed var(--muted3);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
  margin-top: 14px;
  background: rgba(255,255,255,.4);
}

/* Failure / rate-limit cards */
.notice-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-top: 4px;
}
.notice-card.fail { border-left: 4px solid var(--error); }
.notice-card h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  margin: 0 0 8px;
}
.notice-card p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }
.btn-secondary {
  margin-top: 14px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Compact success line (shown on completion instead of a 2nd player) */
.success-line {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--tint);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}
.success-line .success-check {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

/* ---------- Feed ---------- */
.feed { margin-top: 30px; }

/* Newly generated episode: brief highlight when scrolled into view */
.ep-card.just-added {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(207, 91, 37, .18);
  animation: just-added-fade 2.6s ease;
}
@keyframes just-added-fade {
  0%   { box-shadow: 0 0 0 3px rgba(207, 91, 37, .35); }
  100% { box-shadow: 0 0 0 3px rgba(207, 91, 37, 0); }
}
@media (prefers-reduced-motion: reduce) { .ep-card.just-added { animation: none; } }
.feed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.feed-head h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 21px;
  margin: 0;
}
.feed-head .count { font-family: var(--mono); font-size: 11px; color: var(--muted2); }

.ep-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-card);
  margin-bottom: 10px;
}
.ep-card .ep-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16.5px;
  line-height: 1.25;
  margin: 0 0 3px;
  color: var(--ink);
  display: block;
}
a.ep-title:hover { text-decoration: none; color: var(--accent); }
.ep-card .ep-meta { font-family: var(--mono); font-size: 11px; color: var(--muted2); }

.player {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 12px;
}
.play-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.play-btn svg { width: 13px; height: 13px; fill: #fff; }
.play-btn.lg { width: 56px; height: 56px; }
.play-btn.lg svg { width: 20px; height: 20px; }

.scrub { flex: 1; display: flex; align-items: center; gap: 9px; }
.scrub .bar {
  flex: 1;
  height: 5px;
  background: var(--chip);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.scrub .bar .prog { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--accent); }
.scrub .time { font-family: var(--mono); font-size: 10.5px; color: var(--muted2); min-width: 34px; text-align: right; }

.ep-actions { margin-top: 10px; display: flex; gap: 16px; }
.ep-actions button, .ep-actions a {
  background: none; border: none; padding: 0;
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  color: var(--accent); cursor: pointer;
}

.empty-feed {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.empty-feed strong { color: var(--ink); font-family: var(--serif); font-weight: 600; }

.feed-loading, .feed-error { color: var(--muted2); font-size: 13.5px; padding: 6px 0; }
.feed-error a { font-weight: 600; }

/* ---------- Episode permalink page ---------- */
.back-link {
  display: inline-block;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 18px;
}
.ep-hero .eyebrow { font-family: var(--mono); font-size: 11px; color: var(--muted2); letter-spacing: .05em; }
.ep-hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 27px;
  line-height: 1.15;
  margin: 6px 0 6px;
}
.ep-hero .ep-meta { font-family: var(--mono); font-size: 12px; color: var(--muted2); }

.big-player {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-top: 18px;
  box-shadow: var(--shadow-card);
}
.big-player .player { margin-top: 0; }
.big-player .copy-link { margin-top: 14px; }

.takeit { margin-top: 22px; }
.takeit h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  margin: 0 0 10px;
}
.takeit ol { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.takeit ol li { margin-bottom: 4px; }
.takeit .dl-row { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn-download {
  border: none;
  border-radius: 11px;
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 650;
  box-shadow: var(--shadow-btn);
}
.btn-download:hover { text-decoration: none; }
.feed-xml-link { font-family: var(--mono); font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.center-load { text-align: center; color: var(--muted2); padding: 40px 0; font-size: 14px; }
