/* =====================================================
   Dante side-by-side reader — stylesheet
   ===================================================== */

:root {
  /* Inferno (default) */
  --bg: #f6f1e7;
  --paper: #fbf7ee;
  --ink: #2a241d;
  --ink-soft: #5a4f42;
  --rule: #d8cdb8;
  --accent: #8a3a1d;
  --note-bg: #efe7d4;
  --line-num: #b9aa8a;
  --hover: #ede2cc;
  --note-rule: #c8b896;
  --shadow: 0 6px 24px rgba(0,0,0,0.07);
  --shadow-soft: 0 1px 3px rgba(0,0,0,0.05);
  --font-scale: 1;
}

/* Per-canticle accent palettes (light mode) */
body[data-canticle="purgatorio"] {
  --accent: #4a7355;
  --note-rule: #b8c8b6;
}
body[data-canticle="paradiso"] {
  --accent: #b8852a;
  --note-rule: #d8c490;
}

body.dark {
  --bg: #1a1410;
  --paper: #221b15;
  --ink: #ece1cc;
  --ink-soft: #9a8e7a;
  --rule: #322b22;
  --accent: #d97a4a;
  --note-bg: #221c16;
  --line-num: #5a4f3e;
  --hover: #2a2218;
  --note-rule: #4a3e2e;
  --shadow: 0 6px 24px rgba(0,0,0,0.35);
  --shadow-soft: 0 1px 3px rgba(0,0,0,0.25);
}
body.dark[data-canticle="purgatorio"] { --accent: #82b094; --note-rule: #3d4e3e; }
body.dark[data-canticle="paradiso"]   { --accent: #e2b86a; --note-rule: #4d3f24; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  transition: background 0.2s ease, color 0.2s ease;
}

body {
  font-family: "Iowan Old Style", "Palatino Linotype", "Palatino", "Georgia", serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 32px 96px;
  position: relative;
  z-index: 1;
}

/* =====================================================
   Canto parallax background illustration
   ===================================================== */
.canto-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
/* Images are absolutely positioned so multiple plates can stack and
   crossfade. JS controls vertical translation (parallax) and sets
   --fade per image for the segment-to-segment crossfade. The CSS
   variable approach lets per-theme opacity (--base-opacity) and the
   JS fade multiplier compose cleanly via calc(). */
.canto-bg img {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  --base-opacity: 0.13;
  opacity: calc(var(--base-opacity) * var(--fade, 1));
  will-change: transform, opacity;
  transform-origin: top center;
}
body.dark .canto-bg img { --base-opacity: 0.11; }

/* =====================================================
   Top progress bar (sticky, 2px, fills as you scroll)
   ===================================================== */
.progress-track {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 100;
  pointer-events: none;
  background: transparent;
}
.progress-track .progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.08s linear;
}

/* =====================================================
   Floating action buttons (settings + bookmarks)
   ===================================================== */
.fab {
  position: fixed;
  top: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--rule);
  cursor: pointer;
  z-index: 90;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
  padding: 0;
  opacity: 0.65;
  box-shadow: var(--shadow-soft);
  transition: opacity 0.2s, color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.fab:hover {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.fab.open {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
}
.fab svg { width: 16px; height: 16px; display: block; }

.settings-fab  { right: 16px; }
.bookmarks-fab { right: 64px; }
.bookmarks-fab.has-marks {
  color: var(--accent);
  border-color: var(--accent);
  opacity: 0.9;
}
.bookmarks-fab .count-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  background: var(--accent);
  color: white;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 9px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
  line-height: 1;
}

/* =====================================================
   Popovers (settings + bookmarks)
   ===================================================== */
.popover {
  position: fixed;
  top: 60px;
  right: 16px;
  width: 270px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
  z-index: 95;
  font-size: 14px;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.popover[hidden] { display: none; }
.popover h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}
.popover .row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}
.popover .row + .row { border-top: 1px dotted var(--rule); }
.popover label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  color: var(--ink);
  user-select: none;
}
.popover label input[type="checkbox"] { accent-color: var(--accent); margin: 0; cursor: pointer; }
.popover .pill-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s;
}
.popover .pill-btn:hover { color: var(--ink); border-color: var(--accent); }
.popover .size-btns { display: flex; gap: 6px; }
.popover .reset-row { padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--rule); }
.popover .reset-canto {
  width: 100%;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s;
}
.popover .reset-canto:hover { border-color: var(--accent); color: var(--accent); }

/* Bookmarks popover layout */
.bookmarks-popover {
  width: 320px;
  max-height: 60vh;
  overflow-y: auto;
}
.bookmarks-popover .bookmarks-list { margin-top: 4px; }
.bookmark-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 2px 0;
  border-bottom: 1px dotted var(--rule);
}
.bookmark-item:last-child { border-bottom: none; }
.bookmark-jump {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 10px;
  color: var(--ink);
  font: inherit;
  border-radius: 4px;
  transition: background 0.15s;
}
.bookmark-jump:hover { background: var(--hover); }
.bookmark-num {
  display: block;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 3px;
  text-transform: uppercase;
}
.bookmark-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.4;
}
.bookmark-remove {
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 10px;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: center;
  transition: color 0.15s, background 0.15s;
}
.bookmark-remove:hover { background: var(--hover); color: var(--accent); }
.bookmarks-empty {
  color: var(--ink-soft);
  font-style: italic;
  text-align: center;
  padding: 16px 4px 8px;
  font-size: 13px;
  line-height: 1.5;
}

/* =====================================================
   Top / bottom nav
   ===================================================== */
.topnav, .bottomnav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 0 24px;
  font-size: 13px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 28px;
}
/* Right cell: right-align the link; topnav only needs FAB clearance */
.topnav > *:last-child  { text-align: right; padding-right: 110px; }
.bottomnav > *:last-child { text-align: right; }
.bottomnav {
  border-bottom: none;
  border-top: 1px solid var(--rule);
  padding: 24px 0 8px;
  margin: 56px 0 0;
}
.topnav a, .bottomnav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}
.topnav a:hover, .bottomnav a:hover {
  background: var(--hover);
  color: var(--ink);
}
.topnav .nav-center, .bottomnav .nav-center {
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.nav-disabled { opacity: 0.3; cursor: default; }

/* =====================================================
   Header
   ===================================================== */
header.canto-head {
  text-align: center;
  margin-bottom: 16px;
}
header.canto-head .eyebrow {
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
header.canto-head h1 {
  font-size: 42px;
  margin: 0 0 6px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
header.canto-head .sub {
  font-size: 15px;
  color: var(--ink-soft);
  font-style: italic;
}

/* =====================================================
   Reading note (epigraph styling — top/bottom hairlines)
   ===================================================== */
.reading-note {
  max-width: 700px;
  margin: 32px auto 40px;
  padding: 26px 8px;
  background: transparent;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  border-left: none;
  border-right: none;
  border-radius: 0;
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.7;
}
.reading-note b { color: var(--ink); font-weight: 600; }
.reading-note i, .reading-note em { color: var(--ink-soft); }

/* =====================================================
   Mobile reading-mode tabs (Both / Modern / Original)
   shown only at ≤760px
   ===================================================== */
.mobile-mode-tabs {
  display: none;
  justify-content: center;
  gap: 6px;
  padding: 6px 0 10px;
  margin-bottom: 14px;
}
.mobile-mode-tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.mobile-mode-tab:hover { color: var(--ink); border-color: var(--accent); }
.mobile-mode-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* =====================================================
   Tercet grid (left = original, right = modern)
   ===================================================== */
.col-headers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  padding: 0 8px 12px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 24px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.col-headers div:nth-child(2) { color: var(--accent); }

.tercets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 36px;
  padding: 0 8px;
}
.left, .right {
  padding: 14px 0;
  scroll-margin-top: 24px;
  position: relative;
}


/* Single continuous divider spanning both columns.
   Only on .left (col 1); width = left col + 36px gap + right col = 200% + 36px.
   Works because both columns are equal-width (1fr 1fr). */
.left::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: calc(200% + 36px);
  height: 0;
  border-top: 1px dotted var(--rule);
  pointer-events: none;
}

/* No divider above the very first tercet row */
.tercets > .left:first-child {
  padding-top: 0;
}
.tercets > .left:first-child::before {
  display: none;
}

.left {
  font-style: italic;
  color: var(--ink);
  font-size: calc(17px * var(--font-scale));
  line-height: 1.7;
}
.right {
  color: var(--ink);
  font-size: calc(16px * var(--font-scale));
  line-height: 1.7;
}
.right p, .left p { margin: 0; }
.line-num {
  display: inline-block;
  width: 32px;
  color: var(--line-num);
  font-style: normal;
  font-size: 11px;
  font-family: "SF Mono", Menlo, monospace;
  text-align: right;
  margin-right: 8px;
  user-select: none;
  vertical-align: top;
}

/* =====================================================
   Notes — hidden by default, revealed per-tercet via toggle button
   ===================================================== */
.note {
  display: none;
  margin-top: 16px;
  padding: 4px 0 8px 14px;
  background: transparent;
  border-left: 2px solid var(--note-rule);
  border-radius: 0;
  font-size: calc(13px * var(--font-scale));
  color: var(--ink-soft);
  line-height: 1.6;
  font-style: normal;
}
/* Show inline note when its parent .right has .note-open (narrow screens) */
.right.note-open .note { display: block; }

.note b { color: var(--ink); font-weight: 600; }
.note i, .note em { font-style: italic; }

/* Global "show notes" override from settings */
body.no-notes .note { display: none !important; }
body.no-notes .note-btn,
body.no-notes .margin-note { display: none; }
body.no-linenums .line-num { display: none; }

/* =====================================================
   Note toggle button (†) — right margin of .right cell
   ===================================================== */
.note-btn {
  position: absolute;
  right: -26px;
  top: 12px;
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0.55;
  color: var(--accent);
  font: inherit;
  font-style: normal;
  font-size: 16px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  transition: opacity 0.18s ease;
}
.note-btn:hover { opacity: 0.85; }
.note-btn.is-open { opacity: 1; }

/* =====================================================
   Margin notes (≥1100px — full-width row, toggleable)
   ===================================================== */
.margin-note { display: none; }

@media (min-width: 1100px) {
  /* Inline note is always hidden at wide screens — margin-note handles it */
  .right .note { display: none !important; }

  .margin-note {
    grid-column: 1 / -1;
    margin-top: -10px;
    padding: 0 0 16px;
    color: var(--ink-soft);
    font-size: calc(13.5px * var(--font-scale));
    line-height: 1.65;
    /* hidden by default, shown when toggled */
    display: none;
  }
  .margin-note.note-open {
    display: block;
  }
  .margin-note .note {
    display: block;   /* always shown inside an open margin-note */
    margin-top: 0;
    padding: 6px 0 6px 16px;
    border-left: 2px solid var(--note-rule);
    font-size: inherit;
    line-height: inherit;
    max-width: 920px;
  }
}

/* =====================================================
   Bookmark button per tercet (left margin)
   ===================================================== */
.bookmark-btn {
  position: absolute;
  left: -32px;
  top: 16px;
  width: 14px;
  height: 20px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0;
  color: var(--ink-soft);
  transition: opacity 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.left:hover .bookmark-btn { opacity: 0.35; }
.bookmark-btn:hover { opacity: 0.85 !important; transform: translateY(-1px); }
.bookmark-btn.is-bookmarked {
  opacity: 1 !important;
  color: var(--accent);
}
.bookmark-btn svg { width: 100%; height: 100%; display: block; overflow: visible; }
.bookmark-btn svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.bookmark-btn.is-bookmarked svg path { fill: currentColor; }

/* =====================================================
   Permalink ¶ button per tercet (right margin)
   ===================================================== */
.permalink-btn {
  position: absolute;
  right: -28px;
  top: 12px;
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0;
  color: var(--ink-soft);
  font: inherit;
  font-style: normal;
  font-size: 17px;
  line-height: 22px;
  border-radius: 50%;
  transition: opacity 0.18s ease, color 0.18s ease;
}
.left:hover .permalink-btn { opacity: 0.32; }
.permalink-btn:hover { opacity: 1 !important; color: var(--accent); }
.permalink-btn.copied { opacity: 1 !important; color: var(--accent); }
.permalink-btn.copied::after {
  content: "copied";
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.05em;
  color: var(--accent);
  white-space: nowrap;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 2px 6px;
  border-radius: 4px;
}

/* =====================================================
   Resume marker (small dot in left margin of saved tercet)
   ===================================================== */
.left.resume-mark::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 22px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* =====================================================
   Restart pill (floats bottom-right when auto-resumed)
   ===================================================== */
.resume-restart-pill {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  z-index: 80;
  box-shadow: var(--shadow);
  opacity: 0.92;
  transition: opacity 0.4s ease, color 0.2s, border-color 0.2s, transform 0.3s ease;
}
.resume-restart-pill:hover {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
}
.resume-restart-pill.faded { opacity: 0.4; }
.resume-restart-pill.faded:hover { opacity: 1; }
.resume-restart-pill[hidden] { display: none; }

/* =====================================================
   Footer
   ===================================================== */
.final {
  grid-column: 1 / -1;
  text-align: center;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 14px;
  font-style: italic;
}
footer.canto-foot {
  text-align: center;
  margin-top: 32px;
  color: var(--ink-soft);
  font-size: 12px;
}

/* =====================================================
   INDEX PAGE
   ===================================================== */
.index-hero {
  text-align: center;
  margin: 24px 0 36px;
}
.index-hero .eyebrow {
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.index-hero h1 {
  font-size: 56px;
  margin: 0 0 8px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.index-hero .author {
  font-size: 17px;
  color: var(--ink-soft);
  font-style: italic;
}

.continue-card {
  max-width: 720px;
  margin: 0 auto 48px;
  padding: 22px 26px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.continue-card .label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.continue-card .where {
  font-size: 19px;
  color: var(--ink);
  font-weight: 600;
}
.continue-card .meta {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.continue-card a.cta {
  background: var(--accent);
  color: white;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
}
.continue-card a.cta:hover { opacity: 0.9; }

.canticle { margin-bottom: 64px; }
.canticle-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
  margin-bottom: 22px;
}
.canticle-head h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.canticle-head .summary {
  font-size: 13px;
  color: var(--ink-soft);
}

.canto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.canto-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.canto-card.available {
  background: var(--paper);
  border-color: var(--rule);
}
.canto-card.available:hover {
  border-color: var(--accent);
  background: var(--hover);
}
.canto-card.locked {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.canto-card .num {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.canto-card.completed .num { color: var(--accent); }
.canto-card .title {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.4;
}
.canto-card .progress {
  margin-top: 8px;
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}
.canto-card .progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}
.canto-card .badge-done {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-left: 6px;
}
.canto-card .bookmark-count {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-left: 6px;
  font-weight: 600;
}

/* Locked-cantos collapsible group */
.locked-group { margin-top: 16px; }
.locked-summary {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-top: 1px dotted var(--rule);
  border-bottom: 1px dotted var(--rule);
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  transition: color 0.15s, background 0.15s;
}
.locked-summary:hover { color: var(--ink); background: var(--paper); }
.locked-summary .caret {
  display: inline-block;
  width: 14px;
  font-size: 11px;
  color: var(--accent);
  transition: transform 0.18s ease;
}
.locked-summary.expanded .caret { transform: rotate(90deg); }
.locked-detail { margin-top: 12px; }

.index-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--ink-soft);
}
.index-controls .reset {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}
.index-controls .reset:hover { border-color: var(--accent); color: var(--ink); }
.theme-toggle {
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--accent); }

/* =====================================================
   Tap-highlight cleanup (all viewports — flat tap on iOS)
   ===================================================== */
button, a, label { -webkit-tap-highlight-color: transparent; }

/* =====================================================
   MOBILE
   ===================================================== */
@media (max-width: 760px) {
  .wrap { padding: 14px 16px 72px; }

  /* Header — compressed for vertical space */
  header.canto-head { margin-bottom: 10px; }
  header.canto-head h1 { font-size: 28px; line-height: 1.15; }
  header.canto-head .eyebrow {
    font-size: 11px;
    letter-spacing: 0.18em;
    margin-bottom: 6px;
  }
  header.canto-head .sub { font-size: 13.5px; }

  .index-hero { margin: 16px 0 28px; }
  .index-hero h1 { font-size: 38px; }
  .index-hero .author { font-size: 15px; }

  /* Top nav: flex layout; hide centre label (redundant with <header>);
     right link stays clear of the two FABs at the top right */
  .topnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 12px;
    font-size: 12px;
  }
  .topnav .nav-center { display: none; }
  .topnav > *:last-child { padding-right: 108px; text-align: right; }
  .topnav a { padding: 6px 10px; }
  .bottomnav {
    font-size: 13px;
    padding: 22px 0 8px;
    margin-top: 40px;
  }
  .bottomnav a { padding: 8px 14px; }

  /* Reading note */
  .reading-note {
    padding: 18px 4px;
    font-size: 14.5px;
    line-height: 1.65;
    margin: 16px auto 22px;
  }

  /* Tercet grid: single column on mobile, generous gap between tercets */
  .col-headers, .tercets { grid-template-columns: 1fr; gap: 12px; }
  .col-headers {
    font-size: 11px;
    padding-bottom: 10px;
    margin-bottom: 14px;
  }

  /* Reading typography: bump the modern column (primary on mobile),
     keep Longfellow slightly smaller (parallel reference) */
  .left {
    font-size: calc(16px * var(--font-scale));
    line-height: 1.7;
    padding: 10px 0 6px;
    border-bottom: none;
  }
  .right {
    font-size: calc(17.5px * var(--font-scale));
    line-height: 1.75;
    padding: 6px 0 24px;
    padding-right: 36px; /* clearance for the note-btn and bookmark-btn corner */
  }

  /* BUG FIX: desktop divider spans calc(200% + 36px) for the 2-col layout.
     In single-column mobile that doubles the viewport width → horizontal scroll.
     Constrain to the actual column width. */
  .left::before { width: 100%; }

  /* BUG FIX: note-toggle button (†) was right:-26px — outside the viewport on
     mobile. Pull it inside the .right column; padding-right:36px gives room. */
  .note-btn {
    right: 0;
    top: 8px;
    width: 30px;
    height: 30px;
    font-size: 18px;
    line-height: 30px;
  }

  /* Bookmark: top-right corner of the tercet, just left of the note button */
  .bookmark-btn {
    left: auto;
    right: 38px;
    top: 12px;
    width: 16px;
    height: 22px;
    opacity: 0.42;
  }
  .permalink-btn { display: none; }

  /* When showing only one column, hide the col-headers entirely —
     the segmented tab above already labels what's on screen. */
  body.mobile-mode-modern .col-headers,
  body.mobile-mode-original .col-headers { display: none; }

  /* Single-column reading modes */
  body.mobile-mode-modern .left { display: none; }
  body.mobile-mode-original .right { display: none; }
  body.mobile-mode-modern .right { padding: 14px 0 26px; padding-right: 36px; }
  body.mobile-mode-original .left { padding: 14px 0 26px; }

  /* Inline note styling on mobile */
  .note { font-size: calc(13.5px * var(--font-scale)); line-height: 1.65; }

  /* Mobile mode tabs — segmented control look */
  .mobile-mode-tabs {
    display: flex;
    gap: 2px;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding: 3px;
    margin: 0 auto 18px;
    width: fit-content;
    box-shadow: var(--shadow-soft);
  }
  .mobile-mode-tab {
    padding: 7px 18px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 12.5px;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .mobile-mode-tab:hover {
    background: transparent;
    color: var(--ink);
    border-color: transparent;
  }
  .mobile-mode-tab.active {
    background: var(--accent);
    color: white;
    font-weight: 600;
  }

  /* FABs — larger tap targets (40×40 ≥ Apple's 44px target gets close
     while staying visually subtle) */
  .fab { width: 40px; height: 40px; top: 10px; }
  .fab svg { width: 18px; height: 18px; }
  .settings-fab  { right: 12px; }
  .bookmarks-fab { right: 60px; }
  .bookmarks-fab .count-badge {
    bottom: -2px; right: -2px;
    min-width: 16px; height: 16px;
    font-size: 10px;
  }

  /* Popovers — full mobile width with safe gutters and scroll if tall */
  .popover {
    right: 12px;
    left: 12px;
    width: auto;
    top: 60px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
  .popover .row { padding: 11px 0; font-size: 14.5px; }
  .popover .pill-btn { padding: 7px 14px; font-size: 13px; }
  .popover .reset-canto { padding: 10px 12px; font-size: 13px; }

  /* Restart pill — bigger thumb area */
  .resume-restart-pill {
    bottom: 18px;
    right: 18px;
    padding: 10px 18px;
    font-size: 13px;
  }

  /* Progress bar — thicker on mobile so it's actually visible */
  .progress-track { height: 3px; }

  /* Index page: stacked, comfortable taps */
  .canticle { margin-bottom: 44px; }
  .canticle-head { flex-direction: column; gap: 4px; align-items: flex-start; }
  .canticle-head h2 { font-size: 22px; }
  .canto-grid { grid-template-columns: 1fr; gap: 6px; }
  .canto-card { padding: 14px 16px; }
  .canto-card .title { font-size: 14.5px; line-height: 1.45; }
  .continue-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 20px;
  }
  .continue-card .where { font-size: 17px; }
  .continue-card a.cta { padding: 10px 18px; }
  .index-controls { gap: 8px; flex-wrap: wrap; }
}
