/* ── Design tokens ──────────────────────────────────────────────── */
:root {
  --bg:            #F4F0E8;
  --bg-raised:     #FBF7EF;
  --ink:           #1B1814;
  --ink-soft:      #3F3830;
  --ink-faint:     #6B6155;
  --hairline:      #CFC6B2;
  --hairline-soft: #DFD7C3;
  --accent:        #445463;
  --accent-soft:   #D7DCE3;
  --accent-wash:   #E8ECF1;
  --record-red:    #A4493D;
  --radius-card:   18px;
  --radius-pill:   99px;
}

/* ── Reset & base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* Ensure [hidden] always wins even against ID-specific display rules */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Lora', Georgia, serif;
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 0 6rem;
}

h2 { margin: 0 0 1rem; font-size: 1.5rem; font-weight: 600; }
p  { margin: 0 0 1rem; }
.muted { color: var(--ink-faint); }

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes gw-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.85); }
}
@keyframes gw-pulse-ring {
  0%   { transform: scale(1);    opacity: 0.45; }
  100% { transform: scale(1.45); opacity: 0; }
}
@keyframes gw-spin {
  to { transform: rotate(360deg); }
}
@keyframes gw-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes gw-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── Shared components ──────────────────────────────────────────── */

/* Ornament (flanking rules + wordmark) */
.ornament {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 40px;
}
.ornament-rule {
  flex: 1;
  height: 0.5px;
  background: var(--hairline);
  display: block;
  max-width: 48px;
}
.ornament-label {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.ornament-label--accent { color: var(--accent); }
.ornament--small .ornament-rule { max-width: 36px; }
.ornament--small .ornament-label { font-size: 0.75rem; letter-spacing: 0.18em; font-style: normal; text-transform: uppercase; }

/* Chrome strip (greeting + date, shared by lobby + recorder) */
.gw-chrome {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 20px 28px 14px;
}
.gw-greeting {
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}
.gw-greeting em { font-style: italic; }
.gw-date {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.chrome-rule {
  height: 0.5px;
  background: var(--hairline);
  margin: 0 28px;
}

/* Back bar */
.back-bar {
  padding: 10px 14px 0;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 500;
  padding: 8px 8px;
  cursor: pointer;
  min-height: 0;
  width: auto;
  border-radius: 8px;
}
.back-btn:hover { opacity: 0.8; }

/* Screen eyebrow + italic heading */
.screen-eyebrow {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  padding: 10px 28px 8px;
}
.screen-heading-italic {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.45rem;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.02em;
  padding: 0 28px 18px;
  margin: 0;
  text-wrap: pretty;
}

/* Chevron inline */
.chevron { color: var(--ink-faint); flex-shrink: 0; }

/* Prompt card */
.prompt-card {
  background: var(--bg-raised);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 22px 22px 24px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 2px 14px rgba(46,42,38,0.04);
  margin: 24px 24px 0;
  transition: opacity 240ms ease;
}
.prompt-card--dim { opacity: 0.7; }

.prompt-card-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.eyebrow-text {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.eyebrow-rule {
  flex: 1;
  height: 0.5px;
  background: var(--hairline-soft);
  display: block;
}
.prompt-card-text {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.3rem;
  line-height: 1.36;
  font-style: italic;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: pretty;
}
.prompt-card-text--small {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* Pill buttons */
.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 15px 36px;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(46,42,38,0.10), 0 10px 24px rgba(68,84,99,0.2);
  transition: transform 120ms ease, opacity 120ms ease;
  min-height: 52px;
}
.btn-pill--full { width: 100%; }
.btn-pill:active { transform: scale(0.97); }
.btn-pill:disabled { opacity: 0.6; cursor: progress; }

.btn-pill-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink-soft);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-pill);
  padding: 13px 20px;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 48px;
  transition: border-color 120ms ease;
}
.btn-pill-ghost:hover { border-color: var(--ink-faint); }

.btn-outline-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--accent);
  border: 0.5px solid var(--accent-soft);
  border-radius: var(--radius-pill);
  padding: 14px 20px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  min-height: 52px;
}

/* Circular record/stop buttons */
.btn-circle {
  position: relative;
  width: 112px; height: 112px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 120ms ease;
}
.btn-circle:active { transform: scale(0.96); }
.btn-circle--stop {
  background: var(--record-red);
  box-shadow: 0 2px 4px rgba(46,42,38,0.10), 0 8px 22px rgba(164,73,61,0.3);
}
.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--record-red);
  animation: gw-pulse-ring 1.4s ease-out infinite;
}

/* Spinner */
.spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--hairline);
  border-top-color: var(--ink-soft);
  animation: gw-spin 1.1s linear infinite;
  flex-shrink: 0;
}

/* Link button */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  min-height: 0;
  width: auto;
}

/* ── Sign-in screen ─────────────────────────────────────────────── */
#signin-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 40px 32px;
  text-align: center;
}

/* Labeled hairline divider between sign-in paths */
.signin-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 300px;
  margin-bottom: 16px;
}
.signin-divider-rule {
  flex: 1;
  height: 0.5px;
  background: var(--hairline);
  display: block;
}
.signin-divider-label {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.8rem;
  color: var(--ink-faint);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* "Create your memoir" filled pill — same width as Google button */
.signin-pill {
  width: 100%;
  max-width: 300px;
  justify-content: center;
  letter-spacing: 0.02em;
}

/* ── Onboarding choice ──────────────────────────────────────────── */
#onboarding-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  min-height: 100svh;
  padding: 0 28px 40px;
}
.onboarding-lead {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.25rem;
  line-height: 1.35;
  color: var(--ink-soft);
  letter-spacing: -0.01em;
  margin: 0 0 24px;
  text-wrap: pretty;
}
.onboarding-primary-btn {
  width: 100%;
  min-height: 72px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 20px 24px;
  font-family: 'Lora', Georgia, serif;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(46,42,38,0.12), 0 14px 32px rgba(68,84,99,0.25);
  margin-bottom: 14px;
  transition: transform 120ms ease;
}
.onboarding-primary-btn:active { transform: scale(0.985); }
.onboarding-primary-title {
  display: block;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin-bottom: 6px;
}
.onboarding-primary-sub {
  display: block;
  font-style: italic;
  font-size: 0.85rem;
  line-height: 1.45;
  opacity: 0.78;
}
.onboarding-skip-btn {
  width: 100%;
  background: none;
  border: none;
  padding: 14px 0;
  cursor: pointer;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(0,0,0,0.18);
  min-height: 44px;
}
.onboarding-hint {
  text-align: center;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin: 18px 0 0;
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #fff;
  color: var(--ink);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-pill);
  padding: 15px 24px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  width: 100%;
  max-width: 300px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(46,42,38,0.06), 0 6px 18px rgba(46,42,38,0.06);
  transition: transform 120ms ease;
  min-height: 52px;
}
.btn-google:active { transform: scale(0.985); }
.btn-google:disabled { opacity: 0.6; cursor: progress; }
.signin-privacy {
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: 20px;
  max-width: 280px;
}

/* ── Welcome screen ─────────────────────────────────────────────── */
#welcome-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 48px 32px;
  text-align: center;
}
#welcome-section .ornament { justify-content: center; margin-bottom: 32px; }
.welcome-greeting {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.85rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 22px;
}
.welcome-intro {
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink-soft);
  margin-bottom: 42px;
  max-width: 320px;
  text-wrap: pretty;
}

/* ── Lobby v2 — avatar top bar ──────────────────────────────────── */
.lobby-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 16px 18px 20px;
}
.lobby-avatar-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-wash);
  border: 0.5px solid var(--hairline);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(46,42,38,0.06);
  transition: transform 120ms ease;
}
.lobby-avatar-btn:active { transform: scale(0.94); }

.lobby-greeting-v2 {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.3rem;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  padding: 0 28px;
  text-wrap: pretty;
}

/* ── NavBar — Back (left) + Home (right) ────────────────────────── */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.home-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  min-height: 44px;
  border-radius: 8px;
}
.home-btn:hover { opacity: 0.8; }

/* ── Bottom sheet overlays (app menu + recorder exit) ────────────── */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
}
.sheet-overlay[hidden] { display: none; }
.sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(27,24,20,0.38);
  animation: gw-fade-in 240ms ease-out;
}
.sheet-panel {
  position: relative;
  margin-top: auto;
  background: var(--bg-raised);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  padding: 8px 22px max(28px, env(safe-area-inset-bottom));
  box-shadow: 0 -8px 36px rgba(27,24,20,0.18);
  animation: gw-slide-up 320ms cubic-bezier(.2,.7,.3,1);
  max-width: 34rem;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.sheet-grabber {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--hairline);
  margin: 6px auto 20px;
}
.sheet-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}
.sheet-caption {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.4;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0 0 18px;
  text-wrap: pretty;
}
.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.sheet-action-btn {
  width: 100%;
  min-height: 56px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 15px 20px;
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(46,42,38,0.10), 0 8px 20px rgba(68,84,99,0.20);
  transition: transform 120ms ease;
}
.sheet-action-btn:active { transform: scale(0.98); }
.sheet-action-btn--secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 0.5px solid var(--hairline);
  box-shadow: none;
}
.sheet-cancel-btn {
  width: 100%;
  min-height: 48px;
  background: transparent;
  border: none;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-faint);
  cursor: pointer;
  margin-top: 4px;
}

/* ── Lobby ──────────────────────────────────────────────────────── */
#lobby-section { padding-bottom: 2rem; }
.lobby-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 24px 0;
}
.lobby-card {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  text-align: left;
  padding: 20px 22px;
  background: var(--bg-raised);
  color: var(--ink);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-card);
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 2px 14px rgba(46,42,38,0.04);
  transition: transform 120ms ease, border-color 120ms ease;
  min-height: 0;
}
.lobby-card:active {
  transform: scale(0.985);
  border-color: var(--accent);
}

/* Primary action card — the one we want the narrator to tap.
   Accent-filled with cream text so it reads as the main thing to do. */
.lobby-card--primary {
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 2px 18px rgba(46,42,38,0.10);
}
.lobby-card--primary .lobby-card-title,
.lobby-card--primary .chevron {
  color: var(--bg-raised);
}
.lobby-card--primary .lobby-card-sub {
  color: rgba(251, 247, 239, 0.78);
}
.lobby-card--primary .lobby-card-icon {
  background: rgba(251, 247, 239, 0.18);
  color: var(--bg-raised);
}

.lobby-card-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--accent-wash);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.lobby-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lobby-card-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: block;
}
.lobby-card-sub {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: block;
}
.lobby-progress {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-align: center;
  margin: 28px 24px 0;
}

/* ── Selection screen ───────────────────────────────────────────── */
#selection-section { padding-bottom: 2rem; }
.btn-choose-me {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: calc(100% - 48px);
  margin: 0 24px;
  padding: 18px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-card);
  cursor: pointer;
  font-family: 'Lora', Georgia, serif;
  box-shadow: 0 2px 4px rgba(46,42,38,0.10), 0 10px 24px rgba(68,84,99,0.2);
  min-height: 0;
  text-align: left;
  transition: transform 120ms ease;
}
.btn-choose-me:active { transform: scale(0.98); }
.choose-me-text { display: flex; flex-direction: column; gap: 2px; }
.choose-me-title { font-size: 1.1rem; letter-spacing: -0.01em; display: block; }
.choose-me-sub { font-style: italic; font-size: 0.82rem; opacity: 0.78; display: block; }

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 28px 18px;
  color: var(--ink-faint);
}
.or-rule {
  flex: 1;
  height: 0.5px;
  background: var(--hairline);
  display: block;
}
.or-text {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  white-space: nowrap;
}
.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 24px;
}
.suggestion-btn {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  background: var(--bg-raised);
  border: 0.5px solid var(--hairline);
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 2px 10px rgba(46,42,38,0.03);
  min-height: 0;
  transition: transform 120ms ease, border-color 120ms ease;
}
.suggestion-btn:active {
  transform: scale(0.985);
  border-color: var(--accent);
}
.suggestion-category {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-top: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.suggestion-text {
  flex: 1;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);
  letter-spacing: -0.01em;
}
#selection-section .link-btn {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 20px;
  padding: 12px 24px;
}

/* ── Title screen ───────────────────────────────────────────────── */
#title-section {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-bottom: 2rem;
}
.title-heading {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.4rem;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.02em;
  padding: 8px 28px 18px;
  margin: 0;
  text-wrap: pretty;
}
.title-input {
  display: block;
  width: calc(100% - 56px);
  margin: 0 28px;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.35rem;
  line-height: 1.4;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--hairline);
  border-radius: 0;
  padding: 4px 0 14px;
  outline: none;
  letter-spacing: -0.01em;
  resize: none;
}
.title-input:focus { border-bottom-color: var(--accent); }
.title-input::placeholder { color: var(--hairline); }
.title-actions {
  margin-top: auto;
  padding: 28px 24px 12px;
}

/* ── Recorder section ───────────────────────────────────────────── */
#recorder-section {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}
#recorder-section .gw-chrome { padding-top: 24px; }

/* Recording screen */
#recording-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.timer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 30px 0 22px;
}
.rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--record-red);
  animation: gw-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.timer {
  font-family: 'Lora', Georgia, serif;
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  color: var(--ink);
}
.rec-listening {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--record-red);
  font-weight: 600;
  margin-left: 4px;
}
.screen-hint {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: 16px;
  text-align: center;
  padding: 0 24px;
}

/* Processing screen */
#processing-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.processing-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 48px;
}
.saving-text {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}

/* Saved screen */
#saved-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.saved-card {
  background: var(--bg-raised);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 22px 22px 24px;
  margin: 24px 24px 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 2px 14px rgba(46,42,38,0.04);
}
.saved-rule {
  border: none;
  border-top: 0.5px solid var(--hairline-soft);
  margin: 14px 0;
}
.saved-got-it {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.3rem;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.saved-got-it svg { color: var(--accent); flex-shrink: 0; }
.ack-area { min-height: 60px; margin-top: 14px; }
.ack-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-style: italic;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.9rem;
  margin: 0;
}
.ack-dot {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: gw-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.ack-text {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-soft);
  border-left: 2px solid var(--accent-soft);
  padding-left: 12px;
  margin: 0;
  animation: gw-fade-in 600ms ease-out;
}
.saved-actions {
  display: flex;
  gap: 10px;
  margin: 18px 24px 0;
}
.saved-actions .btn-pill-ghost { flex: 1; }
.saved-actions .btn-pill { flex: 1.2; }

/* Error screen */
#error-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#error-screen .prompt-card { width: calc(100% - 48px); }
.error-heading {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.2rem;
  line-height: 1.35;
  color: var(--ink);
  margin: 14px 0 6px;
}
.error-body {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0;
}
#error-screen .btn-pill { margin-top: 22px; }

/* Recorder footer (progress + browse) */
.rec-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px 10px;
  border-top: 0.5px solid var(--hairline);
  margin-top: auto;
}
.progress-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-track {
  width: 80px; height: 4px;
  border-radius: 99px;
  background: var(--hairline);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 400ms ease;
}
.progress-label-small {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.footer-browse-link {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 500;
  padding: 4px;
  cursor: pointer;
  min-height: 0;
}

/* ── Library ─────────────────────────────────────────────────────── */
#library-section { padding-bottom: 2rem; }
.library-heading {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.85rem;
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: -0.03em;
  padding: 12px 28px 0;
  margin: 0;
}
.library-subtitle {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--ink-soft);
  padding: 6px 28px 0;
  margin: 0 0 4px;
}
.library-content { padding: 0 0 8px; }
.library-theme {
  margin-bottom: 8px;
}
.library-theme-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 18px 28px 8px;
}
.library-theme-name {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.library-theme-rule {
  flex: 1;
  height: 0.5px;
  background: var(--hairline-soft);
  display: block;
}
.library-theme-count {
  font-family: system-ui, sans-serif;
  font-size: 0.65rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.library-row {
  padding: 14px 28px;
  border-top: 0.5px solid var(--hairline-soft);
}
.library-row-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}
.library-row-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.library-row-date {
  font-family: system-ui, sans-serif;
  font-size: 0.68rem;
  color: var(--ink-faint);
  white-space: nowrap;
  flex-shrink: 0;
}
.library-row-synopsis {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
  text-wrap: pretty;
}
.library-row-synopsis--pending { color: var(--ink-faint); }
.library-footer {
  padding: 12px 24px 0;
}
.library-empty {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-soft);
  padding: 28px 28px;
}

/* ── Browse drawer (bottom sheet) ───────────────────────────────── */
.browse-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
}
.browse-overlay[hidden] { display: none; }
.browse-scrim {
  position: absolute;
  inset: 0;
  background: rgba(46,42,38,0.32);
  animation: gw-fade-in 240ms ease-out;
}
.browse-sheet {
  position: relative;
  margin-top: auto;
  background: var(--bg-raised);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  padding-top: 8px;
  padding-bottom: max(44px, env(safe-area-inset-bottom));
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 36px rgba(46,42,38,0.16);
  animation: gw-slide-up 320ms cubic-bezier(.2,.7,.3,1);
}
.browse-grabber {
  width: 38px; height: 4px;
  border-radius: 99px;
  background: var(--hairline);
  margin: 6px auto 14px;
  flex-shrink: 0;
}
.browse-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 28px 12px;
  flex-shrink: 0;
}
.browse-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0;
}
.browse-done {
  background: none;
  border: none;
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 500;
  padding: 6px 2px;
  cursor: pointer;
  min-height: 0;
  width: auto;
}
.browse-count {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.82rem;
  color: var(--ink-soft);
  padding: 0 28px 6px;
  flex-shrink: 0;
  margin: 0;
}
.prompt-list {
  overflow: auto;
  flex: 1;
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}
.browse-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  text-align: left;
  padding: 18px 28px;
  border: none;
  border-bottom: 0.5px solid var(--hairline-soft);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  list-style: none;
}
.browse-item button {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  min-height: 0;
}
.browse-item--current { background: var(--accent-wash); }
.browse-check-icon {
  margin-top: 4px;
  flex-shrink: 0;
  width: 18px; height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.browse-item-text {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.1rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.browse-item-text--done {
  color: var(--ink-soft);
  font-style: italic;
}
.browse-item-text--todo { color: var(--ink); }

/* ── Profile form ─────────────────────────────────────────────── */
#profile-section {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  padding-bottom: 2rem;
}
.profile-subheading {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-faint);
  margin: 0 0 20px;
  padding: 0 28px;
  line-height: 1.5;
}
.profile-fields {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 0 24px;
}
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-field-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.82rem;
  color: var(--ink-soft);
  letter-spacing: 0;
}
.profile-field-input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 16px 16px;
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  box-sizing: border-box;
}
.profile-field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.profile-field-input::placeholder { color: var(--hairline); }
.profile-field-textarea {
  resize: vertical;
  padding-top: 14px;
}
.profile-field-pair {
  display: flex;
  gap: 14px;
}
.profile-field-pair .profile-field { flex: 1; }
.profile-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 20px 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   v2 Chapters extension
   ═══════════════════════════════════════════════════════════════════ */

/* ── Lobby nudge card ──────────────────────────────────────────── */
.lobby-nudge {
  position: relative;
  background: #FFFBF1;
  border: 0.5px solid var(--hairline-soft);
  border-radius: 14px;
  margin: 12px 20px 0;
  box-shadow: 0 2px 8px rgba(46,42,38,0.04);
  display: flex;
  align-items: center;
  overflow: hidden;
}
.lobby-nudge-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 14px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  min-height: 0;
}
.lobby-nudge-text {
  flex: 1;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink-soft);
  text-wrap: pretty;
}
.lobby-nudge-arrow {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 500;
  flex-shrink: 0;
}
.lobby-nudge-dismiss {
  width: 40px;
  height: 100%;
  min-height: 52px;
  background: transparent;
  border: none;
  border-left: 0.5px solid var(--hairline-soft);
  color: var(--ink-faint);
  cursor: pointer;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
/* Urgent variant — purge countdown. Same shape; warmer accent. */
.lobby-nudge--urgent {
  background: #FBF1ED;
  border-color: rgba(164, 73, 61, 0.35);
  border-left: 3px solid var(--record-red);
}
.lobby-nudge--urgent .lobby-nudge-text { color: var(--ink); }
.lobby-nudge--urgent .lobby-nudge-arrow { color: var(--record-red); }

/* ── Chapters picker ───────────────────────────────────────────── */
#chapters-section { padding-bottom: 2rem; }
.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 20px 8px;
}
.chapter-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 18px 20px;
  background: var(--bg-raised);
  color: var(--ink);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-card);
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 2px 14px rgba(46,42,38,0.04);
  transition: border-color 160ms ease, box-shadow 160ms ease;
  user-select: none;
  -webkit-user-select: none;
}
.chapter-card:active,
.chapter-card--highlighted {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 8px 24px rgba(46,42,38,0.08);
}
.chapter-card-body { flex: 1; min-width: 0; }
.chapter-card-name {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.2rem;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 4px;
}
.chapter-card-desc {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink-soft);
  margin-bottom: 8px;
  text-wrap: pretty;
}
.chapter-card-count {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
}
.chapter-card-count--has-stories { color: var(--accent); }
/* Drag handle on the left of each chapter card. Same hit area as the menu
   button; uses the universal "⋮⋮" grip glyph. Cursor signals draggability. */
.chapter-card-drag-handle {
  width: 28px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: 1.05rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.1em;
  cursor: grab;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.chapter-card-drag-handle:hover { color: var(--accent); background: var(--accent-wash); }
.chapter-card-drag-handle:active { cursor: grabbing; }
.chapter-card-drag-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.chapter-card--dragging  { opacity: 0.5; }
.chapter-card--drop-target {
  border-color: var(--accent);
  border-top: 3px solid var(--accent);
}
/* ⋯ menu button — primary affordance for Rename / Delete. Works on every
   input method (mouse, touch, keyboard). Long-press still works as a
   secondary path on touch devices. */
.chapter-card-menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: 1.4rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0 0 6px;
  transition: background-color 120ms ease, color 120ms ease;
}
.chapter-card-menu-btn:hover {
  background: var(--accent-wash);
  color: var(--accent);
}
.chapter-card-menu-btn:active { background: var(--accent-soft); }
.chapter-card-menu-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.chapters-loading {
  padding: 24px 28px;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  color: var(--ink-faint);
  margin: 0;
}
.add-chapter-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 18px 20px;
  background: transparent;
  color: var(--accent);
  border: 1.5px dashed var(--accent-soft);
  border-radius: var(--radius-card);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 120ms ease;
  min-height: 0;
}
.add-chapter-btn:hover { border-color: var(--accent); }
.add-chapter-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
  color: var(--accent);
  line-height: 1;
}
.add-chapter-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 2px;
  display: block;
}
.add-chapter-sub {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.75rem;
  color: var(--ink-soft);
  display: block;
}
.chapters-cap-text {
  text-align: center;
  padding: 22px 22px;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--ink-faint);
  border-top: 0.5px solid var(--hairline-soft);
  margin: 4px 0 0;
}

/* Inline rename input (replaces chapter-card-name during edit) */
.chapter-card-name-input {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.2rem;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--accent);
  border-radius: 0;
  outline: none;
  padding: 0 0 2px;
  width: 100%;
  margin-bottom: 4px;
}

/* Add-chapter modal text input */
.add-chapter-input {
  display: block;
  width: 100%;
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 0.5px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 16px;
  outline: none;
  margin: 0 0 20px;
  transition: border-color 120ms ease;
  -webkit-appearance: none;
}
.add-chapter-input:focus { border-color: var(--accent); }
.add-chapter-input::placeholder {
  color: var(--ink-faint);
  font-style: italic;
}
.chapters-hint {
  text-align: center;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin: 8px 24px 0;
  padding: 0;
}

/* Middle button in a 3-up nav-bar (Back · My stories · Home). */
.nav-mid-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  min-height: 44px;
  border-radius: 8px;
}
.nav-mid-btn:hover { opacity: 0.8; }

/* ── Chapter question selection ───────────────────────────────── */
#chapter-selection-section {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  position: relative;
  padding-bottom: 140px; /* room for sticky chsel-footer */
}
.chsel-actions-row {
  display: flex;
  gap: 16px;
  padding: 6px 28px 8px;
  border-bottom: 0.5px solid var(--hairline-soft);
  align-items: center;
}
.inline-link-btn {
  background: none;
  border: none;
  padding: 6px 0;
  cursor: pointer;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(0,0,0,0.15);
  min-height: 0;
  width: auto;
}
.chsel-sep { color: var(--ink-faint); font-size: 0.9rem; }
.chsel-questions-wrap { flex: 1; overflow: auto; }
.chsel-questions-list { /* rows appended by JS */ }
.chsel-ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 32px;
  text-align: center;
}
.chsel-ai-text {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.4;
  color: var(--ink-soft);
  letter-spacing: -0.01em;
  animation: gw-breathe 2.4s ease-in-out infinite;
  margin: 0;
}
@keyframes gw-breathe {
  0%, 100% { opacity: 0.55; }
  50%       { opacity: 1; }
}
.chsel-question-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 0.5px solid var(--hairline-soft);
  cursor: pointer;
  transition: background 160ms ease;
}
.chsel-question-row--checked { background: rgba(232,236,241,0.45); }
.chsel-checkbox {
  flex-shrink: 0;
  width: 24px; height: 24px;
  min-width: 24px;
  margin-top: 2px;
  border-radius: 6px;
  border: 1.5px solid rgba(107,97,85,0.55);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, border-color 120ms ease;
}
.chsel-checkbox--checked {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(46,42,38,0.18);
}
.chsel-question-text {
  flex: 1;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
.chsel-pencil-btn {
  flex-shrink: 0;
  width: 32px; height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  min-height: 0;
}
.chsel-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 12px 20px max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
  z-index: 5;
  max-width: 34rem;
  margin: 0 auto;
}
.chsel-status-text {
  text-align: center;
  margin: 0 0 10px;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
/* disabled state for the start CTA */
.chsel-footer .btn-pill:disabled {
  background: transparent;
  color: var(--ink-faint);
  border: 1px solid var(--hairline);
  box-shadow: none;
  opacity: 1;
  cursor: not-allowed;
}

/* Fifth-checkbox nudge sheet */
.fifth-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70;
  background: var(--bg-raised);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border-top: 0.5px solid var(--hairline-soft);
  box-shadow: 0 -10px 36px rgba(27,24,20,0.16);
  padding: 18px 22px 22px;
  animation: gw-slide-up 320ms cubic-bezier(.2,.7,.3,1);
  cursor: pointer;
  max-width: 34rem;
  margin: 0 auto;
}
.fifth-sheet-grabber {
  width: 36px; height: 4px;
  border-radius: 99px;
  background: var(--hairline);
  margin: 0 auto 12px;
}
.fifth-sheet-text {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  text-wrap: pretty;
}
.fifth-sheet-btns { display: flex; gap: 10px; }
.fifth-btn-refresh {
  flex: 1;
  min-height: 48px;
  font-size: 0.9rem;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.fifth-btn-add {
  flex: 1;
  min-height: 48px;
  font-size: 0.9rem;
  padding: 12px 14px;
}

/* ── Queue counter ("Story N of M") ───────────────────────────── */
.queue-counter {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  margin: 16px 0 6px;
  padding: 0;
}

/* ── Chapter done ──────────────────────────────────────────────── */
#chapter-done-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 48px 28px;
  text-align: center;
}
#chapter-done-section .ornament { justify-content: center; margin-bottom: 28px; }
.chapter-done-heading {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.7rem;
  line-height: 1.25;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin: 0 0 20px;
  text-wrap: pretty;
}
.chapter-done-desc {
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 40px;
  text-wrap: pretty;
  max-width: 300px;
}
.chapter-done-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
.btn-pill-ghost--full { width: 100%; }

/* ── Library accordion (v2) ───────────────────────────────────── */
.library-accordion { padding: 0 0 8px; }
.library-accord-group { border-top: 0.5px solid var(--hairline-soft); }
.library-accord-trigger {
  width: 100%;
  background: transparent;
  border: none;
  /* extra left padding makes room for the absolutely-positioned drag handle
     (.library-chapter-drag-handle, left: 6px width: 28px) so the chapter
     name doesn't sit underneath it. */
  padding: 18px 24px 18px 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  min-height: 56px;
}
.library-accord-trigger:disabled { cursor: default; }
.library-accord-left { flex: 1; min-width: 0; }
.library-accord-name {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.library-accord-name--empty { color: var(--ink-faint); }
.library-accord-name--soft  { color: var(--ink-soft); }
.library-accord-count {
  font-family: system-ui, sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
}
.library-accord-count--empty { color: var(--ink-faint); }
.library-accord-chevron {
  transition: transform 220ms ease;
  color: var(--ink-faint);
  flex-shrink: 0;
}
.library-accord-chevron--open { transform: rotate(90deg); }
.library-accord-stories {
  padding: 0 24px 14px;
  animation: gw-fade-in 220ms ease-out;
}
.library-accord-row {
  padding: 12px 0;
  border-top: 0.5px solid var(--hairline-soft);
}
.library-accord-row-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 4px;
}
.library-uncategorised-caveat {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

/* ── Modal scrim ──────────────────────────────────────────────── */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(27,24,20,0.42);
  animation: gw-fade-in 200ms ease-out;
}

/* ── Chapter long-press menu (floating pill) ─────────────────── */
.chapter-menu-pill {
  position: fixed;
  left: 50%; top: 52%;
  transform: translate(-50%, -50%);
  background: var(--bg-raised);
  border: 0.5px solid var(--hairline);
  border-radius: 99px;
  padding: 6px;
  display: flex;
  gap: 4px;
  box-shadow: 0 16px 40px rgba(27,24,20,0.30);
  z-index: 65;
  animation: gw-card-pop 200ms cubic-bezier(.2,.7,.3,1);
}
@keyframes gw-card-pop {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.96); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.menu-pill-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 12px 18px;
  border-radius: 99px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.95rem;
  color: var(--accent);
  min-height: 44px;
  white-space: nowrap;
}
.menu-pill-btn--danger { color: var(--record-red); }
.menu-pill-sep {
  width: 0.5px;
  background: var(--hairline-soft);
  align-self: stretch;
  display: block;
}

/* ── Modal card (shared by delete confirm, OTP, floor warning) ── */
.modal-card {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 36px);
  max-width: 320px;
  background: var(--bg-raised);
  border: 0.5px solid var(--hairline);
  border-radius: 22px;
  padding: 24px 22px 22px;
  box-shadow: 0 24px 64px rgba(27,24,20,0.32), 0 2px 0 rgba(255,255,255,0.6) inset;
  animation: gw-modal-pop 220ms cubic-bezier(.2,.7,.3,1);
  z-index: 65;
}
@keyframes gw-modal-pop {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal-eyebrow {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
}
.modal-heading {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  text-wrap: pretty;
}
.modal-body {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 22px;
  text-wrap: pretty;
}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-actions .btn-pill     { min-height: 52px; font-size: 0.95rem; }
.modal-actions .btn-pill-ghost { min-height: 52px; font-size: 0.9rem; }

/* Danger outline pill (delete confirm, OTP confirm) */
.btn-outline-pill-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--record-red);
  border: 1px solid var(--record-red);
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 52px;
  transition: color 160ms ease, border-color 160ms ease;
}
.btn-outline-pill-danger:disabled {
  color: var(--ink-faint);
  border-color: var(--hairline);
  cursor: not-allowed;
}

/* Inline text link inside modal body */
.modal-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-style: italic;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 0;
  display: inline;
  width: auto;
}
.otp-hint { font-size: 0.82rem; text-align: center; }

.modal-error {
  margin: 4px 0 8px;
  font-size: 0.85rem;
  text-align: center;
  color: var(--record-red);
}

/* Restore picker — bottom-sheet list of chapters to restore a recording into. */
.restore-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 12px;
  max-height: 50vh;
  overflow-y: auto;
}
.restore-picker-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-raised);
  border: 0.5px solid var(--hairline-soft);
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Lora', Georgia, serif;
  text-align: left;
  min-height: 48px;
}
.restore-picker-row:hover  { border-color: var(--accent); }
.restore-picker-row:active { background: var(--accent-wash); }
.restore-picker-row-name  { font-size: 1rem; color: var(--ink); }
.restore-picker-row-count { font-size: 0.8rem; color: var(--ink-faint); }
.restore-picker-row--working { opacity: 0.55; cursor: default; }

/* Library playback (v1 testing affordance) */
.library-row-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ⋯ menu button on each library chapter group header. Sits absolutely
   in the top-right of the group so it doesn't end up nested inside the
   accordion trigger button (invalid HTML, breaks button activation). */
.library-accord-group { position: relative; }
.library-chapter-menu-btn {
  position: absolute;
  /* Anchor to the top of the group so an expanded accordion's tall body
     doesn't drag the button down with it. ~22px puts the ⋯ vertically
     aligned with the chevron in the trigger row. */
  top: 22px;
  right: 36px; /* keep clear of the trigger's chevron at the far right */
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: 1.4rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 6px;
  transition: background-color 120ms ease, color 120ms ease;
  z-index: 2;
}
.library-chapter-menu-btn:hover {
  background: var(--accent-wash);
  color: var(--accent);
}
.library-chapter-menu-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Drag handle on library chapter group headers — positioned absolutely on
   the left edge so it doesn't end up inside the trigger button (invalid
   HTML). Same ⋮⋮ glyph as the chapter picker for consistency. */
.library-chapter-drag-handle {
  position: absolute;
  top: 22px;
  left: 6px;
  width: 28px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: 1.05rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.1em;
  cursor: grab;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
}
.library-chapter-drag-handle:hover {
  color: var(--accent);
  background: var(--accent-wash);
}
.library-chapter-drag-handle:active { cursor: grabbing; }
.library-chapter-drag-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.library-accord-group--dragging { opacity: 0.5; }
.library-accord-group--drop-target {
  border-top: 3px solid var(--accent);
}

/* Inline rename input that replaces the chapter name during library rename. */
.library-accord-name-input {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.2;
  font-weight: 500;
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--ink);
  width: 100%;
  max-width: 320px;
}

/* Per-story ⋯ menu button — sits in the foot row next to Play. */
.library-row-menu-btn {
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 600;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.library-row-menu-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Story action sheet — replaces the row foot when ⋯ is tapped. */
.library-row-action {
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
  min-height: 36px;
}
.library-row-action:hover  { border-color: var(--accent); }
.library-row-action--delete { color: var(--record-red); border-color: rgba(164, 73, 61, 0.35); }
.library-row-action--delete:hover { border-color: var(--record-red); }

/* "Delete permanently" button on Uncategorised rows — same visual language as
   the in-row delete pill, slightly more emphatic since this is OTP-gated. */
.library-purge-btn {
  background: none;
  border: 1px solid rgba(164, 73, 61, 0.5);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.85rem;
  color: var(--record-red);
  cursor: pointer;
  min-height: 36px;
}
.library-purge-btn:hover  { border-color: var(--record-red); }
.library-row-action--cancel { color: var(--ink-faint); }
.library-row-action:disabled { opacity: 0.55; cursor: default; }

/* Inline rename input for a single recording's narrator_title. */
.library-row-title-input {
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  font-weight: 500;
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--ink);
  width: 100%;
  max-width: 360px;
}
.library-play-btn {
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
  min-height: 36px;
}
.library-play-btn:disabled { opacity: 0.5; cursor: default; }
.library-restore-btn {
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
  min-height: 36px;
}
.library-restore-btn:hover  { border-color: var(--accent); }
.library-restore-btn:active { background: var(--accent-wash); }
.library-row-countdown {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin: 4px 0 0;
}
.library-row-countdown--urgent { color: var(--record-red); }
.library-row-duration {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.8rem;
  color: var(--ink-faint);
}
.library-row-audio {
  width: 100%;
  margin-top: 8px;
  height: 36px;
}

/* OTP digit boxes */
.otp-boxes {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 22px;
  position: relative;
  cursor: text;
}
.otp-box {
  flex: 1;
  height: 56px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 1.35rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  pointer-events: none;
}
.otp-box--cursor {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.otp-input-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  border: none;
  outline: none;
  caret-color: transparent;
  font-size: 1.35rem;
}

/* Single visible OTP input — replaces the hidden-input + boxes pattern.
   Looks chunky thanks to letter-spacing and monospace font; reliably
   receives keystrokes on iOS Safari. */
.otp-visible-input {
  width: 100%;
  height: 56px;
  padding: 0 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--hairline);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 1.6rem;
  letter-spacing: 0.45em;
  text-align: center;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.otp-visible-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.otp-visible-input::placeholder {
  color: var(--ink-faint);
  letter-spacing: 0.45em;
}
