/* 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: var(--glass); 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: var(--accent-fill, var(--accent)); color: var(--on-accent);
}

/* 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: var(--glass); 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; }
.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); }
.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; } }

/* 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; }
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); }
.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); }

@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);
}

.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; }
.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; }

/* 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; }

/* 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); }
}

/* On-screen Back (phones and tablets; desktop has the browser's own) */
.appbar-back { flex: 0 0 auto; margin-left: -6px; }
.appbar-back[hidden] { display: none; }
@media (min-width: 1024px) { .appbar-back { display: none; } }
@media (max-width: 359px) { .appbar-back:not([hidden]) + .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; } }

/* 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); }
/* 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; }
