/* ═══════════════════════════════════════
   SPARK — style.css
   Mobile-first PWA, max-width 430px
═══════════════════════════════════════ */

/* ── Self-hosted fonts (SW-cached, work offline) ── */
/* Previously loaded from Google Fonts — moved to /fonts/ so the Service Worker
   can cache them. After first load the app reads correctly with no network. */

@font-face {
  font-family: 'Literata';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/web/fonts/literata-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Literata';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/web/fonts/literata-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Domine';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/web/fonts/domine-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Kalam';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/web/fonts/kalam-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Kalam';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/web/fonts/kalam-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Variables ── */
:root {
  --cream: #F4EFE6;
  --cream2: #EDE8DC;
  --cream3: #E0D8C8;
  --ink: #1A1A2E;
  --ink2: #5C5C7A;
  --ink3: #5C5C75;  /* darkened from #9696A8 → passes WCAG AA 4.5:1 on --cream */
  --accent: #2E61EB;
  --accent-light: rgba(46,97,235,0.09);
  --accent-mid: rgba(46,97,235,0.16);
  --ul: #2E61EB;
  --danger: #E53E3E;
  --divider: #D0CBC2;
  --serif: 'Literata', 'Domine', Georgia, serif;
  --sans: 'Literata', 'Domine', Georgia, serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-soft: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--cream3);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button { all: unset; cursor: pointer; display: block; box-sizing: border-box; font-family: var(--sans); }
a { color: var(--accent); }

/* ── Focus rings — keyboard navigation (WCAG 2.4.7) ── */
button:focus-visible,
[role="button"]:focus-visible,
[tabindex="0"]:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
/* Chip / toggle focus needs a tighter radius */
.chip:focus-visible    { border-radius: var(--radius-xl); }
.toggle:focus-visible  { border-radius: 20px; }

/* ── App shell ── */
body {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── SCREEN base ── */
.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 430px;
  height: 100vh;
  height: 100dvh;
  background: var(--cream);
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}
.screen.active { display: flex; }

/* ── Divider ── */
.divider { height: 1px; background: var(--divider); flex-shrink: 0; }

/* ═══════════════════════════════════════
   TYPOGRAPHY
═══════════════════════════════════════ */
.logo {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.3px;
}
.screen-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

/* ═══════════════════════════════════════
   BUTTONS
═══════════════════════════════════════ */
.btn-primary {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 14px 20px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 12px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: opacity var(--transition);
  box-sizing: border-box;
}
.btn-primary:active { opacity: 0.8; }
.btn-primary { text-decoration: none; }

.btn-auth-secondary {
  display: block;
  width: 100%;
  padding: 14px 20px;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: opacity var(--transition);
  box-sizing: border-box;
  text-decoration: none;
}
.btn-auth-secondary:active { opacity: 0.7; }
body.dark .btn-auth-secondary { color: var(--cream); border-color: var(--cream); }

.btn-ghost {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: none;
  color: var(--ink3);
  font-family: var(--sans);
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  box-sizing: border-box;
}
.btn-ghost.small { font-size: 12px; margin-top: 4px; }

.btn-apple {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: #1A1A2E;
  color: #FFFFFF;
  border-radius: 12px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition);
  box-sizing: border-box;
}
.btn-apple:active { opacity: 0.85; }
.apple-icon::before { content: ""; font-size: 17px; line-height: 1; }

/* Or row */
.or-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}
.or-line { flex: 1; height: 1px; background: var(--divider); }
.or-text { font-size: 12px; color: var(--ink3); }

/* ═══════════════════════════════════════
   TOP BAR
═══════════════════════════════════════ */
.top-bar {
  padding: max(52px, calc(env(safe-area-inset-top, 0px) + 12px)) 22px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.day-label {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink3);
  text-transform: uppercase;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.new-book-badge {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cream);
  background: var(--ink);
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
  align-self: center;
}

/* ═══════════════════════════════════════
   TAB BAR
═══════════════════════════════════════ */
.tab-bar {
  display: flex;
  padding: 10px 0 calc(18px + var(--safe-bottom));
  border-top: 1px solid var(--divider);
  flex-shrink: 0;
  background: var(--cream);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px;
  font-family: var(--sans);
}
.tab svg { width: 24px; height: 24px; transition: all var(--transition); }
.tab .icon-inactive { display: block; fill: none; stroke: var(--ink3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.65; }
.tab .icon-active   { display: none;  fill: var(--ink); }
.tab.active .icon-inactive { display: none; }
.tab.active .icon-active   { display: block; }
.tab span { font-size: 11px; color: var(--ink3); transition: color var(--transition); }
.tab.active span { color: var(--ink); font-weight: 600; }

/* ═══════════════════════════════════════
   ONBOARDING
═══════════════════════════════════════ */
.ob-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: max(52px, calc(env(safe-area-inset-top, 0px) + 12px)) 24px calc(36px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ob-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.ob-step { font-size: 12px; color: var(--ink3); }
.ob-progress {
  height: 2px;
  background: var(--cream3);
  border-radius: 2px;
  margin-bottom: 28px;
  flex-shrink: 0;
}
.ob-bar {
  height: 100%;
  background: var(--ink);
  border-radius: 2px;
  transition: width 0.35s ease;
}
.ob-title {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.35;
  color: var(--ink);
  margin-bottom: 8px;
}
.ob-sub {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink3);
  line-height: 1.6;
  margin-bottom: 22px;
}
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.chip {
  padding: 9px 16px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  border: 1.5px solid var(--divider);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--sans);
}
.chip.selected { background: var(--ink); color: var(--cream); border-color: var(--ink); }

/* Notification step */
.ob-notif .ob-wrap { justify-content: space-between; }
.notif-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.notif-icon { font-size: 52px; margin-bottom: 20px; }
.notif-btns { display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }

/* ═══════════════════════════════════════
   AUTH
═══════════════════════════════════════ */
.auth-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: max(52px, calc(env(safe-area-inset-top, 0px) + 12px)) 24px calc(36px + var(--safe-bottom));
  overflow-y: auto;
  min-height: 0;
}
.auth-top { margin-bottom: 24px; }
.auth-logo { font-size: 24px; display: block; margin-bottom: 12px; }
.auth-tagline {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.35;
  color: var(--ink);
}
.auth-preview {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-shrink: 0;
}
.mini-card {
  flex: 1;
  height: 120px;
  border-radius: 12px;
  padding: 11px 10px;
  display: flex;
  flex-direction: column;
}
.mc-cream { background: var(--cream2); border: 1px solid rgba(0,0,0,0.08); }
.mc-dark { background: #1A1A2E; }
.mc-purple { background: var(--accent); }
.mc-tag { font-size: 7px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 5px; }
.mc-cream .mc-tag { color: var(--ink3); }
.mc-dark .mc-tag { color: rgba(255,255,255,0.3); }
.mc-purple .mc-tag { color: rgba(255,255,255,0.4); }
.mc-quote { font-family: var(--serif); font-size: 9px; line-height: 1.4; flex: 1; }
.mc-cream .mc-quote { color: var(--ink); }
.mc-dark .mc-quote { color: #FFFFFF; }
.mc-purple .mc-quote { color: #FFFFFF; }
.mc-book { font-size: 7px; font-weight: 600; margin-top: 5px; }
.mc-cream .mc-book { color: var(--ink); }
.mc-dark .mc-book { color: #FFFFFF; }
.mc-purple .mc-book { color: rgba(255,255,255,0.8); }
.mc-logo { font-family: var(--serif); font-size: 7px; font-weight: 700; margin-top: auto; }
.mc-cream .mc-logo { color: var(--ink); }
.mc-dark .mc-logo { color: rgba(255,255,255,0.35); }
.mc-purple .mc-logo { color: rgba(255,255,255,0.4); }
.auth-actions { padding: 0 4px; }

/* Email/password auth forms (fetch-флоу) */
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form .btn-primary { margin-top: 2px; }
.auth-input { margin: 0; }
.auth-error {
  font-size: 13px;
  color: #C0392B;
  min-height: 16px;
  margin: -2px 2px 0;
  line-height: 1.4;
}
body.dark .auth-error { color: #E8857A; }
.auth-tagline {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 8px;
}
.auth-sub {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink3);
  margin-top: 0;
}
.auth-featured {
  margin: 12px 0 28px;
  flex-shrink: 0;
}

.auth-card {
  border-radius: 8px;
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 170px;
}
.auth-card-tag {
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-bottom: 12px;
}
.auth-card-quote {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.5;
  color: #FFFFFF;
  flex: 1;
}
.auth-card-meta {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.auth-card-book {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
}
.auth-card-author {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-top: 2px;
}
.auth-card-logo {
  display: none; /* branding hidden inside card — logo is already at top */
}
.auth-social-proof {
  font-size: 12px;
  color: var(--ink3);
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 0.2px;
}
.auth-terms { font-size: 11px; color: var(--ink3); text-align: center; margin-top: 10px; line-height: 1.5; }
.auth-terms a { color: var(--ink3); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* Google button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background: #FFFFFF;
  color: #1A1A2E;
  border: 1.5px solid rgba(0,0,0,0.10);
  border-radius: var(--radius-md);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.btn-google:active { background: #F5F5F5; box-shadow: none; }
.btn-google:disabled { opacity: 0.6; cursor: default; }

/* Spinner inside Google button */
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
.btn-google-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(244,239,230,0.25);
  border-top-color: var(--cream);
  border-radius: 50%;
  animation: btn-spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════
   PAYWALL
═══════════════════════════════════════ */
.paywall-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: max(52px, calc(env(safe-area-inset-top, 0px) + 12px)) 22px calc(28px + var(--safe-bottom));
  overflow-y: auto;
  position: relative;
}
.paywall-close {
  position: absolute;
  top: max(52px, calc(env(safe-area-inset-top, 0px) + 12px));
  right: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--cream);
}
.paywall-top { margin-bottom: 20px; }
.paywall-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin: 12px 0 6px;
}
.paywall-sub { font-size: 13px; color: var(--ink3); }
.paywall-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.paywall-features li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink2); }
.feat-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.price-box {
  background: var(--accent-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.price-trial { font-size: 13px; font-weight: 600; color: var(--accent); }
.price-then { font-size: 11px; color: var(--ink3); margin-top: 2px; }
.price-main { font-family: var(--serif); font-size: 24px; color: var(--ink); text-align: right; }
.price-per { font-size: 10px; color: var(--ink3); text-align: right; }
.paywall-actions { margin-bottom: 10px; padding: 0 4px; }
.paywall-fine { font-size: 10px; color: var(--ink3); text-align: center; line-height: 1.6; }

/* ═══════════════════════════════════════
   TODAY — READING SCREEN
═══════════════════════════════════════ */
.persona-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 22px 6px;
  flex-shrink: 0;
}
.persona-label { font-size: 12px; color: var(--ink3); }
.persona-name {
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  color: var(--ink2);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 55vw;
}

.chip-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 22px 12px;
  flex-shrink: 0;
}
.chip-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  flex: 1;
  min-width: 0;
}
.cat-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  background: transparent;
  color: var(--ink2);
  border: 1.5px solid var(--divider);
  white-space: nowrap;
}
body.dark .cat-tag {
  color: rgba(255,255,255,0.5);
  border-color: rgba(255,255,255,0.15);
}
.read-time {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink3);
  white-space: nowrap;
  width: 100%; /* forces its own row inside chip-meta */
}
.action-icons { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
@media (max-width: 360px) { .action-icons { gap: 6px; } }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--ink);
  opacity: 0.6;
  cursor: pointer;
  transition: opacity var(--transition), transform 0.15s;
}
.icon-btn:active { opacity: 0.3; }
.icon-btn.active { opacity: 1; color: var(--ul); }
.icon-btn.saved .heart-icon path { fill: #C0392B; stroke: #C0392B; }

/* Pencil hint — always in layout to prevent reader-zone resize on toggle */
.pencil-hint {
  display: block;
  visibility: hidden;
  text-align: center;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 5px 16px;
  border-radius: 20px;
  margin: 6px auto 2px;
  flex-shrink: 0;
}
.pencil-hint.visible { visibility: visible; }

/* ── Reader Zone ── */
.reader-zone {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}
.pages-container {
  display: flex;
  height: 100%;
  transition: transform 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
  touch-action: pan-y; /* tell browser: vertical scroll = yours, horizontal swipe = ours */
}
.page {
  flex-shrink: 0;
  width: 100%;
  height: 100%;
  padding: 20px 26px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Cover page — quote anchored to top, book info immediately below */
.page-cover {
  justify-content: flex-start; /* override: don't distribute vertically */
}
.page-cover .cover-quote {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.5;
  color: var(--ink);
  padding-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Swipe hint — fades in after 1s, sits at the bottom of the cover */
.swipe-hint {
  margin-top: auto;
  padding-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink3);
  font-size: 12px;
  font-family: var(--sans);
  opacity: 0;
  animation: swipe-hint-fade 0.6s ease 1.1s forwards;
}
.swipe-hint svg { flex-shrink: 0; }
@keyframes swipe-hint-fade {
  to { opacity: 1; }
}

/* ── Underline discovery tooltip (one-time contextual hint) ── */
.underline-hint-tooltip {
  /* position: fixed — не мешает свайпу и навигации, всегда над экраном */
  position: fixed;
  /* Над nav-row (~56px) + tab-bar (~72px) + safe-area: итого ~150px минимум */
  bottom: calc(var(--safe-bottom, 0px) + 148px);
  left: 50%;
  transform: translateX(-50%);
  background: #1A2545;
  color: #F5F3E8;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 22px;
  white-space: nowrap;
  pointer-events: none; /* не блокирует свайп и клики насквозь */
  opacity: 0;
  transition: opacity 0.35s ease;
  z-index: 45; /* выше контента, ниже done-card (150) и тостов (200) */
}
.underline-hint-tooltip.visible { opacity: 1; }
body.dark .underline-hint-tooltip {
  background: rgba(255,255,255,0.88);
  color: #111;
}

/* ── Sentence pulse (contextual underline hint) ── */
@keyframes underline-pulse {
  0%   { background: transparent; }
  35%  { background: rgba(46,97,235,0.13); border-radius: 3px; }
  100% { background: transparent; }
}
.sentence.underline-pulse {
  animation: underline-pulse 1.3s ease forwards;
}

.book-meta {
  padding-top: 14px;
  border-top: 1px solid var(--divider);
  flex-shrink: 0;
  margin-top: 24px; /* gap between quote and book info */
}
.book-title {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author { font-family: var(--serif); font-size: 12px; color: var(--ink3); margin-top: 3px; }

/* Text page */
.excerpt-text {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink2);
  flex: 1;
  overflow: hidden;
}
body.dark .excerpt-text { font-size: 18px; }
body.fs-18 .excerpt-text { font-size: 18px; }
body.fs-20 .excerpt-text { font-size: 20px; }
body.dark.fs-18 .excerpt-text { font-size: 18px; }
body.dark.fs-20 .excerpt-text { font-size: 20px; }
.sentence {
  cursor: default;
  transition: border-bottom 0.15s;
}
.sentence.underlined {
  border-bottom: 2px solid var(--ul);
}

/* Pencil mode: sentences are tappable */
body.pencil-mode .sentence {
  cursor: pointer;
}
body.pencil-mode .sentence:hover {
  border-bottom: 2px solid rgba(107,159,240,0.5);
}

/* Page actions (last page) */
.page-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  padding-left: 2px;
  padding-right: 2px;
}
.continue-link {
  display: flex;
  align-items: center;
  padding: 9px 16px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink3);
  font-weight: 400;
  border: 1px solid var(--divider);
  border-radius: 10px;
  transition: opacity var(--transition);
}
.continue-link:active { opacity: 0.6; }
.continue-link span:first-child { flex: 1; }
.arrow-right { font-size: 15px; flex-shrink: 0; }
.apply-btn {
  display: flex;
  align-items: center;
  background: var(--ink);
  color: var(--cream);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  transition: opacity var(--transition);
}
.apply-btn:active { opacity: 0.85; }

/* ── Nav row (arrows + dots) ── */
.nav-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 0 6px;
  flex-shrink: 0;
}
.nav-dots {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  max-width: calc(100% - 108px);
}
.dot {
  position: relative;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
  cursor: pointer;
  transition: all 0.22s;
  flex-shrink: 0;
}
/* Expand tap target to 44px without affecting layout */
.dot::before {
  content: '';
  position: absolute;
  top: -20px; bottom: -20px;
  left: -12px; right: -12px;
}
.dot.active { background: var(--ink); width: 16px; border-radius: 3px; }
.nav-arr {
  width: 44px;
  height: 44px;
  background: #EDE8DC;
  border-radius: 50%;
  box-shadow: var(--shadow-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  color: var(--ink);
  flex-shrink: 0;
}
.nav-arr:hover { transform: scale(1.1); box-shadow: var(--shadow-md); }
.nav-arr:active { transform: scale(0.93); }
.nav-arr.hidden { opacity: 0; pointer-events: none; }

/* ═══════════════════════════════════════
   LIBRARY
═══════════════════════════════════════ */
.library-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
}
/* Пустая рамка — место на стене галереи */
.gallery-frame {
  width: 200px;
  height: 260px;
  border: 1.5px dashed var(--divider);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.gallery-frame::before,
.gallery-frame::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--ink3);
  border-style: solid;
  opacity: 0.35;
}
.gallery-frame::before { top: -1px; left: -1px; border-width: 1.5px 0 0 1.5px; }
.gallery-frame::after  { bottom: -1px; right: -1px; border-width: 0 1.5px 1.5px 0; }
.gallery-frame-inner {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: var(--ink3);
  opacity: 0.6;
  padding: 0 24px;
  line-height: 1.5;
}
.gallery-frame-cta {
  font-size: 13px;
  color: var(--ink2);
  letter-spacing: 0.1px;
}

.library-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 12px;
  -webkit-overflow-scrolling: touch;
}
.lib-card {
  background: var(--cream);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 9px;
  /* Тень сверху — как будто карточка висит на стене */
  box-shadow: 0 -2px 6px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
}
.lib-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.lib-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  display: inline-block;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.lib-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.lib-title { font-family: var(--serif); font-size: 14px; font-weight: 600; color: var(--ink); flex: 1; line-height: 1.35; }
.lib-card-arrow { font-size: 18px; color: var(--ink3); flex-shrink: 0; line-height: 1.4; }
.lib-author { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.lib-date { font-size: 11px; color: var(--ink3); }

/* ── Library underlines (saved highlights) ── */
.lib-underlines {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
}
.lib-ul-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 6px;
}
.lib-ul-item {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: var(--ink2);
  line-height: 1.6;
  padding: 6px 0;
  border-bottom: 1px solid var(--divider);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lib-ul-item:last-child { border-bottom: none; }
.lib-ul-more {
  font-size: 11px;
  color: var(--accent);
  margin-top: 6px;
  font-style: normal;
  font-weight: 500;
}

/* ── Library reflection block ── */
.lib-reflection {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
}
.lib-ref-question {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink2);
  line-height: 1.45;
  margin: 0 0 8px;
}
.lib-ref-label {
  display: block;
  font-size: 11px;
  font-style: italic;
  color: var(--ink3);
  margin-bottom: 7px;
}
.lib-ref-choices {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.lib-ref-choice {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink3);
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  line-height: 1.4;
}
.lib-ref-choice.chosen {
  background: var(--accent-light);
  border-color: rgba(46,97,235,0.3);
  color: var(--accent);
  font-weight: 500;
}

/* ═══════════════════════════════════════
   PROFILE
═══════════════════════════════════════ */
.profile-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  font-size: 20px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 10px;
}
.profile-name {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin: 4px auto 18px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 80%;
}
.profile-plan { text-align: center; font-size: 12px; color: var(--ink3); margin-bottom: 18px; }

/* Old streak-card kept for dark mode compat */
.streak-card { display: none; }

/* ── Streak row ── */
.streak-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--cream);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 14px;
}
.streak-flame { font-size: 30px; line-height: 1; flex-shrink: 0; }
.streak-body {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.streak-count {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.streak-days {
  font-size: 13px;
  color: var(--ink3);
  font-weight: 500;
}
.streak-frozen-badge {
  font-size: 11px;
  font-family: var(--sans);
  color: var(--ink3);
  background: rgba(0,0,0,0.06);
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 2px;
  letter-spacing: 0.2px;
}
body.dark .streak-frozen-badge {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.4);
}

/* ── Profile 2-column grid (streak + share) ── */
.profile-quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.profile-quick-grid .streak-row {
  margin-bottom: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px 14px;
  text-align: center;
  min-height: 108px;
}
.profile-quick-grid .streak-body {
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.profile-quick-grid .streak-days { font-size: 12px; }

/* ── Share friend button (inside grid) ── */
.share-friend-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--divider);
  background: var(--cream);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink2);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.profile-quick-grid .share-friend-btn {
  flex-direction: column;
  gap: 10px;
  padding: 20px 14px;
  min-height: 108px;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}
.sfb-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--cream2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ink2);
}
.sfb-text { display: block; }
.share-friend-btn:active { background: rgba(0,0,0,0.04); }

/* ══════════════════════════════════════════
   LIBRARY CARD — vintage borrower's card style
   Inspired by classic library card typography:
   typewriter labels · handwritten name · ruled
   paper · double-rule dividers · paper grain
══════════════════════════════════════════ */

/* ── Ink colour per card variant ────────── */
/* All variants share the same deep-navy ink  */
:root {
  --card-ink:     #1A2545;   /* deep navy — same on all cards      */
  --card-ink2:    rgba(26,37,69,0.55);  /* secondary labels        */
  --card-ink3:    rgba(26,37,69,0.35);  /* tertiary / dividers      */
}

/* ── Card background colours ─────────────  */
.reader-card,
.card-reader                    { background-color: #E9DFC3; } /* default cream */
.reader-card.rc-cream,
.card-reader.rc-cream           { background-color: #E9DFC3; } /* warm parchment */
.reader-card.rc-blue,
.card-reader.rc-blue            { background-color: #BAD0E2; } /* periwinkle     */
.reader-card.rc-gold,
.card-reader.rc-gold            { background-color: #C48A28; } /* amber gold     */
.reader-card.rc-rose,
.card-reader.rc-rose            { background-color: #DFC0C4; } /* dusty rose     */

/* ── SPARK logo tint per colour ─────────── */
/* Cream: classic library blue               */
.reader-card .rc-lib-logo,
.card-reader .rc-lib-logo        { color: #2550D0; }
/* Blue: deep navy on periwinkle = wow       */
.reader-card.rc-blue .rc-lib-logo,
.card-reader.rc-blue .rc-lib-logo { color: #1A2545; }
/* Gold: dark navy on amber                 */
.reader-card.rc-gold .rc-lib-logo,
.card-reader.rc-gold .rc-lib-logo { color: #1A2545; }
/* Rose: dark navy on rose                  */
.reader-card.rc-rose .rc-lib-logo,
.card-reader.rc-rose .rc-lib-logo { color: #1A2545; }

/* ── Card shell ─────────────────────────── */
.reader-card {
  position: relative;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 21px,
    rgba(26,37,69,0.07) 21px, rgba(26,37,69,0.07) 22px
  );
  border-radius: var(--radius-md);
  padding: 14px 16px 14px;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid rgba(26,37,69,0.12);
  box-shadow: 0 2px 12px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.07);
}

/* Paper grain overlay — subtle noise texture */
.reader-card::after,
.card-reader::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.045;
  mix-blend-mode: multiply;
}

/* ── Header row ─────────────────────────── */
.rc-lib-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.rc-lib-header-left { display: flex; flex-direction: column; gap: 2px; }

/* SPARK — bold serif, blue-accented */
.rc-lib-logo {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  /* colour set per-variant above */
}

/* "THE READING CARD" — typewriter micro caps */
.rc-lib-subtitle {
  font-family: 'Courier New', Courier, monospace;
  font-size: 6.5px;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--card-ink2);
}

/* Card number — top right, faint serif */
.rc-lib-num {
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 600;
  color: var(--card-ink2);
  letter-spacing: 0.5px;
}

/* ── Field labels — typewriter caps ─────── */
.rc-lib-field-label {
  font-family: 'Courier New', Courier, monospace;
  font-size: 6.5px;
  font-weight: 400;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--card-ink2);
  margin-bottom: 1px;
}

/* ── Borrower name — handwriting + slight tilt */
.rc-lib-name {
  font-family: 'Kalam', cursive;
  font-size: 25px;
  font-weight: 400;
  color: var(--card-ink);
  line-height: 1.1;
  margin-bottom: 4px;
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transform: rotate(-1.5deg) translateX(-1px);
  transform-origin: left center;
}

/* ── Double rule divider ─────────────────── */
.rc-lib-rule {
  height: 5px;
  background: transparent;
  border-top: 1px solid rgba(26,37,69,0.22);
  border-bottom: 1px solid rgba(26,37,69,0.22);
  margin: 9px 0 7px;
}

/* ── Column headers ──────────────────────── */
.rc-lib-cols {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}
.rc-lib-col-title,
.rc-lib-col-date {
  font-family: 'Courier New', Courier, monospace;
  font-size: 6.5px;
  font-weight: 400;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--card-ink2);
}

/* ── Book rows ───────────────────────────── */
.rc-lib-books {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 44px;
}
.rc-lib-book-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px solid rgba(26,37,69,0.07);
}
.rc-lib-book-title {
  font-family: var(--serif);
  font-size: 11px;
  color: var(--card-ink);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}
.rc-lib-book-date {
  font-family: 'Courier New', Courier, monospace;
  font-size: 9.5px;
  color: var(--card-ink2);
  flex-shrink: 0;
}
/* Empty placeholder lines (like un-filled rows) */
.rc-lib-book-empty {
  height: 22px;
  border-bottom: 1px solid rgba(26,37,69,0.06);
}

/* ── Footer ──────────────────────────────── */
.rc-lib-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.rc-since {
  font-family: 'Courier New', Courier, monospace;
  font-size: 7.5px;
  color: var(--card-ink2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.rc-lib-streak {
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 600;
  color: var(--card-ink);
}

/* keep legacy selectors quiet */
.rc-logo, .rc-label, .rc-name, .rc-bottom, .rc-stamp { display: none; }

/* ── Auth email form ── */
.auth-email-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}
.auth-input {
  width: 100%;
  padding: 13px 14px;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-md);
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.auth-input:focus {
  border-color: var(--accent);
}
.auth-input::placeholder { color: var(--ink3); }
.auth-error {
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  margin: 0;
  line-height: 1.4;
}
.auth-toggle-row {
  font-size: 13px;
  color: var(--ink3);
  text-align: center;
  margin: 2px 0 0;
}
.auth-toggle-btn {
  all: unset;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-left: 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-or-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}
.auth-or-line {
  flex: 1;
  height: 1px;
  background: var(--divider);
}
.auth-or-text {
  font-size: 12px;
  color: var(--ink3);
  flex-shrink: 0;
}

/* dark mode */
body.dark .auth-input {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  color: var(--ink);
}
body.dark .auth-input:focus { border-color: var(--accent); }

/* ── Auth free badge ── */
.auth-free-badge {
  text-align: center;
  padding: 6px 0;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.auth-badge-main {
  font-size: 12px;
  font-weight: 500;
  color: #1a8c52;
  letter-spacing: 0.1px;
}
.auth-badge-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink3);
}

/* ── Legal screen ── */
.legal-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 40px;
  -webkit-overflow-scrolling: touch;
}
.legal-section {
  margin-bottom: 24px;
}
.legal-section h3 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.legal-section p {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.72;
  color: var(--ink2);
}
.legal-updated {
  font-size: 11px;
  color: var(--ink3);
  margin-bottom: 20px;
}

.settings-group {
  background: var(--cream);
  border-radius: var(--radius-lg);
  border: 1px solid var(--divider);
  overflow: hidden;
  margin-bottom: 10px;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  min-height: 44px;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
  color: var(--ink);
}
.setting-row:last-child { border-bottom: none; }
.setting-val {
  font-size: 13px;
  color: var(--ink3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 60%;
}
.setting-danger { color: var(--danger); }

/* Text size selector */
.setting-row.fs-row { flex-wrap: wrap; gap: 0; }
.fs-btn-group {
  display: flex;
  gap: 6px;
}
.fs-btn {
  padding: 10px 13px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink2);
  background: var(--cream2);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.fs-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
body.dark .fs-btn { background: #241D14; }
body.dark .fs-btn.active { background: rgba(200,150,60,0.15); border-color: #C8963C; color: #C8963C; }

/* Toggle */
.toggle {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: var(--cream3);
  position: relative;
  cursor: pointer;
  transition: background 0.22s;
  flex-shrink: 0;
}
.toggle.active { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #F4EFE6;
  top: 2px;
  left: 2px;
  transition: transform 0.22s;
  box-shadow: 0 1px 4px rgba(26,20,16,0.2);
}
.toggle.active::after { transform: translateX(16px); }

/* ═══════════════════════════════════════
   CHAPTER (fullscreen reader)
═══════════════════════════════════════ */
.chapter-header {
  padding: max(52px, calc(env(safe-area-inset-top, 0px) + 12px)) 22px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--divider);
}
.chapter-label {
  font-size: 13px;
  color: var(--ink3);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 40px;
}
@media (max-width: 360px) {
  .chapter-header { gap: 8px; }
  .chapter-icon-right { margin-left: 6px; }
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: var(--ink);
  opacity: 0.7;
  min-height: 44px;
  transition: opacity var(--transition);
}
.back-btn:active { opacity: 0.4; }

/* ═══════════════════════════════════════
   SHARE SCREEN
═══════════════════════════════════════ */
.share-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: 10px 20px 16px;
  gap: 10px;
}
.share-tabs {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.share-tab {
  flex: 1;
  padding: 0;
  min-height: 44px;   /* iOS HIG touch target */
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  color: var(--ink3);
  border: 1px solid var(--divider);
  font-family: var(--sans);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.share-tab.active { background: var(--ink); color: var(--cream); border-color: var(--ink); }

/* ── Share Cards — portrait, Instagram-ready ── */
.share-card-wrap { flex-shrink: 0; }
.share-card {
  width: 100%;
  min-height: 420px; /* iOS 14 fallback — aspect-ratio not supported there (4/5 × ~335px ≈ 419px) */
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: none;
  flex-direction: column;
  padding: 22px 22px 20px;
}
.share-card.active { display: flex; }

.card-cream { background: var(--cream2); border: 1px solid var(--divider); }
.card-dark  { background: #1A1A2E; }
.card-reader {
  position: relative;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 21px,
    rgba(26,37,69,0.07) 21px, rgba(26,37,69,0.07) 22px
  );
  border: 1px solid rgba(26,37,69,0.12);
  padding: 18px 20px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
}
/* Slightly larger name in share card */
.card-reader .rc-lib-name { font-size: 27px; }

/* Eyebrow label */
.sc-eyebrow {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.card-cream .sc-eyebrow { color: var(--ink3); }
.card-dark  .sc-eyebrow { color: rgba(255,255,255,0.28); }

/* Hero quote — this is the star */
.sc-quote-hero {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.45;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-cream .sc-quote-hero { color: var(--ink); }
.card-dark  .sc-quote-hero { color: #FFFFFF; }

/* Rule separator */
.sc-rule {
  width: 28px;
  height: 1.5px;
  margin: 16px 0 12px;
  flex-shrink: 0;
  border-radius: 1px;
}
.card-cream .sc-rule { background: var(--ink); }
.card-dark  .sc-rule { background: rgba(255,255,255,0.22); }

/* Book meta */
.sc-meta { flex-shrink: 0; }
.sc-book { font-size: 11px; font-weight: 600; }
.card-cream .sc-book { color: var(--ink); }
.card-dark  .sc-book { color: rgba(255,255,255,0.85); }
.sc-author { font-size: 10px; margin-top: 2px; }
.card-cream .sc-author { color: var(--ink3); }
.card-dark  .sc-author { color: rgba(255,255,255,0.3); }

/* Footer */
.sc-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
  padding-top: 14px;
  flex-shrink: 0;
}
.sc-logo { font-family: var(--serif); font-size: 12px; font-weight: 700; }
.card-cream .sc-logo { color: var(--ink); }
.card-dark  .sc-logo { color: rgba(255,255,255,0.4); }
.card-reader .sc-logo { color: var(--ink); }
.sc-cta { font-size: 10px; color: var(--ink3); }
.sc-cta-light { font-size: 10px; color: rgba(255,255,255,0.35); }

/* Streak pill on dark card */
.sc-streak-pill {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.08);
  padding: 3px 8px;
  border-radius: 20px;
}

/* ── Reader's Card variant ── */
.sc-rc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-shrink: 0;
}
.sc-rc-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(0,0,0,0.35);
}
.sc-rc-num {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 700;
  color: rgba(0,0,0,0.08);
  line-height: 1;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.sc-rc-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
}
.sc-rc-divider {
  width: 100%;
  height: 1px;
  background: rgba(0,0,0,0.1);
  margin: 18px 0;
  flex-shrink: 0;
}
.sc-rc-stats {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  margin-bottom: 18px;
}
.sc-rc-stat { flex: 1; }
.sc-rc-val { font-size: 17px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.sc-rc-lbl { font-size: 9px; color: rgba(0,0,0,0.35); letter-spacing: 0.4px; }
.sc-rc-quote-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sc-rc-ql {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(0,0,0,0.3);
  margin-bottom: 6px;
}
.sc-rc-qt {
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  color: rgba(0,0,0,0.6);
  line-height: 1.45;
}
.sc-rc-footer { padding-top: 14px; }
.sc-rc-since { font-size: 9px; color: rgba(0,0,0,0.25); }

/* Quote copy */
.quote-copy {
  background: var(--cream);
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.quote-copy-text { font-family: var(--serif); font-size: 12px; line-height: 1.4; color: var(--ink2); flex: 1; font-style: italic; }
.copy-icon { flex-shrink: 0; color: var(--ink3); display: flex; }
.copied-badge { font-size: 11px; font-weight: 600; color: var(--accent); display: none; flex-shrink: 0; }
.copied-badge.show { display: block; }

/* ── Highlights picker (share screen) ── */
.highlights-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.highlights-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.highlights-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--ink3);
}
.highlights-hint {
  font-size: 12px;
  font-style: italic;
  color: var(--ink3);
  line-height: 1.5;
}
.highlights-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.highlights-chips::-webkit-scrollbar { display: none; }
.highlight-chip {
  flex-shrink: 0;
  max-width: 220px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--divider);
  background: var(--cream);
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  color: var(--ink2);
  line-height: 1.45;
  cursor: pointer;
  transition: all 0.15s;
  white-space: normal;
  text-align: left;
}
.highlight-chip:active { opacity: 0.7; }
.highlight-chip.active {
  background: var(--accent-light);
  border-color: rgba(46,97,235,0.3);
  color: var(--accent);
}
.highlights-empty {
  font-size: 12px;
  font-style: italic;
  color: var(--ink3);
  opacity: 0.7;
}

.share-action-row { display: flex; gap: 7px; flex-shrink: 0; }
.share-action-btn {
  flex: 1;
  padding: 10px 6px;
  border-radius: 12px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: opacity var(--transition);
}
.share-action-btn:active { opacity: 0.7; }
.share-action-btn.dark { background: var(--ink); color: var(--cream); }
.share-action-btn.accent { background: var(--accent-light); color: var(--accent); }

.quick-share-row { display: flex; gap: 8px; flex-shrink: 0; }
.quick-btn {
  flex: 1;
  padding: 12px 4px 11px;
  border-radius: 16px;
  background: var(--cream);
  border: 1px solid var(--divider);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  transition: background var(--transition), transform 0.12s;
}
.qb-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.qb-icon { background: transparent; }
body.dark .qb-icon { background: transparent; }
.quick-btn span { font-size: 11px; font-weight: 500; color: var(--ink2); letter-spacing: -0.1px; }
.quick-btn:active { background: rgba(0,0,0,0.06); transform: scale(0.95); }

/* ═══════════════════════════════════════
   BOTTOM SHEET (How to Apply)
═══════════════════════════════════════ */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sheet-overlay.open { display: flex; }

.bottom-sheet {
  width: 100%;
  max-width: 430px;
  background: var(--cream);
  border-radius: 26px 26px 0 0;
  padding: 18px 24px calc(32px + var(--safe-bottom));
  max-height: 86vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(100%);
  transition: transform 340ms cubic-bezier(0.32, 0.72, 0, 1);
  -webkit-overflow-scrolling: touch;
}
.sheet-overlay.open .bottom-sheet { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--divider);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.sheet-close {
  position: absolute;
  right: 14px;
  top: 10px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--cream);
}
.sheet-title {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
}
.sheet-body {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.72;
  color: var(--ink2);
  margin-bottom: 12px;
}

/* ── In-sheet contextual links (Wikipedia etc.) ── */
.sheet-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.sheet-link:active { opacity: 0.55; }

.try-block {
  background: var(--cream2);
  border-radius: var(--radius-md);
  padding: 14px 16px 16px;
  margin-bottom: 16px;
}
.try-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.7px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.try-text { font-family: var(--serif); font-size: 14px; line-height: 1.65; color: var(--ink); }

/* ── Reflection mechanic ── */
.reflection-block {
  background: var(--cream2);
  border-radius: var(--radius-md);
  padding: 16px 16px 14px;
  margin-bottom: 14px;
}
.reflection-question {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink);
  margin: 6px 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.reflection-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  margin-bottom: 14px;
}
.choice-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--cream);
  border: 1.5px solid var(--divider);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: var(--sans);
  color: var(--ink2);
  cursor: pointer;
  transition: all 0.18s;
  line-height: 1.4;
}
.choice-btn:active { opacity: 0.75; }
.choice-btn.selected {
  background: var(--accent-light);
  border-color: rgba(46,97,235,0.3);
  color: var(--accent);
  font-weight: 500;
}
.reflection-privacy {
  font-size: 11px;
  font-style: italic;
  color: var(--ink3);
  line-height: 1.6;
  margin: 0;
}

/* dark mode */

/* Add to Library button */
.add-to-library {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.add-to-library.added {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.add-bookmark-icon {
  flex-shrink: 0;
  color: var(--ink3);
  transition: all 0.2s;
}
.add-to-library.added .add-bookmark-icon {
  fill: var(--accent);
  stroke: var(--accent);
  color: var(--accent);
}

/* ── Topics sheet extras ── */
.topics-sheet { padding-bottom: calc(24px + var(--safe-bottom)); }
.sheet-sub {
  font-size: 13px;
  color: var(--ink3);
  margin-bottom: 18px;
  margin-top: -8px;
}
.topics-chip-grid {
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════
   DONE CARD
═══════════════════════════════════════ */
.done-card-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, calc(env(safe-area-inset-top, 0px) + 12px)) 24px max(24px, calc(var(--safe-bottom) + 12px));
  background: rgba(26,26,46,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.done-card-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.done-card {
  width: 100%;
  max-width: 360px;
  background: #1A1A2E;
  border-radius: var(--radius-xl);
  padding: 32px 24px 24px;
  text-align: center;
  position: relative;
  transform: scale(0.92) translateY(12px);
  transition: transform 0.32s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 8px 48px rgba(0,0,0,0.36), 0 0 0 1px rgba(255,255,255,0.06);
}
.done-card-overlay.show .done-card {
  transform: scale(1) translateY(0);
}
.done-card-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: background 0.15s;
}
.done-card-close:active { background: rgba(255,255,255,0.22); }
.done-card-streak-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-bottom: 14px;
}
.done-streak-num {
  font-family: var(--serif);
  font-size: 52px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1;
  letter-spacing: -1px;
  white-space: nowrap;
  flex-shrink: 0;
}
.done-streak-fire { font-size: 34px; line-height: 1; }
.done-streak-days {
  font-family: var(--sans);
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  align-self: flex-end;
  padding-bottom: 7px;
}
.done-card-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: #FFFFFF;
  margin-bottom: 6px;
}
.done-card-sub {
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  color: rgba(255,255,255,0.45);
  margin-bottom: 12px;
  line-height: 1.5;
}
/* "... is now in your gallery →" — только если книга сохранена */
.done-card-gallery {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: rgba(255,255,255,0.32);
  margin-bottom: 20px;
  line-height: 1.5;
}
.done-card-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.85);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.done-card-share:active { background: rgba(255,255,255,0.15); }

/* ═══════════════════════════════════════
   CONTACT FORM
═══════════════════════════════════════ */
.contact-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.contact-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink3);
}
.contact-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 14px;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-md);
  background: var(--cream);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  resize: none;
  outline: none;
  box-sizing: border-box;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color 0.15s;
}
.contact-textarea:focus {
  border-color: var(--accent);
}
.contact-textarea::placeholder {
  color: var(--ink3);
  opacity: 0.7;
}
.contact-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-md);
  background: var(--cream);
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  outline: none;
  box-sizing: border-box;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color 0.15s;
}
.contact-input:focus { border-color: var(--accent); }
.contact-input::placeholder { color: var(--ink3); opacity: 0.7; }
.contact-optional {
  font-size: 10px;
  font-weight: 400;
  color: var(--ink3);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

/* ═══════════════════════════════════════
   TOAST
═══════════════════════════════════════ */
.toast {
  position: fixed;
  top: max(52px, calc(env(safe-area-inset-top, 0px) + 16px));
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: #1A1A2E;
  color: #FFFFFF;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
  font-family: var(--sans);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═══════════════════════════════════════
   SCREEN TRANSITIONS
═══════════════════════════════════════ */
.screen {
  transition: opacity 0.18s ease;
}
.screen.slide-in {
  animation: slideInRight 0.3s cubic-bezier(0.25,0.46,0.45,0.94) forwards;
}
.screen.slide-out {
  animation: slideOutLeft 0.3s cubic-bezier(0.25,0.46,0.45,0.94) forwards;
}
@keyframes slideInRight {
  from { transform: translateX(calc(50% + 100%)); }
  to { transform: translateX(-50%); }
}
@keyframes slideOutLeft {
  from { transform: translateX(-50%); }
  to { transform: translateX(calc(-50% - 100%)); }
}

/* ═══════════════════════════════════════
   DARK MODE
═══════════════════════════════════════ */
/* ── Kindle Warm Dark ──────────────────────────────────────────
   Dark sepia background + warm parchment text.
   Modelled on Kindle "Warm" mode — proven for extended night reading.
   Pure black/white is replaced with tonal warm values throughout.
─────────────────────────────────────────────────────────────── */

/* Auth FOUC bridge: переключаем секции screen-auth в зависимости от наличия JWT.
   Срабатывает до выполнения app.js — ноль мигания кнопок.
   _tryRestoreSession() снимет has-session если токен невалидный. */
html.has-session [data-ui="guest"] { display: none  !important; }
html.has-session [data-ui="user"]  { display: block !important; }

/* FOUC bridge: fires when the <head> inline script sets .dark on <html>
   (before <body> exists). app.js adds body.dark on init, after which the
   full variable cascade below takes over. Only sets the two properties that
   are visible before JS runs — background and text colour. */
html.dark body {
  background: #14100B;
  color: #E8D5B0;
}

body.dark {
  --cream:         #1C1610;   /* main bg — warm dark brown, not pure black  */
  --cream2:        #241D14;   /* card / elevated surfaces                   */
  --cream3:        #14100B;   /* app shell bg                               */
  --ink:           #E8D5B0;   /* main text — warm parchment, not pure white */
  --ink2:          #B89E78;   /* secondary text                             */
  --ink3:          #8C7A5C;   /* muted text — lightened from #7A6A50 for WCAG AA */
  --divider:       rgba(232,213,176,0.13); /* warm, barely-there lines      */
  --ul:            #C8963C;   /* underlines — amber, easy on dark-adapted eyes */
  --accent-light:  rgba(200,150,60,0.13);
  --accent-mid:    rgba(200,150,60,0.22);
  background: #14100B;
}

/* Navigation arrows */
body.dark .nav-arr { background: #241D14; border-color: rgba(232,213,176,0.1); }

/* Cards and groups */
body.dark .settings-group,
body.dark .lib-card       { background: #1C1610; border-color: rgba(232,213,176,0.1); }
body.dark .quote-copy,
body.dark .quick-btn      { background: #1C1610; border-color: rgba(232,213,176,0.1); }

/* Sheets */
body.dark .bottom-sheet   { background: #1C1610; }
body.dark .try-block      { background: #241D14; }
body.dark .add-to-library { border-color: rgba(232,213,176,0.12); }

/* Reflection choices */
body.dark .reflection-block { background: #241D14; }
body.dark .choice-btn       { background: #1C1610; border-color: rgba(232,213,176,0.1); color: var(--ink2); }
body.dark .choice-btn.selected { background: rgba(200,150,60,0.16); border-color: #C8963C; color: #C8963C; }

/* Library */
body.dark .lib-reflection { border-top-color: rgba(232,213,176,0.1); }
body.dark .lib-ref-choice { background: #1C1610; border-color: rgba(232,213,176,0.08); }
body.dark .lib-ref-choice.chosen { background: rgba(200,150,60,0.15); border-color: #C8963C; color: #C8963C; }
body.dark .auth-badge-main { color: #2ecc71; }

/* Contact inputs */
body.dark .contact-textarea,
body.dark .contact-input  { background: #1C1610; border-color: rgba(232,213,176,0.13); color: var(--ink); }

/* Share friend button */
body.dark .share-friend-btn { border-color: rgba(232,213,176,0.1); }

/* Google button in dark mode — keep it light for contrast */
body.dark .btn-google { background: #FFFFFF; color: #1A1A2E; border-color: rgba(255,255,255,0.15); }

/* ═══════════════════════════════════════
   MARK AS DONE
═══════════════════════════════════════ */
.mark-done-full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 14px;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--divider);
  background: transparent;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink2);
  cursor: pointer;
  transition: all 0.25s;
}
.mark-done-full.done {
  background: #1a8c52;
  border-color: #1a8c52;
  color: #FFFFFF;
}
.mark-done-circle {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid var(--ink3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s;
  color: transparent;
}
.mark-done-full.done .mark-done-circle {
  border-color: rgba(244,239,230,0.5);
  background: rgba(244,239,230,0.15);
  color: #FFFFFF;
}

/* ═══════════════════════════════════════
   LIBRARY READER CONTEXT
═══════════════════════════════════════ */
.lib-reader-info {
  padding: 2px 22px 14px;
  flex-shrink: 0;
  border-bottom: none;
}
.lib-reader-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 3px;
}
.lib-reader-author {
  font-size: 12px;
  color: var(--ink3);
}

/* ═══════════════════════════════════════
   FROM LIBRARY BADGE + BACK BUTTON
═══════════════════════════════════════ */
.from-library-badge {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 9px;
  border-radius: 20px;
  margin-left: auto;
  font-weight: 500;
}
.back-to-library {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  background: none;
  cursor: pointer;
  padding: 4px 0;
  transition: opacity var(--transition);
}
.back-to-library:active { opacity: 0.6; }

/* ═══════════════════════════════════════
   CHAPTER HEADER
═══════════════════════════════════════ */
.chapter-header {
  display: flex;
  align-items: center;
}
.chapter-icon-right { margin-left: 18px; }
.chapter-icon-right:first-of-type { margin-left: auto; }

/* Bookmark saved state */
#chapter-btn-save.saved { opacity: 1; }
#chapter-btn-save.saved #chapter-save-icon path {
  fill: var(--accent);
  stroke: var(--accent);
}

/* ═══════════════════════════════════════
   RESPONSIVE — small devices (iPhone SE 320px)
═══════════════════════════════════════ */
@media (max-width: 360px) {
  .page-cover .cover-quote { font-size: 24px; }
  .top-bar { padding-top: max(44px, calc(env(safe-area-inset-top, 0px) + 8px)); }
  .chapter-header { padding-top: max(44px, calc(env(safe-area-inset-top, 0px) + 8px)); }
}

/* ═══════════════════════════════════════
   SCROLL HELPERS
═══════════════════════════════════════ */
/* Hide all scrollbars — app feel */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* ═══════════════════════════════════════
   ADD TO HOME SCREEN sheet
═══════════════════════════════════════ */
.sheet-close-btn {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--cream2);
  border: 1px solid var(--divider);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink2);
  cursor: pointer;
}
.a2hs-sheet { text-align: center; padding-top: 28px; }
.a2hs-bookmark { font-size: 32px; line-height: 1; margin-bottom: 14px; }
.a2hs-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.3;
}
.a2hs-sub { font-size: 14px; color: var(--ink2); line-height: 1.6; margin-bottom: 24px; }
.a2hs-install-btn {
  width: 100%;
  padding: 14px 20px;
  background: var(--ink);
  color: var(--cream);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  transition: opacity 0.15s;
}
.a2hs-install-btn:active { opacity: 0.8; }
.a2hs-ios-steps {
  background: var(--cream2);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  text-align: left;
}
.a2hs-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
  padding: 7px 0;
}
.a2hs-step + .a2hs-step { border-top: 1px solid var(--divider); }
.a2hs-step-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.a2hs-skip-btn {
  font-size: 13px;
  color: var(--ink3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 16px;
  min-height: 44px;
}

/* ═══════════════════════════════════════
   GALLERY FOOTER NOTE
   "Well done, keep going!" + grows hint
═══════════════════════════════════════ */
.gallery-footer-note {
  text-align: center;
  padding: 16px 24px 28px;
  font-size: 14px;
  color: var(--ink3);
  line-height: 1.6;
}
.gallery-footer-note strong {
  color: var(--ink);
  font-weight: 600;
}
.gallery-grows-hint {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink3);
  opacity: 0.75;
}

/* ═══════════════════════════════════════
   STREAK START NUDGE (streak === 0)
═══════════════════════════════════════ */
.streak-start-nudge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
}
.streak-nudge-flame {
  font-size: 20px;
  line-height: 1;
}
.streak-nudge-text {
  font-size: 14px;
  color: var(--ink3);
  line-height: 1.4;
}

/* ═══════════════════════════════════════
   SKELETON LOADER
   Shimmer placeholder while book loads
═══════════════════════════════════════ */
.book-skeleton {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.sk-line {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--divider) 25%, rgba(0,0,0,0.06) 50%, var(--divider) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s infinite;
}
.sk-line-full   { width: 100%; }
.sk-line-wide   { width: 72%; height: 18px; }
.sk-line-medium { width: 55%; }
.sk-line-narrow { width: 38%; }
.sk-gap { height: 8px; }
@keyframes sk-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.dark .sk-line {
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.06) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s infinite;
}

/* ═══════════════════════════════════════
   ABOUT SPARK SHEET
═══════════════════════════════════════ */
.about-sheet {
  padding: 28px 24px 40px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.about-logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.3px;
  margin-bottom: 20px;
}
.about-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.about-body p {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  margin: 0;
}
.about-sign {
  font-style: italic;
  color: var(--ink3) !important;
  margin-top: 6px !important;
  line-height: 1.7 !important;
}
.about-contact {
  font-size: 13px !important;
  color: var(--ink3) !important;
  margin-top: 4px !important;
}
.about-email {
  color: var(--ink3);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.about-company {
  font-size: 12px !important;
  color: var(--ink3) !important;
  opacity: 0.6;
  margin-top: 0 !important;
}
.about-legal-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

/* auth-terms: "About Spark" on its own line */
.auth-link-about {
  color: var(--ink3);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* ═══════════════════════════════════════
   SHARE NUDGE BAR
   Soft banner from bottom — every 10th visit
═══════════════════════════════════════ */
.share-nudge {
  position: fixed;
  bottom: 80px;        /* above tab bar */
  left: 12px;
  right: 12px;
  z-index: 60;
  pointer-events: none;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22,1,0.36,1), opacity 0.3s ease;
}
.share-nudge.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.share-nudge-inner {
  background: var(--navy);
  color: #fff;
  border-radius: 16px;
  padding: 14px 14px 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(26,37,69,0.28);
}
.share-nudge-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}
.share-nudge-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.share-nudge-text strong {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}
.share-nudge-text span {
  font-size: 12px;
  color: rgba(255,255,255,0.72);
  line-height: 1.4;
}
.share-nudge-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.share-nudge-btn:active { background: rgba(255,255,255,0.25); }
.share-nudge-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 4px 4px 2px;
  line-height: 1;
  min-width: 28px;
  text-align: right;
}
.dark .share-nudge-inner {
  background: #2a3250;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
