/* Nicaea Library — web edition, release 1.3 "Hope".

   The desktop design system (docs/DESIGN_SYSTEM.md) in CSS: a light canvas,
   a bold accent banner behind each page title with white cards floating on
   its lower edge, soft shadows, big numbers, colour-coded icon chips and
   accent pill navigation. Every colour is a custom property. The accent-
   derived tokens are written onto <html> by js/theme.js before first paint
   (from the reader's Personalize choices, contrast-checked for any accent);
   the values below are the defaults (Royal blue) for a page without JS.

   Mobile first: base rules are for phones (360 px and up); larger layouts
   are layered on with min-width queries at 720, 1024 and 1200 px. */

/* ------------------------------------------------------------------ fonts */

@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-ExtraBold.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Literata"; src: url("../fonts/Literata-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Literata"; src: url("../fonts/Literata-Italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Literata"; src: url("../fonts/Literata-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Literata"; src: url("../fonts/Literata-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* ----------------------------------------------------------------- tokens */

:root {
  /* neutrals (light) — design.py _NEUTRALS["light"] */
  --canvas: #F4F6FB; --surface: #FFFFFF; --raised: #FFFFFF; --raised-alt: #F7F8FC;
  --field: #F3F5FA; --hover: #ECEFF7; --pressed: #E2E7F2; --border: #E6E9F2;
  --border-strong: #D2D8E5; --text: #1E2843; --muted: #4B566D; --faint: #5A657C;
  --success: #08724E; --success-soft: #E2F5EC; --warning: #995607; --warning-soft: #FFF0DB;
  --danger: #BE2E46; --danger-soft: #FDE7EB; --info: #1D4ED8; --info-soft: #E5EDFE;
  --violet: #6236C7; --violet-soft: #EFE9FD; --orange: #B4460C; --orange-soft: #FFEEDF;
  --rose: #BE123C; --rose-soft: #FFE4E9; --sky: #0369A1; --sky-soft: #E0F2FE;
  --highlight: #FFE38A;

  /* accent-derived (default accent, light) — overwritten by theme.js */
  --accent: #3A57E8; --accent-hover: #3550D5; --accent-pressed: #3047BE; --accent-soft: #E9EDFC;
  --accent-text: #3A57E8; --on-accent: #FFFFFF; --banner-start: #3A57E8; --banner-end: #526BEB;
  --on-banner: #FFFFFF; --glass: rgba(0, 0, 0, 0.16); --glass-hover: rgba(0, 0, 0, 0.24);
  --glass-border: rgba(255, 255, 255, 0.22); --accent-glow: rgba(58, 87, 232, 0.28);
  --accent-ring: rgba(58, 87, 232, 0.35); --map-sea: #DCE1F9; --banner-primary-text: #3A57E8;
  --banner-bg: radial-gradient(circle farthest-corner at 88% -30%, rgba(255, 255, 255, 0.12) 0 34%, transparent calc(34% + 0.6px)), radial-gradient(circle farthest-corner at 62% 150%, rgba(0, 0, 0, 0.1) 0 40%, transparent calc(40% + 0.6px)), radial-gradient(circle farthest-corner at 20% 160%, rgba(0, 0, 0, 0.06) 0 38%, transparent calc(38% + 0.6px)), #3A57E8;

  /* verse highlights — five colours, each with a light and a dark variant
     that keeps body text above 7:1 */
  --hl-gold: #FFE58F; --hl-sky: #CFE6FF; --hl-rose: #FFD3DC; --hl-violet: #E4DAFF; --hl-peach: #FFDBC2;

  /* map */
  --map-land: #FFFFFF; --map-coast: #C9D5EE; --map-label-bg: rgba(255, 255, 255, 0.94);

  /* elevation */
  --shadow-1: 0 10px 30px rgba(17, 38, 146, 0.06);
  --shadow-2: 0 14px 34px rgba(17, 38, 146, 0.11);
  --shadow-3: 0 18px 44px rgba(17, 38, 146, 0.16);
  --shadow-chip: 0 4px 14px rgba(17, 38, 146, 0.07);
  --card-border: transparent;
  --scrim: rgba(14, 18, 32, 0.46);

  /* shape — one radius drives every corner (Personalize → Corners) */
  --radius: 16px;
  --r-lg: calc(var(--radius) + 4px);
  --r-md: max(6px, calc(var(--radius) - 4px));
  --r-sm: max(4px, calc(var(--radius) - 8px));
  --r-banner: calc(var(--radius) + 12px);

  /* type — one scale drives every rem (Personalize → Text size) */
  --scale: 1;
  --font-ui: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Literata", Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-reading: var(--font-serif);
  --font-mono: "Cascadia Mono", Consolas, "Courier New", monospace;
  --reading-size: 1.125rem;

  /* layout */
  --gutter: 16px;
  --maxw: 1320px;
  --sidebar-w: 248px;
  --appbar-h: 60px;
  --tabbar-h: calc(64px + env(safe-area-inset-bottom, 0px));
  --bottom-offset: var(--tabbar-h);
  --overlap: 44px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --canvas: #0E1220; --surface: #141A2B; --raised: #1A2034; --raised-alt: #1F263C;
  --field: #1E2539; --hover: #262E47; --pressed: #2E3755; --border: #283048;
  --border-strong: #38425F; --text: #E9ECF5; --muted: #B3BBD2; --faint: #A0A8BF;
  --success: #4ADE9B; --success-soft: #12322A; --warning: #F5B455; --warning-soft: #3A2A12;
  --danger: #F7899B; --danger-soft: #3D1D26; --info: #7EAAFF; --info-soft: #1A2848;
  --violet: #B69DFF; --violet-soft: #2A2148; --orange: #FDBA74; --orange-soft: #3A2414;
  --rose: #FDA4AF; --rose-soft: #3D1A24; --sky: #7DD3FC; --sky-soft: #0F2A3D;
  --highlight: #5C4A14;

  --accent-hover: #526BEB; --accent-soft: #222D5F; --accent-text: #8396F0;
  --banner-start: #344ED1; --banner-end: #596ED9; --map-sea: #121934;
  --accent-ring: rgba(131, 150, 240, 0.35);

  --hl-gold: #5C4A14; --hl-sky: #173D5E; --hl-rose: #5E2434; --hl-violet: #3D2F6B; --hl-peach: #5E3518;

  --map-land: #1C2338; --map-coast: #34405F; --map-label-bg: rgba(26, 32, 52, 0.94);

  --shadow-1: 0 10px 30px rgba(0, 0, 0, 0.34);
  --shadow-2: 0 14px 34px rgba(0, 0, 0, 0.46);
  --shadow-3: 0 18px 44px rgba(0, 0, 0, 0.55);
  --shadow-chip: 0 4px 14px rgba(0, 0, 0, 0.3);
  --card-border: var(--border);
  --scrim: rgba(3, 5, 12, 0.62);
  color-scheme: dark;
}

:root[data-reading="sans"] { --font-reading: var(--font-ui); }

@media (min-width: 720px) {
  :root { --gutter: 24px; --overlap: 56px; }
}
@media (min-width: 1024px) {
  :root { --gutter: 32px; --appbar-h: 72px; --overlap: 64px; --bottom-offset: 0px; }
}

/* ------------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: calc(16px * var(--scale));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--appbar-h) + 12px);
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

img, svg, canvas { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
a { color: var(--accent-text); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
b, strong { font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
[hidden] { display: none !important; }

::selection { background: var(--accent); color: var(--on-accent); }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--accent-text);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.page-head :focus-visible, .appbar :focus-visible, .on-banner :focus-visible { outline-color: var(--on-banner); }
#view:focus, #view:focus-visible { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; left: 12px; top: -80px; z-index: 300;
  background: var(--accent); color: var(--on-accent);
  padding: 12px 18px; border-radius: var(--r-md); font-weight: 700;
  transition: top 0.15s var(--ease);
}
.skip-link:focus, .skip-link:focus-visible { top: 12px; text-decoration: none; }

.serif { font-family: var(--font-serif); }
.reading-font { font-family: var(--font-reading); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.grow { flex: 1 1 auto; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* ------------------------------------------------------------------ shell */

.app { min-height: 100vh; }

.main-col {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--bottom-offset);
}

.view { flex: 1 0 auto; min-width: 0; }

/* The app bar floats over the top of each page's banner; once the page
   scrolls it takes the banner's colour so it stays legible. */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--appbar-h);
  margin-bottom: calc(-1 * var(--appbar-h));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--gutter);
  color: var(--on-banner);
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.appbar.scrolled { background: var(--banner-start); box-shadow: 0 6px 20px rgba(10, 13, 22, 0.18); }

.appbar-brand {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  color: var(--on-banner); font-weight: 800; font-size: 1.0625rem; letter-spacing: -0.2px;
  text-decoration: none;
}
.appbar-brand:hover { text-decoration: none; }
.appbar-brand .logo-chip { background: #000; border: 1px solid var(--glass-border); }
.appbar-brand .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.appbar-search {
  position: relative;
  display: none;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  max-width: 520px;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--on-banner);
}
.appbar-search:focus-within { background: var(--glass-hover); border-color: var(--on-banner); }
.appbar-search input {
  flex: 1 1 auto; min-width: 0; height: 100%;
  background: transparent; border: 0; outline: none;
  color: var(--on-banner); font-size: 0.9375rem;
}
.appbar-search input::placeholder { color: var(--on-banner); opacity: 0.86; }
.appbar-search kbd {
  font-family: var(--font-mono); font-size: 0.6875rem; padding: 2px 6px;
  border-radius: 6px; border: 1px solid var(--glass-border); opacity: 0.9; white-space: nowrap;
}

.appbar .spacer { flex: 1 1 auto; }

.glass-btn, .glass-icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; min-width: 44px;
  padding: 0 14px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--on-banner);
  font-weight: 700; font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
}
.glass-icon { padding: 0; width: 44px; }
.glass-btn:hover, .glass-icon:hover { background: var(--glass-hover); text-decoration: none; color: var(--on-banner); }
.glass-btn[aria-pressed="true"] { background: var(--on-banner); color: var(--banner-start); border-color: var(--on-banner); }

.lang-seg {
  display: none; padding: 3px; gap: 2px;
  border-radius: var(--r-md); background: var(--glass); border: 1px solid var(--glass-border);
}
.lang-seg button {
  min-height: 38px; padding: 0 12px; border: 0; border-radius: calc(var(--r-md) - 3px);
  background: transparent; color: var(--on-banner); font-weight: 700; font-size: 0.8125rem;
}
.lang-seg button[aria-pressed="true"] { background: var(--on-banner); color: var(--banner-start); }
.lang-seg button:not([aria-pressed="true"]):hover { background: var(--glass-hover); }

.logo-chip {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: #000; color: #fff; overflow: hidden;
}
/* the NL logo fills its chip (silver letters on their own black) */
.logo-chip .logo-img { width: 100%; height: 100%; display: block; object-fit: cover; }

/* sidebar = desktop navigation, slide-in menu on phones and tablets */
.sidebar {
  position: fixed;
  z-index: 120;
  top: 0; bottom: 0; left: 0;
  width: min(320px, 88vw);
  display: flex; flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-3);
  transform: translateX(-104%);
  visibility: hidden;
  transition: transform 0.24s var(--ease), visibility 0s linear 0.24s;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar.open { transform: none; visibility: visible; transition: transform 0.24s var(--ease), visibility 0s; }

.scrim {
  position: fixed; inset: 0; z-index: 110;
  background: var(--scrim);
  opacity: 0; visibility: hidden;
  transition: opacity 0.2s var(--ease), visibility 0s linear 0.2s;
}
.scrim.show { opacity: 1; visibility: visible; transition: opacity 0.2s var(--ease), visibility 0s; }

.side-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 18px 16px 22px;
}
.side-brand .brand-name { font-size: 1.1875rem; font-weight: 800; letter-spacing: -0.2px; color: var(--text); flex: 1 1 auto; }
.side-home { display: flex; align-items: center; gap: inherit; flex: 1 1 auto; min-width: 0; color: inherit; text-decoration: none; border-radius: 12px; }
.side-home:hover { text-decoration: none; }
.side-brand .icon-btn { margin-right: -6px; }

.side-search {
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px 6px; min-height: 44px; padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--muted);
  font-weight: 600; font-size: 0.875rem; text-align: left;
}
.side-search span { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-search kbd {
  font-family: var(--font-mono); font-size: 0.6875rem; color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 1px 6px; background: var(--raised);
}
.side-search:hover { border-color: var(--border-strong); color: var(--text); }

.nav { padding: 4px 16px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-group {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--faint); padding: 16px 12px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 14px;
  border-radius: var(--r-md);
  color: var(--muted);
  font-weight: 600; font-size: 0.875rem;
  text-decoration: none;
}
.nav-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-link.active {
  background: var(--accent-fill, var(--accent)); color: var(--on-accent); font-weight: 700;
  box-shadow: 0 8px 18px var(--accent-glow);
}

.side-foot { margin-top: auto; padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.privacy-card {
  padding: 14px 16px; border-radius: var(--r-lg);
  background: var(--accent-soft); color: var(--text);
  display: flex; flex-direction: column; gap: 4px;
}
.privacy-card b { font-size: 0.8125rem; }
.privacy-card span { font-size: 0.75rem; color: var(--text); line-height: 1.5; }
/* account (js/sync.js) */
.acct-side-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 0.8125rem; font-weight: 700; color: var(--accent-text); }
.acct-side { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-lg); background: var(--accent-soft); color: var(--text); text-decoration: none; }
.acct-side:hover { background: var(--hover); }
.acct-side-text { display: flex; flex-direction: column; min-width: 0; }
.acct-side-text b { font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-side-text span { font-size: 0.75rem; color: var(--muted); }
.acct-avatar { flex: 0 0 auto; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-fill, var(--accent)); color: var(--on-accent); font-weight: 800; font-size: 0.8125rem; object-fit: cover; }
.acct-head { display: flex; align-items: center; gap: 14px; }
.acct-head .acct-avatar { font-size: 1.1rem; }
.acct-status { margin-top: 14px; font-size: 0.875rem; color: var(--muted); }
.acct-list { margin: 4px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }
.acct-list li { margin: 6px 0; }
.acct-danger { color: var(--danger); }
.acct-error { margin-top: 10px; color: var(--danger); font-size: 0.875rem; }
.side-links { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0 4px; font-size: 0.8125rem; }
.side-links a { font-weight: 600; }

/* bottom tab bar (phones and tablets) */
.tabbar {
  position: fixed;
  z-index: 90;
  left: 0; right: 0; bottom: 0;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(17, 38, 146, 0.06);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 56px; padding: 6px 2px 4px;
  background: none; border: 0;
  color: var(--muted);
  font-size: 0.6875rem; font-weight: 700;
  text-decoration: none;
}
.tab:hover { text-decoration: none; color: var(--text); }
.tab-icon {
  display: grid; place-items: center;
  width: 52px; height: 30px; border-radius: 999px;
  transition: background-color 0.15s var(--ease);
}
.tab.active { color: var(--accent-text); }
.tab.active .tab-icon { background: var(--accent-soft); }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.desktop-only { display: none !important; }

@media (min-width: 720px) {
  .appbar-search { display: flex; }
  .mobile-search { display: none !important; }
  .lang-seg { display: inline-flex; }
  .lang-quick { display: none !important; }
}

@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; height: 100vh; width: auto;
    transform: none; visibility: visible; transition: none;
    box-shadow: 0 0 30px rgba(17, 38, 146, 0.05);
    border-right: 1px solid transparent;
  }
  :root[data-theme="dark"] .sidebar { border-right-color: var(--border); box-shadow: none; }
  .side-brand .icon-btn { display: none; }
  .scrim, .tabbar, .menu-btn, .appbar-brand { display: none !important; }
  .desktop-only { display: initial !important; }
  /* "initial" is plain inline: a glass button keeps the flex box that centres its icon. */
  .glass-icon.desktop-only, .glass-btn.desktop-only { display: inline-flex !important; }
  .appbar { gap: 12px; }
}

/* ----------------------------------------------------------- page layout */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* The banner: accent fill behind the title, running `--overlap` px below it
   so the first row of cards floats half on it. Only cards may sit on that
   lower part; a page that starts with anything else uses --overlap: 0. */
.page-head {
  position: relative;
  background: var(--banner-bg);
  color: var(--on-banner);
  border-bottom-left-radius: var(--r-banner);
  padding-top: calc(var(--appbar-h) + 10px);
  padding-bottom: calc(var(--overlap) + 26px);
}
.page-head.flat { padding-bottom: 28px; }
.ph {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px 24px;
}
.ph-main { min-width: 0; flex: 1 1 320px; }
.ph-eyebrow {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase;
  margin-bottom: 6px; color: var(--on-banner);
}
.ph-title {
  font-size: 1.75rem; font-weight: 800; letter-spacing: -0.6px; line-height: 1.15;
  color: var(--on-banner); overflow-wrap: anywhere;
}
.ph-title .ph-title-sub { font-weight: 600; font-size: 0.6em; letter-spacing: 0; }
.ph-sub { margin-top: 6px; font-size: 0.9375rem; line-height: 1.5; color: var(--on-banner); max-width: 70ch; }
.ph-sub a, .page-head a:not(.glass-btn):not(.btn):not(.pill) { color: var(--on-banner); text-decoration: underline; text-underline-offset: 3px; }
.ph-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
@media (max-width: 719px) {
  .ph-actions { width: 100%; }
  .ph-actions .search-field { width: 100% !important; }
}
@media (max-width: 399px) {
  #mode-btn { display: none; }
}
.ph-extra { margin-top: 18px; }

.page-body {
  position: relative;
  padding-top: 20px;
  padding-bottom: 32px;
  display: flex; flex-direction: column; gap: 20px;
}
.page-head:not(.flat) + .page-body { margin-top: calc(-1 * var(--overlap)); padding-top: 0; }

@media (min-width: 720px) {
  .ph-title { font-size: 2rem; }
}
@media (min-width: 1024px) {
  .page-head { padding-top: calc(var(--appbar-h) + 8px); }
  .ph-title { font-size: 2.125rem; }
  .page-body { gap: 24px; padding-bottom: 40px; }
}

/* glass controls inside the banner */
.page-head .input, .page-head select.select, .page-head .search-field {
  background: var(--glass); border-color: var(--glass-border); color: var(--on-banner);
}
.page-head .input::placeholder, .page-head .search-field input::placeholder { color: var(--on-banner); opacity: 0.86; }
.page-head select.select option, .page-head select.select optgroup { color: var(--text); background: var(--raised); }
.page-head .input:focus, .page-head select.select:focus, .page-head .search-field:focus-within {
  border-color: var(--on-banner); background: var(--glass-hover);
}
.page-head .btn { background: var(--glass); color: var(--on-banner); border: 1px solid var(--glass-border); }
.page-head .btn:hover { background: var(--glass-hover); }
.page-head .btn-primary { background: #FFFFFF; color: var(--banner-primary-text, var(--banner-start)); border-color: #FFFFFF; }
.page-head .btn-primary:hover { background: #FFFFFF; filter: brightness(0.97); }
.page-head .picker-label { color: var(--on-banner); }

/* ------------------------------------------------------------------ cards */

.card {
  position: relative;
  min-width: 0;
  background: var(--raised);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 20px;
}
.card.pad-lg { padding: 22px; }
.card.flush { padding: 0; overflow: hidden; }
a.card, button.card { color: inherit; text-decoration: none; font-weight: inherit; text-align: left; }
:where(a.card, button.card) { display: block; width: 100%; }
a.card:hover, button.card:hover, .card.interactive:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); text-decoration: none; }
a.card, button.card, .card.interactive { transition: box-shadow 0.18s var(--ease), transform 0.18s var(--ease); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .card-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-title h2, .card-title h3, h2.card-title, h3.card-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.2px; }
.card-sub { color: var(--muted); font-size: 0.875rem; }
.card p + p { margin-top: 10px; }
.card .meta, .meta { color: var(--muted); font-size: 0.8125rem; }

@media (min-width: 1024px) {
  .card { padding: 24px; }
  .card.pad-lg { padding: 26px; }
}

.section-title {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin: 6px 0 -4px;
}
.card .section-title { margin: 18px 0 8px; }

/* grids */
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid-auto { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (min-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .grid-auto { gap: 20px; }
  .stats { gap: 20px; }
}
@media (min-width: 1200px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
  .grid-2 { gap: 24px; }
  .grid-auto { gap: 24px; }
}

/* ---------------------------------------------------------- icon chips */

.chip {
  --chip: 44px;
  width: var(--chip); height: var(--chip); flex: 0 0 var(--chip);
  border-radius: max(8px, calc(var(--radius) - 2px));
  display: grid; place-items: center;
  background: var(--tone-bg, var(--accent-soft));
  color: var(--tone-fg, var(--accent-text));
}
.chip.lg { --chip: 52px; }
.chip.sm { --chip: 34px; border-radius: max(6px, calc(var(--radius) - 6px)); }
.t-accent { --tone-fg: var(--accent-text); --tone-bg: var(--accent-soft); }
.t-info { --tone-fg: var(--info); --tone-bg: var(--info-soft); }
.t-violet { --tone-fg: var(--violet); --tone-bg: var(--violet-soft); }
.t-orange { --tone-fg: var(--orange); --tone-bg: var(--orange-soft); }
.t-rose { --tone-fg: var(--rose); --tone-bg: var(--rose-soft); }
.t-sky { --tone-fg: var(--sky); --tone-bg: var(--sky-soft); }
.t-warning { --tone-fg: var(--warning); --tone-bg: var(--warning-soft); }
.t-success { --tone-fg: var(--success); --tone-bg: var(--success-soft); }
.t-danger { --tone-fg: var(--danger); --tone-bg: var(--danger-soft); }
.t-neutral { --tone-fg: var(--muted); --tone-bg: var(--field); }
.t-solid { --tone-fg: var(--on-accent); --tone-bg: var(--accent); }

/* ------------------------------------------------------------ stat cards */

.stat { display: flex; align-items: center; gap: 14px; padding: 16px; }
.stat-label { color: var(--muted); font-size: 0.8125rem; font-weight: 600; line-height: 1.3; }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.4px; line-height: 1.15; }
.stat-value small { font-size: 0.8125rem; font-weight: 700; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
a.stat:hover { text-decoration: none; }
@media (max-width: 719px) {
  .stat { padding: 14px; gap: 10px; }
  .stat .chip.lg { --chip: 40px; }
  .stat-value { font-size: 1.375rem; }
}
@media (min-width: 1024px) {
  .stat { padding: 22px; gap: 16px; }
  .stat-value { font-size: 1.625rem; }
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--field);
  color: var(--text);
  font-weight: 700; font-size: 0.875rem; line-height: 1.2;
  text-decoration: none; text-align: center;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.btn:active { background: var(--pressed); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent-fill, var(--accent)); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-pressed); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); filter: brightness(0.97); }
.btn-outline { background: transparent; border-color: var(--border-strong); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.btn .count { font-weight: 700; opacity: 0.75; }
.btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: var(--r-md);
  border: 0; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.soft { background: var(--field); color: var(--text); }
.icon-btn.soft:hover { background: var(--hover); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 4px 0; min-height: 32px;
  color: var(--accent-text); font-weight: 700; font-size: 0.875rem; text-decoration: none;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------------------------------------------------------------- inputs */

.input, select.select, textarea.textarea, .search-field {
  width: 100%;
  min-height: 46px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
  font-size: 1rem; /* 16 px keeps iOS from zooming on focus */
  padding: 0 14px;
}
textarea.textarea { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.5; }
select.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16'%3E%3Cpath d='M6.4 9.4 12 14.8l5.6-5.4' fill='none' stroke='%23808AA3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  text-overflow: ellipsis;
  cursor: pointer;
}
.page-head select.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16'%3E%3Cpath d='M6.4 9.4 12 14.8l5.6-5.4' fill='none' stroke='%23FFFFFF' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
:root[data-on-banner="dark"] .page-head select.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16'%3E%3Cpath d='M6.4 9.4 12 14.8l5.6-5.4' fill='none' stroke='%230A0D16' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.input:hover, select.select:hover, textarea.textarea:hover { border-color: var(--border-strong); }
.input:focus, select.select:focus, textarea.textarea:focus, .search-field:focus-within {
  border-color: var(--accent-text); background: var(--raised); outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.page-head .input:focus, .page-head select.select:focus, .page-head .search-field:focus-within { box-shadow: none; }
.input::placeholder, textarea.textarea::placeholder { color: var(--faint); }
.search-field { display: flex; align-items: center; gap: 10px; padding: 0 12px; }
.search-field input { flex: 1 1 auto; min-width: 0; height: 44px; border: 0; background: transparent; outline: none; font-size: 1rem; color: inherit; }
.search-field input::placeholder { color: var(--faint); }
.search-field input::-webkit-search-cancel-button { filter: grayscale(1); }
.field-label { display: block; font-size: 0.875rem; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.field-hint { font-size: 0.8125rem; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.picker { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.picker-label { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }

input[type="range"] { accent-color: var(--accent); width: 100%; height: 32px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; cursor: pointer; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.controls .grow { flex: 1 1 200px; min-width: 0; }

/* -------------------------------------------------- pills and segments */

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; margin: -2px -2px -6px; }
.pills.scroll::-webkit-scrollbar { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  font-size: 0.8125rem; font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: var(--shadow-chip);
}
.pill:hover { border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.pill .count { color: var(--muted); font-weight: 700; }
.pill.active, .pill[aria-pressed="true"] { background: var(--text); color: var(--raised); border-color: var(--text); }
.pill.active .count, .pill[aria-pressed="true"] .count { color: var(--raised); opacity: 0.8; }
.page-head .pill { border-color: transparent; }
/* Phones: header filter rows are one swipeable line instead of many rows. */
@media (max-width: 719px) {
  .page-head .pills {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter));
    padding: 2px var(--gutter) 8px; scroll-padding-left: var(--gutter);
  }
  .page-head .pills::-webkit-scrollbar { display: none; }
  .page-head .pill { flex: 0 0 auto; }
}

.seg {
  display: flex; gap: 4px; padding: 4px;
  border-radius: calc(var(--r-md) + 2px);
  background: var(--field);
  flex-wrap: wrap;
}
.seg button {
  flex: 1 1 0; min-width: max-content;
  min-height: 40px; padding: 0 12px;
  border: 0; border-radius: max(4px, calc(var(--r-md) - 2px));
  background: transparent; color: var(--muted);
  font-weight: 700; font-size: 0.8125rem;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent-fill, var(--accent)); color: var(--on-accent); }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%;
  padding: 3px 10px; border-radius: 14px;
  font-size: 0.75rem; font-weight: 700; line-height: 1.5;
  background: var(--tone-bg, var(--accent-soft));
  color: var(--tone-fg, var(--accent-text));
  overflow-wrap: anywhere;
  vertical-align: middle;
}
.badge.neutral { background: var(--field); color: var(--muted); }
.badge.caps { letter-spacing: 0.6px; text-transform: uppercase; font-size: 0.6875rem; font-weight: 800; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }

/* --------------------------------------------------------- progress ring */

.ring {
  --p: 0; --size: 92px; --thick: 10px;
  width: var(--size); height: var(--size); flex: 0 0 var(--size);
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--field) 0);
  display: grid; place-items: center;
  position: relative;
}
.ring::before {
  content: ""; position: absolute; inset: var(--thick);
  border-radius: 50%; background: var(--raised);
}
.ring > span { position: relative; font-weight: 800; font-size: calc(var(--size) * 0.22); letter-spacing: -0.3px; }
.ring.sm { --size: 52px; --thick: 6px; }
.ring.sm > span { font-size: 0.75rem; }

.bar { height: 8px; border-radius: 999px; background: var(--field); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); width: calc(var(--p, 0) * 1%); }

/* ------------------------------------------------------- notices, empty */

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--info-soft);
  color: var(--text);
  font-size: 0.875rem; line-height: 1.55;
}
.notice svg { color: var(--info); margin-top: 1px; }
.notice.warn { background: var(--warning-soft); }
.notice.warn svg { color: var(--warning); }
.card .notice { margin: 4px 0 14px; }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 10px; padding: 24px 12px;
}
.empty h3 { font-size: 1.0625rem; font-weight: 700; }
.empty p { color: var(--muted); font-size: 0.875rem; max-width: 46ch; }

.loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--muted); padding: 32px 0; font-size: 0.9375rem;
}
.loading::before {
  content: ""; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.kbd {
  font-family: var(--font-mono); font-size: 0.75rem;
  padding: 1px 6px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--field); color: var(--text);
}

/* ------------------------------------------------------------------ home */

.home-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.home-grid > * { min-width: 0; }
@media (min-width: 720px) {
  .home-grid { gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-grid .span-2 { grid-column: 1 / -1; }
}
@media (min-width: 1200px) {
  .home-grid {
    gap: 24px;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    grid-template-areas: "resume streak" "votd plans";
  }
  .home-grid .span-2 { grid-column: auto; }
  .home-resume { grid-area: resume; }
  .home-streak { grid-area: streak; }
  .home-votd { grid-area: votd; }
  .home-plans { grid-area: plans; }
}

.resume-ref { font-size: 1.625rem; font-weight: 800; letter-spacing: -0.3px; margin: 2px 0 8px; }
.resume-text {
  font-family: var(--font-reading); font-size: 1rem; line-height: 1.7; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.home-resume .btn-row { margin-top: 18px; }

.votd-text {
  font-family: var(--font-reading); font-size: 1.3125rem; line-height: 1.6; color: var(--text);
  margin: 6px 0 10px; overflow-wrap: break-word;
}
.votd-ref { font-weight: 800; font-size: 0.9375rem; color: var(--accent-text); }
.votd-ref span { color: var(--muted); font-weight: 600; }
.votd-other { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.votd-other p { font-family: var(--font-reading); font-size: 0.9375rem; line-height: 1.6; color: var(--muted); }
.votd-other .votd-ref { font-size: 0.8125rem; margin-top: 6px; }
.home-votd .btn-row { margin-top: 18px; }
@media (min-width: 1024px) { .votd-text { font-size: 1.4375rem; } }

.streak-num { display: flex; align-items: baseline; gap: 8px; }
.streak-num b { font-size: 2.5rem; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.streak-num span { font-weight: 700; color: var(--muted); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 18px 0 12px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.6875rem; font-weight: 700; color: var(--muted); }
.week-dot {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--field); color: var(--faint);
  border: 2px solid transparent;
}
.week-dot.on { background: var(--accent-fill, var(--accent)); color: var(--on-accent); }
.week-dot.today { border-color: var(--accent-text); }
.week-dot.future { opacity: 0.55; }
.week-day.today { color: var(--text); }

.plan-mini { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.plan-mini:first-of-type { border-top: 0; padding-top: 4px; }
.plan-mini-body { min-width: 0; flex: 1 1 auto; }
.plan-mini-title { font-weight: 700; font-size: 0.9375rem; line-height: 1.35; }
.plan-mini-sub { color: var(--muted); font-size: 0.8125rem; }

.explore { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; border-radius: var(--r-lg);
  background: var(--raised); border: 1px solid var(--card-border);
  box-shadow: var(--shadow-1);
  color: var(--text); text-decoration: none; font-weight: inherit;
  transition: box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
  min-width: 0;
}
.tile:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); text-decoration: none; color: var(--text); }
.tile-title { font-weight: 700; font-size: 0.9375rem; }
.tile-sub { color: var(--muted); font-size: 0.75rem; line-height: 1.4; }
@media (min-width: 720px) { .explore { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1200px) { .explore { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px; } .tile { padding: 18px; } }

/* -------------------------------------------------------------- personalize */

.personalize-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1200px) { .personalize-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 24px; } }
.p-section { display: flex; flex-direction: column; gap: 10px; }
.p-section + .p-section { margin-top: 22px; }
.p-title { font-size: 0.875rem; font-weight: 700; }
.p-row { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .p-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.swatch {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid var(--raised);
  box-shadow: 0 0 0 1px var(--border-strong);
  background: var(--sw);
  padding: 0;
  display: grid; place-items: center;
  color: #FFFFFF;
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.swatch svg { opacity: 0; }
.swatch[aria-pressed="true"] svg { opacity: 1; }
.any-color {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  font-size: 0.8125rem; font-weight: 700; margin-left: 4px; cursor: pointer;
}
.any-color input[type="color"] {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: conic-gradient(#E11D48, #EA580C, #B8862F, #0284C7, #3A57E8, #7C3AED, #E11D48);
  cursor: pointer;
}
.any-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 4px; }
.any-color input[type="color"]::-webkit-color-swatch { border: 2px solid var(--raised); border-radius: 50%; }
.any-color input[type="color"]::-moz-color-swatch { border: 2px solid var(--raised); border-radius: 50%; }

.banner-options { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 480px) { .banner-options { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.banner-option {
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px; border-radius: var(--r-md);
  background: var(--field); border: 2px solid transparent;
  color: var(--text); font-size: 0.75rem; font-weight: 700;
}
.banner-option[aria-pressed="true"] { border-color: var(--accent-text); }
.banner-thumb { display: block; height: 44px; border-radius: max(4px, calc(var(--radius) - 8px)); }

.font-sample { font-size: 1.25rem; line-height: 1; }

.preview {
  border-radius: calc(var(--radius) + 6px); overflow: hidden;
  background: var(--canvas); border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
}
.preview-banner { background: var(--banner-bg); color: var(--on-banner); padding: 22px 22px 48px; }
.preview-banner b { display: block; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.4px; line-height: 1.2; overflow-wrap: anywhere; }
.preview-banner span { font-size: 0.8125rem; }
.preview-body { padding: 0 18px 18px; margin-top: -28px; display: flex; flex-direction: column; gap: 12px; position: relative; }
.preview-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.preview-stat { background: var(--raised); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow-1); display: flex; align-items: center; gap: 8px; min-width: 0; }
.preview-stat .chip { --chip: 28px; border-radius: max(4px, calc(var(--radius) - 8px)); }
.preview-stat small { display: block; font-size: 0.6875rem; color: var(--muted); }
.preview-stat b { display: block; font-size: 1.125rem; font-weight: 800; line-height: 1.1; }
.preview-card { background: var(--raised); border: 1px solid var(--card-border); border-radius: calc(var(--radius) + 2px); padding: 16px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 8px; }
.preview-card .reading-font { font-size: 0.9375rem; line-height: 1.6; color: var(--muted); }
@media (max-width: 400px) { .preview-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .preview-stats > :nth-child(3) { display: none; } }

/* ----------------------------------------------------------------- dialog */

.dialog-scrim {
  position: fixed; inset: 0; z-index: 200;
  background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  animation: fade-in 0.18s var(--ease);
}
.dialog {
  width: 100%; max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--raised); color: var(--text);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: sheet-up 0.24s var(--ease);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 8px; }
.dialog-head h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.3px; flex: 1 1 auto; padding-top: 8px; }
.dialog-body { padding: 8px 20px 16px; overflow-y: auto; overscroll-behavior: contain; }
.dialog-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 14px 20px 20px; border-top: 1px solid var(--border); }
@media (min-width: 720px) {
  .dialog-scrim { align-items: center; padding: 24px; }
  .dialog { max-width: 560px; border-radius: calc(var(--r-lg) + 4px); max-height: 88vh; animation: pop-in 0.2s var(--ease); }
  .dialog.wide { max-width: 760px; }
  .dialog-head { padding: 24px 24px 8px; }
  .dialog-body { padding: 8px 24px 18px; }
  .dialog-foot { padding: 16px 24px 22px; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes pop-in { from { transform: scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* tour (home.js openTour): a real screenshot, a sentence or two, and Try it */
.tour-dialog .dialog-body { padding-top: 4px; }
.tour { display: flex; flex-direction: column; gap: 14px; touch-action: pan-y; user-select: none; }
.tour-shot {
  margin: 0; border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--border); background: var(--field);
  aspect-ratio: 390 / 470; max-height: 42vh; box-shadow: var(--shadow-1);
}
.tour-shot img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.tour-copy h3 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 6px; }
.tour-copy p { color: var(--muted); line-height: 1.55; margin-bottom: 12px; }
.tour-dialog .dialog-foot { flex-wrap: nowrap; align-items: center; }
.tour-dots { display: flex; gap: 5px; margin-right: auto; align-self: center; }
.tour-dots button { width: 16px; height: 6px; border-radius: 99px; border: 0; padding: 0; background: var(--field); cursor: pointer; }
.tour-dots button[aria-current="true"] { background: var(--accent); }
.tour-dots button:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 3px; }
@media (min-width: 720px) {
  .tour-shot { aspect-ratio: 1280 / 720; max-height: 46vh; }
  .tour-dots button { width: 22px; }
  .tour-copy h3 { font-size: 1.375rem; }
}

/* welcome */
.welcome-steps { display: flex; gap: 6px; }
.welcome-steps span { width: 22px; height: 6px; border-radius: 99px; background: var(--field); }
.welcome-steps span.on { background: var(--accent); }
.welcome-hero { display: flex; flex-direction: column; gap: 14px; }
.welcome-banner { border-radius: var(--r-lg); background: var(--banner-bg); color: var(--on-banner); padding: 20px; display: flex; gap: 14px; align-items: center; }
.welcome-banner b { font-size: 1.125rem; font-weight: 800; display: block; }
.welcome-banner span { font-size: 0.875rem; }
.welcome-banner .logo-chip { background: #000; border: 1px solid var(--glass-border); color: var(--on-banner); width: 48px; height: 48px; flex-basis: 48px; }
.lang-choices { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lang-choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 84px; padding: 16px; border-radius: var(--r-md);
  background: var(--raised); border: 2px solid var(--border); color: var(--text); text-align: left;
}
.lang-choice b { font-size: 1.0625rem; }
.lang-choice span { color: var(--muted); font-size: 0.8125rem; }
.lang-choice[aria-pressed="true"] { border-color: var(--accent-text); background: var(--accent-soft); }
.welcome-features { display: grid; gap: 10px; margin-top: 4px; }
.welcome-feature { display: flex; gap: 12px; align-items: center; font-size: 0.875rem; }
.welcome-feature .chip { --chip: 36px; }

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed; z-index: 250;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom-offset) + 16px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(92vw, 440px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-md);
  background: var(--text); color: var(--raised);
  font-size: 0.875rem; font-weight: 600;
  box-shadow: var(--shadow-3);
  animation: toast-in 0.22s var(--ease);
  pointer-events: auto;
}
.toast svg { flex: 0 0 auto; }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------- command palette */

.palette-scrim {
  position: fixed; inset: 0; z-index: 210;
  background: var(--scrim);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 10vh 12px 12px;
  animation: fade-in 0.15s var(--ease);
}
.palette-box {
  width: min(640px, 100%); max-height: 76vh;
  display: flex; flex-direction: column;
  background: var(--raised); color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input input {
  flex: 1 1 auto; min-width: 0; height: 58px; border: 0; outline: none; background: transparent;
  font-size: 1.0625rem; color: var(--text);
}
.palette-list { overflow-y: auto; padding: 8px; }
.palette-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 46px; padding: 8px 12px; border-radius: var(--r-md);
  color: var(--text); font-weight: 600; font-size: 0.9375rem; text-decoration: none;
}
.palette-row:hover { text-decoration: none; color: var(--text); }
.palette-row .chip { --chip: 32px; border-radius: max(6px, calc(var(--radius) - 8px)); }
.palette-row .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-row .meta { flex: 0 0 auto; }
.palette-row.active { background: var(--accent-soft); }
.palette-empty { padding: 24px; text-align: center; color: var(--muted); }
.palette-foot { padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.75rem; }
@media (max-width: 719px) {
  .palette-scrim { padding: 0; align-items: stretch; }
  .palette-box { max-height: none; height: 100%; width: 100%; border-radius: 0; }
  .palette-foot { display: none; }
}

/* ------------------------------------------------------------------- plans */

.plan-card { display: flex; flex-direction: column; gap: 14px; }
.plan-card-top { display: flex; gap: 14px; align-items: flex-start; }
.plan-card h3 { font-size: 1.0625rem; font-weight: 700; line-height: 1.3; }
.plan-card p { color: var(--muted); font-size: 0.875rem; }
.plan-card .btn-row { margin-top: auto; }
.plan-progress { display: flex; align-items: center; gap: 14px; }
.today-list { display: flex; flex-direction: column; gap: 10px; }
.today-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 14px;
  border-radius: var(--r-md); background: var(--field);
  color: var(--text); font-weight: 700; text-decoration: none;
}
.today-item:hover { background: var(--hover); text-decoration: none; color: var(--text); }
.today-item .grow { min-width: 0; }
.day-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
.day-chip {
  min-height: 48px; border-radius: var(--r-md);
  border: 2px solid transparent; background: var(--field); color: var(--muted);
  font-weight: 800; font-size: 0.875rem;
  display: grid; place-items: center;
}
.day-chip:hover { color: var(--text); background: var(--hover); }
.day-chip.done { background: var(--accent-fill, var(--accent)); color: var(--on-accent); }
.day-chip.next { border-color: var(--accent-text); color: var(--accent-text); }
.day-chip[aria-current="true"] { box-shadow: 0 0 0 3px var(--accent-ring); }
.plan-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--text); font-size: 0.875rem; font-weight: 600;
  margin-bottom: 14px;
}
.plan-strip .grow { min-width: 160px; }

/* -------------------------------------------------------------------- bible */

.bible-pickers { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); width: 100%; margin-top: 16px; }
.bible-pickers .picker:first-child { grid-column: 1 / -1; }
@media (min-width: 720px) {
  .bible-pickers { grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 0.8fr); }
  .bible-pickers .picker:first-child { grid-column: auto; }
}
@media (min-width: 1200px) {
  .bible-pickers { width: auto; flex: 0 1 640px; margin-top: 0; }
}

.bible-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1200px) { .bible-grid { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 24px; } }

.reader { padding: 0; overflow: visible; }
.reader-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
.reader-title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.reader-title { font-family: var(--font-serif); font-size: 1.75rem; font-weight: 600; letter-spacing: -0.3px; }
.reader-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.reader-tools .btn { min-height: 40px; padding: 0 12px; }
.reader-tools .icon-btn { width: 40px; height: 40px; flex-basis: 40px; }
.size-label { min-width: 40px; text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); }
@media (max-width: 719px) {
  .bible-page .ph-sub { display: none; }
  .reader-tools .size-label { display: none; }
  .reader-tools .btn { width: 40px; padding: 0; }
  .reader-tools .btn span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
}
.reader-body { padding: 18px 18px 22px; }
@media (min-width: 720px) {
  .reader-head { padding: 22px 28px 16px; }
  .reader-body { padding: 22px 32px 28px; }
  .reader-title { font-size: 2rem; }
}

.chap-chips { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; scroll-snap-type: x proximity; }
.chap-chips::-webkit-scrollbar { display: none; }
.chap-chip {
  flex: 0 0 auto; min-width: 40px; min-height: 40px; padding: 0 6px;
  display: grid; place-items: center;
  border-radius: max(6px, calc(var(--radius) - 7px));
  background: var(--field); color: var(--muted);
  font-size: 0.8125rem; font-weight: 700; text-decoration: none;
  scroll-snap-align: center;
}
.chap-chip:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.chap-chip.active { background: var(--accent-fill, var(--accent)); color: var(--on-accent); }
@media (min-width: 720px) {
  .chap-chips { flex-wrap: wrap; overflow: visible; }
  .chap-chips.collapsed { max-height: 92px; overflow: hidden; }
}
.chap-more { align-self: flex-start; display: none; }
@media (min-width: 720px) { .chap-more { display: inline-flex; } }
@media (min-width: 1024px) and (max-width: 1199px) { .bible-side { left: var(--sidebar-w); } }

.verses {
  font-family: var(--font-reading);
  font-size: var(--reading-size);
  line-height: 1.85;
  color: var(--text);
  overflow-wrap: break-word;
}
.verses .vpara { margin: 0 0 0.9em; }
.verse {
  cursor: pointer;
  border-radius: 4px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  padding: 1px 0;
  transition: background-color 0.15s var(--ease);
}
.verse:hover { background: var(--hover); box-shadow: 0 0 0 2px var(--hover); }
.verse sup, .vnum {
  font-family: var(--font-ui); font-size: 0.62em; font-weight: 800;
  color: var(--accent-text); padding: 0 3px 0 1px; vertical-align: 0.5em; line-height: 0;
  user-select: none;
}
.verse i { font-style: italic; }
.verse.sel { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); text-decoration: underline dotted var(--accent-text); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.verse.hl-gold { background: var(--hl-gold); box-shadow: 0 0 0 2px var(--hl-gold); }
.verse.hl-sky { background: var(--hl-sky); box-shadow: 0 0 0 2px var(--hl-sky); }
.verse.hl-rose { background: var(--hl-rose); box-shadow: 0 0 0 2px var(--hl-rose); }
.verse.hl-violet { background: var(--hl-violet); box-shadow: 0 0 0 2px var(--hl-violet); }
.verse.hl-peach { background: var(--hl-peach); box-shadow: 0 0 0 2px var(--hl-peach); }
.verse[class*="hl-"] sup { color: var(--text); }
.verse.sel[class*="hl-"] { text-decoration: underline dotted var(--text); text-decoration-thickness: 2px; }
.verse.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 30% { background: var(--highlight); box-shadow: 0 0 0 4px var(--highlight); } 100% { } }
.note-mark {
  display: inline-grid; place-items: center; vertical-align: -0.15em;
  width: 1.15em; height: 1.15em; margin: 0 2px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent-text);
}
.verses.by-verse .vpara { margin: 0; }
.verses.by-verse .verse { display: block; padding: 3px 6px; margin: 0 -6px 4px; }

.parallel { display: flex; flex-direction: column; gap: 2px; font-family: var(--font-reading); font-size: var(--reading-size); line-height: 1.75; }
.par-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 10px; }
.par-head .badge { justify-self: start; }
.par-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 28px; padding: 6px 0; border-top: 1px solid var(--border); }
.par-row:first-of-type { border-top: 0; }
.par-b { color: var(--muted); font-size: 0.92em; }
.par-b .vnum { color: var(--muted); }
.par-row .verse { display: block; }
@media (min-width: 720px) {
  .par-head, .par-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .par-b { color: var(--text); font-size: 1em; }
}

.pager { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.pager .btn { max-width: 100%; }
.pager .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* selection panel + compare: the side column on desktop, a bottom sheet on
   phones and tablets */
.bible-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.verse-panel h3 { font-size: 1.0625rem; font-weight: 800; }
.panel-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-label { font-size: 0.8125rem; font-weight: 700; color: var(--muted); min-width: 72px; }
.hl-swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hl-swatch {
  width: 36px; height: 36px; border-radius: 50%; padding: 0;
  border: 3px solid var(--raised); box-shadow: 0 0 0 1px var(--border-strong);
  background: var(--sw); color: var(--text); display: grid; place-items: center;
  position: relative;
}
.hl-swatch::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; } /* 46 px touch target */
.hl-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.hl-swatch.none { background: var(--raised); color: var(--muted); }
.panel-actions { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel-actions .btn { padding: 0 10px; }
.verse-panel .textarea { min-height: 84px; }
.verse-panel .empty { padding: 10px 4px; }
.compare-item { padding: 12px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.compare-item:first-of-type { border-top: 0; padding-top: 4px; }
.compare-code { font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.6px; color: var(--accent-text); text-transform: uppercase; }
.compare-text { font-family: var(--font-reading); font-size: 0.9375rem; line-height: 1.6; color: var(--text); }
.compare-text.missing { color: var(--muted); font-style: italic; font-family: var(--font-ui); font-size: 0.8125rem; }
.compare-choose { display: grid; gap: 4px; margin: 8px 0 4px; max-height: 260px; overflow-y: auto; }
.compare-lang { margin: 8px 0 0; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; }
.compare-lang:first-child { margin-top: 0; }
/* Bibles in right-to-left scripts (Hebrew, Arabic, Persian): verse numbers stay with their verse. */
.verses[dir="rtl"], .par-b[dir="rtl"], .sref-verses[dir="rtl"] { text-align: right; }
.verses[dir="rtl"] .vnum, .par-b[dir="rtl"] .vnum { margin-left: .3em; margin-right: 0; }
.verses:lang(he), .par-b:lang(he), .sref-verses:lang(he) { font-size: 1.15em; line-height: 1.9; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 6px; border-radius: var(--r-sm); font-size: 0.875rem; cursor: pointer; }
.check-row:hover { background: var(--hover); }

/* study card: cross-references, the Fathers, the Greek or Hebrew */
.study-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; padding: 0 8px; }
.study-tabs button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.study-body { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.study-empty { padding: 14px 4px; text-align: center; }
.study-eyebrow { margin: 12px 0 2px; }
.study-source { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 0.75rem; }
.study-list { display: flex; flex-direction: column; gap: 2px; }
.study-row {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 8px; border-radius: var(--r-sm);
  color: var(--text); text-decoration: none;
}
.study-row:hover, .study-row:focus-visible { background: var(--hover); text-decoration: none; color: var(--text); }
.study-row-title { font-size: 0.8125rem; font-weight: 800; color: var(--accent-text); }
.study-row-sub { font-size: 0.75rem; color: var(--faint); }
.study-row-text { font-family: var(--font-reading); font-size: 0.9375rem; line-height: 1.55; }
.study-row-text:empty { display: none; }
.study-row-text.muted { font-family: var(--font-ui); font-size: 0.8125rem; color: var(--muted); }
.study-lxx-greek { font-size: 1.0625rem; }
.study-lxx { margin-top: 4px; }
.study-comment { padding: 8px 0; border-top: 1px solid var(--border); }
.study-comment:first-of-type { border-top: 0; }
.study-author { font-size: 0.8125rem; font-weight: 800; color: var(--accent-text); }
.study-cite { font-weight: 500; color: var(--faint); font-size: 0.75rem; }
.study-text p { font-family: var(--font-reading); font-size: 0.9375rem; line-height: 1.6; margin-top: 4px; }
.study-more { margin-top: 2px; }
.study-def { font-family: var(--font-reading); font-size: 0.9375rem; line-height: 1.55; }
.word-tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.word-tile {
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 46px; max-width: 150px; padding: 6px 9px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--raised-alt); color: var(--text); text-align: center;
}
.word-tile:hover { background: var(--hover); }
.word-tile[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.word-tile.variant { border-style: dashed; border-color: var(--border-strong); }
.wt-orig { font-family: var(--font-reading); font-size: 1.1875rem; line-height: 1.35; }
.wt-orig:lang(hbo) { font-size: 1.3125rem; }
.wt-tl { font-size: 0.6875rem; font-style: italic; color: var(--faint); }
.wt-gloss { font-size: 0.75rem; font-weight: 700; color: var(--accent-text); line-height: 1.3; }
/* passage guide and topic pages */
.word-filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 12px; }
.word-filters .select { width: 100%; }
.guide-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) { .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.guide-lemma { font-family: var(--font-reading); font-size: 1.125rem; font-weight: 500; color: var(--text); }
.topic-list { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .topic-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.topic-row { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center; color: var(--text); text-decoration: none; padding: 14px 16px; }
.topic-row:hover { text-decoration: none; color: var(--text); box-shadow: var(--shadow-2); }
.topic-name { font-weight: 800; font-size: 0.9375rem; }
.topic-sub { grid-column: 2 / 4; font-size: 0.8125rem; color: var(--muted); }
.topic-count { font-size: 0.75rem; color: var(--faint); }
.topic-detail { display: flex; flex-direction: column; gap: 10px; }
.topic-family { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.topic-point { padding: 8px 0; border-top: 1px solid var(--border); }
.topic-point:first-of-type { border-top: 0; }
.topic-point-text { font-family: var(--font-reading); font-size: 1rem; margin-bottom: 4px; }
.study-guide-link { white-space: nowrap; font-size: 0.8125rem; font-weight: 700; }
.word-tile.phrase .wt-en { font-size: 0.8125rem; font-weight: 800; order: -1; }
.word-tile.phrase .wt-orig { font-size: 1.0625rem; }
.study-order { margin-bottom: 8px; }
.study-order button { min-height: 34px; }
.word-detail { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.word-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.word-lemma { font-family: var(--font-reading); font-size: 1.625rem; line-height: 1.2; }
.word-dict { font-family: var(--font-reading); font-size: 1.0625rem; color: var(--muted); }
.word-here { font-weight: 700; }
.word-places { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.chip-link { font-size: 0.8125rem; font-weight: 700; }

.sheet-grip { display: none; }
.panel-actions .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1199px) {
  .note-area:not(.open) { display: none; }
  .panel-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel-actions .btn { flex-direction: column; gap: 4px; min-height: 58px; padding: 6px 4px; font-size: 0.75rem; }
  .bible-side .compare-panel.collapsed, .bible-side .study-panel.collapsed { display: none; }
  .panel-actions .study-toggle { grid-column: 1 / -1; flex-direction: row; gap: 8px; min-height: 46px; font-size: 0.8125rem; }
  .bible-side .study-panel { border-top: 1px solid var(--border); }
}
@media (min-width: 1200px) {
  .panel-actions .note-toggle, .panel-actions .compare-toggle, .panel-actions .study-toggle { display: none; }
  .study-panel .sheet-close { display: none; }
}
@media (max-width: 1199px) {
  .bible-side {
    position: fixed; z-index: 80;
    left: 0; right: 0; bottom: var(--bottom-offset);
    max-height: min(72vh, 620px);
    overflow-y: auto; overscroll-behavior: contain;
    background: var(--raised);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: 0 -12px 40px rgba(10, 13, 22, 0.22);
    border-top: 1px solid var(--border);
    padding: 6px 0 8px;
    gap: 0;
    transform: translateY(110%);
    visibility: hidden;
    transition: transform 0.24s var(--ease), visibility 0s linear 0.24s;
  }
  .bible-side.open { transform: none; visibility: visible; transition: transform 0.24s var(--ease), visibility 0s; }
  .bible-side .card { box-shadow: none; border: 0; border-radius: 0; background: transparent; padding: 10px 16px; }
  .bible-side .compare-panel { border-top: 1px solid var(--border); }
  .sheet-grip { display: block; width: 44px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 4px auto 0; }
  .compare-panel.collapsed .compare-body { display: none; }
  .bible-page .page-body { padding-bottom: 24px; }
  .bible-page.has-sheet .page-body { padding-bottom: 300px; }
}
@media (min-width: 1200px) {
  .bible-side { position: sticky; top: calc(var(--appbar-h) + 16px); max-height: calc(100vh - var(--appbar-h) - 32px); overflow-y: auto; scrollbar-width: thin; }
  .compare-toggle-icon { display: none; }
  .verse-panel .sheet-close { display: none; }
}

/* ------------------------------------------------------------------ library */

.books { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 560px) { .books { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .books { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; } }
@media (min-width: 1200px) { .books { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 22px; } }
@media (min-width: 1600px) { .books { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.book {
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px; border-radius: calc(var(--radius) + 2px);
  background: var(--raised); border: 1px solid var(--card-border);
  box-shadow: var(--shadow-1);
  color: var(--text); text-decoration: none; font-weight: inherit;
  transition: box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
  min-width: 0;
}
.book:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); text-decoration: none; color: var(--text); }
/* Each book with its favourite star (a button beside the link, drawn over the cover's corner). */
.book-cell { position: relative; display: flex; min-width: 0; }
.book-cell > .book { flex: 1 1 auto; }
.book-star {
  position: absolute; top: 4px; right: 4px; width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.book-star svg {
  box-sizing: content-box; padding: 6px; border-radius: 999px;
  background: var(--raised); border: 1px solid var(--card-border); box-shadow: var(--shadow-1);
}
.book-star:hover svg, .book-star:focus-visible svg { color: var(--warning); border-color: var(--warning); }
.book-star[aria-pressed="true"] { color: var(--warning); }
.book-star[aria-pressed="true"] svg { fill: currentColor; }
.book-cell:hover .book-star { transform: translateY(-2px); }
.books.size-list .book-star { top: 50%; transform: translateY(-50%); right: 6px; }
.books.size-list .book-cell:hover .book-star { transform: translateY(-50%); }
.books.size-list .book { padding-right: 52px; }
[data-filter][hidden] { display: none; }
@media (forced-colors: active) { .book-star svg { border-color: ButtonText; } .book-star[aria-pressed="true"] svg { fill: Highlight; } }
.cover {
  position: relative; overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: max(6px, calc(var(--radius) - 4px));
  padding: 14px 12px 14px 16px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  color: #FFFFFF;
  background:
    radial-gradient(circle at 110% -10%, rgba(255, 255, 255, 0.16) 0 30%, transparent 30.4%),
    radial-gradient(circle at -20% 120%, rgba(0, 0, 0, 0.16) 0 42%, transparent 42.4%),
    linear-gradient(160deg, var(--c2), var(--c1));
}
.cover::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 1.2px; background: rgba(255, 255, 255, 0.18); box-shadow: 1.4px 0 0 rgba(0, 0, 0, 0.14); }
.cover-title {
  font-family: var(--font-serif); font-weight: 600; font-size: 1rem; line-height: 1.22;
  display: -webkit-box; -webkit-line-clamp: 5; line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.cover-author {
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cover-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, 0.3); }
.cover-progress span { display: block; height: 100%; background: #FFFFFF; width: calc(var(--p) * 1%); }
.book-info { padding: 0 4px 4px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.book-title { font-size: 0.8125rem; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-width: 0; }
.book-meta .meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.75rem; }
.lang-tag { font-size: 0.6875rem; font-weight: 800; padding: 2px 8px; border-radius: 99px; flex: 0 0 auto; }
.lang-tag.en { background: var(--accent-soft); color: var(--accent-text); }
.lang-tag.es { background: var(--orange-soft); color: var(--orange); }
@media (min-width: 720px) { .cover-title { font-size: 1.0625rem; } .cover-author { font-size: 0.6875rem; } .book { padding: 12px; } }

.lib-tools { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); margin-top: 16px; }
@media (min-width: 720px) { .lib-tools { grid-template-columns: minmax(0, 1fr) 220px; max-width: 760px; } }
/* A few quick filters, and the era, level and topic menus beside them. */
.lib-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 14px; }
.lib-filters .pills { flex: 0 1 auto; min-width: 0; }
@media (max-width: 719px) {
  .lib-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
}
.lib-reset {
  background: none; border: 0; padding: 0 0 0 4px; font: inherit; font-weight: 700; cursor: pointer;
  color: var(--on-banner); text-decoration: underline; text-underline-offset: 3px;
}
.lib-status:has(#lib-count:empty):has(.lib-reset[hidden]) { display: none; }
.audio-tag {
  display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; margin-left: auto;
  font-size: 0.6875rem; font-weight: 800; padding: 2px 7px; border-radius: 99px;
  background: var(--violet-soft); color: var(--violet);
}
.books.size-small .audio-tag .audio-time { display: none; }
.books.size-small .audio-tag { padding: 3px 5px; }
.work-audio svg { vertical-align: -2px; }

/* reader */
.reader-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) { .reader-layout { grid-template-columns: 300px minmax(0, 1fr); gap: 24px; } }
.toc { padding: 12px; }
.toc-list { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto; margin-top: 10px; overscroll-behavior: contain; }
.toc-list a {
  display: block; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 600; font-size: 0.8125rem; line-height: 1.4; text-decoration: none;
}
.toc-list a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.toc-list a.active { background: var(--accent-soft); color: var(--accent-text); }
@media (min-width: 1024px) {
  .toc { position: sticky; top: calc(var(--appbar-h) + 16px); }
  .toc-list { max-height: calc(100vh - var(--appbar-h) - 150px); }
}
/* Phones and tablets: the sections fold away under a bar that says where you are. */
.toc-toggle { display: none; }
@media (max-width: 1023.98px) {
  .toc { padding: 0; }
  .toc-toggle {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px;
    background: none; border: 0; border-radius: inherit; color: var(--text); font: inherit; text-align: left; cursor: pointer;
  }
  .toc-toggle > svg:last-child { margin-left: auto; flex: none; transition: transform 0.2s ease; color: var(--muted); }
  .toc.open .toc-toggle > svg:last-child { transform: rotate(180deg); }
  .toc-toggle-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
  .toc-toggle-text b { font-size: 0.9375rem; }
  .toc-toggle-text span { font-size: 0.8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .toc-body { display: none; padding: 0 12px 12px; border-top: 1px solid var(--border); }
  .toc.open .toc-body { display: block; padding-top: 12px; }
  .toc-list { max-height: min(60vh, 520px); }
  .toc-list a { font-size: 0.9375rem; line-height: 1.45; color: var(--text); padding: 10px 12px; }
  .toc-list a.active { font-weight: 700; }
  .toc-part { font-size: 0.75rem; margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) { .toc-toggle > svg:last-child { transition: none; } }
.prose { font-family: var(--font-reading); font-size: var(--reading-size); line-height: 1.8; max-width: 72ch; overflow-wrap: break-word; }
.prose p { margin: 0 0 1em; }

/* Books (scripts/book_structure.py): sub-headings, note numbers, notes. */
.book-prose p { margin: 0 0 1.05em; hyphens: auto; -webkit-hyphens: auto; }
.book-prose em { font-style: italic; }
.prose-sub {
  font-family: var(--font-sans); font-size: 0.82em; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-text); margin: 2.2em 0 0.8em; line-height: 1.4;
}
.prose-sub:first-child { margin-top: 0.4em; }
.prose-sub + .prose-sub { margin-top: -0.2em; }
/* Photographs inside a book (1.40): the picture, then its caption. */
.prose-figure { margin: 1.6em 0 1.8em; }
.prose-figure img {
  display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain;
  border-radius: 10px; background: var(--surface-2, rgba(127, 127, 127, 0.12));
}
.prose-figure figcaption { font-family: var(--font-sans); font-size: 0.82em; line-height: 1.5; color: var(--muted); margin-top: 0.6em; }
/* Hebrew (the Dead Sea Scrolls' appendix): right to left, a little larger. */
.book-prose p.hebrew { font-family: "SBL Hebrew", "Ezra SIL", "Times New Roman", "David", "Noto Serif Hebrew", serif; font-size: 1.12em; line-height: 1.9; hyphens: none; -webkit-hyphens: none; text-align: right; }
sup.fn { line-height: 0; font-size: 0.62em; font-family: var(--font-sans); vertical-align: super; margin-left: 1px; }
.fn-ref {
  border: 0; background: var(--accent-soft); color: var(--accent-text); font: inherit; font-weight: 700;
  border-radius: 6px; padding: 1px 4px; cursor: pointer; min-width: 1.4em;
}
.fn-ref:hover { background: var(--accent-fill, var(--accent)); color: var(--on-accent); }
.fn-plain { color: var(--faint); }
/* Scripture cited in a book: opens the verses over the page (core.js showScripture). */
a.sref { color: inherit; text-decoration: underline dotted var(--accent-text); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a.sref:hover { color: var(--accent-text); text-decoration-style: solid; }
.sref-verses { font-family: var(--font-reading); line-height: 1.7; }
.sref-verses p { margin: 0 0 0.6em; }
.sref-alt { margin-top: 1em; font-family: var(--font-sans); }
.notes { margin-top: 2.6em; padding-top: 1.2em; border-top: 1px solid var(--border); font-family: var(--font-sans); font-size: 0.82em; line-height: 1.6; color: var(--muted); }
.notes h3 { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin: 0 0 0.8em; }
.notes ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55em; }
.notes li { display: grid; grid-template-columns: 2.6em 1fr auto; gap: 0.4em; align-items: start; border-radius: 8px; padding: 2px 4px; }
.fn-num { color: var(--accent-text); font-weight: 700; text-align: right; }
.fn-back { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 1em; padding: 0 4px; }
.fn-back:hover { color: var(--accent-text); }
.notes li.flash, .fn-ref.flash { animation: nl-flash 1.4s var(--ease); }
@keyframes nl-flash { 0%, 40% { background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-ring); } 100% { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .notes li.flash, .fn-ref.flash { animation: none; background: var(--accent-soft); } }
.reader-part { margin: 0 0 4px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-text); }
.toc-part { margin: 12px 0 4px; padding: 0 10px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.toc-part:first-child { margin-top: 2px; }
.toc-list a.toc-opens { margin-top: 10px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.toc-list a.toc-opens.active { color: var(--accent-text); }
.toc-list a.toc-opens:first-child { margin-top: 0; }
mark { background: var(--highlight); color: var(--text); border-radius: 3px; padding: 0 2px; }
.read-progress { margin: -4px 0 16px; }

.place-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.note-box { flex: 1 0 100%; margin-top: 6px; }
.note-box .btn-row { margin-top: 8px; }

/* -------------------------------------------------------------------- maps */

.map-card { padding: 0; overflow: hidden; }
.map-stage {
  position: relative;
  height: clamp(330px, 52vh, 480px);
  background: var(--map-sea);
  overflow: hidden;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  cursor: grab;
  outline: none;
}
.map-stage.dragging { cursor: grabbing; }
.map-stage:focus-visible { box-shadow: inset 0 0 0 3px var(--accent-text); border-radius: 0; outline: none; }
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-land { fill: var(--map-land); stroke: var(--map-coast); stroke-width: 0.8; vector-effect: non-scaling-stroke; }
.map-grid { fill: none; stroke: var(--map-coast); stroke-width: 0.6; stroke-dasharray: 2 4; opacity: 0.55; vector-effect: non-scaling-stroke; }
.map-markers { position: absolute; inset: 0; pointer-events: none; }
.marker {
  position: absolute; left: 0; top: 0;
  pointer-events: auto;
  width: 30px; height: 30px; margin: -15px 0 0 -15px;
  padding: 0; border: 0; background: transparent;
  display: grid; place-items: center;
  will-change: transform;
}
.marker-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--mc);
  border: 2.5px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(17, 38, 146, 0.35);
  transition: transform 0.15s var(--ease);
}
.marker:hover .marker-dot, .marker:focus-visible .marker-dot { transform: scale(1.25); }
.marker:focus-visible { outline: none; }
.marker:focus-visible .marker-dot { box-shadow: 0 0 0 3px var(--accent-text); }
.marker.selected .marker-dot { width: 20px; height: 20px; border-width: 3px; box-shadow: 0 0 0 7px var(--mcg, rgba(17, 38, 146, 0.2)), 0 2px 8px rgba(17, 38, 146, 0.4); }
.marker.dim { opacity: 0.25; }
.map-label {
  position: absolute; left: 0; top: 0;
  pointer-events: auto;
  padding: 2px 8px; border-radius: 7px;
  background: var(--map-label-bg); color: var(--text);
  font-size: 0.75rem; font-weight: 700; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(17, 38, 146, 0.14);
  border: 0; cursor: pointer;
  will-change: transform;
}
.map-label.selected { font-weight: 800; box-shadow: 0 2px 10px rgba(17, 38, 146, 0.22), 0 0 0 2px var(--mc); }
.map-overlay { position: absolute; z-index: 3; }
.map-legend { left: 12px; right: 12px; top: 12px; }
.legend-chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 0 12px; border-radius: 999px;
  background: var(--raised); color: var(--text); border: 1px solid var(--border-strong);
  box-shadow: 0 4px 14px rgba(17, 38, 146, 0.12);
  font-size: 0.75rem; font-weight: 700; white-space: nowrap;
}
.legend-chip[aria-pressed="false"] { color: var(--muted); background: var(--raised-alt); }
.legend-chip[aria-pressed="false"] .dot { background: transparent !important; box-shadow: inset 0 0 0 2px var(--faint); }
.map-zoom {
  right: 12px; bottom: 12px;
  display: flex; flex-direction: column;
  background: var(--raised); border: 1px solid var(--card-border);
  border-radius: var(--r-md); box-shadow: 0 6px 18px rgba(17, 38, 146, 0.14);
  overflow: hidden;
}
.map-zoom button { width: 44px; height: 44px; border: 0; background: transparent; color: var(--text); display: grid; place-items: center; }
.map-zoom button + button { border-top: 1px solid var(--border); }
.map-zoom button:hover { background: var(--hover); }
.map-hint {
  left: 50%; bottom: 12px; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 99px; background: var(--raised); color: var(--muted);
  font-size: 0.75rem; font-weight: 600; box-shadow: var(--shadow-chip); white-space: nowrap;
  pointer-events: none;
}
.map-below { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .map-below { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.era-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 0.8125rem; font-weight: 700; margin-bottom: 14px; }
.era-head .era-value { color: var(--accent-text); white-space: nowrap; }
.era-slider { position: relative; height: 44px; margin: 0 12px; touch-action: none; }
.era-track { position: absolute; left: 0; right: 0; top: 19px; height: 6px; border-radius: 6px; background: var(--field); }
.era-range { position: absolute; top: 19px; height: 6px; border-radius: 6px; background: var(--accent); }
.era-thumb {
  position: absolute; top: 22px; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  padding: 0; border: 0; background: transparent; display: grid; place-items: center;
  cursor: grab; touch-action: none;
}
.era-thumb::before {
  content: ""; width: 22px; height: 22px; border-radius: 50%;
  background: var(--raised); border: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(17, 38, 146, 0.25);
}
.era-thumb:focus-visible { outline: none; }
.era-thumb:focus-visible::before { box-shadow: 0 0 0 4px var(--accent-ring); }
.era-marks { position: relative; height: 18px; margin: 4px 12px 0; }
.era-mark {
  position: absolute; top: 0; transform: translateX(-50%);
  display: flex; align-items: flex-start;
  font-size: 0.6875rem; font-weight: 700; color: var(--muted); white-space: nowrap;
  background: none; border: 0; padding: 1px 2px 0; min-height: 18px;
}
.era-mark::before { content: ""; position: absolute; left: 50%; top: -9px; width: 2px; height: 6px; border-radius: 2px; background: var(--border-strong); }
.era-mark:hover { color: var(--text); }
.era-mark.first { transform: none; }
.era-mark.first::before { left: 0; }
.era-mark.last { transform: translateX(-100%); }
.era-mark.last::before { left: auto; right: 0; }

.place-card-band { height: 8px; background: var(--pc); }
.place-card .badge { align-self: flex-start; }
.place-name { font-size: 1.375rem; font-weight: 800; letter-spacing: -0.3px; line-height: 1.2; margin: 10px 0 6px; }
.place-name span { font-weight: 500; color: var(--muted); font-size: 0.75em; letter-spacing: 0; }
.place-desc { font-size: 0.875rem; line-height: 1.6; color: var(--muted); }
.place-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 0.8125rem; color: var(--muted); }
.place-links { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
.place-links .section-title { margin: 0 0 6px; }
.place-links a { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 0.875rem; }
.place-results {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--raised); color: var(--text); border: 1px solid var(--card-border);
  border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: 6px; max-height: 320px; overflow-y: auto;
}
.place-result { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 10px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; font-weight: 600; font-size: 0.875rem; color: var(--text); }
.place-result:hover, .place-result.active { background: var(--accent-soft); }

/* Play: the Explore chip and menu, journey playback, the quiz, the pulse */
.explore-chip .dot { background: #E07A3D; }
.explore-chip.on { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-ring); }
.explore-chip svg { margin-left: -2px; opacity: 0.7; }
.map-menu {
  z-index: 6; width: min(350px, calc(100% - 24px)); padding: 6px;
  background: var(--raised); color: var(--text); border: 1px solid var(--card-border);
  border-radius: var(--r-md); box-shadow: var(--shadow-3);
}
.map-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--text); text-align: left; font-size: 0.875rem; font-weight: 600;
}
.map-menu button:hover, .map-menu button:focus-visible { background: var(--accent-soft); outline: none; }
.map-menu button[aria-current="true"] { color: var(--accent-text); }
.map-menu button .meta { margin-left: auto; font-weight: 500; font-size: 0.75rem; white-space: nowrap; }
.map-menu .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.map-menu-head { margin: 6px 10px 2px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.map-routes .route-casing { stroke: var(--map-label-bg); stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.map-routes .route-leg { stroke-width: 2.6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.map-routes .route-leg.sea { stroke-dasharray: 7 5; }
.quiz-line { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
.map-play { position: absolute; inset: 0; pointer-events: none; }
.map-play > span { position: absolute; left: 0; top: 0; will-change: transform; }
.route-stop { width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--rc); box-shadow: 0 0 0 1.5px var(--map-label-bg); }
.traveller, .quiz-answer, .quiz-guess { width: 0; height: 0; }
.play-dot { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--rc); border: 3px solid #FFFFFF; box-shadow: 0 0 0 7px color-mix(in srgb, var(--rc) 24%, transparent), 0 2px 8px rgba(17, 38, 146, 0.35); }
.quiz-guess .play-dot { background: transparent; border: 3px solid var(--accent); box-shadow: 0 0 0 2px var(--raised), inset 0 0 0 4px var(--raised); }
.quiz-guess .play-dot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.play-tag {
  position: absolute; left: 18px; top: -12px; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--raised); color: var(--text); border: 1px solid var(--border-strong);
  font-size: 0.75rem; font-weight: 800; box-shadow: 0 2px 8px rgba(17, 38, 146, 0.16);
}
.map-stage.quiz { cursor: crosshair; }
.map-stage.quiz .marker, .map-stage.quiz .map-label { visibility: hidden; }
.marker.pulse::after, .traveller.pulse::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%; border: 2.5px solid var(--mc, var(--rc)); pointer-events: none;
  animation: map-pulse 0.9s var(--ease) 3;
  opacity: 0;
}
.traveller.pulse::after { left: 0; top: 0; }
@keyframes map-pulse { from { transform: scale(0.8); opacity: 0.6; } to { transform: scale(3.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .marker.pulse::after, .traveller.pulse::after { animation: none; } }
.play-card[hidden] { display: none; }
.play-body { padding: 12px 18px 14px; display: flex; flex-direction: column; gap: 8px; }
.play-body p { margin: 0; }
.play-head { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; }
.play-head .icon-btn { margin: -6px -10px -6px 0; }
.play-stop { display: flex; align-items: center; gap: 8px; }
.play-stop-name { font-size: 1.125rem; font-weight: 800; letter-spacing: -0.2px; }
.sea-badge { background: var(--sky-soft, var(--info-soft)); color: var(--sky, var(--info)); }
.new-best { background: var(--warning-soft); color: var(--warning); }
.quiz-score { color: var(--accent-text); font-weight: 700; font-size: 0.875rem; }
.stops-bar { position: relative; height: 14px; margin: 0 6px; }
.stops-bar::before, .stops-bar::after { content: ""; position: absolute; left: 0; top: 6px; height: 2px; border-radius: 2px; }
.stops-bar::before { right: 0; background: var(--border-strong); }
.stops-bar::after { width: var(--done); background: var(--rc); }
.stops-bar span { position: absolute; top: 7px; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--raised); box-shadow: inset 0 0 0 1.5px var(--border-strong); z-index: 1; }
.stops-bar span.done { background: var(--rc); box-shadow: none; }
.stops-bar span.now { width: 12px; height: 12px; margin: -6px 0 0 -6px; background: var(--rc); box-shadow: 0 0 0 2px var(--raised); }
.play-note { line-height: 1.5; }
.play-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.play-controls .icon-btn[disabled] { opacity: 0.4; cursor: default; }
.play-read { color: var(--accent-text); }

@media (min-width: 1024px) {
  .map-stage { height: max(540px, calc(100vh - 250px)); }
  .map-legend { right: auto; max-width: calc(100% - 380px); }
  .map-legend .pills { flex-wrap: wrap; }
  .map-detail-overlay { right: 16px; top: 16px; width: 320px; max-height: calc(100% - 196px); overflow-y: auto; border-radius: var(--r-lg); box-shadow: var(--shadow-3); }
  .map-detail-overlay .card { box-shadow: none; }
  .map-era-overlay { left: 16px; bottom: 16px; width: min(520px, calc(100% - 420px)); }
  .map-era-overlay .card { box-shadow: var(--shadow-3); }
}

/* ---------------------------------------------------------------- timeline */

.tl { position: relative; padding-left: 28px; }
.tl::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 2px; }
.tl-item { position: relative; padding: 10px 12px 14px; margin: 0 -12px 4px; border-radius: var(--r-md); scroll-margin-top: calc(var(--appbar-h) + 20px); }
.tl-item::before {
  content: ""; position: absolute; left: -26px; top: 15px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--tone-fg, var(--accent)); border: 3px solid var(--raised);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.tl-item.focus { background: var(--accent-soft); }
.tl-year { font-weight: 800; font-size: 0.875rem; color: var(--tone-fg, var(--accent-text)); }
.tl-title { font-weight: 700; font-size: 1rem; margin: 2px 0 4px; }
.tl-desc { color: var(--muted); font-size: 0.875rem; line-height: 1.6; max-width: 76ch; }
.tl-people { color: var(--muted); font-size: 0.8125rem; margin-top: 4px; }

/* links between councils, fathers, timeline and map */
.ref-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ref-link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--raised); color: var(--text);
  font-size: 0.8125rem; font-weight: 600; line-height: 1.3;
  text-decoration: none;
}
.ref-link:hover { border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.ref-link svg { flex: 0 0 auto; color: var(--accent-text); }
.pill-gap { flex: 0 0 8px; }
.card-group[hidden], .entry-card[hidden] { display: none; }
.card-group > .section-title { margin: 4px 0 12px; }

/* creed comparison: added in 381 / dropped from 325 */
.diff-in { background: var(--success-soft); color: var(--text); padding: 1px 0; }
.diff-out { background: var(--danger-soft); color: var(--muted); text-decoration: line-through; padding: 1px 0; }

/* -------------------------------------------------- fathers, councils, … */

.entry-card { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: calc(var(--appbar-h) + 20px); }
.entry-card.focus { box-shadow: 0 0 0 3px var(--accent-text), var(--shadow-2); }
.entry-head { display: flex; gap: 14px; align-items: flex-start; }
.entry-head h3 { font-size: 1.0625rem; font-weight: 700; line-height: 1.3; }
.entry-head .meta { margin-top: 2px; }
.entry-card p { font-size: 0.875rem; color: var(--muted); line-height: 1.6; }
.entry-card p b { color: var(--text); }
.entry-card .btn-row { margin-top: auto; padding-top: 4px; }
.avatar {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 0.9375rem;
  background: var(--tone-bg); color: var(--tone-fg);
}
/* A Father's portrait (data/portraits/): a little larger than the initials, so the face reads. */
.avatar-photo {
  width: 56px; height: 56px; flex-basis: 56px; margin: -4px 0;
  object-fit: cover; object-position: center top; background: var(--surface-2, var(--hover));
  box-shadow: 0 0 0 2px var(--surface, #fff), 0 0 0 3px var(--border);
}
.ph-portrait {
  display: block; width: 148px; aspect-ratio: 4 / 5; object-fit: cover; object-position: center top;
  border-radius: var(--r-lg, 16px); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), var(--shadow-2);
  background: rgba(255, 255, 255, 0.15);
}
@media (max-width: 719px) { .ph-portrait { width: 104px; } }

.split { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) { .split { grid-template-columns: 320px minmax(0, 1fr); gap: 24px; } }
.list-card { padding: 8px; }
.list-scroll { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 2px; }
@media (min-width: 1024px) { .list-card { position: sticky; top: calc(var(--appbar-h) + 16px); } .list-scroll { max-height: calc(100vh - var(--appbar-h) - 140px); } }
.list-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: var(--text); font-weight: 600; font-size: 0.875rem; line-height: 1.4;
  text-decoration: none; border: 0; background: none; text-align: left; width: 100%;
}
.list-item small { color: var(--muted); font-weight: 500; font-size: 0.75rem; }
.list-item:hover { background: var(--hover); text-decoration: none; color: var(--text); }
.list-item:hover small { color: var(--text); }
.list-item.active { background: var(--accent-soft); color: var(--text); }
.list-item.active small { color: var(--text); }
.detail h2 { font-family: var(--font-serif); font-size: 1.625rem; font-weight: 600; margin-bottom: 6px; }

.flashcard {
  max-width: 720px; margin: 0 auto; width: 100%;
  text-align: center; padding: 32px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.flash-front { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 600; line-height: 1.35; }
.flash-hint { color: var(--muted); font-size: 0.875rem; }
.flash-back { color: var(--text); font-size: 1rem; line-height: 1.65; white-space: pre-line; margin-top: 6px; text-align: left; max-width: 62ch; }
.flashcard .btn-row { justify-content: center; margin-top: 14px; }
@media (min-width: 720px) { .flashcard { padding: 48px 40px; } }

.lex-lemma { font-family: var(--font-serif); font-size: 2rem; font-weight: 600; line-height: 1.2; }

.tick {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 12px; margin: 0 -12px; border-radius: var(--r-md);
  cursor: pointer; font-size: 0.875rem; line-height: 1.55; color: var(--text);
}
.tick:hover { background: var(--hover); }
.tick input { margin-top: 2px; flex: 0 0 auto; width: 20px; height: 20px; }
.tick.done > span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.reading-instruction { display: block; color: var(--muted); font-size: 0.8125rem; }
.reading-link { font-size: 0.8125rem; white-space: nowrap; }
.reading-link + .reading-link { margin-left: 10px; }
.reading-edition { font-size: 0.75rem; opacity: 0.85; }
/* Courses: the Creed, key passages and questions, quoted from the bundled texts. */
.course-confess { margin: 14px 0 4px; padding: 12px 16px; border-radius: var(--r-md); background: var(--accent-soft, var(--hover)); }
.course-confess .section-title { margin-top: 0; }
.course-quote { margin: 8px 0 12px; }
.course-quote blockquote { margin: 0; font-family: var(--font-serif, Georgia, serif); font-size: 1.0625rem; line-height: 1.6; }
.course-quote figcaption { margin-top: 6px; font-size: 0.8125rem; color: var(--muted); }
.course-check { border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 14px; margin: 8px 0; }
.course-check > summary { cursor: pointer; font-weight: 600; }
.course-check[open] > summary { margin-bottom: 6px; }
.course-review { margin-top: 24px; }
.course-review p + p { margin-top: 8px; }
.course-corrections { margin-top: 12px; }
.course-corrections > summary { cursor: pointer; font-weight: 600; }
.course-checked { margin-top: 14px; }
.plain-list { margin: 0; padding-left: 20px; color: var(--muted); font-size: 0.875rem; }
.plain-list li { margin: 4px 0; }
.release { border-top: 1px solid var(--border); padding: 12px 0; }
.release:first-child { border-top: 0; padding-top: 0; }
.release summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; cursor: pointer; list-style: none; min-height: 32px; }
.release summary .muted { font-size: 0.875rem; }
.release summary::-webkit-details-marker { display: none; }
.release summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); margin-right: 4px; align-self: center; transition: transform 140ms ease; }
.release[open] summary::before { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .release summary::before { transition: none; } }
.release .plain-list { margin-top: 8px; }

.hit { display: flex; flex-direction: column; gap: 6px; }
.hit-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.hit p { font-family: var(--font-reading); font-size: 0.9375rem; line-height: 1.65; color: var(--text); }
.hits { display: flex; flex-direction: column; gap: 12px; }
/* Read aloud (library.js startNarration): a bar over the bottom of the page,
   above the tab bar on phones, and the paragraph being read. */
.tts-bar {
  position: fixed; z-index: 95; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom-offset) + 12px); width: min(560px, calc(100% - 24px));
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 10px 30px rgba(10, 20, 60, 0.22);
}
.tts-bar .tts-play { background: var(--accent-fill, var(--accent)); color: var(--on-accent); border-radius: 999px; }
.tts-status { flex: 1; min-width: 0; font-size: 0.82rem; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tts-bar .select { width: auto; min-height: 36px; padding: 4px 28px 4px 10px; font-size: 0.82rem; border-radius: 999px; }
.tts-voice { max-width: 140px; }
@media (max-width: 480px) { .tts-voice { display: none; } }
.book-prose .speaking { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); border-radius: 6px; }
#tts-start[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
@media print { .tts-bar { display: none !important; } }
/* Search everything: one card per book, its matching sections as small links. */
.book-hit-title { font-weight: 700; color: var(--text); text-decoration: none; }
.book-hit-title:hover { color: var(--accent-text); text-decoration: underline; }
.hit p.book-hit-sections { display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--font-sans); font-size: 0.82rem; line-height: 1.4; }
.book-hit-sections a { padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-hit-sections a:hover { background: var(--accent-fill, var(--accent)); color: var(--on-accent); }
.book-hit .link-btn { align-self: flex-start; }

/* citations */
.cites { display: grid; gap: 8px; }
.cite-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 10px 12px; border-radius: var(--r-md); background: var(--field); }
.cite-style { color: var(--muted); font-weight: 800; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.06em; }
.cite-row code { font-family: var(--font-serif); color: var(--text); line-height: 1.5; font-size: 0.875rem; word-break: break-word; }
.cite-row .btn { justify-self: start; }
@media (min-width: 720px) { .cite-row { grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 12px; } }

/* saved */
.saved-item { display: flex; flex-direction: column; gap: 6px; }
.saved-item h3 { font-size: 1rem; font-weight: 700; }
.saved-excerpt { font-family: var(--font-reading); font-size: 0.9375rem; line-height: 1.6; color: var(--text); }
.saved-excerpt.hl { padding: 2px 6px; border-radius: 4px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.saved-note { white-space: pre-line; border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text); font-size: 0.9375rem; }
.saved-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }

/* share dialog */
.share-preview { display: grid; place-items: center; background: var(--field); border-radius: var(--r-md); padding: 12px; }
.share-preview canvas { width: auto; max-width: 100%; max-height: 46vh; border-radius: 8px; box-shadow: var(--shadow-2); }
.share-status { font-size: 0.8125rem; color: var(--muted); min-height: 1.4em; margin-top: 10px; }
/* 1.22: editing the card — background, pattern, photo, alignment, the words themselves. */
.share-edit { margin-top: 4px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--raised); }
.share-edit > summary {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; cursor: pointer;
  font-weight: 700; font-size: 0.9rem; list-style: none; color: var(--text);
}
.share-edit > summary::-webkit-details-marker { display: none; }
.share-edit > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s; }
.share-edit[open] > summary::after { transform: rotate(-135deg); }
.share-edit-body { display: grid; gap: 14px; padding: 4px 14px 14px; }
.share-field { display: grid; gap: 8px; min-width: 0; }
.share-field[hidden] { display: none; }
.share-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; color: var(--muted); }
.share-field .seg { flex-wrap: wrap; }
.share-field input[type="range"] { width: 100%; accent-color: var(--accent); }
.share-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.share-swatch {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; cursor: pointer;
  border-radius: 50%; border: 2px solid var(--border); background: linear-gradient(135deg, var(--sw-a), var(--sw-b));
  color: #FFFFFF;
}
.share-swatch > svg { opacity: 0; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); }
.share-swatch[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 3px var(--accent-ring); }
.share-swatch[aria-pressed="true"] > svg { opacity: 1; }
.share-swatch[data-bg="parchment"], .share-swatch[data-bg="stone"] { color: #1F1C19; }
.share-swatch[data-bg="parchment"] > svg, .share-swatch[data-bg="stone"] > svg { filter: none; }
.share-swatch:focus-visible, .share-photo:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.share-photo { background: var(--field); color: var(--text); border-style: dashed; }
.share-photo > svg { opacity: 1; filter: none; }
.share-edit .textarea { min-height: 88px; }
@media (max-width: 480px) { .share-swatch { width: 44px; height: 44px; } }
@media (forced-colors: active) { .share-swatch { forced-color-adjust: none; } }

/* footer */
.site-foot {
  padding-top: 8px; padding-bottom: 28px;
  color: var(--muted); font-size: 0.8125rem; line-height: 1.7;
}
.site-foot-inner { border-top: 1px solid var(--border); padding-top: 18px; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.site-foot a { font-weight: 600; }

/* ------------------------------------------------------- touch targets */

/* Phones, tablets and any touch screen: every control is at least 44 px. */
@media (pointer: coarse), (max-width: 1023px) {
  .appbar-brand { min-height: 44px; }
  .btn-sm, .link-btn { min-height: 44px; }
  .icon-btn, .reader-tools .icon-btn { width: 44px; height: 44px; flex-basis: 44px; }
  .reader-tools .btn { min-height: 44px; }
  .chap-chip { min-width: 44px; min-height: 44px; }
  .pill, .legend-chip { min-height: 44px; }
  .seg button { min-height: 44px; }
  input[type="range"] { height: 44px; }
  .toc-list a { min-height: 44px; display: flex; align-items: center; }
  .site-foot a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
  .marker { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
  .era-mark { min-height: 44px; }
  .era-marks { height: 44px; }
  .list-item { min-height: 44px; justify-content: center; }
  .check-row { min-height: 44px; }
  .palette-row { min-height: 48px; }
}
@media (pointer: coarse) and (max-width: 719px), (max-width: 719px) {
  .reader-tools .btn { width: 44px; }
}

/* ------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------ print */

@media print {
  .sidebar, .appbar, .tabbar, .scrim, .bible-side, .reader-tools, .chap-chips, .pager, .site-foot, .ph-actions, .toasts { display: none !important; }
  .app { display: block; }
  body { background: #FFFFFF; color: #000000; }
  .page-head { background: none !important; color: #000000; padding: 0 0 12px; }
  .ph-title, .ph-sub, .ph-eyebrow { color: #000000; }
  .page-head + .page-body { margin-top: 0; }
  .card { box-shadow: none; border: 1px solid #CCCCCC; }
}

#lib-count:empty, .meta:empty { display: none; }

/* The palette and app-bar search have their own close/clear affordances. */
.palette-input input::-webkit-search-cancel-button, .appbar-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }

/* ---------------------------------------------------------------- metal
   Metallic finishes (Personalize › Metallic): metal fills carry a fine bevel,
   and banners get a slow sheen — one glide, then a long rest. Off when the
   reader prefers reduced motion or turns Shine off. */
.metal-swatches { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.metal-swatch { display: grid; justify-items: center; gap: 4px; background: none; border: 0; padding: 2px; cursor: pointer; color: var(--muted); font-size: 0.75rem; }
.metal-disc {
  position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,0.75), rgba(255,255,255,0) 45%), var(--metal);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.16), 0 3px 8px rgba(0,0,0,0.14);
  color: #0A0D16;
}
.metal-disc svg { opacity: 0; }
.metal-swatch[data-metal="graphite"] .metal-disc { color: #FFFFFF; }
.metal-swatch[aria-pressed="true"] .metal-disc { outline: 2px solid var(--text); outline-offset: 3px; }
.metal-swatch[aria-pressed="true"] .metal-disc svg { opacity: 1; }
.metal-swatch[aria-pressed="true"] .metal-name { color: var(--text); font-weight: 700; }
.metal-swatch:focus-visible .metal-disc { outline: 2px solid var(--accent-text); outline-offset: 3px; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 0.875rem; color: var(--text); cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-row .switch { flex: 0 0 auto; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.2s var(--ease); }
.switch-row .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.2s var(--ease); }
.switch-row input:checked + .switch { background: var(--accent-fill, var(--accent)); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.switch-row input:disabled ~ * { opacity: 0.5; cursor: not-allowed; }

:root[data-metal] .btn-primary,
:root[data-metal] .nav-link.active,
:root[data-metal] .seg button[aria-pressed="true"],
:root[data-metal] .chap-chip.active {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -1px 0 rgba(0, 0, 0, 0.18), 0 6px 16px rgba(0, 0, 0, 0.12);
}
:root[data-shine="on"] .page-head,
:root[data-shine="on"] .preview-banner { isolation: isolate; }
:root[data-shine="on"] .preview-banner { position: relative; }
:root[data-shine="on"] .page-head::before,
:root[data-shine="on"] .preview-banner::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, var(--sheen, 0.30)) 50%, transparent 60%) 0 0 / 300% 100% no-repeat;
  animation: nl-sheen 10.8s cubic-bezier(0.45, 0, 0.55, 1) 1.2s infinite;
  background-position: 150% 0;
}
:root[data-shine="on"][data-on-banner="light"] { --sheen: 0.12; }
@keyframes nl-sheen {
  0% { background-position: 150% 0; }
  17% { background-position: -50% 0; }
  100% { background-position: -50% 0; }
}
@media (prefers-reduced-motion: reduce) {
  :root[data-shine="on"] .page-head::before,
  :root[data-shine="on"] .preview-banner::before { animation: none; display: none; }
}

/* "Saved on this device" mark on library book tiles. */
.book-meta .on-device { display: inline-flex; color: var(--success); margin-left: 4px; }

/* ------------------------------------------- welcome strip (deep arrivals) */

.welcome-strip {
  position: fixed; z-index: 100; /* above the tab bar, under the menu and dialogs */
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom-offset) + 12px);
  width: min(calc(100vw - 24px), 640px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 14px 16px;
  border-radius: 16px; border: 1px solid var(--border);
  background: var(--raised); color: var(--text);
  box-shadow: var(--shadow-2);
}
.welcome-strip p { flex: 1 1 260px; margin: 0; font-size: 0.875rem; line-height: 1.5; color: var(--muted); }
.welcome-strip p b { color: var(--text); }
.welcome-strip-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
/* Never over the Bible's verse sheet. */
body:has(.bible-page.has-sheet) .welcome-strip { display: none; }

/* Home: the study pages, one tap from the top */
.home-jump .pill svg { color: var(--accent-text); }
@media print { .welcome-strip { display: none; } }
/* Desktop: centred in the reading column, clear of the side menu. */
@media (min-width: 1024px) {
  .welcome-strip { left: calc(50% + var(--sidebar-w) / 2); width: min(calc(100vw - var(--sidebar-w) - 48px), 640px); }
}

/* 1.36: your first study — the coach card and what it points at. */
.coach {
  position: fixed; z-index: 100;
  right: 16px; bottom: calc(var(--bottom-offset) + 12px);
  width: min(calc(100vw - 32px), 380px);
  padding: 12px 14px 12px 16px;
  border-radius: 16px; border: 1px solid var(--border); border-top: 4px solid var(--accent);
  background: var(--raised); color: var(--text); box-shadow: var(--shadow-2);
}
.coach-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.coach-eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; color: var(--accent-text); }
.coach-title { margin: 2px 0 4px; font-weight: 800; font-size: 1rem; }
.coach-text { margin: 0; font-size: 0.875rem; line-height: 1.5; color: var(--muted); }
.coach-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.coach-dots { display: inline-flex; gap: 4px; margin-right: auto; }
.coach-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.coach-dots span.on { background: var(--accent); }
.coach-target { outline: 3px solid var(--accent) !important; outline-offset: 3px; border-radius: 8px; }
@media (prefers-reduced-motion: no-preference) {
  .coach-target { animation: coach-pulse 1.6s ease-in-out infinite; }
  @keyframes coach-pulse { 50% { outline-offset: 6px; } }
}
.verse.coach-read { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 4px; }
/* With the verse sheet up, the card moves to the top, clear of it. */
body:has(.bible-page.has-sheet) .coach { bottom: auto; top: calc(var(--appbar-h) + 8px); }
@media (max-width: 1023px) { .coach { left: 12px; right: 12px; width: auto; } }
@media print { .coach { display: none; } }
body:has(#coach) .welcome-strip { display: none; }

/* On-screen Back (phones and tablets; desktop has the browser's own) */
/* 1.35: Back and Forward, at the far left of the app bar on every screen. */
.appbar-steps { flex: 0 0 auto; display: inline-flex; gap: 4px; margin-left: -6px; }
.appbar-steps .glass-btn, .appbar-steps .glass-icon { min-width: 40px; width: auto; padding: 0 8px; gap: 4px; }
.appbar-steps button:disabled { opacity: 0.45; cursor: default; }
.appbar-steps button:disabled:hover { background: var(--glass); }
.appbar-steps button:focus-visible { outline: 3px solid var(--on-banner); outline-offset: 2px; }
.appbar-steps .step-label { display: none; }
@media (min-width: 1024px) {
  .appbar-steps { margin-left: 0; }
  .appbar-steps .appbar-back { padding: 0 14px 0 8px; }
  .appbar-steps .step-label { display: inline; }
}
@media (max-width: 479px) { .appbar-brand .brand-name { display: none; } }

/* Map on phones and tablets: a place's story comes right under the map, before the era slider. */
@media (max-width: 1023px) { .map-below > .map-detail-overlay { order: -1; } }
/* While a journey plays or the quiz runs, its card comes straight under the map on phones. */
@media (max-width: 1023px) { .map-below > .map-era-overlay:has(.play-card:not([hidden])) { order: -2; } }

/* Church Fathers: a Father's page */
.profile { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) { .profile { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 24px; } .profile-side { position: sticky; top: calc(var(--appbar-h) + 16px); } }
.profile-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.profile-section h2, .profile-side h2 { font-size: 1.125rem; font-weight: 700; margin-bottom: 12px; }
.profile-section p { line-height: 1.7; max-width: 70ch; }
.profile-section p + p { margin-top: 12px; }
.profile-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; line-height: 1.6; }
.father-quote { margin: 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent); }
.father-quote + .father-quote { margin-top: 18px; }
.father-quote blockquote { margin: 0; font-family: var(--font-serif, Georgia, serif); font-size: 1.125rem; line-height: 1.6; }
.father-quote figcaption { margin-top: 8px; font-size: 0.8125rem; color: var(--muted); }
.works-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.works-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.works-list li:first-child { border-top: 0; padding-top: 0; }
.works-list li .btn { flex: 0 0 auto; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 0.875rem; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; }
.entry-link { color: inherit; text-decoration: none; }
.entry-link:hover { text-decoration: underline; }

/* ---------------------------------------------- library covers (admin: Library covers) */
.cover-foot { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cover-series { font-size: 0.5625rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Classic: cloth binding, a gilt frame and emblem, a centred serif title. */
.cover-classic {
  padding: 18px 14px 16px 18px; align-items: center; text-align: center; justify-content: flex-start; gap: 10px;
  color: #F6EEDC;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.12), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 4px),
    linear-gradient(165deg, var(--c2), var(--c1) 70%);
}
.cover-classic::after { content: ""; position: absolute; inset: 7px 7px 7px 12px; border: 1px solid rgba(217, 184, 102, 0.75); box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.12), inset 0 0 0 4px rgba(217, 184, 102, 0.35); border-radius: 2px; pointer-events: none; }
.cover-classic .cover-emblem { color: #D9B866; display: grid; place-items: center; margin-top: 2px; }
.cover-classic .cover-title { font-weight: 600; font-size: 0.9375rem; line-height: 1.2; -webkit-line-clamp: 5; line-clamp: 5; text-wrap: balance; }
.cover-classic .cover-foot { margin-top: auto; align-items: center; width: 100%; }
.cover-classic .cover-author { font-family: var(--font-serif); font-weight: 600; letter-spacing: 0.06em; color: #E9DDBF; max-width: 100%; }
.cover-classic .cover-series { color: #D9B866; max-width: 100%; }
/* Minimal: light paper, a coloured spine, dark type. */
.cover-minimal { background: #F4EFE6; color: #1E1A16; padding-left: 22px; }
.cover-minimal::before { left: 0; width: 9px; background: linear-gradient(180deg, var(--c2), var(--c1)); box-shadow: none; }
.cover-minimal .cover-author { color: #5A5148; }
.cover-minimal .cover-series { color: var(--c1); opacity: 1; }
.cover-minimal .cover-progress { background: rgba(0, 0, 0, 0.12); }
.cover-minimal .cover-progress span { background: var(--c1); }
/* Editorial: warm paper, a short accent rule, a large dark title; the author on a colour band. */
.cover-editorial { background: #F7F3EA; color: #1B1814; padding: 16px 14px 0; justify-content: flex-start; gap: 0; }
.cover-editorial::before { left: 14px; top: 14px; bottom: auto; width: 26px; height: 3px; background: var(--c1); box-shadow: none; }
.cover-editorial .cover-title { margin-top: 12px; flex-shrink: 0; font-weight: 700; font-size: 0.9375rem; line-height: 1.18; -webkit-line-clamp: 4; line-clamp: 4; }
.cover-editorial .cover-foot { margin: auto -14px 0; padding: 9px 14px 11px; background: var(--c1); }
.cover-editorial .cover-author { color: #FFFFFF; }
.cover-editorial .cover-series { color: rgba(255, 255, 255, 0.82); opacity: 1; }
.cover-editorial .cover-progress { background: rgba(255, 255, 255, 0.25); }
/* Academic: one deep colour, the author above a hairline, the title centred, the series below. */
.cover-scholar { background: var(--c1); color: #F3EBDD; padding: 14px 14px 12px; align-items: center; text-align: center; justify-content: flex-start; gap: 0; }
.cover-scholar::before, .cover-scholar::after { content: ""; position: absolute; left: 14px; right: 14px; width: auto; height: 1px; background: rgba(243, 235, 221, 0.5); box-shadow: none; }
.cover-scholar::before { top: 34px; bottom: auto; }
.cover-scholar::after { bottom: 30px; }
.cover-scholar .cover-foot { display: contents; }
.cover-scholar .cover-author { order: -1; max-width: 100%; font-family: var(--font-serif); font-weight: 600; letter-spacing: 0.12em; color: #E7DAC0; }
.cover-scholar .cover-title { order: 1; margin: auto 0; font-size: 0.9375rem; line-height: 1.2; -webkit-line-clamp: 4; line-clamp: 4; text-wrap: balance; color: #FFFFFF; }
.cover-scholar .cover-series { order: 2; max-width: 100%; color: #E7DAC0; opacity: 1; }
/* Library label: a cloth binding with a paper label holding the title and author. */
.cover-label { justify-content: center; gap: 0; padding: 14px 8px 14px 13px; background: linear-gradient(170deg, var(--c2), var(--c1) 75%); }
.cover-label .cover-title, .cover-label .cover-foot { background: #F5EEDF; color: #1E1A16; text-align: center; border: 1px solid rgba(0, 0, 0, 0.25); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.cover-label .cover-title { padding: 11px 6px 0; border-bottom: 0; border-radius: 3px 3px 0 0; font-size: 0.875rem; line-height: 1.2; -webkit-line-clamp: 3; line-clamp: 3; flex-shrink: 0; text-wrap: balance; box-shadow: none; }
.cover-label .cover-foot { padding: 7px 6px 9px; border-top: 0; border-radius: 0 0 3px 3px; align-items: center; }
.cover-label .cover-author { max-width: 100%; padding-top: 6px; border-top: 1px solid rgba(30, 26, 22, 0.25); color: var(--c1); }
.cover-label .cover-series { max-width: 100%; color: #5A5148; opacity: 1; }
/* Typographic: white paper, a colour bar across the top, a bold title in the book's colour. */
.cover-swiss { background: #FBFAF7; color: #15131A; padding: 22px 14px 14px; }
.cover-swiss::before { left: 0; right: 0; top: 0; bottom: auto; width: auto; height: 8px; background: var(--c1); box-shadow: none; }
.cover-swiss .cover-title { font-family: var(--font-ui); font-weight: 800; font-size: 1rem; line-height: 1.12; letter-spacing: -0.01em; color: var(--c1); -webkit-line-clamp: 4; line-clamp: 4; }
.cover-swiss .cover-author { color: #3D3A44; }
.cover-swiss .cover-series { color: #6B6773; opacity: 1; }
.cover-swiss .cover-progress { background: rgba(0, 0, 0, 0.1); }
.cover-swiss .cover-progress span { background: var(--c1); }
/* The newer styles break a long word only when it cannot fit on a line of its own. */
.cover-editorial .cover-title, .cover-scholar .cover-title, .cover-label .cover-title, .cover-swiss .cover-title { overflow-wrap: break-word; hyphens: auto; }
/* A cover picture chosen in the admin. */
.cover-image { padding: 0; background: var(--c1); }
.cover-image::before { display: none; }
.cover-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-image.with-title .cover-title { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 12px 12px; background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.72)); color: #FFFFFF; }

/* ------------------------------------------------- Scripture Connections
   js/connections.js: the Arcs and Threads views. The canvases take their ink
   from these tokens (light and dark); the section colours are in the script. */

.bx { container-type: inline-size; display: flex; flex-direction: column; font-family: var(--font-ui); }
.bx > .loading { padding: 64px 16px; text-align: center; }
.bx[hidden] { display: none !important; }
.bx-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--raised-alt); }
.bx-tabs, .bx-dirs { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--field); border: 1px solid var(--border); }
.bx-dirs[hidden], .bx-top .bx-btn[hidden] { display: none; }
.bx-tab, .bx-dir, .bx-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 11px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted);
  font: 600 0.8125rem/1 var(--font-ui); white-space: nowrap; cursor: pointer;
}
.bx-btn { border: 1px solid var(--border); background: var(--field); border-radius: var(--r-md); min-height: 42px; }
.bx-tab:hover, .bx-dir:hover, .bx-btn:hover { color: var(--text); background: var(--hover); }
.bx-tab[aria-pressed="true"], .bx-dir[aria-pressed="true"] { background: var(--raised); color: var(--accent-text); box-shadow: var(--shadow-chip); }
.bx-btn[aria-pressed="true"], .bx-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.bx-search { flex: 1 1 220px; display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 380px; margin-left: auto; padding: 0 12px; min-height: 42px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--field); }
.bx-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.bx-qicon { display: inline-flex; color: var(--muted); }
.bx-q { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: 1rem var(--font-ui); padding: 8px 0; }
.bx-q:focus { outline: none; }
.bx-q::placeholder { color: var(--faint); }
.bx-select {
  min-height: 42px; max-width: 200px; padding: 0 30px 0 10px; border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='14' height='14'%3E%3Cpath d='M6.4 9.4 12 14.8l5.6-5.4' fill='none' stroke='%23808AA3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 9px center / 14px;
  color: var(--text); font: 0.875rem var(--font-ui); appearance: none; -webkit-appearance: none; text-overflow: ellipsis; cursor: pointer;
}
.bx-tab:focus-visible, .bx-dir:focus-visible, .bx-btn:focus-visible, .bx-icon:focus-visible, .bx-select:focus-visible, .bx-pv:focus-visible, .bx-tv:focus-visible, .bx-rref:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.bx-filters {
  position: absolute; right: 12px; top: 62px; z-index: 6; width: min(320px, calc(100% - 24px)); display: grid; gap: 12px; padding: 14px;
  background: var(--raised); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-3);
}
.bx-filters[hidden] { display: none; }
.bx-filters label { display: grid; gap: 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); }
.bx-filters .bx-select { max-width: none; width: 100%; }
.bx-fnote { margin: 0; font-size: 0.78rem; line-height: 1.45; color: var(--muted); }

/* body: the stage or the threads, and the side panel */
.bx-body { position: relative; display: flex; height: clamp(520px, calc(100vh - var(--appbar-h) - 250px), 860px); }
.bx-stage { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.bx-stage[hidden], .bx-threads[hidden] { display: none; }
.bx-gl, .bx-ov { position: absolute; left: 0; top: 0; touch-action: none; }
/* the page-scroll strip (phones only, below) */
.bx-lane { display: none; }
/* a scroll bar that stays on touch screens: a track, and a thumb wide enough for a finger */
.bx-rail { position: absolute; z-index: 5; width: 24px; pointer-events: none; }
.bx-rail[hidden] { display: none; }
.bx-rail::before { content: ""; position: absolute; top: 4px; bottom: 4px; right: 6px; width: 4px; border-radius: 2px; background: var(--border); }
.bx-thumb { position: absolute; top: 0; right: 0; width: 24px; pointer-events: auto; touch-action: none; cursor: grab; }
.bx-thumb::after { content: ""; position: absolute; top: 3px; bottom: 3px; right: 4px; width: 8px; border-radius: 4px; background: var(--muted); opacity: 0.7; }
.bx-rail.is-drag .bx-thumb::after { background: var(--accent); opacity: 1; }
.bx.has-rails .bx-panel { padding-right: 28px; }
.bx.has-rails .bx-ttext { padding-right: 28px; }
.bx-ov { cursor: crosshair; }
.bx-legend {
  position: absolute; left: 12px; top: 12px; display: flex; gap: 22px; padding: 10px 13px; pointer-events: none;
  background: color-mix(in srgb, var(--raised) 86%, transparent); border: 1px solid var(--border); border-radius: var(--r-md);
}
.bx-legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.bx-legend li { display: flex; align-items: center; gap: 7px; font-size: 0.75rem; color: var(--text); white-space: nowrap; }
.bx-lh { margin: 0 0 6px; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.bx-sw { display: inline-block; width: 12px; height: 4px; border-radius: 2px; flex: none; }
.bx-stats { position: absolute; right: 14px; top: 12px; text-align: right; pointer-events: none; }
.bx-stats p { margin: 0 0 3px; font-size: 0.78rem; color: var(--muted); }
.bx-stats b { color: var(--text); font-weight: 700; }
.bx-stats .bx-hints { font-size: 0.72rem; color: var(--faint); }
.bx-reset { position: absolute; right: 14px; top: 76px; z-index: 3; min-height: 34px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--raised); color: var(--text); font: 600 0.78rem var(--font-ui); cursor: pointer; box-shadow: var(--shadow-chip); }
.bx-reset[hidden] { display: none; }
.bx-tip {
  position: absolute; z-index: 4; display: grid; gap: 2px; min-width: 150px; padding: 8px 11px; pointer-events: none;
  background: var(--raised); border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: var(--shadow-2);
}
.bx-tip[hidden] { display: none; }
.bx-tip strong { font-size: 0.875rem; color: var(--text); }
.bx-tip span { font-size: 0.78rem; color: var(--muted); }
.bx-tip small { font-size: 0.7rem; color: var(--faint); }

/* the side panel */
.bx-panel { flex: 0 0 360px; width: 360px; overflow-y: auto; padding: 14px 16px 22px; border-left: 1px solid var(--border); background: var(--raised-alt); overscroll-behavior: contain; }
.bx-panel[hidden] { display: none; }
.bx-phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.bx-pkicker { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 0.75rem; color: var(--muted); }
.bx .bx-ptitle { margin: 4px 0 0; font-family: var(--font-ui); font-size: 1.25rem; font-weight: 800; color: var(--text); }
.bx-pnav { display: flex; gap: 4px; flex: none; }
.bx-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--raised); color: var(--muted); cursor: pointer; text-decoration: none; }
.bx-icon:hover { color: var(--text); background: var(--hover); text-decoration: none; }
.bx-icon:disabled { opacity: 0.4; cursor: default; }
.bx-pactions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.bx-pactions .btn { gap: 6px; }
.bx-psub { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 14px 0 8px; font-size: 0.76rem; color: var(--muted); }
.bx-psub b { letter-spacing: 0.1em; color: var(--text); }
.bx-ricon { display: inline-flex; color: var(--accent-text); }
.bx-pverses { list-style: none; margin: 0; padding: 0; }
.bx-pv, .bx-tv { display: grid; grid-template-columns: 1.8rem 1fr auto; gap: 8px; padding: 7px 7px; border-radius: var(--r-sm); cursor: pointer; }
.bx-pv:hover, .bx-tv:hover { background: var(--hover); }
.bx-vn { padding-top: 4px; text-align: right; font: 600 0.74rem var(--font-ui); color: var(--faint); }
.bx-vt { font-family: var(--font-reading); font-size: 1.02rem; line-height: 1.55; color: var(--text); }
.bx-vc { min-width: 1.6rem; padding-top: 4px; text-align: right; font: 700 0.8rem var(--font-ui); color: var(--muted); }
.bx-pverse { margin: 4px 0 12px; font-family: var(--font-reading); font-size: 1.12rem; line-height: 1.6; color: var(--text); }
.bx-connects { display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--raised); }
.bx-clabel { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); white-space: nowrap; }
.bx-cbar { flex: 1; display: flex; gap: 1px; height: 5px; overflow: hidden; border-radius: 3px; background: var(--field); }
.bx-cn { font: 700 0.85rem var(--font-ui); color: var(--text); }
.bx-refs { margin-top: 6px; }
.bx-rbook { display: flex; align-items: center; gap: 7px; margin: 14px 0 4px; font-size: 0.85rem; font-weight: 700; color: var(--text); }
.bx-rcard { padding: 7px 8px 9px; border-radius: var(--r-sm); }
.bx-rcard:hover { background: var(--hover); }
.bx-rrow { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.bx-racts { display: inline-flex; gap: 4px; }
.bx a.bx-rref { font-weight: 700; font-size: 0.9rem; color: var(--accent-text); text-decoration: none; }
.bx a.bx-rref:hover { text-decoration: underline; text-underline-offset: 3px; }
.bx-rtext { margin: 3px 0 0; font-family: var(--font-reading); font-size: 0.98rem; line-height: 1.55; color: var(--muted); }
.bx-copy { width: 28px; height: 28px; opacity: 0; transition: opacity 0.15s; }
.bx-rcard:hover .bx-copy, .bx-copy:focus-visible { opacity: 1; }
@media (hover: none) { .bx-copy { opacity: 1; } }
.bx-pmuted { margin: 4px 0; font-size: 0.78rem; font-weight: 400; color: var(--muted); }
.bx-perr { color: var(--danger); font-size: 0.85rem; }

/* threads */
.bx-threads { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(170px, 0.75fr); grid-template-rows: minmax(0, 1fr); }
.bx-tcol { position: relative; display: flex; flex-direction: column; min-height: 0; }
.bx-thead { padding: 14px 18px 10px; border-bottom: 1px solid var(--border); }
.bx .bx-ttitle { margin: 4px 0 10px; font-family: var(--font-ui); font-size: 1.5rem; font-weight: 800; color: var(--text); }
.bx-tnav { display: flex; flex-wrap: wrap; gap: 8px; }
.bx-tnav .btn { gap: 6px; }
.bx-tver { margin: 10px 0 0; font-size: 0.75rem; color: var(--muted); }
.bx-tver a { color: var(--accent-text); font-weight: 700; }
.bx-ttext { flex: 1; overflow-y: auto; padding: 8px 12px 32px 14px; overscroll-behavior: contain; }
.bx-tv .bx-vt { font-size: var(--reading-size, 1.125rem); }
.bx-tv.is-sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.bx-tmid { position: relative; min-width: 0; }
.bx-tcanvas { position: absolute; left: 0; top: 0; }

.bx-note { margin: 0; padding: 9px 14px; border-top: 1px solid var(--border); background: var(--raised-alt); font-size: 0.75rem; color: var(--muted); }

/* full screen (the Fullscreen API, or a fixed layer where it is missing) */
.bx:fullscreen, .bx.bx-full { width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--raised); }
.bx.bx-full { position: fixed; inset: 0; z-index: 2147483000; height: 100vh; height: 100dvh; }
html.bx-full-on, html.bx-full-on body { overflow: hidden !important; }
.bx:fullscreen .bx-body, .bx.bx-full .bx-body { flex: 1 1 auto; height: auto; min-height: 0; }
.bx:fullscreen .bx-note, .bx.bx-full .bx-note { display: none; }
.bx::backdrop { background: var(--canvas); }

/* narrower cards: the panel slims, then stacks under the map */
@container (max-width: 1340px) {
  .bx.has-panel .bx-legend { display: none; }
}
@container (max-width: 1080px) {
  .bx-panel { flex-basis: 320px; width: 320px; }
  .bx-legend { display: none; }
}
@container (max-width: 780px) {
  .bx-top { padding: 8px; gap: 6px; }
  .bx-search { order: 9; flex: 1 0 100%; max-width: none; margin-left: 0; }
  .bx-select { max-width: 150px; }
  .bx-tab span, .bx-top .bx-btn span, .bx-dir span { display: none; }
  .bx-top .bx-full-btn span { display: inline; }
  .bx-body { flex-direction: column; height: auto; }
  .bx-stage { flex: none; height: 62vh; min-height: 380px; }
  .bx-stats { left: 10px; right: 10px; text-align: left; }
  .bx-stats p { font-size: 0.72rem; }
  .bx-reset { top: auto; bottom: 72px; }
  .bx.has-rails .bx-stats, .bx.has-rails .bx-reset { right: 46px; }
  /* Under the map the panel runs on down the page (no box inside a box to get stuck in). */
  .bx-panel { flex: none; width: auto; max-height: none; overflow: visible; border-left: 0; border-top: 1px solid var(--border); }
  .bx-threads { grid-template-columns: minmax(0, 1fr) 64px; height: 68vh; }
  .bx-ttext { overscroll-behavior: auto; }
  .bx-filters { top: 110px; }
  .bx.has-rails .bx-lane {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 3; width: 36px; touch-action: pan-y;
    border-left: 1px solid var(--border); background: var(--raised-alt); color: var(--muted);
  }
  .bx-lane::before, .bx-lane::after { content: ""; width: 4px; height: 22%; border-radius: 2px; background: var(--border); }
  /* full screen on a phone: the map (or the text) fills what the panel leaves, and each scrolls inside */
  .bx.has-rails.bx-full .bx-lane, .bx.has-rails:fullscreen .bx-lane { display: none; }
  .bx.bx-full .bx-stage, .bx:fullscreen .bx-stage { flex: 1 1 auto; height: auto; min-height: 220px; }
  .bx.bx-full .bx-threads, .bx:fullscreen .bx-threads { flex: 1 1 auto; height: auto; min-height: 0; }
  .bx.bx-full .bx-panel, .bx:fullscreen .bx-panel { flex: 0 1 auto; max-height: 44%; overflow-y: auto; overscroll-behavior: contain; }
  .bx.bx-full .bx-stats, .bx:fullscreen .bx-stats, .bx.bx-full .bx-reset, .bx:fullscreen .bx-reset { right: 10px; }
  .bx.bx-full .bx-top, .bx:fullscreen .bx-top { padding-top: max(8px, env(safe-area-inset-top)); }
  .bx.bx-full .bx-body, .bx:fullscreen .bx-body { padding-bottom: env(safe-area-inset-bottom); }
}
@container (max-width: 420px) {
  .bx-tnav .btn span { display: none; }
}
/* Gallery (the default): the book's public-domain painting fills the cover; a soft
   shade rises from the foot to carry the title in the reading serif, a short gilt
   rule and the author in spaced capitals. Books without a painting wear .cover-classic. */
.books.gallery .cover { aspect-ratio: 20 / 29; }
.cover-gallery { padding: 0 12px 13px; justify-content: flex-end; align-items: center; text-align: center; gap: 0; background: var(--c1); color: #FBF7EF; }
.cover-gallery img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-gallery::before { z-index: 1; left: 6px; width: 1px; background: rgba(255, 255, 255, 0.14); box-shadow: none; }
.cover-gallery::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(14, 11, 8, 0) 40%, rgba(14, 11, 8, 0.42) 60%, rgba(14, 11, 8, 0.8) 80%, rgba(14, 11, 8, 0.92)); }
.cover-gallery .cover-title, .cover-gallery .cover-foot { position: relative; z-index: 1; }
.cover-gallery .cover-title { font-weight: 600; font-size: 0.9375rem; line-height: 1.2; -webkit-line-clamp: 3; line-clamp: 3; text-wrap: balance; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25); }
.cover-gallery .cover-foot { width: 100%; align-items: center; gap: 3px; margin-top: 7px; padding-top: 8px; background: linear-gradient(#D9B866, #D9B866) center top / 20px 1px no-repeat; }
.cover-gallery .cover-author { font-family: var(--font-serif); font-weight: 600; letter-spacing: 0.1em; color: #E8D5A6; max-width: 100%; }
.cover-gallery .cover-series { color: #E8D5A6; max-width: 100%; }
.cover-gallery .cover-progress { z-index: 2; }

/* The Library's size control: a compact list, or small, medium (the usual) or large covers. */
@media (min-width: 720px) { .lib-tools { grid-template-columns: minmax(0, 1fr) 200px auto; max-width: 900px; } }
.lib-size button { min-width: 44px; padding: 0 10px; display: inline-grid; place-items: center; }
.book-author { display: none; }
.books.size-small { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.books.size-small .book { padding: 8px; gap: 8px; }
.books.size-small .cover:not(.cover-gallery) { padding: 10px 9px 10px 12px; }
.books.size-small .cover-gallery { padding: 0 8px 9px; }
.books.size-small .cover-title { font-size: 0.8125rem; -webkit-line-clamp: 3; line-clamp: 3; }
.books.size-small .cover-author { font-size: 0.5625rem; }
.books.size-small .cover-series, .books.size-small .cover-emblem { display: none; }
/* Small painted covers keep two lines of title low in a deeper shade; the name is under the cover. */
.books.size-small .cover-gallery .cover-title { font-size: 0.75rem; -webkit-line-clamp: 2; line-clamp: 2; }
.books.size-small .cover-gallery .cover-foot { display: none; }
.books.size-small .cover-gallery::after { background: linear-gradient(180deg, rgba(14, 11, 8, 0) 45%, rgba(14, 11, 8, 0.6) 68%, rgba(14, 11, 8, 0.9) 88%, rgba(14, 11, 8, 0.94)); }
.books.size-small .book-title { font-size: 0.75rem; }
.books.size-large { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 26px; }
@media (min-width: 1600px) { .books.size-large { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); } }
.books.size-large .cover-title { font-size: 1.25rem; }
.books.size-large .cover-author { font-size: 0.75rem; }
.books.size-large .cover-gallery { padding: 0 18px 18px; }
.books.size-large .book-title { font-size: 0.875rem; }
.books.size-list { grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 900px) { .books.size-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.books.size-list .book { flex-direction: row; align-items: center; gap: 14px; padding: 8px 12px 8px 8px; }
.books.size-list .book:hover { transform: none; }
.books.size-list .cover { flex: 0 0 40px; width: 40px; aspect-ratio: 2 / 3; padding: 0; border-radius: 4px; }
.books.size-list .cover > :not(img):not(.cover-progress), .books.size-list .cover::after { display: none; }
.books.size-list .book-info { flex: 1 1 auto; padding: 0; gap: 3px; }
.books.size-list .book-title { -webkit-line-clamp: 1; line-clamp: 1; }
.books.size-list .book-author { display: block; font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-cover { font-size: 0.8125rem; opacity: 0.9; }

/* Favorites: a star on the book's page, and a small one beside starred books in the Library. */
.work-fav svg { opacity: 0.55; transition: opacity 0.15s var(--ease), transform 0.2s var(--ease); }
.work-fav[aria-pressed="true"] svg { opacity: 1; color: var(--warning); }
.work-fav[aria-pressed="true"]:active svg { transform: scale(1.18); }
.book-fav { color: var(--warning); display: inline-flex; vertical-align: -2px; }
.fav-list { display: grid; gap: 4px; }
.fav-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--r-md); color: inherit; text-decoration: none; }
.fav-item:hover, .fav-item:focus-visible { background: var(--hover); }
.fav-item .fav-star { color: var(--warning); flex: none; display: inline-flex; }
.fav-item .fav-text { min-width: 0; flex: 1; }
.fav-item .fav-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-item .fav-sub { color: var(--muted); font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head .work-fav[aria-pressed="true"] { background: var(--glass-hover); color: var(--on-banner); }
.page-head .work-fav[aria-pressed="true"] svg { color: #FFD866; }

/* Scanned books: "p. 27" where a page of the printed book begins, the page itself in a
   dialog, and "Report a mistake" (web/js/library.js openScanPage, openReport). */
.scan-page {
  display: inline-flex; align-items: center; gap: 3px; vertical-align: 0.12em;
  margin-right: 0.5em; padding: 1px 7px; min-height: 22px;
  border: 1px solid var(--border); border-radius: 999px; background: transparent;
  color: var(--muted); font: 600 0.62em/1.4 var(--font-sans); letter-spacing: 0.02em;
  cursor: pointer; user-select: none; -webkit-user-select: none; white-space: nowrap;
}
.scan-page:hover, .scan-page:focus-visible { color: var(--accent-text); border-color: var(--accent-text); background: var(--accent-soft); }
.prose-sub .scan-page { text-transform: none; letter-spacing: 0.02em; font-size: 0.78em; }
.scan-dialog.dialog.wide { max-width: 980px; }
.scan-dialog .dialog-body { padding-top: 4px; }
.scan-stage { position: relative; }
.scan-frame {
  position: relative; display: flex; justify-content: center; align-items: flex-start;
  /* The page as tall as the window allows, leaving room for the slider and buttons below. */
  min-height: min(46vh, calc(92dvh - 320px)); max-height: max(260px, calc(92dvh - 305px)); overflow: auto; overscroll-behavior: contain;
  background: var(--sunken, rgba(127, 127, 127, 0.08)); border-radius: var(--r-md, 12px);
  touch-action: pan-y pinch-zoom;
}
.scan-frame.zoomed { touch-action: auto; }
.scan-status { align-self: center; padding: 24px; text-align: center; }
.scan-image { display: block; max-width: 100%; max-height: max(260px, calc(92dvh - 305px)); width: auto; height: auto; cursor: zoom-in; background: #fff; transition: opacity 0.15s; }
.scan-image.waiting { opacity: 0.45; }
.scan-image[hidden] { display: none; }
.scan-frame.zoomed .scan-image { max-height: none; width: 100%; cursor: zoom-out; }
/* Big arrows at the sides of the page, the easiest way to turn it. */
.scan-side {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 64px; border: 1px solid var(--border); border-radius: 12px;
  background: color-mix(in srgb, var(--raised) 88%, transparent); color: var(--text);
  box-shadow: var(--shadow-2); cursor: pointer;
}
.scan-side.prev { left: 8px; }
.scan-side.next { right: 8px; }
.scan-side:hover, .scan-side:focus-visible { background: var(--raised); color: var(--accent-text); border-color: var(--accent-text); }
.scan-side:disabled { opacity: 0; pointer-events: none; }
.scan-busy {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite;
}
.scan-busy[hidden] { display: none; }
.scan-caption { margin-top: 10px; text-align: center; }
.scan-seek { display: flex; align-items: center; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.scan-slider { flex: 1 1 240px; min-width: 0; accent-color: var(--accent); height: 28px; cursor: pointer; }
.scan-go { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.scan-go .input { width: 5.5em; padding-top: 6px; padding-bottom: 6px; text-align: center; }
.scan-dialog .dialog-foot { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.scan-nav { display: flex; gap: 4px; margin-right: auto; }
/* In the reader: the button a little brighter than its neighbours, and a first-time tip. */
.btn.btn-scan { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
/* "Page beside" (1.20.6, library.js mountScanSide): the printed page in a column next to the
   text, staying in view as the text scrolls; only where there is room for both. */
.scan-side-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
@media (max-width: 1099px) { .scan-side-toggle { display: none !important; } }
@media (min-width: 1100px) {
  .reader-layout.scanside { grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr); }
  .reader-layout.scanside #toc { grid-column: 1 / -1; position: static; }
  .reader-layout.scanside #reading .book-prose { max-width: none; }
  html.reading-focus .reader-layout.scanside { display: grid; max-width: 1560px; margin: 0 auto; gap: 20px; }
  html.reading-focus .reader-layout.scanside #reading.card { max-width: none; margin-left: 0; margin-right: 0; }
}
.scan-beside {
  position: sticky; top: calc(var(--appbar-h, 64px) + 16px); align-self: start;
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  max-height: calc(100dvh - var(--appbar-h, 64px) - 32px);
}
html.reading-focus .scan-beside { top: 48px; max-height: calc(100dvh - 64px); margin-top: clamp(28px, 7vh, 72px); }
.scan-side-head { display: flex; align-items: center; gap: 4px; }
.scan-side-label { flex: 1; text-align: center; font-weight: 700; }
.scan-side-follow { flex: none; }
.scan-side-frame {
  position: relative; flex: 1; min-height: 240px; overflow: auto; display: flex; justify-content: center; align-items: flex-start;
  background: var(--sunken, rgba(127, 127, 127, 0.08)); border-radius: var(--r-md, 12px);
}
.scan-side-image { display: block; max-width: 100%; max-height: calc(100dvh - var(--appbar-h, 64px) - 110px); background: #fff; cursor: zoom-in; transition: opacity 0.15s; }
html.reading-focus .scan-side-image { max-height: calc(100dvh - 140px); }
.scan-side-image.waiting { opacity: 0.45; }
.scan-side-image[hidden] { display: none; }
.scan-side-status { align-self: center; padding: 24px; text-align: center; }
.scan-save-progress { margin-top: 14px; }
.scan-save-progress .bar { height: 8px; border-radius: 4px; background: var(--sunken, rgba(127, 127, 127, 0.15)); overflow: hidden; }
.scan-save-progress .bar span { display: block; height: 100%; width: calc(var(--p, 0) * 1%); background: var(--accent); transition: width 0.2s; }
.scan-save-progress p { margin-top: 6px; }
#saved-scans .offline-row a { font-weight: 700; }
.btn.btn-scan:hover { border-color: var(--accent-text); }
.scan-tip {
  display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding: 12px 12px 12px 16px;
  border-radius: var(--r-md, 12px); background: var(--accent-soft); color: var(--text);
}
.scan-tip > svg { flex: none; color: var(--accent-text); }
.scan-tip p { flex: 1; margin: 0; font-size: 0.9rem; line-height: 1.45; }
.scan-tip .btn { flex: none; }
.scan-tag {
  display: inline-flex; align-items: center; flex: 0 0 auto; margin-left: auto;
  padding: 2px 6px; border-radius: 99px; background: var(--sky-soft); color: var(--sky);
}
.audio-tag + .scan-tag { margin-left: 0; }
.book-prose .scan-flash { animation: nl-flash 2.4s ease-out; border-radius: 6px; }
.report-row { display: flex; justify-content: center; margin-top: 18px; }
.report-row .btn { color: var(--muted); }
.report-chip {
  position: fixed; z-index: 150; box-shadow: var(--shadow-3);
  background: var(--raised); color: var(--text); border: 1px solid var(--border);
}
.report-error { margin-top: 12px; color: var(--danger, #C2412D); font-size: 0.875rem; }
@media (max-width: 600px) {
  .scan-frame { max-height: max(220px, calc(92dvh - 300px)); min-height: 36vh; }
  .scan-image { max-height: max(220px, calc(92dvh - 300px)); }
  .scan-frame.zoomed .scan-image { width: 220%; max-width: none; }
  .scan-side { width: 36px; height: 52px; }
  .scan-side.prev { left: 4px; }
  .scan-side.next { right: 4px; }
  .scan-seek { gap: 8px; }
  .scan-go label { display: none; }
  .scan-dialog .dialog-foot .btn:not([data-scan-read]) span { display: none; }
  .scan-dialog .dialog-foot .btn:not([data-scan-read]) { width: 44px; padding: 0; justify-content: center; }
  .scan-tip { flex-wrap: wrap; }
  .scan-tip p { flex-basis: calc(100% - 64px); }
}
@media print { .scan-page, .report-row, .report-chip { display: none !important; } }

/* Reading settings and Focus (web/js/library.js readSettingsHTML): column width, line
   spacing, sepia paper, and a reading view with nothing but the text. */
html[data-read-width="narrow"] .book-prose { max-width: 58ch; }
html[data-read-width="wide"] .book-prose { max-width: 92ch; }
html[data-read-spacing="compact"] .book-prose { line-height: 1.6; }
html[data-read-spacing="airy"] .book-prose { line-height: 2.05; }
html[data-read-spacing="airy"] .book-prose p { margin-bottom: 1.3em; }
html[data-read-paper="sepia"] #reading.card { background: #F6EEDC; color: #3B2F1E; border-color: #E6D8BA; }
html[data-read-paper="sepia"] #reading .meta, html[data-read-paper="sepia"] #reading .muted { color: #6E5B40; }
html[data-read-paper="sepia"] #reading .prose-sub { color: #7A4E1C; }
html[data-read-paper="sepia"] #reading a:not(.btn) { color: #7A4E1C; }
html[data-read-paper="sepia"] #reading .scan-page { color: #6E5B40; border-color: #D9C8A4; }
html[data-theme="dark"][data-read-paper="sepia"] #reading.card { background: #2A241A; color: #EADFC6; border-color: #3B3324; }
html[data-theme="dark"][data-read-paper="sepia"] #reading .meta, html[data-theme="dark"][data-read-paper="sepia"] #reading .muted { color: #BFAE8C; }
html[data-theme="dark"][data-read-paper="sepia"] #reading .prose-sub, html[data-theme="dark"][data-read-paper="sepia"] #reading a:not(.btn) { color: #E2B877; }
.read-set { border: 0; padding: 0; margin: 0 0 14px; }
.read-set .seg { display: flex; flex-wrap: wrap; }
html.reading-focus .sidebar, html.reading-focus .appbar, html.reading-focus .tabbar,
html.reading-focus .page-head, html.reading-focus #toc, html.reading-focus #work-cite-box,
html.reading-focus .site-footer, html.reading-focus footer, html.reading-focus .read-progress,
html.reading-focus #reading .place-tools, html.reading-focus .welcome-strip { display: none !important; }
html.reading-focus .main-col { margin-left: 0 !important; padding-left: 0 !important; }
html.reading-focus .reader-layout { display: block; }
html.reading-focus #reading.card { max-width: none; margin: 24px auto; box-shadow: none; }
html.reading-focus #reading .book-prose { margin-left: auto; margin-right: auto; }
/* The page body tucks up under the banner (a negative margin); with the banner gone in Focus that
   pulled the title off the top of the screen. */
html.reading-focus .page-body { padding-top: 0; margin-top: 0 !important; }

/* 1.16 — "What the Fathers said (N)" on the selected verse, and room for the
   "Fathers & commentaries" study tab (web/js/bible.js, web/js/study.js). */
.verse-panel .fathers-said {
  width: 100%; margin-top: 14px; justify-content: flex-start;
  background: var(--accent-soft); color: var(--accent-text);
}
.verse-panel .fathers-said:hover { filter: brightness(0.97); }
.verse-panel .fathers-said span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Each tab as wide as its label needs, the spare room shared out (the labels differ in length). */
.study-tabs button { flex: 1 1 auto; }

/* Search inside a work, grouped by section (web/js/library.js renderFind). */
.hit-group { padding: 16px 18px; margin-bottom: 12px; }
.hit-group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; font-size: 1rem; font-weight: 800; margin: 0 0 6px; }
.hit-group-head a { color: var(--text); }
.hit-snippet { display: block; color: inherit; padding: 8px 0; border-top: 1px solid var(--border); text-decoration: none; }
.hit-snippet:first-of-type { border-top: 0; }
.hit-snippet:hover p { color: var(--text); }
.hit-snippet p { margin: 0; color: var(--muted); font-family: var(--font-reading); line-height: 1.6; }
.hit-more { display: inline-block; margin-top: 6px; }

/* Install & offline (web/js/library.js renderOffline). */
.offline-page .card + .card { margin-top: 16px; }
.offline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0; }
.steps { margin: 10px 0 12px 1.2em; line-height: 1.7; }
html.reading-focus .app { display: block; }
html.reading-focus .reader-layout { grid-template-columns: minmax(0, 1fr); }
html.reading-focus #reading.card { max-width: 980px; padding-left: clamp(16px, 5vw, 56px); padding-right: clamp(16px, 5vw, 56px); }
/* Focus as a reading room (1.20.4, web/js/library.js mountFocusDock): room above the text and
   below it for the dock, a thin line for how far through the section, and the dock itself. */
html.reading-focus #reading.card {
  margin: clamp(28px, 7vh, 72px) auto calc(120px + env(safe-area-inset-bottom, 0px));
  padding-top: clamp(24px, 4vh, 44px);
}
html.reading-focus #reading .reader-title { font-size: clamp(1.5rem, 2.4vw, 2rem) !important; }
html.reading-focus #reading .reader-tools #focus-toggle,
html.reading-focus #reading .reader-tools #read-settings,
html.reading-focus #reading .reader-tools [data-size],
html.reading-focus #reading .reader-tools .size-label { display: none; }
.focus-line { position: fixed; z-index: 160; top: 0; left: 0; right: 0; height: 3px; pointer-events: none; }
.focus-line span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s linear; }
/* The toolbar runs down the right-hand side and stays there (the user asked for it beside
   the text, always on); the colours of the highlighter open beside the pen. */
.focus-dock {
  position: fixed; z-index: 155; right: max(12px, env(safe-area-inset-right, 0px)); top: 50%;
  transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px;
  max-height: calc(100dvh - 24px); padding: 6px; overflow-y: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--raised) 94%, transparent); color: var(--text);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-3);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.focus-dock::-webkit-scrollbar { display: none; }
.focus-dock .icon-btn { width: 40px; height: 40px; flex: none; border-radius: 12px; }
.focus-dock .icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.focus-dock .icon-btn:disabled { opacity: 0.35; }
.focus-dock .sel-sep { flex: none; width: 24px; height: 1px; margin: 3px 0; }
.focus-colors { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; flex: none; }
.focus-colors[hidden] { display: none; }
.focus-colors .sel-swatch { width: 26px; height: 26px; }
.focus-colors .sel-swatch[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--raised) inset; }
.focus-leave { flex: none; width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 12px; }
.focus-leave span { display: none; }
.focus-where {
  position: fixed; z-index: 150; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; align-items: baseline; max-width: calc(100vw - 120px);
  padding: 4px 12px; border-radius: 999px; pointer-events: none;
  background: var(--raised); border: 1px solid var(--border); box-shadow: var(--shadow-2); color: var(--muted); font-size: 0.75rem; line-height: 1.4;
}
.focus-where b { color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.focus-where span { white-space: nowrap; }
/* Room for the toolbar beside the text where the window is not wide enough for both. */
@media (max-width: 1180px) { html.reading-focus .main-col { padding-right: 64px !important; } }
html.pen-on #reading .book-prose { cursor: text; touch-action: pan-y pinch-zoom; -webkit-touch-callout: none; }
html.pen-on #reading .book-prose ::selection { background: var(--hl-gold); }
@media (max-width: 719px) {
  .focus-dock { right: 4px; padding: 4px; }
  .focus-dock .icon-btn, .focus-leave { width: 36px; height: 38px; }
  .focus-dock [data-focus="width"] { display: none; }
  .focus-where b { display: none; }
  html.reading-focus .main-col { padding-right: 46px !important; }
  html.reading-focus #reading.card { margin-top: 0; padding-top: 40px; border-radius: 0; border-left: 0; border-right: 0; }
}
@media print { .focus-dock, .focus-line, .focus-where { display: none !important; } }

/* Highlights and notes in books, and the bar over selected words (web/js/library.js watchSelection). */
.sel-bar {
  position: fixed; z-index: 150; display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-3);
}
.sel-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.sel-swatch:hover, .sel-swatch:focus-visible { border-color: var(--text); }
.sel-sep { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.sel-btn { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; color: var(--text); font: 600 0.8125rem var(--font-sans); cursor: pointer; }
.sel-btn:hover, .sel-btn:focus-visible { background: var(--accent-soft); color: var(--accent-text); }
@media (max-width: 600px) { .sel-btn span:not(.sr-only) { display: none; } .sel-btn { padding: 0 8px; } .sel-swatch { width: 30px; height: 30px; } }
#reading mark.bh { color: inherit; border-radius: 3px; padding: 0 1px; cursor: pointer; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
#reading mark.bh.hl-gold { background: var(--hl-gold); }
#reading mark.bh.hl-sky { background: var(--hl-sky); }
#reading mark.bh.hl-rose { background: var(--hl-rose); }
#reading mark.bh.hl-violet { background: var(--hl-violet); }
#reading mark.bh.hl-peach { background: var(--hl-peach); }
#reading mark.bh.has-note { text-decoration: underline dotted var(--accent-text); text-underline-offset: 3px; }
#reading mark.bh:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.bh-quote { margin: 0 0 14px; padding: 10px 14px; border-left: 3px solid var(--accent-text); font-family: var(--font-reading); line-height: 1.6; color: var(--text); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
@media print { .sel-bar { display: none !important; } #reading mark.bh { background: none; text-decoration: underline; } }

/* Side by side: the other edition in a second column (web/js/library.js renderParallel). */
@media (min-width: 1024px) {
  .reader-layout.parallel { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .reader-layout.parallel #toc { grid-column: 1 / -1; position: static; }
}
.reading-other .book-prose { max-width: none; }
.parallel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.parallel-edition { font: 800 0.75rem var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text); }
.parallel-nav { display: inline-flex; align-items: center; gap: 4px; }
html.reading-focus .reader-layout.parallel { display: grid; }

/* "Bible beside" (1.30, web/js/library.js mountBibleBeside): a chapter of the Bible next to
   the book. A column on the right from 1024px (its left edge drags the width), a sheet
   along the bottom below that, which folds down to its title bar. */
.bible-beside-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.bible-beside { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; min-width: 0; }
.bb-head { display: flex; align-items: center; gap: 4px; }
.bb-label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; margin: 0; font: 800 0.9375rem var(--font-sans); color: var(--text); }
.bb-label svg { flex: none; color: var(--accent-text); }
.bb-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-head .icon-btn { width: 36px; height: 36px; flex: none; }
.bb-follow[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.bb-main { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; }
.bb-tools { display: flex; flex-direction: column; gap: 6px; }
.bb-tools .select { width: 100%; min-width: 0; padding-top: 6px; padding-bottom: 6px; font-size: 0.875rem; }
.bb-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) 5.5em auto; gap: 4px; align-items: center; }
.bb-nav .icon-btn { width: 36px; height: 36px; }
.bb-nav .icon-btn:disabled { opacity: 0.35; }
.bb-body {
  position: relative; flex: 1; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  padding: 10px 12px; border-radius: var(--r-md, 12px); background: var(--sunken, rgba(127, 127, 127, 0.06));
  font-family: var(--font-reading); font-size: calc(var(--reading-size) * 0.94); line-height: 1.7; color: var(--text);
}
.bb-body:focus { outline: none; }
.bb-body:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.bb-verses { margin: 0; }
.bb-v { border-radius: 4px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.bb-v .vnum { margin-right: 3px; }
.bb-v.lit { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.bb-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.bb-alt { margin: 0; font-family: var(--font-sans); }
.bb-resize { display: none; }
@media (min-width: 1024px) {
  .reader-layout.biblebeside { grid-template-columns: minmax(0, 1fr) var(--bible-pane-w, 420px); }
  .reader-layout.biblebeside #toc { grid-column: 1 / -1; position: static; }
  .reader-layout.biblebeside #reading .book-prose { max-width: none; }
  html.reading-focus .reader-layout.biblebeside { display: grid; grid-template-columns: minmax(0, 1fr) var(--bible-pane-w, 420px); max-width: 1560px; margin: 0 auto; gap: 20px; }
  html.reading-focus .reader-layout.biblebeside #reading.card { max-width: none; margin-left: 0; margin-right: 0; }
  .bible-beside {
    position: sticky; top: calc(var(--appbar-h, 64px) + 16px); align-self: start;
    height: calc(100dvh - var(--appbar-h, 64px) - 32px);
  }
  html.reading-focus .bible-beside { top: 48px; height: calc(100dvh - 64px); margin-top: clamp(28px, 7vh, 72px); }
  .bb-fold { display: none !important; }
  .bb-resize {
    display: block; position: absolute; left: -13px; top: 0; bottom: 0; width: 12px; cursor: col-resize; touch-action: none;
    border-radius: 6px;
  }
  .bb-resize::after {
    content: ""; position: absolute; left: 4px; top: 50%; width: 4px; height: 44px; margin-top: -22px;
    border-radius: 2px; background: var(--border-strong); opacity: 0.7; transition: opacity 0.15s, background 0.15s;
  }
  .bb-resize:hover::after, .bb-resize:focus-visible::after, .bible-beside.resizing .bb-resize::after { background: var(--accent-text); opacity: 1; }
  .bb-resize:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 0; }
  .bible-beside.resizing, .bible-beside.resizing ~ * { user-select: none; }
}
@media (max-width: 1023px) {
  .bible-beside {
    position: fixed; z-index: 85; left: 0; right: 0; bottom: var(--bottom-offset); margin: 0;
    height: min(52dvh, 480px); padding: 8px 12px 10px;
    border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0;
    box-shadow: 0 -12px 40px rgba(10, 13, 22, 0.22);
  }
  .bible-beside.folded { height: auto; }
  .bible-beside.folded .bb-main { display: none; }
  .bb-tools { flex-direction: row; }
  .bb-tools .bb-trans { flex: 0 1 34%; }
  .bb-nav { flex: 1; }
  html.bible-sheet .page-body { padding-bottom: calc(min(52dvh, 480px) + 24px); }
  html.bible-sheet.bible-sheet-folded .page-body { padding-bottom: 80px; }
  html.reading-focus .bible-beside { bottom: 0; }
}
@media (max-width: 560px) {
  .bb-tools { flex-direction: column; }
  .bb-tools .bb-trans { flex: none; }
}
@media print { .bible-beside { display: none !important; } }

/* "You were reading … on another device" (web/js/library.js offerContinue). */
.continue-card {
  position: fixed; z-index: 140; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 12px; max-width: min(560px, calc(100vw - 24px)); padding: 10px 10px 10px 16px;
  background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
}
.continue-card > span { flex: 1 1 auto; font-size: 0.9rem; line-height: 1.4; }
@media (min-width: 1024px) { .continue-card { bottom: 24px; } }

/* ======================================================================
   v1.17 accessibility pass + the "Easy to read" reading font.
   To merge into web/css/app.css. Each block says where it belongs.
   ====================================================================== */


/* ---- 1. @font-face: append after the Literata @font-face rules (app.css ~line 24).
   Atkinson Hyperlegible (c) 2020 Braille Institute of America, SIL OFL 1.1
   (web/fonts/OFL-AtkinsonHyperlegible.txt). Only downloaded when a reader picks
   "Easy to read", because nothing else names the family. */
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/AtkinsonHyperlegible-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/AtkinsonHyperlegible-Italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/AtkinsonHyperlegible-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/AtkinsonHyperlegible-BoldItalic.woff2") format("woff2"); font-weight: 700; font-style: italic; font-display: swap; }


/* ---- 2. Reading-font variable: next to `:root[data-reading="sans"]` (app.css ~line 117).
   theme.js sets data-reading="legible". Atkinson covers Latin only, so Greek
   and Hebrew fall through to the interface sans stack exactly as "sans" does. */
:root[data-reading="legible"] { --font-reading: "Atkinson Hyperlegible", var(--font-ui); }

/* The "Aa" sample on the Personalize button (next to `.font-sample`, ~line 972). */
.font-sample.legible { font-family: "Atkinson Hyperlegible", var(--font-ui); }


/* ---- 3. Touch targets on phones: add inside the existing
   `@media (pointer: coarse), (max-width: 1023px)` block (~line 1940).
   Each was measured at 375 px wide and was under 40 px tall. */
@media (pointer: coarse), (max-width: 1023px) {
  /* Councils, Timeline, Fathers: place/event/father pills were 32 px. */
  .ref-link { min-height: 44px; }
  /* Fathers list: the name links in each entry heading were 22 px. The
     negative margin keeps the heading's layout unchanged. */
  .entry-link { display: inline-flex; align-items: center; min-height: 44px; margin-block: -11px; }
  /* Verse study panel: topic chips were 20 px, the cross-reference rows 38 px,
     the "Guide" link 36 px. Wider row gap so the taller chips do not overlap. */
  .word-places { gap: 0 14px; }
  .chip-link { display: inline-flex; align-items: center; min-height: 44px; }
  .study-row { min-height: 44px; }
  .study-guide-link { display: inline-flex; align-items: center; min-height: 44px; }
  /* Phone menu (More): the brand link was 38 px, the account and footer links 20 px. */
  .side-home { min-height: 44px; }
  .acct-side-link { min-height: 44px; }
  .side-links a { display: inline-flex; align-items: center; min-height: 44px; }
}


/* ---- 4. Focus visibility: next to `.map-menu button:hover, ...:focus-visible` (~line 1709).
   The map's Explore menu showed keyboard focus only as the pale accent-soft
   fill (about 1.2:1 against the menu); add a ring that reads at 3:1+. */
.map-menu button:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-text); }


/* ---- 5. Windows High Contrast / forced colours: append near the reduced-motion
   block (~line 1964). Pressed/current states are drawn only with background
   fills, which forced-colours mode removes, so the chosen segment, pill, swatch,
   chapter or selected verse became invisible. Draw them with a system colour. */
@media (forced-colors: active) {
  [aria-pressed="true"], [aria-current="page"], [aria-selected="true"], .chap-chip.active {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
  .switch { border: 1px solid CanvasText; }
}

/* Inside the Android app (core.js "store-app"): no donation links (store payment rules). */
html.store-app a[href*="honestapologist.com/donate"] { display: none !important; }

/* ---- 1.21: a book's typography (Reading settings → Typography: Book, the default). A
   drop capital opens each section, figures sit like a printed book's (old-style), the right
   edge is even (with hyphenation), lines avoid one-word endings, and a fleuron marks the
   breaks. Nothing changes the words themselves: highlights, quotes and narration read the same. */
html[data-read-type="book"] .book-prose {
  font-variant-numeric: oldstyle-nums proportional-nums; font-kerning: normal;
  font-variant-ligatures: common-ligatures; hanging-punctuation: first allow-end;
}
html[data-read-type="book"] .book-prose p:not(.verse) { text-align: justify; text-wrap: pretty; }
html[data-read-type="book"] .book-prose sup, html[data-read-type="book"] .book-prose .scan-page { font-variant-numeric: lining-nums tabular-nums; }
html[data-read-type="book"] .book-prose > p.lead::first-letter {
  initial-letter: 3 2; -webkit-initial-letter: 3 2; color: var(--accent-text); font-weight: 600; margin-right: 0.14em;
}
@supports not ((initial-letter: 3) or (-webkit-initial-letter: 3)) {
  html[data-read-type="book"] .book-prose > p.lead::first-letter {
    float: left; font-size: 3.35em; line-height: 0.82; padding: 0.07em 0.1em 0 0; color: var(--accent-text); font-weight: 600;
  }
}
html[data-read-type="book"] .book-prose > p.lead::first-line { font-variant-caps: small-caps; letter-spacing: 0.03em; }
html[data-read-type="book"] .book-prose > .prose-sub::before {
  content: "\2766"; display: block; text-align: center; font-family: var(--font-reading); font-size: 1.25rem; font-weight: 400;
  letter-spacing: 0; text-transform: none; color: var(--accent-text); opacity: 0.75; margin: 0 0 1.1em;
}
html[data-read-type="book"] .book-prose > p:last-child::after {
  content: "\2766"; display: block; text-align: center; margin-top: 1.6em; color: var(--accent-text); opacity: 0.6; font-size: 1.15em; text-indent: 0;
}
/* An even right edge only where the column is wide enough not to open gaps between words. */
html[data-read-type="book"] .book-prose { container-type: inline-size; }
@container (max-width: 34em) {
  html[data-read-type="book"] .book-prose p:not(.verse) { text-align: start; }
}

/* Wider letters and words: more room between letters, words and lines. */
html[data-read-letters="wide"] .book-prose, html[data-read-letters="wide"] #reading .prose {
  letter-spacing: 0.035em; word-spacing: 0.16em; line-height: 1.95;
}
html[data-read-letters="wide"] .book-prose p:not(.verse) { text-align: left; }

/* High-contrast paper: black on white (white on black in dark mode), links underlined. */
html[data-read-paper="contrast"] #reading.card { background: #FFFFFF; color: #000000; border-color: #000000; }
html[data-read-paper="contrast"] #reading .meta, html[data-read-paper="contrast"] #reading .muted { color: #1A1A1A; }
html[data-read-paper="contrast"] #reading .prose-sub, html[data-read-paper="contrast"] #reading a:not(.btn) { color: #00308F; }
html[data-read-paper="contrast"] #reading a:not(.btn) { text-decoration: underline; }
html[data-theme="dark"][data-read-paper="contrast"] #reading.card { background: #000000; color: #FFFFFF; border-color: #FFFFFF; }
html[data-theme="dark"][data-read-paper="contrast"] #reading .meta, html[data-theme="dark"][data-read-paper="contrast"] #reading .muted { color: #EDEDED; }
html[data-theme="dark"][data-read-paper="contrast"] #reading .prose-sub, html[data-theme="dark"][data-read-paper="contrast"] #reading a:not(.btn) { color: #9CC4FF; }
html[data-read-paper="contrast"] .book-prose > p.lead::first-letter, html[data-read-paper="contrast"] .book-prose > .prose-sub::before,
html[data-read-paper="contrast"] .book-prose > p:last-child::after { color: inherit; opacity: 1; }

/* The system's "more contrast" setting: firmer borders and muted text everywhere. */
@media (prefers-contrast: more) {
  :root, html[data-theme] { --border: color-mix(in srgb, var(--text) 55%, transparent); }
  .muted, .meta, .field-hint { color: var(--text) !important; }
  a:not(.btn):not(.pill):not(.palette-row) { text-decoration: underline; }
}
/* Touch screens: every small control at least 44 px to tap. */
@media (pointer: coarse) {
  .icon-btn { min-height: 44px; min-width: 44px; }
}

/* ---- 1.21: turning pages. The page doesn't scroll freely; the arrows, keys, wheel and swipes
   move it a screenful at a time with a short slide; the next page repeats the last line and a half. */
html.turning-pages, html.turning-pages body { overflow: hidden; overscroll-behavior: none; }
html.turning-pages #reading .book-prose { touch-action: pinch-zoom; }
html.turning-pages.pen-on #reading .book-prose { touch-action: pinch-zoom; }
.page-turn {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 30; width: 44px; height: 88px; border: 0; border-radius: 14px;
  display: grid; place-items: center; background: transparent; color: var(--muted); cursor: pointer; opacity: 0.45;
  transition: opacity 0.15s, background 0.15s;
}
.page-turn:hover, .page-turn:focus-visible { opacity: 1; background: var(--hover); color: var(--text); }
.page-turn.prev { left: max(8px, env(safe-area-inset-left)); }
.page-turn.next { right: max(8px, env(safe-area-inset-right)); }
html.reading-focus .page-turn.next { right: 76px; }
@media (hover: none) { .page-turn { display: none; } }
@media print {
  .page-turn, #page-count { display: none !important; }
  html.turning-pages, html.turning-pages body { overflow: visible !important; }
}
@media (min-width: 1024px) { html:not(.reading-focus) .page-turn.prev { left: calc(var(--sidebar-w, 0px) + 8px); } }
.page-count {
  position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 31; margin: 0;
  padding: 4px 12px; border-radius: 999px; background: var(--raised); border: 1px solid var(--border); color: var(--muted);
  font: 600 0.75rem/1.4 var(--font-sans); box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.08)); pointer-events: none;
}
body:has(.tts-bar) .page-count { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 72px); }
@keyframes nl-turn-next { from { transform: translateX(28px); opacity: 0.35; } to { transform: none; opacity: 1; } }
@keyframes nl-turn-prev { from { transform: translateX(-28px); opacity: 0.35; } to { transform: none; opacity: 1; } }
.book-prose.turn-next { animation: nl-turn-next 0.22s ease-out; }
.book-prose.turn-prev { animation: nl-turn-prev 0.22s ease-out; }
@media (prefers-reduced-motion: reduce) { .book-prose.turn-next, .book-prose.turn-prev { animation: none; } }

/* ---- 1.21: reading aloud. The sentence being read is drawn over the lit paragraph; the sleep
   timer sits in the bar; away from the book the bar becomes a mini player with its name. */
::highlight(nl-reading) { background-color: color-mix(in srgb, var(--accent) 26%, transparent); text-decoration: underline 2px; text-decoration-color: var(--accent); }
.tts-sleep { max-width: 150px; }
/* On phones the sleep timer is a moon-shaped button: the chosen option's words are hidden
   (they only fitted as a clipped first letter) and the native picker still opens on tap. */
@media (max-width: 480px) {
  select.select.tts-sleep {
    width: 44px; max-width: 44px; padding: 0 !important; color: transparent; text-shadow: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Cpath d='M19.5 14.6A7.6 7.6 0 0 1 9.4 4.5a7.6 7.6 0 1 0 10.1 10.1z' fill='none' stroke='%23808AA3' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-position: center; background-size: 20px;
  }
  select.select.tts-sleep:not(:has(option[value="off"]:checked)) { border-color: var(--accent); }
  select.select.tts-sleep option { color: var(--text); }
}
.tts-back {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 42%; padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text); font: 600 0.82rem/1.3 var(--font-sans); text-decoration: none;
}
.tts-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tts-back[hidden] { display: none; }
.tts-mini .tts-rate, .tts-mini .tts-voice { display: none; }
@media (max-width: 480px) { .tts-mini .tts-status { display: none; } .tts-back { max-width: none; flex: 1; } }

/* ---- 1.21: feast days, a highlight of the day, and the commonplace book. */
.home-feast .feast { padding: 10px 0; border-top: 1px solid var(--border); }
.home-feast .feast:first-of-type { border-top: 0; padding-top: 4px; }
.feast-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 1.02rem; }
.feast-works { margin-top: 8px; }
.feast-work { max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feast-next { margin: 0 0 4px; }
.feast-note { margin-top: 10px; }
.cp-quote {
  margin: 0; padding: 4px 0 4px 16px; border-left: 4px solid var(--hl-gold); font-family: var(--font-reading);
  font-size: 1.05rem; line-height: 1.7; white-space: pre-line;
}
.cp-quote.hl-edge-sky { border-left-color: var(--hl-sky); }
.cp-quote.hl-edge-rose { border-left-color: var(--hl-rose); }
.cp-quote.hl-edge-violet { border-left-color: var(--hl-violet); }
.cp-quote.hl-edge-peach { border-left-color: var(--hl-peach); }
html[data-theme="dark"] .cp-quote { border-left-width: 5px; }
.cp-note { margin: 8px 0 0 20px; font-style: italic; color: var(--muted); }
.home-highlight .meta { margin-top: 8px; }
.cp-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; }
.cp-filter { max-width: 320px; }
.commonplace { display: grid; gap: 16px; }
.cp-title { font-family: var(--font-reading); font-size: 1.35rem; margin: 0; }
.cp-sub { margin: 2px 0 6px; }
.cp-item { padding: 14px 0; border-top: 1px solid var(--border); }
.cp-group .cp-item:first-of-type { border-top: 0; }
.cp-where { margin: 8px 0 0 20px; }
@media print {
  .commonplace { display: block; }
  .cp-group { break-inside: auto; border: 0 !important; padding: 0 !important; margin: 0 0 18pt; }
  .cp-item { break-inside: avoid; border-top: 0.5pt solid #BBBBBB; }
  .cp-quote { border-left: 3pt solid #999999 !important; font-size: 11.5pt; color: #000000; }
  .cp-note { color: #333333; }
  .cp-tools, .cp-where a { text-decoration: none; }
  .cp-tools { display: none; }
}
.section-sub { margin: -6px 0 14px; max-width: 70ch; }

/* ---- 1.21: a screen's outline while it loads. */
.sk-head .wrap { display: grid; gap: 12px; padding-top: 28px; padding-bottom: 36px; }
.sk-body { display: grid; gap: 16px; }
.sk-body .card { display: grid; gap: 12px; }
.sk-line {
  display: block; height: 0.8rem; border-radius: 6px;
  background: linear-gradient(90deg, var(--hover) 0%, var(--pressed) 40%, var(--hover) 80%); background-size: 300% 100%;
  animation: nl-shimmer 1.3s ease-in-out infinite;
}
.sk-title { height: 1.8rem; width: 38%; }
.sk-head .sk-line { background: linear-gradient(90deg, rgba(255,255,255,.18) 0%, rgba(255,255,255,.32) 40%, rgba(255,255,255,.18) 80%); background-size: 300% 100%; }
@keyframes nl-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .sk-line { animation: none; } }

/* ---- the daily lectionary (Home's "Today's readings", #/plans/lectionary). */
.lect-title { font-family: var(--font-reading); font-size: 1.22rem; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.lect-subtitles { margin: 4px 0 0; }
.lect-set { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.lect-set-label { font-size: .92rem; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.lect-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 0; }
.lect-kind { flex: 0 0 5.5rem; font-size: .82rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.lect-ref { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
a.lect-ref { color: var(--accent-text, var(--accent)); text-decoration: none; }
a.lect-ref:hover { text-decoration: underline; }
.lect-guide { flex: 0 0 auto; }
.lect-note { margin: 10px 0 0; font-size: .92rem; }
.lect-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; margin-bottom: 14px; }
.lect-field { display: grid; gap: 4px; font-size: .86rem; color: var(--muted); min-width: 0; }
.lect-field .input, .lect-field .select { min-width: 11rem; max-width: 100%; }
.lect-date { margin: 0 0 4px; color: var(--muted); }
.lect-source { margin-top: 14px; max-width: 75ch; }
.lect-plans { margin-bottom: 20px; }
@media (max-width: 520px) {
  .lect-kind { flex-basis: 100%; }
  .lect-tools .btn-row { width: 100%; }
  .lect-field, .lect-field .input, .lect-field .select { width: 100%; }
}

/* The reading guide (1.31): level bars on a book card, the level and topic menus,
   the "New here?" shelf and the line under a book's title. */
.lib-filters select.lib-guide { width: auto; min-width: 170px; max-width: 100%; flex: 0 1 auto; }
.page-head .lib-filters select.lib-guide.is-set { border-color: var(--on-banner); background-color: var(--glass-hover); font-weight: 650; }
@media (max-width: 719px) { .lib-filters select.lib-guide { width: 100%; } }
.level-tag { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; margin-left: auto; padding: 3px 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text, var(--accent)); font-size: 0.75rem; font-weight: 750; }
.level-tag + .audio-tag, .level-tag + .scan-tag { margin-left: 0; }
.level-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.level-bars i { display: block; width: 3px; border-radius: 1px; background: currentColor; opacity: 0.28; }
.level-bars i:nth-child(1) { height: 4px; } .level-bars i:nth-child(2) { height: 7px; } .level-bars i:nth-child(3) { height: 10px; }
.level-tag.l1 .level-bars i:nth-child(1), .level-tag.l2 .level-bars i:nth-child(-n+2), .level-tag.l3 .level-bars i { opacity: 1; }
.start-shelf { margin-bottom: 18px; }
.start-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; }
.start-head h2 { margin: 0 0 4px; font-size: 1.125rem; }
.start-head p { margin: 0; }
.start-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(118px, 132px); gap: 14px; overflow-x: auto; padding: 14px 2px 6px; scroll-snap-type: x proximity; }
.start-book { display: grid; gap: 6px; color: inherit; text-decoration: none; scroll-snap-align: start; font-size: 0.8125rem; }
.start-book .start-title { font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.start-book:hover .start-title, .start-book:focus-visible .start-title { text-decoration: underline; }
.start-note { margin: 8px 0 0; font-size: 0.8125rem; }
.work-guide { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; }
.page-head .work-guide .level-tag { margin-left: 0; background: var(--glass); color: var(--on-banner); }
.work-time { opacity: 0.92; }
.topic-chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; background: var(--glass); color: var(--on-banner); font-size: 0.8125rem; font-weight: 650; text-decoration: none; }
.topic-chip:hover, .topic-chip:focus-visible { background: var(--glass-hover); text-decoration: underline; }
.work-next { display: block; margin-top: 8px; }
.work-next a { color: var(--on-banner); font-weight: 650; }

/* 1.32: a book's era, first in its guide line. */
.work-guide .era-chip { font-variant-numeric: tabular-nums; }

/* 1.33: each book's introduction above chapter 1, and one line on each chapter. */
.book-intro {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--raised);
  padding: 18px 20px; margin: 0 0 14px;
}
.book-intro .intro-eyebrow { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text); margin: 0 0 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.book-intro h3 { font-size: 1.1rem; line-height: 1.4; font-weight: 750; margin: 0 0 8px; }
.book-intro p { margin: 0 0 10px; color: var(--muted); line-height: 1.6; }
.intro-facts { display: grid; gap: 8px; margin: 4px 0 12px; }
@media (min-width: 720px) { .intro-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.intro-facts dt { font-size: 0.75rem; font-weight: 800; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.intro-facts dd { margin: 2px 0 0; font-size: 0.9rem; line-height: 1.5; }
.intro-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.intro-label { font-size: 0.8rem; color: var(--faint); margin: 10px 0 0; }
.intro-lang { font-size: 0.7rem; font-weight: 700; letter-spacing: 0; text-transform: none; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.chapter-context { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.chapter-context p { margin: 0; flex: 1 1 320px; color: var(--muted); line-height: 1.55; }
.chapter-context .cc-label { font-weight: 800; color: var(--text); margin-right: 4px; }
.intro-dialog .intro-tagline { font-size: 1.05rem; font-weight: 650; line-height: 1.5; }
.intro-dialog .intro-section h3 { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-text); margin: 18px 0 6px; }
.intro-dialog .intro-section p, .intro-dialog li { line-height: 1.6; }
.intro-dialog ul { padding-left: 1.2em; margin: 0; }
.intro-dialog .intro-outline a, .intro-dialog .intro-outline span:first-child { font-weight: 750; font-variant-numeric: tabular-nums; margin-right: 6px; }
.intro-dialog .intro-sources { font-size: 0.9rem; }

/* 1.34: encouragement — the Bible map, finish moments, the edge frame. */
.bible-map { margin-top: 18px; }
.bible-map .bm-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.bible-map .bm-head .section-title { margin: 0; }
.bible-map .bm-head p { margin: 0; }
.bm-bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 10px 0 6px; }
.bm-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.bm-group h4 { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin: 14px 0 6px; }
.bm-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 14px; }
.bm-book { display: flex; flex-direction: column; gap: 3px; padding: 4px 6px; border-radius: 8px; color: var(--text); text-decoration: none; }
.bm-book:hover, .bm-book:focus-visible { background: var(--accent-soft); }
.bm-name { font-size: 0.8rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-book.done .bm-name { color: var(--accent-text); }
.bm-cells { display: flex; flex-wrap: wrap; gap: 2px; }
.bm-cells i { width: 7px; height: 7px; border-radius: 2px; background: var(--border); }
.bm-cells i.on { background: var(--accent); }
.toast .toast-action { margin-left: 10px; background: none; border: 0; color: inherit; font: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; padding: 0; }
.finish-card { text-align: center; padding: 8px 4px 4px; }
.finish-card .finish-mark { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--on-accent, #fff); margin-bottom: 10px; }
.finish-card.glow .finish-mark { animation: finish-glow 1.6s ease-out 1; }
.finish-card h3 { font-size: 1.25rem; margin: 0 0 6px; }
.finish-card .finish-line { color: var(--muted); margin: 0 0 8px; }
.finish-card .finish-tagline { font-style: italic; line-height: 1.55; margin: 0; }
@keyframes finish-glow {
  0% { transform: scale(0.7); opacity: 0; box-shadow: 0 0 0 0 var(--accent); }
  50% { transform: scale(1.05); opacity: 1; box-shadow: 0 0 0 14px transparent; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}
.p-inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0 10px; }
#edge-frame { position: fixed; inset: 0; pointer-events: none; z-index: 2147483000; border: var(--frame-width, 4px) solid var(--text); }
#edge-frame[data-color="accent"] { border-color: var(--accent); }
@media print { #edge-frame { display: none; } }

.milestones { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 12px; }
.milestones h3 { font-size: 0.95rem; font-weight: 800; margin: 0 0 8px; }
.ms-earned, .ms-next { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 10px; }
.ms-earned li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 0.85rem; font-weight: 650; }
.ms-earned li .muted { font-weight: 500; }
.ms-next-title { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin: 12px 0 6px; }
.ms-next li { font-size: 0.85rem; padding: 4px 10px; border: 1px dashed var(--border); border-radius: 999px; }
.history-card h3 { font-size: 1rem; line-height: 1.4; margin: 4px 0 6px; }
.history-card p { color: var(--muted); line-height: 1.55; margin: 0 0 8px; }
.did-you-know { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius); background: var(--accent-soft); }
.did-you-know .dyk-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--accent-text); font-size: 0.85rem; }
.did-you-know p { margin: 0; flex: 1 1 280px; line-height: 1.55; }
