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

:root {
  --night: #0d0b1e;
  --night-2: #13102b;
  --night-3: #1e1840;
  --surface: rgba(255,255,255,.07);
  --surface-solid: #1e1840;
  --ink: #f0eeff;
  --ink-soft: rgba(200,190,255,.6);
  --purple: #8b5cf6;
  --purple-bright: #a78bfa;
  --purple-mid: #7c3aed;
  --gold: #fbbf24;
  --gold-soft: #fde68a;
  --rose: #fb7185;
  --green: #34d399;
  --teal: #22d3ee;
  --r: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --sh: 0 4px 20px rgba(0,0,0,.4);
  --sh-glow: 0 0 20px rgba(139,92,246,.3);
  --sh-card: 0 8px 32px rgba(0,0,0,.5);
}

html, body {
  height: 100%; overflow: hidden;
  background: var(--night);
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── Screens ─────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--night);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  opacity: 0; pointer-events: none;
  transform: translateY(12px);
  transition: opacity .3s ease, transform .3s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.screen.active { opacity: 1; pointer-events: auto; transform: none; }

/* ── Starfield background ─────────────────────────────────── */
.screen::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,.7) 0%, transparent 100%),
    radial-gradient(1px 1px at 25% 40%, rgba(255,255,255,.5) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 40% 8%, rgba(255,255,255,.8) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 55%, rgba(255,255,255,.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 20%, rgba(255,255,255,.7) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 80% 75%, rgba(255,255,255,.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 35%, rgba(255,255,255,.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 15% 70%, rgba(255,255,255,.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 35% 85%, rgba(255,255,255,.5) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 60% 92%, rgba(255,255,255,.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 75% 50%, rgba(255,255,255,.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 92% 80%, rgba(255,255,255,.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 5% 50%, rgba(255,255,255,.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 48% 28%, rgba(255,255,255,.6) 0%, transparent 100%);
}

/* Non-home screens don't need the starfield as much */
#screen-loading::before, #screen-reader::before, #screen-end::before { display: none; }

/* All content inside screens needs to be above the starfield */
.screen > * { position: relative; z-index: 1; }

/* ── Common header ─────────────────────────────────────────── */
.screen-header {
  display: flex; align-items: center; gap: 10px;
  padding: max(56px, calc(env(safe-area-inset-top) + 20px)) 20px 16px;
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(to bottom, var(--night) 70%, transparent);
}
.screen-header h2 {
  font-size: 1.4rem; font-weight: 800; color: var(--ink);
}
.back-btn {
  background: var(--surface); border: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(12px); cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.1rem; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s;
}
.back-btn:active { background: rgba(255,255,255,.15); }

/* ── Buttons ─────────────────────────────────────────────── */
.primary-btn {
  display: block; width: 100%; padding: 16px;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple));
  color: #fff;
  font-family: inherit; font-size: 1.05rem; font-weight: 800;
  border: none; border-radius: var(--r); cursor: pointer;
  box-shadow: 0 4px 20px rgba(139,92,246,.45);
  transition: transform .1s, box-shadow .1s;
}
.primary-btn:active { transform: scale(.97); box-shadow: 0 2px 8px rgba(139,92,246,.25); }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 20px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: var(--ink); border-radius: var(--r);
  font-family: inherit; font-size: .95rem; font-weight: 700; cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background .15s;
}
.ghost-btn:active { background: rgba(255,255,255,.15); }

/* ── HOME ────────────────────────────────────────────────── */
#screen-home {
  background: radial-gradient(ellipse at 30% 0%, #2a1060 0%, var(--night) 65%);
}

.home-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(20px, calc(env(safe-area-inset-top) + 12px)) 20px 12px;
  position: sticky; top: 0; z-index: 10;
  background: var(--night);
}
.home-title-wrap {
  display: flex; align-items: center; gap: 10px;
}
.home-star-icon {
  font-size: 2rem; line-height: 1;
  filter: drop-shadow(0 0 8px rgba(251,191,36,.8));
  animation: pulse-star 3s ease-in-out infinite;
}
@keyframes pulse-star {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 8px rgba(251,191,36,.8)); }
  50% { transform: scale(1.12); filter: drop-shadow(0 0 16px rgba(251,191,36,1)); }
}
.home-title {
  font-size: 2rem; font-weight: 800; color: var(--ink);
  letter-spacing: -.02em;
  text-shadow: 0 0 30px rgba(139,92,246,.5);
}

.home-header-actions { display: flex; gap: 8px; }
.icon-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(12px); cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.icon-btn:active { background: rgba(255,255,255,.18); transform: scale(.9); }


/* Setup banner */
.setup-banner {
  margin: 0 16px 4px;
  padding: 12px 14px;
  background: rgba(251,191,36,.12);
  border: 1px solid rgba(251,191,36,.35);
  border-radius: var(--r); display: flex; gap: 10px; align-items: center;
  cursor: pointer; backdrop-filter: blur(8px);
}
.setup-banner-icon { font-size: 1.2rem; flex-shrink: 0; }
.setup-banner-text { flex: 1; font-size: .82rem; font-weight: 700; color: var(--gold-soft); }
.setup-banner-arrow { color: var(--gold); font-size: .9rem; }
.setup-banner.hidden { display: none; }

.shelf-intro { padding: 2px 20px 6px; }
.shelf-intro-text {
  font-size: .75rem; font-weight: 700; color: var(--ink-soft);
  text-align: center; letter-spacing: .03em;
}

/* Main Page Dev Mode Bar */
.home-dev-bar {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 6px 14px; margin: 0 auto 10px;
  width: fit-content; max-width: 90%;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 100px;
  backdrop-filter: blur(8px);
}
.dev-bar-label {
  font-size: 0.76rem; font-weight: 800; color: #e0e7ff;
}
.dev-mode-select {
  background: rgba(30, 27, 75, 0.85);
  border: 1px solid rgba(167, 139, 250, 0.5);
  border-radius: 20px;
  color: #fff;
  font-family: inherit; font-size: 0.78rem; font-weight: 700;
  padding: 4px 10px; cursor: pointer; outline: none;
}
.dev-mode-select option {
  background: #1e1b4b; color: #fff;
}

/* ── SHELF GRID ─────────────────────────────────────────── */
.shelf-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; padding: 4px 14px 80px;
  width: 100%;
}
.shelf-loading {
  padding: 60px 20px; color: var(--ink-soft);
  text-align: center; font-size: .9rem;
  grid-column: 1 / -1;
}

/* Book-style portrait card */
.shelf-card {
  background: var(--night-3);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; cursor: pointer;
  overflow: hidden;
  box-shadow: 2px 0 0 rgba(255,255,255,0.12), 4px 0 0 rgba(0,0,0,0.4), 4px 8px 24px rgba(0,0,0,.6);
  transition: transform .18s ease, box-shadow .18s ease;
  aspect-ratio: 2 / 3;
  position: relative;
}
.shelf-card:active { transform: scale(.96); box-shadow: 2px 3px 10px rgba(0,0,0,.5); }

/* Cover fills the whole card */
.shelf-card-cover {
  position: absolute; inset: 0;
  overflow: hidden;
}
.shelf-card.locked .shelf-card-cover { filter: brightness(.6) saturate(.6); }

/* 3D Book Spine Left Shadow */
.shelf-card-cover::before {
  content: '';
  position: absolute; top: 0; bottom: 0; left: 0; width: 14px;
  background: linear-gradient(to right, rgba(0,0,0,.45) 0%, rgba(0,0,0,.15) 60%, transparent 100%);
  z-index: 2; pointer-events: none;
}

/* Gradient so title reads over art */
.shelf-card-cover::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg,
    rgba(0,0,0,.08) 0%,
    transparent 30%,
    rgba(0,0,0,.25) 55%,
    rgba(0,0,0,.85) 100%);
  z-index: 1;
}

/* Lock icon — top right */
.shelf-lock {
  position: absolute; top: 10px; right: 10px;
  z-index: 3; font-size: 1rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.6));
}

/* Time badge — top left */
.shelf-badges {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
}
.shelf-badge-age {
  background: rgba(0,0,0,.55); color: rgba(255,255,255,.9);
  font-size: .58rem; font-weight: 800; border-radius: 100px;
  padding: 2px 7px; backdrop-filter: blur(8px);
  letter-spacing: .04em; text-transform: uppercase;
}
.shelf-badge-time {
  background: rgba(139,92,246,.85); color: #fff;
  font-size: .58rem; font-weight: 800; border-radius: 100px;
  padding: 2px 7px; backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 3px;
}
.shelf-badge-time::before { content: '🎙'; font-size: .48rem; }
.shelf-badge-free {
  background: rgba(52,211,153,.9); color: #052e16;
  font-size: .6rem; font-weight: 900; border-radius: 100px;
  padding: 2px 8px; backdrop-filter: blur(8px);
  letter-spacing: .04em;
}

/* Category Filter Pills */
.category-pills-bar {
  display: flex; gap: 8px; overflow-x: auto;
  align-items: center;
  padding: 8px 20px 14px;
  margin-bottom: 2px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.category-pills-bar::-webkit-scrollbar { display: none; }

.category-pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px;
  min-height: 38px;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 100px;
  color: var(--ink-soft);
  font-family: inherit; font-size: 0.85rem; font-weight: 700;
  cursor: pointer; backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
  white-space: nowrap;
}
.category-pill:active { transform: scale(0.96); }
.category-pill.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(124, 58, 237, 0.9));
  border-color: rgba(167, 139, 250, 0.5);
  color: #fff;
  box-shadow: 0 3px 12px rgba(139, 92, 246, 0.35);
}

/* Category Section Headers on Shelf Grid */
.shelf-section-header {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 0 10px; padding: 0 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.shelf-section-title {
  font-size: 1.05rem; font-weight: 800; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.shelf-section-count {
  font-size: 0.72rem; font-weight: 800; color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.09); padding: 3px 10px; border-radius: 100px;
}

/* Category Card Badges */
.shelf-badge-cat {
  font-size: 0.58rem; font-weight: 800; border-radius: 100px;
  padding: 2px 7px; backdrop-filter: blur(8px);
  letter-spacing: 0.03em;
}
.shelf-badge-cat.brazilian {
  background: rgba(16, 185, 129, 0.9); color: #fff;
}
.shelf-badge-cat.spanish {
  background: rgba(245, 158, 11, 0.9); color: #fff;
}
.shelf-badge-cat.classic {
  background: rgba(139, 92, 246, 0.9); color: #fff;
}

/* Avatar Option Cards */
.avatar-option-card {
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px; padding: 14px 10px;
  cursor: pointer; transition: transform 0.15s, border-color 0.2s, background 0.2s;
  text-align: center;
}
.avatar-option-card:active { transform: scale(0.96); }
.avatar-option-card.selected {
  border-color: var(--purple-bright);
  background: rgba(139, 92, 246, 0.25);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.35);
}

/* Cover photo */
.shelf-cover-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; object-position: center top;
  z-index: 0;
}

/* Download cloud badge */
.shelf-dl-badge {
  position: absolute; top: 9px; right: 10px; z-index: 3;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,.55); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.18);
  font-size: .75rem; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.8);
}
.shelf-dl-badge.hidden { display: none; }

/* Download progress overlay */
.shelf-card-dl-overlay {
  position: absolute; inset: 0; z-index: 8;
  background: rgba(13,11,30,.82);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  border-radius: inherit;
  backdrop-filter: blur(4px);
}
.shelf-card-dl-overlay.hidden { display: none; }
.shelf-card-dl-label {
  font-size: .68rem; font-weight: 800; color: var(--ink-soft);
  letter-spacing: .05em; text-transform: uppercase;
}
.shelf-card-dl-bar {
  width: 68%; height: 3px;
  background: rgba(255,255,255,.15); border-radius: 100px; overflow: hidden;
}
.shelf-card-dl-fill {
  height: 100%; width: 0%;
  background: linear-gradient(to right, var(--purple-mid), var(--purple-bright));
  border-radius: 100px;
  transition: width .18s linear;
}

/* Title overlaid at bottom of card */
.shelf-card-title {
  position: absolute; bottom: 0; left: 0; right: 0;
  z-index: 2; padding: 8px 10px 12px;
  font-size: .8rem; font-weight: 800; color: #fff;
  line-height: 1.25; text-align: left;
  text-shadow: 0 1px 6px rgba(0,0,0,.9);
}
.shelf-card.locked .shelf-card-title { color: rgba(255,255,255,.65); }

/* ── LOADING ─────────────────────────────────────────────── */
#screen-loading {
  justify-content: center; align-items: center;
  background: radial-gradient(ellipse at center, #2d1270 0%, #0d0b1e 70%);
}
.loading-scene { text-align: center; padding: 40px 28px; }
.loading-star {
  font-size: 5rem; display: block; margin-bottom: 28px;
  animation: pulse-star 2.2s ease-in-out infinite;
}
.loading-message { font-size: 1.3rem; font-weight: 800; color: var(--ink); margin-bottom: 8px; }
.loading-sub { font-size: .85rem; color: var(--ink-soft); margin-bottom: 40px; }
.loading-dots { display: flex; justify-content: center; gap: 8px; }
.loading-dots span {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--purple-bright);
  animation: bounce 1.4s infinite ease-in-out both;
}
.loading-dots span:nth-child(1) { animation-delay: -.32s; }
.loading-dots span:nth-child(2) { animation-delay: -.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── READER ──────────────────────────────────────────────── */
#screen-reader {
  background: #080613;
  overflow: hidden;
  display: flex; flex-direction: column;
  padding-bottom: 0;
}

/* Illustration: top 55% of screen */
.reader-illustration {
  flex: 0 0 55%;
  position: relative;
  overflow: hidden;
}
.scene-backdrop { position: absolute; inset: 0; transition: background 1s ease; }
#reader-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  transition: opacity .6s ease;
}

/* Header overlaid on illustration */
.reader-header {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 44px) + 8px) 16px 16px;
  background: linear-gradient(to bottom, rgba(8,6,19,.85) 0%, transparent 100%);
}
.reader-back-btn, .reader-bookmark-btn {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.1);
  width: 48px; height: 48px; border-radius: 50%;
  color: #fff; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  backdrop-filter: blur(8px); transition: background .15s;
}
.reader-back-btn svg, .reader-bookmark-btn svg { width: 20px; height: 20px; display: block; }
.reader-back-btn:active, .reader-bookmark-btn:active { background: rgba(255,255,255,.25); }
.reader-mode-badge {
  font-size: .65rem; font-weight: 700; color: rgba(255,255,255,.7);
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px; padding: 3px 8px; white-space: nowrap; flex-shrink: 0;
}
.reader-title {
  flex: 1; margin: 0 8px;
  font-size: .75rem; font-weight: 700; color: rgba(255,255,255,.8);
  text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.3;
}

/* Page dots at bottom of illustration */
.page-indicator {
  position: absolute; bottom: 10px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px; z-index: 5;
  background: rgba(0,0,0,.25); border-radius: 20px;
  width: fit-content; margin: 0 auto;
  padding: 5px 10px;
  backdrop-filter: blur(4px);
}
.page-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.35);
  transition: background .25s, transform .25s;
}
.page-dot.active {
  background: var(--gold);
  transform: scale(1.5);
  box-shadow: 0 0 8px rgba(251,191,36,.6);
}

/* Text panel: slides up over the illustration bottom with rounded top */
.reader-text-panel {
  flex: 1;
  display: flex; flex-direction: column;
  background: var(--night-2);
  border-radius: 24px 24px 0 0;
  margin-top: -28px;
  position: relative; z-index: 5;
  overflow: hidden;
  box-shadow: 0 -4px 20px rgba(0,0,0,.4);
}

.reader-text-area {
  flex: 1;
  padding: 18px 22px 6px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; align-items: flex-start;
}
.reader-text {
  font-size: 1.08rem; line-height: 1.75;
  color: rgba(255,255,255,.93); font-weight: 500;
}
#screen-reader.text-large .reader-text {
  font-size: 1.35rem; line-height: 1.8;
}
#screen-reader.text-xlarge .reader-text {
  font-size: 1.65rem; line-height: 1.85;
}
.rss-textsize-btn {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
  color: var(--ink-soft); padding: 5px 12px; border-radius: 8px;
  font-family: inherit; font-size: 0.85rem; font-weight: 800;
  cursor: pointer; transition: background .15s, color .15s;
}
.rss-textsize-btn.active {
  background: var(--purple-mid); border-color: var(--purple-bright); color: #fff;
}
.reader-text .word { transition: background .08s; border-radius: 3px; }
.reader-text .word.highlight {
  background: rgba(255,252,120,.22);
  outline: 3px solid rgba(255,252,120,.15);
  outline-offset: 1px;
  color: rgba(255,255,255,.98);
  text-shadow: none;
}

/* Landscape: open-book side-by-side layout */
@media (orientation: landscape) {
  #screen-reader { flex-direction: row; }
  .reader-illustration {
    flex: 0 0 50%;
    height: 100%;
  }
  .reader-text-panel {
    border-radius: 0;
    margin-top: 0;
    border-left: 1px solid rgba(255,255,255,.07);
    box-shadow: none;
  }
  .reader-text-area { padding: 20px 24px 6px; align-items: center; padding-top: 24px; }
}

.reader-controls {
  display: flex; align-items: center; justify-content: center; gap: 22px;
  padding: 10px 0 calc(14px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}
.reader-nav-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.85); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; transition: background .12s;
}
.reader-nav-btn svg { width: 22px; height: 22px; display: block; }
.reader-nav-btn:active { background: rgba(255,255,255,.22); }
.reader-replay-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.75); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; transition: background .12s, transform .1s;
}
.reader-replay-btn svg { width: 18px; height: 18px; display: block; }
.reader-replay-btn:active { background: rgba(255,255,255,.2); transform: scale(.88); }
.reader-play-btn {
  width: 66px; height: 66px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple));
  border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  box-shadow: 0 4px 24px rgba(139,92,246,.6), 0 0 0 4px rgba(139,92,246,.15);
  transition: transform .12s, box-shadow .12s;
}
.reader-play-btn:active { transform: scale(.9); box-shadow: 0 2px 10px rgba(139,92,246,.4); }
.reader-play-btn svg, .reader-play-btn .icon-loading { display: none; width: 26px; height: 26px; }
.reader-play-btn[data-state="play"] .icon-play { display: block; }
.reader-play-btn[data-state="pause"] .icon-pause { display: block; }
.reader-play-btn[data-state="loading"] .icon-loading { display: block; }
.icon-loading {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.reader-progress-bar {
  height: 3px; background: rgba(255,255,255,.08);
  flex-shrink: 0;
}
.reader-progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--purple-mid), var(--purple-bright));
  transition: width .5s linear;
  box-shadow: 0 0 8px rgba(139,92,246,.5);
}

/* Auto-play countdown bar */
.reader-autoplay-bar {
  height: 2px; background: transparent; flex-shrink: 0;
}
.reader-autoplay-fill {
  height: 100%; width: 0%;
  background: linear-gradient(to right, var(--teal), var(--green));
  box-shadow: 0 0 6px rgba(34,211,238,.6);
}

/* ── READER SETTINGS SHEET ────────────────────────────────── */
.reader-settings-sheet {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: flex-end;
}
.reader-settings-sheet.hidden { display: none; }
.rss-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
}
.rss-panel {
  position: relative; z-index: 1;
  width: 100%; background: #1a1535;
  border-top: 1px solid rgba(255,255,255,.1);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 20px;
}
.rss-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.2); margin: 0 auto 4px;
}
.rss-title {
  font-size: 1rem; font-weight: 700; color: var(--ink); text-align: center;
}
.rss-section {
  display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid rgba(255,255,255,.08); padding-top: 16px;
}
.rss-section:first-of-type { border-top: none; padding-top: 0; }
.rss-section-label {
  font-size: .73rem; font-weight: 700; letter-spacing: .06em;
  color: var(--ink-soft); text-transform: uppercase;
}

/* Toggle rows */
.rss-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.rss-row-label { font-size: .95rem; font-weight: 600; color: var(--ink); }
.rss-row-sub { font-size: .75rem; color: var(--ink-soft); margin-top: 2px; }
.rss-toggle {
  width: 48px; height: 28px; border-radius: 14px;
  background: rgba(255,255,255,.15); border: none; cursor: pointer;
  padding: 3px; flex-shrink: 0; transition: background .2s;
  display: flex; align-items: center;
}
.rss-toggle[data-on="true"] { background: var(--purple); }
.rss-toggle-knob {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; display: block;
  transform: translateX(0); transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.rss-toggle[data-on="true"] .rss-toggle-knob { transform: translateX(20px); }

/* Speed & Timer Pickers */
.rss-speed-picker, .rss-timer-picker {
  display: flex; gap: 4px; background: rgba(255,255,255,.08);
  padding: 3px; border-radius: 20px; border: 1px solid rgba(255,255,255,.1);
}
.rss-speed-btn, .rss-timer-btn {
  background: transparent; border: none; color: var(--ink-soft);
  font-family: inherit; font-size: .8rem; font-weight: 700;
  padding: 5px 11px; border-radius: 16px; cursor: pointer;
  transition: background .15s, color .15s;
}
.rss-speed-btn.active, .rss-timer-btn.active {
  background: var(--purple-mid); color: #fff;
  box-shadow: 0 2px 8px rgba(124,58,237,.4);
}

/* Sleepy Night Mode Overlay */
.sleepy-overlay {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(251, 146, 60, 0.12);
  mix-blend-mode: multiply;
  pointer-events: none;
  opacity: 0; transition: opacity .4s ease;
}
#screen-reader.sleepy-mode .sleepy-overlay { opacity: 1; }
#screen-reader.sleepy-mode #reader-img { filter: brightness(.85) contrast(.95); }

/* ── END SCREEN ──────────────────────────────────────────── */
#screen-end {
  justify-content: center; align-items: center;
  background: radial-gradient(ellipse at center, #2d1270 0%, #080613 70%);
}
.end-scene { text-align: center; padding: 32px 28px; }
.end-stars {
  font-size: 2.2rem; letter-spacing: 16px; margin-bottom: 24px;
  filter: drop-shadow(0 0 10px rgba(251,191,36,.8));
  animation: pulse-star 2s ease-in-out infinite;
}
.end-title {
  font-size: 2.6rem; font-weight: 800; color: var(--ink);
  margin-bottom: 10px; text-shadow: 0 0 30px rgba(139,92,246,.5);
}
.end-sub { font-size: .92rem; color: var(--ink-soft); margin-bottom: 44px; font-style: italic; }
.end-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.end-actions .primary-btn { max-width: 280px; }

/* ── PAYWALL ─────────────────────────────────────────────── */
#screen-paywall { background: radial-gradient(ellipse at top, #1e1060 0%, var(--night) 65%); }
.paywall-body {
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 28px 60px; gap: 20px; text-align: center;
}
.paywall-icon {
  font-size: 4.5rem; line-height: 1;
  filter: drop-shadow(0 0 16px rgba(251,191,36,.5));
}
.paywall-title { font-size: 1.6rem; font-weight: 800; color: var(--ink); }
.paywall-desc { font-size: .9rem; color: var(--ink-soft); line-height: 1.65; max-width: 300px; }
.paywall-coming {
  background: rgba(251,191,36,.1);
  border: 1px solid rgba(251,191,36,.3);
  border-radius: var(--r); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px; width: 100%;
}
.paywall-coming-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), #f97316);
  color: #fff;
  font-size: .72rem; font-weight: 800; border-radius: 100px;
  padding: 3px 12px; letter-spacing: .07em; text-transform: uppercase;
}
.paywall-coming p { font-size: .85rem; color: var(--gold-soft); font-weight: 600; line-height: 1.5; }
.paywall-body .primary-btn { max-width: 300px; }

/* ── LIBRARY ─────────────────────────────────────────────── */
.library-grid { padding: 8px 18px 60px; display: flex; flex-direction: column; gap: 10px; }
.library-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-lg); cursor: pointer;
  transition: transform .1s, background .15s;
  backdrop-filter: blur(8px);
}
.library-card:active { transform: scale(.98); background: rgba(255,255,255,.1); }
.library-card-thumb {
  width: 58px; height: 58px; border-radius: 12px;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: rgba(255,255,255,.7);
}
.library-card-info { flex: 1; min-width: 0; }
.library-card-title {
  font-size: .95rem; font-weight: 800; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.library-card-meta { font-size: .75rem; color: var(--ink-soft); margin-top: 3px; }
.library-card-actions { display: flex; }
.lib-action-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; padding: 6px; border-radius: 8px;
  color: var(--ink-soft); transition: color .15s;
}
.lib-action-btn:active { color: var(--rose); }
.library-empty {
  text-align: center; padding: 60px 24px; color: var(--ink-soft);
}
.library-empty-icon { font-size: 3.5rem; display: block; margin-bottom: 14px; }
.resume-badge {
  display: inline-block; margin-top: 5px;
  background: rgba(139,92,246,.25); color: var(--purple-bright);
  font-size: .7rem; font-weight: 800; border-radius: 100px;
  padding: 2px 9px; border: 1px solid rgba(139,92,246,.3);
}

.loading-line { color: var(--ink-soft); font-size: .9rem; padding: 20px; }

/* ── MODE PICKER ─────────────────────────────────────────── */
.mode-picker {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end;
}
.mode-picker.hidden { display: none; }
.mode-picker-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
}
.mode-picker-sheet {
  position: relative; z-index: 1;
  width: 100%;
  background: #1e1840;
  border-top: 1px solid rgba(255,255,255,.1);
  border-radius: 28px 28px 0 0;
  padding: 12px 20px 40px;
  box-shadow: 0 -12px 40px rgba(0,0,0,.5);
  animation: slide-up .25s ease;
}
@keyframes slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.mode-picker-handle {
  width: 40px; height: 4px; border-radius: 4px;
  background: rgba(255,255,255,.2);
  margin: 0 auto 18px;
}
.mode-picker-title {
  font-size: 1rem; font-weight: 800; color: var(--ink);
  text-align: center; margin-bottom: 20px; letter-spacing: -.01em;
}
.mode-picker-options { display: flex; flex-direction: column; gap: 10px; }
.mode-option {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-lg); cursor: pointer;
  text-align: left; transition: background .12s, transform .1s;
  width: 100%;
}
.mode-option:active { background: rgba(255,255,255,.12); transform: scale(.98); }
.mode-option-icon { font-size: 1.8rem; flex-shrink: 0; line-height: 1; }
.mode-option-body { flex: 1; }
.mode-option-label { font-size: 1rem; font-weight: 800; color: var(--ink); }
.mode-option-sub { font-size: .8rem; color: var(--ink-soft); margin-top: 2px; }
.mode-option-arrow { font-size: 1.3rem; color: var(--ink-soft); }

/* ── STORY PREVIEW SHEET ─────────────────────────────────── */
.story-preview-sheet {
  padding: 0 0 calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  overflow: hidden;
}
.story-preview-sheet .mode-picker-handle {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2;
}
.sp-hero {
  position: relative; height: 260px; overflow: hidden;
  background: linear-gradient(160deg, #3b1f8c, #6d3fc4);
}
.sp-cover {
  width: 100%; height: 100%; object-fit: cover; object-position: top;
  opacity: 0; transition: opacity .4s ease;
}
.sp-cover.loaded { opacity: 1; }
.sp-hero-grad {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 30%, rgba(13,11,30,.9) 100%);
}
.sp-body {
  padding: 16px 20px 8px;
}
.sp-title {
  font-size: 1.3rem; font-weight: 800; color: var(--ink); margin-bottom: 6px;
}
.sp-meta {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
}
.sp-meta-chip {
  background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px; padding: 3px 10px;
  font-size: .75rem; color: var(--ink-soft); font-weight: 600;
}
.sp-summary {
  font-size: .9rem; color: var(--ink-soft); line-height: 1.6;
  margin-bottom: 4px;
}
.sp-actions { padding: 0 20px 4px; }

/* Per-story language selector */
.sp-lang-row {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 20px 14px;
}
.sp-lang-label {
  font-size: .75rem; font-weight: 700; color: var(--ink-soft);
  letter-spacing: .02em; margin-right: 4px;
}
.sp-lang-btn {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.08); border: 2px solid transparent;
  border-radius: 10px; padding: 6px 10px; cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, transform .1s;
}
.sp-lang-btn:active { transform: scale(.9); }
.sp-lang-btn.active {
  border-color: var(--purple);
  background: rgba(139,92,246,.2);
}
.sp-lang-bg-flag {
  font-size: 1.15rem; line-height: 1;
  user-select: none;
}
.sp-lang-code {
  font-size: .72rem; font-weight: 900; letter-spacing: .04em;
  color: rgba(255,255,255,.9);
  font-family: inherit;
}


/* ── EXIT CONFIRMATION SHEET ─────────────────────────────── */
.exit-sheet-panel {
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}
.exit-sheet-title {
  font-size: 1.1rem; font-weight: 700; color: var(--ink);
  text-align: center; margin: 4px 0 20px;
}
.exit-sheet-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.exit-sheet-cancel { width: 100%; }
.exit-icon { display: flex; align-items: center; justify-content: center; }
.exit-icon svg { width: 20px; height: 20px; display: block; }
.mode-option[data-locked="1"] { opacity: .55; }
.mode-option[data-locked="1"] .mode-option-arrow::after { content: ' 🔒'; font-size: .9rem; }

/* ── END-OF-STORY POPUP ─────────────────────────────────── */
.end-popup {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.end-popup.hidden { display: none; }
.end-popup-backdrop {
  position: absolute; inset: 0;
  background: rgba(4,2,18,.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.end-popup-card {
  position: relative; z-index: 1;
  background: linear-gradient(160deg, #1e1060 0%, #0d0828 100%);
  border: 1px solid rgba(139,92,246,.25);
  border-radius: 24px;
  padding: 36px 28px 32px;
  text-align: center;
  max-width: 340px; width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(139,92,246,.15);
}
.end-popup-stars {
  font-size: 1.8rem; letter-spacing: 12px; margin-bottom: 18px;
  filter: drop-shadow(0 0 8px rgba(251,191,36,.8));
  animation: pulse-star 2s ease-in-out infinite;
}
.end-popup-title {
  font-size: 2.2rem; font-weight: 800; color: var(--ink);
  margin-bottom: 8px; text-shadow: 0 0 24px rgba(139,92,246,.5);
}
.end-popup-sub {
  font-size: .88rem; color: var(--ink-soft); margin-bottom: 32px; font-style: italic;
}
.end-popup-actions { display: flex; flex-direction: column; gap: 12px; }
.end-popup-actions .primary-btn, .end-popup-actions .ghost-btn { width: 100%; }

/* ── TOAST ───────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 36px; left: 50%;
  transform: translateX(-50%) translateY(70px);
  background: rgba(30,24,64,.95);
  border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(16px);
  color: var(--ink);
  padding: 12px 24px; border-radius: 100px;
  font-size: .88rem; font-weight: 700;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; z-index: 999;
  transition: transform .3s ease, opacity .3s ease;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── CREDITS BADGE ──────────────────────────────────────── */
.credits-badge {
  display: flex; align-items: center; gap: 4px;
  background: rgba(251,191,36,.15);
  border: 1px solid rgba(251,191,36,.3);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: .78rem; font-weight: 800; color: var(--gold);
  white-space: nowrap;
}
.credits-badge.hidden { display: none !important; }

/* ── AUTH SHEET ─────────────────────────────────────────── */
.auth-sheet-panel {
  padding: 0 20px calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 0;
}
.auth-header { text-align: center; padding: 24px 0 20px; }
.auth-logo {
  font-size: 2rem; color: var(--gold); margin-bottom: 10px;
}
.auth-title { font-size: 1.3rem; font-weight: 800; color: var(--ink); margin-bottom: 6px; }
.auth-sub { font-size: .875rem; color: var(--ink-soft); line-height: 1.5; }
.auth-social { display: flex; flex-direction: column; gap: 10px; }
.auth-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px 20px; border-radius: var(--r);
  font-size: .95rem; font-weight: 700; border: none; cursor: pointer;
  transition: opacity .15s;
}
.auth-btn:active { opacity: .8; }
.auth-btn-apple {
  background: #111; color: #fff;
}
.auth-btn-google {
  background: #fff; color: #1f1f1f;
  border: 1px solid rgba(0,0,0,.12);
}
.auth-btn-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem;
}
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px;
  background: rgba(255,255,255,.12);
}
.auth-divider span { font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.auth-email-form { display: flex; flex-direction: column; gap: 10px; }
.auth-input {
  width: 100%; padding: 13px 16px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--r);
  color: var(--ink); font-size: .95rem;
  outline: none; transition: border-color .2s;
}
.auth-input:focus { border-color: var(--purple); }
.auth-error {
  font-size: .82rem; color: var(--rose);
  min-height: 1em; text-align: center;
}
.auth-toggle-btn {
  background: none; border: none; color: var(--ink-soft);
  font-size: .82rem; cursor: pointer; padding: 4px;
  text-decoration: underline; text-underline-offset: 2px;
}
.auth-dismiss-btn {
  background: none; border: none; color: rgba(255,255,255,.3);
  font-size: .78rem; cursor: pointer; padding: 4px;
  text-align: center; width: 100%; margin-top: 4px;
}

/* ── ACCOUNT SHEET ──────────────────────────────────────── */
.account-sheet-panel {
  padding: 0 20px calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 12px;
}
.account-info {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 0 8px;
}
.account-avatar {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple-bright));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff; flex-shrink: 0;
}
.account-plan-badge {
  font-size: .75rem; font-weight: 700; color: var(--gold);
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.25);
  padding: 2px 8px; border-radius: 12px;
  display: inline-block; margin-top: 4px;
}

/* ── PARENT GATE SHEET ────────────────────────────────────── */
/* ── WELCOME BANNER ────────────────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(251, 191, 36, 0.2));
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 14px; margin: 0 16px 14px; padding: 10px 14px;
}
.welcome-banner.hidden { display: none; }
.welcome-banner-content {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: .82rem; color: var(--ink);
}
.welcome-banner-btn {
  background: var(--gold); color: #000; font-family: inherit; font-size: .78rem; font-weight: 800;
  border: none; border-radius: 12px; padding: 5px 10px; cursor: pointer; flex-shrink: 0;
}
.welcome-banner-close {
  background: none; border: none; color: var(--ink-soft); font-size: 1rem; cursor: pointer; padding: 0 4px;
}

/* ── HELP & KB SHEET ─────────────────────────────────────── */
.help-sheet-panel {
  padding: 0 20px calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
.help-header { text-align: center; padding-top: 12px; }
.help-icon { font-size: 2.2rem; margin-bottom: 4px; }
.help-title { font-size: 1.25rem; font-weight: 800; color: var(--ink); }
.help-sub { font-size: .85rem; color: var(--ink-soft); margin-top: 2px; }
.help-faq-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.help-faq-item {
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 12px 14px; font-size: .88rem; text-align: left;
}
.help-faq-question { font-weight: 700; color: var(--ink); cursor: pointer; outline: none; }
.help-faq-answer { margin-top: 8px; color: var(--ink-soft); font-size: .82rem; line-height: 1.5; }
.help-code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(251, 191, 36, 0.15); border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 8px 12px; border-radius: 10px; margin-top: 8px;
}
.help-code-text { font-family: monospace; font-size: 1.1rem; font-weight: 800; color: var(--gold); }
.help-apply-btn { font-size: .78rem; padding: 6px 12px; width: auto; }
.parent-gate-header { text-align: center; padding-top: 12px; }
.parent-gate-icon { font-size: 2.2rem; margin-bottom: 6px; }
.parent-gate-title { font-size: 1.25rem; font-weight: 800; color: var(--ink); }
.parent-gate-sub { font-size: .85rem; color: var(--ink-soft); margin-top: 4px; }
.parent-gate-question {
  font-size: 1.4rem; font-weight: 800; color: var(--gold);
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  padding: 12px 24px; border-radius: var(--r); width: 100%;
}
.parent-gate-input { text-align: center; font-size: 1.2rem; font-weight: 800; letter-spacing: 2px; }
.parent-gate-panel .primary-btn, .parent-gate-panel .ghost-btn { width: 100%; }
.account-email {
  font-size: .9rem; color: var(--ink-soft);
  word-break: break-all;
}
.account-credits-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r);
  padding: 14px 18px;
}
.account-credits-label { font-size: .85rem; color: var(--ink-soft); font-weight: 600; }
.account-credits-value {
  font-size: 1.6rem; font-weight: 800; color: var(--gold);
}
.promo-row {
  display: flex; gap: 8px; align-items: center;
}
.promo-input { flex: 1; margin: 0; }
.promo-btn {
  flex-shrink: 0; padding: 0 18px; height: 46px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r); color: var(--ink); font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: background .18s;
}
.promo-btn:hover { background: rgba(255,255,255,.17); }
.promo-btn:disabled { opacity: .45; cursor: default; }
.promo-msg {
  font-size: .82rem; min-height: 1em; text-align: center; margin-top: -4px;
}
.promo-msg-ok { color: var(--sage, #86efac); }
.promo-msg-err { color: var(--rose); }

/* ── STORY PREVIEW OFFLINE ROW ──────────────────────────── */
.sp-offline-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0 4px;
}
.sp-offline-row.hidden { display: none; }
.sp-offline-status {
  font-size: .8rem; color: var(--ink-soft);
}
.sp-offline-status.sp-offline-cached { color: var(--sage, #86efac); font-weight: 600; }
.sp-offline-status.sp-offline-error  { color: var(--rose); }
.sp-dl-btn {
  background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px; padding: 5px 14px;
  font-size: .8rem; font-weight: 600; color: var(--ink);
  cursor: pointer; transition: background .18s;
}
.sp-dl-btn:hover { background: rgba(255,255,255,.16); }
.sp-dl-btn:disabled { opacity: .5; cursor: default; }
.sp-dl-btn.hidden { display: none; }

/* ── UNLOCK CONFIRM SHEET ───────────────────────────────── */
.unlock-sheet-panel {
  padding: 0 20px calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
}
.unlock-icon { font-size: 2.4rem; padding: 20px 0 4px; }
.unlock-title { font-size: 1.2rem; font-weight: 800; color: var(--ink); }
.unlock-desc { font-size: .88rem; color: var(--ink-soft); line-height: 1.5; }
.unlock-balance { font-size: .88rem; color: var(--ink-soft); }
.unlock-sheet-panel .primary-btn, .unlock-sheet-panel .ghost-btn { width: 100%; }

/* ── PAYWALL PACKS ──────────────────────────────────────── */
.paywall-packs {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; margin: 16px 0;
}
.paywall-pack {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r);
  padding: 14px 18px;
  display: flex; flex-direction: column; gap: 2px;
  position: relative;
}
.paywall-pack.featured {
  border-color: var(--purple);
  background: rgba(139,92,246,.12);
}
.pack-best {
  position: absolute; top: -10px; left: 16px;
  background: var(--purple); color: #fff;
  font-size: .7rem; font-weight: 800;
  padding: 3px 10px; border-radius: 20px;
}
.pack-label { font-size: 1rem; font-weight: 800; color: var(--ink); }
.pack-credits { font-size: .8rem; color: var(--ink-soft); }
.pack-price { font-size: 1.1rem; font-weight: 800; color: var(--gold); margin-top: 4px; }
.pack-coming {
  font-size: .72rem; color: var(--ink-soft);
  background: rgba(255,255,255,.06);
  border-radius: 20px; padding: 2px 8px;
  display: inline-block; margin-top: 4px; width: fit-content;
}

/* ── RESPONSIVE: wider screens (tablet / desktop) ────────────────────────── */

/* Shelf: 3 columns at tablet width, 4+ at desktop */
@media (min-width: 560px) {
  .shelf-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 720px; margin: 0 auto;
    padding: 4px 20px 80px;
  }
  .screen-header { max-width: 720px; margin: 0 auto; width: 100%; }
  .shelf-intro { max-width: 720px; margin: 0 auto; }
}
@media (min-width: 860px) {
  .shelf-grid { grid-template-columns: repeat(4, 1fr); max-width: 960px; }
  .screen-header { max-width: 960px; }
  .shelf-intro { max-width: 960px; }
}

/* Mode picker / story preview: cap width so it doesn't span 1440px */
@media (min-width: 640px) {
  .mode-picker-sheet {
    max-width: 540px;
    margin: 0 auto;
    border-radius: 24px 24px 0 0;
  }
  .mode-picker-backdrop { border-radius: 0; }
}

/* Reader: improve landscape text layout on wide screens */
@media (orientation: landscape) {
  .reader-text-area { align-items: center; }
  .reader-text { max-width: 600px; font-size: 1.1rem; line-height: 1.8; }
}
@media (orientation: landscape) and (min-width: 900px) {
  .reader-illustration { flex: 0 0 52%; }
  .reader-text { font-size: 1.15rem; }
}
