/* ── Self-hosted type (offline-safe). Newsreader: characterful reading serif with
   Vietnamese coverage. Spline Sans Mono: specimen-tag labels. ── */
@font-face {
  font-family: 'Newsreader'; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url('fonts/newsreader-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Newsreader'; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url('fonts/newsreader-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Newsreader'; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url('fonts/newsreader-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Spline Sans Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/splinemono-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+2122, U+2212, U+FEFF, U+FFFD;
}

/* Lora — warm book serif. Roboto Slab — slab (between serif and mono).
   Source Sans 3 — humanist sans. All variable, self-hosted, Vietnamese-capable. */
@font-face {
  font-family: 'Lora'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('fonts/lora-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Lora'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('fonts/lora-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Lora'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('fonts/lora-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Roboto Slab'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('fonts/robotoslab-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Roboto Slab'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('fonts/robotoslab-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Roboto Slab'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('fonts/robotoslab-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Sans 3'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('fonts/sourcesans-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Source Sans 3'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('fonts/sourcesans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Source Sans 3'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('fonts/sourcesans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root,
:root[data-theme="paper"] {
  --paper: #efe7d6; --card: #f7f1e3; --ink: #2c271d; --muted: #8c7f66; --accent: #4a5d3a; --rule: #d8ccb4;
}
:root[data-theme="light"] {
  --paper: #fafafa; --card: #ffffff; --ink: #1b1c1e; --muted: #9a9aa0; --accent: #2f7d5b; --rule: #ececee;
}
:root[data-theme="sage"] {
  --paper: #e6ece3; --card: #f1f5ee; --ink: #28302a; --muted: #7e8c7c; --accent: #43694a; --rule: #cdd7c8;
}
:root[data-theme="sepia"] {
  --paper: #ece0c6; --card: #f5ecd6; --ink: #4b3b29; --muted: #9c8763; --accent: #9a5b25; --rule: #ddccaa;
}
:root[data-theme="vintage"] {
  --paper: #ddcfac; --card: #e7dbbd; --ink: #3f3322; --muted: #84714e; --accent: #93472a; --rule: #c7b790;
}
:root[data-theme="dusk"] {
  --paper: #1a1e24; --card: #222831; --ink: #d6dce4; --muted: #828d9c; --accent: #8fb9d8; --rule: #2f3743;
}
:root[data-theme="forest"] {
  --paper: #13201a; --card: #1c2a22; --ink: #dde6da; --muted: #7e9283; --accent: #ceaa6a; --rule: #27372e;
}
:root[data-theme="night"] {
  --paper: #0d0d0c; --card: #161613; --ink: #e7e2d6; --muted: #7e7a6e; --accent: #9ec79a; --rule: #242220;
}

:root {
  --reading: 'Newsreader', Georgia, 'Times New Roman', serif;
  --label: 'Spline Sans Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  /* reading-text typography (user-adjustable; see typography.js) */
  --body-font: var(--reading);
  --body-weight: 400;
  --body-style: normal;
  --body-size: 1.2rem;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  overflow-x: hidden;
  transition: background 0.25s ease;
}

html, body {
  margin: 0;
  color: var(--ink);
  font-family: var(--reading);
  font-optical-sizing: auto;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; min-height: 100dvh; }

/* faint paper grain — tactile, not decorative */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.4;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 41rem;
  min-width: 0;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
}

.screen {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.screen.entering { opacity: 0; transform: translateY(8px); }
.screen.leaving { opacity: 0; transform: translateY(-8px); }
@media (prefers-reduced-motion: reduce) {
  .screen { transition: opacity 0.12s ease; }
  .screen.entering, .screen.leaving { transform: none; }
}

/* ── top bar ── */
.bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  padding: calc(0.8rem + env(safe-area-inset-top)) 1.25rem 0.5rem;
}
.bar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--reading);
  font-style: italic;
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--ink);
}
.wordmark {
  font-family: var(--reading);
  font-style: italic;
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--accent);
}
.label, .bar-pct, .mode-pill, .hint, .sec, .book-end, .report-stat, .theme-chip, .bar-link {
  font-family: var(--label);
}
.bar-pct {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.bar-btn, .bar-link {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  -webkit-tap-highlight-color: transparent;
}
.bar-btn {
  font-size: 1.15rem;
  line-height: 1;
  padding: 0.3rem 0.35rem;
}
.bar-link {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  padding: 0.3rem 0;
}
.bar-spacer { flex: 1; }
.done {
  font-family: var(--label);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.36rem 0.95rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.done:hover, .done:active { background: var(--card); border-color: var(--accent); }
.mode-pill {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.22rem 0.5rem;
  white-space: nowrap;
}

/* hairline progress (reading only) */
.progress {
  height: 1.5px;
  width: 0;
  background: var(--accent);
  margin: 0 1.25rem;
  transition: width 0.3s ease;
}

/* ── content ── */
.content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  font-size: 1.2rem;
  line-height: 1.72;
}
.para {
  margin: 0 0 1.05em;
  font-family: var(--body-font);
  font-weight: var(--body-weight);
  font-style: var(--body-style);
  font-size: var(--body-size);
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* DISCOVERY — a pressed specimen card */
.screen.discover .content {
  margin: 0.4rem 1.1rem 0.2rem;
  padding: 1.6rem 1.5rem 1.4rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 1px 0 var(--rule), 0 14px 30px -18px rgba(0, 0, 0, 0.45);
  position: relative;
}
.screen.discover .content::after {
  content: '\2767'; /* rotated floral heart — printer's leaf */
  position: absolute;
  right: 1rem;
  bottom: 0.7rem;
  font-size: 1.1rem;
  color: var(--accent);
  opacity: 0.4;
}

/* READING — full bleed */
.content.reading {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.6rem 1.5rem calc(2rem + env(safe-area-inset-bottom));
}
.content.reading .para:first-of-type { margin-top: 0.4rem; }

.hint {
  text-align: center;
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 1.5rem calc(1rem + env(safe-area-inset-bottom));
}
.sentinel { height: 1px; }
.book-end {
  text-align: center;
  font-size: 0.66rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 1.4rem 0 2.2rem;
}

.empty {
  margin: 24vh auto 0;
  max-width: 22rem;
  text-align: center;
  font-family: var(--label);
  font-size: 0.8rem;
  line-height: 1.9;
  letter-spacing: 0.03em;
  color: var(--muted);
}

/* ── settings (themes + progress) ── */
.content.settings { overflow-y: auto; padding: 0.4rem 1.5rem 2rem; }
.sec {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.6rem 0 0.7rem;
}
.themes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.theme-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.4rem 0.45rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.theme-chip.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.theme-chip .sw {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(128, 128, 128, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* smooth the recolour when switching themes */
body, .bar, .content, .theme-chip, .chip, .type-preview, .install-btn, .mode-pill, .sec, .bar-title, .wordmark {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

/* font / weight / style choosers */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.type-preview {
  margin: 1rem 0 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--card);
  font-family: var(--body-font);
  font-weight: var(--body-weight);
  font-style: var(--body-style);
  font-size: var(--body-size);
  line-height: 1.7;
  color: var(--ink);
}
/* install prompt */
.install { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.install-btn {
  font-family: var(--label);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--paper);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.install-btn:disabled { opacity: 0.5; cursor: default; }
.install-note {
  margin: 0;
  font-family: var(--label);
  font-size: 0.72rem;
  line-height: 1.75;
  color: var(--muted);
}

/* danger zone — typed-confirm progress reset */
.danger { --danger: #c0563f; }
.danger-btn {
  font-family: var(--label);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--danger);
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: 2px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.danger-btn:disabled { opacity: 0.4; cursor: default; }
.danger-msg {
  font-family: var(--label);
  font-size: 0.74rem;
  line-height: 1.75;
  color: var(--ink);
  margin: 0 0 0.75rem;
}
.danger-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.danger-input {
  font-family: var(--label);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  width: 7rem;
  padding: 0.45rem 0.6rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.danger-input:focus { outline: none; border-color: var(--danger); }

.report-list { list-style: none; margin: 0; padding: 0; }
.report-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--rule);
}
.report-title { font-family: var(--reading); font-size: 1.1rem; }
.report-stat { font-size: 0.7rem; letter-spacing: 0.04em; color: var(--muted); }
