:root {
  /* Flat "paper" theme (ai-2027-ish) with turnip accents. */
  --bg: #fffdf7;
  --surface: #ffffff;
  --surface-2: #f7f3e8;
  --ink: #26241f;
  --muted: #6f6a5e;
  --border: #ded7c6;

  /* Turnip: magenta top -> pink -> cream body. */
  --purple: #a8477f;
  --purple-dark: #8a3667;
  --purple-light: #e6bcd2;
  --cream: #f3ead7;
  --green: #5f7d3f;
  --green-light: #cfe0b8;
  --gradient: linear-gradient(120deg, #a8477f 0%, #cf7fae 55%, #f0e2cf 100%);
  --gradient-btn: linear-gradient(120deg, #55703a 0%, #7d9f55 100%);

  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute must win over any `display` rule we set. */
[hidden] {
  display: none !important;
}

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

body {
  /* Gentle turnip wash: light blossom at the top fading to cream. */
  background: linear-gradient(180deg, #f9dcec 0%, #fffdf7 50%, #f5eeda 100%);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
  min-height: 100vh;
}

.section-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}

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

/* ---- forms ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.create {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.create label {
  font-size: 0.95rem;
  color: var(--muted);
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  font: inherit;
}

textarea:focus {
  outline: none;
  border-color: var(--purple);
}

button {
  font: inherit;
  cursor: pointer;
}

.primary {
  background: var(--gradient-btn);
  color: #fff;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 13px;
}

.ghost {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0 0 14px;
  font-size: 0.95rem;
}

.ghost:hover {
  color: var(--purple);
}

/* ---- feed ---- */

.feed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 28px 0 12px;
}

.sort {
  display: flex;
  gap: 6px;
}

.sort-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
}

.sort-btn.is-active {
  color: var(--purple);
  border-color: var(--purple);
  background: var(--cream);
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feed-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 13px 15px;
}

.feed-item:hover {
  background: var(--surface-2);
}

.feed-row {
  display: flex;
  flex-direction: column;
}

.feed-resume {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--purple);
  font-size: 0.82rem;
  padding: 4px 0 2px 4px;
}

.feed-resume:hover {
  text-decoration: underline;
}

.feed-title {
  font-weight: 600;
}

.feed-meta {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ---- producing / generating ---- */

.producing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 18px;
  text-align: center;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--cream);
  border-top-color: var(--purple);
  animation: spin 0.9s linear infinite;
}

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

/* ---- player ---- */

.player-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 14px;
}

audio {
  width: 100%;
  margin-bottom: 12px;
}

.progressive {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.playpause {
  flex: none;
  width: 96px;
  text-align: center;
  background: linear-gradient(120deg, #8a3667 0%, #b8588f 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 0;
  font-weight: 600;
}

.playpause:hover {
  filter: brightness(1.08);
}

.bar {
  flex: 1;
  display: flex;
  gap: 3px;
  height: 8px;
}

.bar-seg {
  background: #e7e4d8; /* not generated yet */
  border-radius: 3px;
  overflow: hidden;
  min-width: 4px;
  cursor: pointer;
}

.bar-seg.ready,
.bar-seg.playing,
.bar-seg.played {
  background: var(--green-light); /* generated / downloaded */
}

.bar-seg-fill {
  height: 100%;
  width: 0%;
  background: var(--green); /* solid, matching the button */
}

.countdown {
  color: var(--purple);
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}

.transcript {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 18px;
}

.transcript p {
  margin: 0 0 6px;
  padding-left: 8px;
  border-left: 2px solid transparent;
  transition: background-color 120ms ease, border-color 120ms ease;
}

/* Hovering a chunk bar segment previews the lines it covers. */
.transcript p.chunk-hover {
  background: var(--surface-2);
  border-left-color: var(--green-light);
}

/* The chunk currently playing. Declared after hover so it wins when both apply. */
.transcript p.chunk-current {
  background: var(--green-light);
  border-left-color: var(--green);
}

.transcript .speaker {
  color: var(--ink);
  font-weight: 600;
}

/* ---- choices ---- */

.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 15px 16px;
}

.choice:hover {
  background: var(--surface-2);
}

.choice:disabled {
  opacity: 0.5;
}

.choice-default {
  border-color: var(--purple);
  background: var(--cream);
}

.choice-selected {
  border-color: var(--green);
  background: var(--green-light);
}

.choice-share {
  color: var(--purple);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Offline / notice banners */
.offline,
.notice {
  background: var(--cream);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
}
