/* ============================================================
   Vangelo di Giovanni — design system
   Mobile-first; tablet ≥720px; desktop con sidebar fissa ≥1160px.
   Temi: auto (prefers-color-scheme), light, dark, sepia.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --serif: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --greek: 'EB Garamond', 'SBL Greek', Georgia, serif;

  /* Inset della barra di stato/notifiche (notch). Il fallback 0px mantiene
     valida la regola anche dove env() non è supportato o vale 0 (desktop,
     browser con barra propria). Richiede viewport-fit=cover (vedi index.html). */
  --sat: env(safe-area-inset-top, 0px);
  --topbar-controls-h: 56px; /* altezza della sola riga dei controlli */
  /* Altezza totale della topbar: riga controlli + inset. Tutti gli offset
     "sotto la topbar" (reader, scroll-margin, goto) usano questa e restano
     corretti quando l'inset non è zero. */
  --topbar-h: calc(var(--topbar-controls-h) + var(--sat));
  --sidebar-w: 264px;
  --panel-w: 400px;
  --gutter: 20px;
  --radius: 14px;
  --radius-s: 9px;
  --transition: 220ms cubic-bezier(.4, 0, .2, 1);
  --transition-panel: 300ms cubic-bezier(.32, .72, 0, 1); /* apertura pannelli: scatto + atterraggio morbido */
  --reader-fs: 18px;
  --reader-max: 700px;

  --shadow: 0 12px 40px rgba(24, 18, 10, .16), 0 2px 8px rgba(24, 18, 10, .08);
  --shadow-soft: 0 1px 3px rgba(24, 18, 10, .07);
}

/* Light (default) */
:root, [data-theme='light'] {
  color-scheme: light;
  --bg: #faf7f1;
  --bg-soft: #f1ece1;
  --bg-elev: #fffdf9;
  --border: #e4dccb;
  --text: #211b12;
  --text-soft: #4b4334;
  --text-muted: #8d8270;
  --accent: #8a5a28;
  --accent-soft: #d9c4a3;
  --highlight: #f3e3c2;
  --mark: #f5dfa8;
  --danger: #a33;
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg: #15110c;
  --bg-soft: #201a13;
  --bg-elev: #1d1812;
  --border: #362c20;
  --text: #ede5d8;
  --text-soft: #c9bda9;
  --text-muted: #8d816c;
  --accent: #d2a566;
  --accent-soft: #6b5435;
  --highlight: #3a2f1d;
  --mark: #57431f;
  --danger: #e08585;
  --shadow: 0 12px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, .3);
}

[data-theme='sepia'] {
  color-scheme: light;
  --bg: #f3ead7;
  --bg-soft: #eadfc6;
  --bg-elev: #faf3e3;
  --border: #dcceac;
  --text: #3f3421;
  --text-soft: #5d4e33;
  --text-muted: #94835f;
  --accent: #7c5220;
  --accent-soft: #cfb88c;
  --highlight: #eedfb6;
  --mark: #ecd79c;
}

@media (prefers-color-scheme: dark) {
  [data-theme='auto'] {
    color-scheme: dark;
    --bg: #15110c;
    --bg-soft: #201a13;
    --bg-elev: #1d1812;
    --border: #362c20;
    --text: #ede5d8;
    --text-soft: #c9bda9;
    --text-muted: #8d816c;
    --accent: #d2a566;
    --accent-soft: #6b5435;
    --highlight: #3a2f1d;
    --mark: #57431f;
    --danger: #e08585;
    --shadow: 0 12px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
    --shadow-soft: 0 1px 3px rgba(0, 0, 0, .3);
  }
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
button { font-family: inherit; cursor: pointer; color: inherit; }
::selection { background: var(--highlight); color: var(--text); }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }

* { scrollbar-width: thin; scrollbar-color: var(--accent-soft) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent-soft); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* I dialoghi (goto, scheda parola, azioni versetto) impostano display via classe:
   senza questa regola l'attributo hidden verrebbe sovrascritto e l'elemento,
   pur invisibile (opacity 0), continuerebbe a intercettare i click. */
[hidden] { display: none !important; }

.skip-link {
  position: absolute; top: -48px; left: 12px; z-index: 200;
  background: var(--accent); color: var(--bg-elev);
  padding: 8px 14px; border-radius: var(--radius-s);
  font-weight: 600; text-decoration: none;
  transition: top var(--transition);
}
.skip-link:focus { top: 8px; }

/* ---------- Header evento (Gospel Village 2026) ---------- */
.event-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 7%, var(--bg-elev)), var(--bg-elev));
  border-bottom: 1px solid var(--border);
  padding: 9px clamp(12px, 4vw, 28px);
  padding-top: calc(9px + var(--sat));
  max-width: 1700px; margin: 0 auto;
  transition: background var(--transition);
}
.event-banner:hover { background: var(--bg-soft); }
.event-banner .eb-logo { flex: none; display: flex; }
.event-banner .eb-logo img {
  height: 46px; width: auto; display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .18));
}
.event-banner .eb-text { display: flex; flex-direction: column; line-height: 1.18; min-width: 0; }
.event-banner .eb-title {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(17px, 4.4vw, 22px); color: var(--text);
}
.event-banner .eb-sub {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  letter-spacing: .04em; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.event-banner .eb-ext { flex: none; margin-inline-start: auto; color: var(--text-muted); transition: color var(--transition); }
.event-banner:hover .eb-ext { color: var(--accent); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  /* min-height (non height fissa): sotto box-sizing:border-box il padding-top
     dell'inset si SOMMA alla riga controlli invece di comprimerla. Border box
     = controls-h + sat; area contenuto = controls-h → i tasti (40px) stanno
     tutti sotto la barra di stato, mai a cavallo del suo bordo. */
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 6px;
  /* padding-inline (non lo shorthand `padding`): così un override successivo
     dei margini laterali non azzera più il padding-top dell'inset. */
  padding-inline: 10px;
  padding-top: var(--sat); /* spinge la riga controlli sotto la barra di stato/notifiche */
  max-width: 1700px; margin: 0 auto;
}
.topbar-title {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--serif); font-size: 19px; min-width: 0;
  background: none; border: 0; color: var(--text); cursor: pointer;
  padding: 4px 8px; margin: -4px 0 -4px -8px; border-radius: 10px;
  transition: background var(--transition);
}
.topbar-title:hover { background: var(--bg-soft); }
.topbar-title svg { opacity: .55; flex: none; }
.topbar-title .book { font-weight: 600; letter-spacing: .01em; white-space: nowrap; }

/* Selettore libro nel pannello "vai a" */
.goto-books { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.book-chip {
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-soft);
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.book-chip:hover { background: var(--bg-soft); }
.book-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast, #fff); }

/* Note testuali (versetti assenti dai manoscritti più antichi, finali di Marco) */
.txt-note {
  border: 0; background: none; cursor: pointer;
  font-size: .68em; vertical-align: super; line-height: 1;
  color: var(--text-faint, var(--text-soft)); opacity: .75;
  padding: 1px 3px; border-radius: 6px;
  border-bottom: 1px dotted currentColor;
  transition: opacity var(--transition), background var(--transition);
}
.txt-note:hover { opacity: 1; background: var(--bg-soft); }

/* Indicatore del commento personale */
.comment-dot {
  border: 0; background: none; cursor: pointer;
  font-size: .72em; vertical-align: super; line-height: 1;
  color: var(--accent); opacity: .85; padding: 1px 3px; border-radius: 6px;
  transition: opacity var(--transition), background var(--transition);
}
.comment-dot:hover { opacity: 1; background: var(--bg-soft); }

/* Selezione multipla */
body.sel-mode .prose .verse { cursor: pointer; }
.prose .verse.sel { background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 6px; padding: 1px 2px; }
/* selezione visibile anche nelle modalità a schede (parallelo, interlineare, letterale) */
article.verse.sel { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 10px; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.multi-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 60; max-width: min(720px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 16px; padding: 10px 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .18);
}
.mb-count { font-size: 13.5px; font-weight: 600; color: var(--text-soft); }
.mb-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mb-dots { display: inline-flex; align-items: center; gap: 6px; margin-right: 4px; }
.multi-bar button:not(.va-dot):not(.iconbtn) {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 13.5px; font-weight: 600; padding: 7px 12px; border-radius: 10px; cursor: pointer;
  transition: background var(--transition);
}
.multi-bar button:not(.va-dot):not(.iconbtn):hover:not(:disabled) { background: var(--bg-soft); }
.multi-bar button:disabled { opacity: .45; cursor: default; }
.mb-close { margin-left: 2px; }

/* Editor del commento */
.cp-text {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 96px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 15px; line-height: 1.55; padding: 10px 12px;
  margin: 10px 0 12px;
}
.cp-text:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Modalità non disponibili per il libro attivo */
.segmented label.disabled { opacity: .4; cursor: not-allowed; }

/* ── Appendice: i finali aggiunti (Mc 16,9-20) ──
   Il racconto antico si chiude al v. 8 con un asterismo tipografico; ciò che
   i manoscritti tardi aggiungono segue come appendice curata, non come toppa. */
.later-fleuron {
  text-align: center;
  margin: 34px 0 26px;
  font-family: var(--serif);
  font-size: 17px;
  color: var(--text-soft);
  opacity: .55;
  letter-spacing: .6em;
  text-indent: .6em; /* compensa l'ultimo spazio del letter-spacing */
  user-select: none;
}
.later-block {
  margin: 0 0 10px;
  padding: 22px 24px 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-elev);
}
.later-block .prose { color: var(--text-soft); }
.later-head {
  display: flex; align-items: center; gap: 12px;
  font-size: 11.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-soft);
}
.later-head::before, .later-head::after {
  content: ''; height: 1px; flex: 1;
  background: var(--border);
}
.later-head .txt-note {
  flex: none;
  width: 19px; height: 19px; line-height: 17px;
  border: 1px solid var(--border); border-bottom-style: solid;
  border-radius: 999px; text-align: center;
  font-size: 11px; vertical-align: middle;
  padding: 0; opacity: .85;
}
/* Il titolo della nota, cliccabile, al posto del "?" e della frase introduttiva */
.later-intro-link,
.later-head .later-intro-link {
  display: block;
  width: auto; height: auto;
  margin: 13px auto 2px; padding: 2px 4px;
  background: none; border: 0; cursor: pointer;
  font-family: var(--serif); font-style: italic;
  font-size: 15px; line-height: 1.5; letter-spacing: 0;
  text-transform: none; text-align: center; vertical-align: baseline;
  color: var(--text-soft);
  border-bottom: 1px dotted currentColor; border-radius: 0;
  opacity: 1;
  transition: color var(--transition);
}
.later-intro-link:hover { color: var(--text); background: none; }
.later-divider .later-intro-link { display: inline-block; margin: 0; flex: none; }
.later-sub {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0 8px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-soft); opacity: .9;
}
.later-sub::after { content: ''; height: 1px; flex: 1; background: var(--border); }
.later-short {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: calc(var(--reader-fs) - 2px);
  line-height: 1.75;
  color: var(--text-soft);
}
.later-content .prose { font-size: calc(var(--reader-fs) - 1px); }
/* divisore per le modalità a schede (parallelo, interlineare, letterale) */
.later-divider { margin: 26px 0 14px; }

.ref-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-soft);
  font-size: 13px; font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  transition: border-color var(--transition), color var(--transition), transform 120ms ease;
  white-space: nowrap;
}
.ref-chip:hover { border-color: var(--accent-soft); color: var(--accent); }
.ref-chip:active { transform: scale(.96); }
.ref-chip svg { color: var(--accent); flex: none; }

.topbar-actions { display: flex; gap: 2px; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border: 0; background: transparent; border-radius: 10px;
  color: var(--text-soft);
  transition: background var(--transition), color var(--transition);
}
.iconbtn:hover { background: var(--bg-soft); color: var(--text); }
.iconbtn:active { background: var(--bg-soft); color: var(--text); transform: scale(.9); }

.progress { height: 2px; background: transparent; }
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  transition: width 80ms linear;
}

/* ---------- Shell ---------- */
.shell { display: block; max-width: 1700px; margin: 0 auto; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(18, 13, 7, .45);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
}
.overlay.open { opacity: 1; pointer-events: auto; }

/* ---------- Reader ---------- */
.reader {
  min-height: calc(100dvh - var(--topbar-h));
  padding: clamp(16px, 3vw, 36px) var(--gutter) 56px;
  outline: none;
}
.reader-inner { max-width: var(--reader-max); margin: 0 auto; }
[data-width='compact'] { --reader-max: 580px; }
[data-width='wide'] { --reader-max: 920px; }

.loading { color: var(--text-muted); text-align: center; padding: 48px 0; font-size: 15px; }

.chapter-heading { margin: 6px 0 30px; }
.chapter-heading h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 5.5vw, 44px);
  font-weight: 600; line-height: 1.08;
  letter-spacing: -.01em;
}
.chapter-heading .sub { margin: 8px 0 0; color: var(--text-muted); font-size: 13.5px; }
.chapter-heading::after {
  content: '';
  display: block; width: 64px; height: 3px;
  margin-top: 18px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
}

.verses { display: flex; flex-direction: column; gap: 4px; }

.verse { border-radius: var(--radius-s); padding: 6px 10px; margin: 0 -10px; scroll-margin-top: calc(var(--topbar-h) + 18px); }
.verse.flash-target { animation: verse-flash 1.6s ease-out 1; }
@keyframes verse-flash {
  0% { background: var(--highlight); }
  100% { background: transparent; }
}

.verse-num {
  display: inline-block;
  font-family: var(--sans);
  font-size: .62em; font-weight: 700;
  color: var(--accent);
  vertical-align: super;
  margin-inline-end: 7px;
  letter-spacing: .02em;
  border: 0; background: transparent; padding: 0 2px;
  cursor: pointer;
  border-radius: 4px;
  transition: background var(--transition);
}
.verse-num:hover { background: var(--highlight); }

.verse-text {
  margin: 0;
  font-family: var(--serif);
  font-size: var(--reader-fs);
  line-height: 1.72;
  color: var(--text);
}

.greek-wrap { margin-top: 9px; padding-inline-start: 14px; border-inline-start: 3px solid var(--accent-soft); }
.greek {
  margin: 0;
  font-family: var(--greek);
  font-size: calc(var(--reader-fs) * 1.02);
  line-height: 1.74;
  color: var(--text-soft);
}
.translit {
  margin: 4px 0 0;
  font-family: var(--sans);
  font-size: calc(var(--reader-fs) * .72);
  line-height: 1.6;
  font-style: italic;
  color: var(--text-muted);
}

.verse.greek-only .verse-text { display: none; }
.verse.italian-only .greek-wrap { display: none; }
.verse.greek-only .greek-wrap { border: 0; padding: 0; margin-top: 0; }
.verse.greek-only .greek { color: var(--text); }

/* ---------- Lettura scorrevole (flusso continuo) ----------
   In italiano/greco i versetti scorrono come prosa dentro paragrafi di senso:
   il numero è un piccolo esponente inline, il testo prosegue naturalmente. */
.verses.flow { display: block; }
.prose {
  margin: 0 0 1.15em;
  font-family: var(--serif);
  font-size: var(--reader-fs);
  line-height: 1.78;
  color: var(--text);
  text-wrap: pretty;
}
.prose:last-of-type { margin-bottom: 0; }
.prose-grc { font-family: var(--greek); line-height: 1.9; color: var(--text-soft); }
/* Ogni versetto resta un elemento (evidenziabile, con azioni), ma è inline */
.prose .verse {
  display: inline;
  margin: 0; padding: 0;
  border-radius: 4px;
  scroll-margin-top: calc(var(--topbar-h) + 96px);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background var(--transition);
}
.prose .verse[data-hl] { padding: 1px 2px; }
.prose .verse.flash-target { padding: 1px 2px; }
.prose .verse-num { margin-inline-end: 0; } /* lo spazio nel testo fa da stacco */

/* Literal */
.verse.literal .verse-text { color: var(--text-soft); }
.lit-tag {
  display: inline-block;
  font-family: var(--sans);
  font-size: .58em; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent);
  vertical-align: super; margin-inline-start: 7px;
}

/* Interlinear */
.verse.interlinear { padding-block: 12px; }
.verse.interlinear + .verse.interlinear { border-top: 1px solid var(--border); }
.verse-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.verse-head .verse-num { vertical-align: baseline; font-size: 13px; }
.interlinear-grid { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 8px; }
.iw {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: transparent;
  transition: background var(--transition), border-color var(--transition), transform 100ms ease;
  min-width: 0;
}
.iw:hover { background: var(--bg-soft); border-color: var(--border); }
.iw:active { transform: scale(.95); }
.iw-gr { font-family: var(--greek); font-size: calc(var(--reader-fs) * .98); line-height: 1.35; color: var(--text); white-space: nowrap; }
.iw-tr { font-family: var(--sans); font-size: .68rem; color: var(--text-muted); font-style: italic; white-space: nowrap; }
.iw-it { font-family: var(--serif); font-size: .84rem; color: var(--accent); font-weight: 500; white-space: nowrap; }
.iw-st { font-family: var(--sans); font-size: .58rem; color: var(--text-muted); opacity: .75; letter-spacing: .03em; }

.lit-line {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: calc(var(--reader-fs) * .9);
  line-height: 1.62;
  color: var(--text-soft);
  padding: 9px 13px;
  background: var(--bg-soft);
  border-radius: var(--radius-s);
  border-inline-start: 3px solid var(--accent-soft);
}
.lit-line b {
  font-family: var(--sans);
  font-size: .58em; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-inline-end: 8px;
}
.no-greek-note { margin: 2px 0 6px; font-size: .76rem; font-style: italic; color: var(--text-muted); }

/* Termine annotato + marker "?" cliccabile nel testo */
.term-annotated { border-bottom: 1px dotted var(--accent); }
.term-note {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px;
  margin-inline-start: 3px;
  padding: 0; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--bg-elev);
  font-family: var(--sans); font-size: 10px; font-weight: 700; line-height: 1;
  vertical-align: super; cursor: pointer;
  transition: transform 100ms ease, filter var(--transition);
}
/* Area di tocco ampliata (~35px) senza alterare la grafica del pallino */
.term-note::before { content: ''; position: absolute; inset: -10px; border-radius: 50%; }
.term-note:hover { filter: brightness(1.12); transform: scale(1.12); }
.term-note:active { transform: scale(.92); }

/* Popup nota di traduzione (riusa il posizionamento di .word-popup) */
.np-title { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--text); padding-inline-end: 38px; line-height: 1.3; }
.np-body { margin: 12px 0 0; font-family: var(--serif); font-size: 15.5px; line-height: 1.62; color: var(--text-soft); }
.np-body em { font-style: italic; }
.np-or [lang='grc'] { font-family: var(--greek); color: var(--text); font-size: 17px; }
.np-or em { font-style: italic; color: var(--text-muted); }
.np-usual { font-family: var(--sans); font-size: 12.5px; color: var(--text-muted); }

/* ---------- Note a margine (desktop con spazio) ---------- */
.reader { position: relative; }
.margin-notes { position: absolute; top: 0; pointer-events: none; }
.margin-notes[hidden] { display: none; }
.mnote {
  position: absolute; left: 0; width: 100%;
  pointer-events: auto;
  display: flex; flex-direction: column; gap: 2px;
  text-align: start;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent-soft);
  border-radius: var(--radius-s);
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform 120ms ease;
}
.mnote:hover { border-inline-start-color: var(--accent); transform: translateX(-2px); }
.mnote-flash { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.mnote-term { font-family: var(--serif); font-weight: 600; font-size: 14.5px; color: var(--text); }
.mnote-or { font-size: 12px; }
.mnote-or [lang='grc'] { font-family: var(--greek); color: var(--text-soft); font-size: 14px; }
.mnote-tr { font-style: italic; color: var(--text-muted); }
.mnote-mean { margin-top: 3px; font-size: 12px; line-height: 1.45; color: var(--text-soft); }
.np-foot { margin: 14px 0 0; font-family: var(--sans); font-size: 12px; color: var(--text-muted); }

/* ---------- Prev/Next ---------- */
.prevnext {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  max-width: var(--reader-max);
  margin: 44px auto 0;
}
.navcard {
  display: flex; flex-direction: column; gap: 3px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow-soft);
  text-align: start;
  transition: border-color var(--transition), transform 120ms ease, box-shadow var(--transition);
}
.navcard.next { text-align: end; align-items: flex-end; }
.navcard:not(:disabled):hover { border-color: var(--accent-soft); transform: translateY(-1px); }
.navcard:not(:disabled):active { transform: translateY(0) scale(.99); }
.navcard:disabled { opacity: .42; cursor: default; }
.navcard .dir {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted);
}
.navcard .dest { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--text); }

.reader-footer {
  max-width: var(--reader-max);
  margin: 44px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
.reader-footer p { margin: 4px 0; }

/* ---------- Panels (impostazioni / ricerca) ---------- */
.panel {
  position: fixed; z-index: 80;
  background: var(--bg-elev);
  transition: transform var(--transition-panel);
  overscroll-behavior: contain;
  /* bottom sheet (mobile default) */
  inset-inline: 0; inset-block-end: 0;
  max-height: 86dvh;
  border-radius: 18px 18px 0 0;
  border: 1px solid var(--border); border-bottom: 0;
  box-shadow: var(--shadow);
  transform: translateY(104%);
  display: flex;
  flex-direction: column;
}
.panel.open { transform: translateY(0); }
.panel-inner {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0; /* senza, il flex item rifiuta di restringersi e il foglio sfora sopra lo schermo */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 20px calc(26px + env(safe-area-inset-bottom));
}
.panel-inner::before {
  content: '';
  display: block;
  width: 42px; height: 4px;
  margin: 0 auto 10px;
  border-radius: 2px;
  background: var(--border);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.panel-header h2 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 600; }

.setting { padding: 14px 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; }
.setting h3 {
  margin: 0 0 10px;
  font-size: 11.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted);
}
.setting.about p { margin: 8px 0; font-size: 14px; line-height: 1.55; color: var(--text-soft); }
.note {
  margin: 14px 0;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-s);
}
.note p { margin: 0; }
.note p + p { margin-top: 7px; }
.note-title { font-family: var(--serif); font-weight: 600; font-size: 15px; color: var(--text); }
.note em { font-style: italic; }
.mode-hint { margin: 10px 0 0; min-height: 1em; }

.kbd-list { margin: 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--text-soft); }
.kbd-list li { margin: 6px 0; }
kbd {
  font-family: var(--sans); font-size: 11.5px; font-weight: 600;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 7px;
}

/* Segmented control */
.segmented {
  display: flex; gap: 3px;
  background: var(--bg-soft);
  padding: 3px; border-radius: 10px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  flex: 1;
  text-align: center;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  user-select: none;
}
.segmented input:checked + label {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
  font-weight: 600;
}
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmented.wrap { flex-wrap: wrap; }
.segmented.wrap label { flex: 1 1 calc(33.333% - 3px); min-width: 88px; }

/* Switch */
.switch { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track {
  flex: none;
  width: 42px; height: 24px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}
.switch .track::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg-elev);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform var(--transition-panel);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .lbl { font-size: 14px; color: var(--text-soft); }

/* Range */
input[type='range'] {
  width: 100%; height: 4px;
  appearance: none; -webkit-appearance: none;
  background: var(--bg-soft);
  border-radius: 2px;
  accent-color: var(--accent);
}
input[type='range']::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-elev);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
  cursor: grab;
}

/* ---------- Search ---------- */
.search-bar { display: flex; flex-direction: column; gap: 9px; margin-bottom: 10px; }
#searchInput {
  width: 100%;
  font-family: var(--sans); font-size: 16px; /* ≥16px: evita l'auto-zoom di iOS che lascia la pagina spostata */
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
}
#searchInput:focus { outline: 2px solid var(--accent); border-color: transparent; }
#searchCount { margin: 0; }
.search-results { display: flex; flex-direction: column; gap: 4px; }
.search-result {
  text-align: start;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: transparent;
  padding: 10px 12px;
  transition: background var(--transition), border-color var(--transition);
}
.search-result:hover { background: var(--bg-soft); border-color: var(--border); }
.search-result .ref { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.search-result .snippet { font-family: var(--serif); font-size: 15px; line-height: 1.5; color: var(--text-soft); }
.search-result mark { background: var(--mark); color: var(--text); border-radius: 3px; padding: 0 2px; }
.search-empty { color: var(--text-muted); text-align: center; padding: 22px 0; }

/* ---------- Go-to dialog ---------- */
.goto {
  position: fixed; z-index: 90;
  inset-inline: 0;
  top: calc(var(--topbar-h) + 14px);
  display: flex; justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}
.goto-inner {
  pointer-events: none; /* attivati solo da .goto.open: mai hitbox invisibili */
  width: 100%; max-width: 430px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  opacity: 0; transform: translateY(-8px) scale(.985);
  transition: opacity var(--transition), transform var(--transition);
}
.goto.open .goto-inner { opacity: 1; transform: none; pointer-events: auto; }
.goto-label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 9px; }
.goto-row { display: flex; gap: 8px; }
#gotoInput {
  flex: 1;
  font-family: var(--sans); font-size: 17px; font-weight: 600;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 0;
}
#gotoInput:focus { outline: 2px solid var(--accent); border-color: transparent; }
.goto-go {
  border: 0; border-radius: 10px;
  background: var(--accent); color: var(--bg-elev);
  font-size: 15px; font-weight: 600;
  padding: 0 22px;
  transition: filter var(--transition), transform 100ms ease;
}
.goto-go:hover { filter: brightness(1.08); }
.goto-go:active { transform: scale(.96); }
.goto-chapters { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 13px; }
.goto-chapters button {
  aspect-ratio: 1.25;
  border: 0; border-radius: 8px;
  background: var(--bg-soft);
  font-size: 13px; font-weight: 600; color: var(--text-soft);
  transition: background var(--transition), color var(--transition);
}
.goto-chapters button:hover { background: var(--highlight); color: var(--text); }
.goto-chapters button.active { background: var(--accent); color: var(--bg-elev); }

/* ---------- Word popup ---------- */
.word-popup {
  position: fixed; z-index: 90;
  inset-inline: 0; inset-block-end: 0;
  display: flex; justify-content: center;
  padding: 0 12px max(14px, env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform var(--transition-panel);
  pointer-events: none;
}
.word-popup.open { transform: translateY(0); pointer-events: auto; }
.word-popup-inner {
  position: relative;
  width: 100%; max-width: 430px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.word-popup-close { position: absolute; top: 8px; inset-inline-end: 8px; }
.wp-greek { font-family: var(--greek); font-size: 31px; color: var(--text); padding-inline-end: 38px; line-height: 1.25; }
.wp-translit { font-family: var(--sans); font-size: 14px; color: var(--text-muted); font-style: italic; margin-top: 2px; }
.wp-fields { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 16px 0 12px; }
.wp-fields dt {
  font-family: var(--sans); font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted);
  align-self: start; padding-top: 3px;
}
.wp-fields dd { margin: 0; font-family: var(--serif); font-size: 16.5px; color: var(--text); }
.wp-link { font-family: var(--sans); font-size: 13.5px; font-weight: 600; }

/* ---------- Verse actions ---------- */
.verse-actions {
  position: fixed; z-index: 90;
  inset-inline: 0; inset-block-end: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 12px max(14px, env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform var(--transition-panel);
  pointer-events: none;
}
.verse-actions.open { transform: translateY(0); pointer-events: auto; }
.va-ref {
  margin: 0 0 8px;
  width: 100%; max-width: 430px;
  font-family: var(--serif); font-size: 17px; font-weight: 600;
  color: var(--bg-elev);
  background: var(--accent);
  border-radius: 14px 14px 4px 4px;
  padding: 11px 18px;
  box-shadow: var(--shadow);
}
.va-buttons {
  width: 100%; max-width: 430px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.va-buttons button {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 11px;
  font-size: 13.5px; font-weight: 600;
  color: var(--text-soft);
  padding: 12px 6px;
  box-shadow: var(--shadow-soft);
  transition: background var(--transition), color var(--transition), transform 100ms ease;
}
.va-buttons button:hover { background: var(--bg-soft); color: var(--text); }
.va-buttons button:active { transform: scale(.96); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 120;
  left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  background: var(--text); color: var(--bg);
  font-size: 13.5px; font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  max-width: min(86vw, 480px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Consenso archiviazione (banner cookie) ---------- */
.consent {
  position: fixed; z-index: 130;
  inset-inline: 0; inset-block-end: 0;
  display: flex; justify-content: center;
  padding: 0 12px max(12px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.consent-inner {
  pointer-events: auto;
  width: 100%; max-width: 580px;
  margin-bottom: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 15px 17px;
  display: flex; flex-direction: column; gap: 12px;
}
.consent-text { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-soft); }
.consent-text strong { color: var(--text); font-weight: 600; }
.consent-actions { display: flex; gap: 8px; justify-content: flex-end; }
.consent-btn {
  border: 1px solid var(--border); border-radius: 10px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  padding: 9px 20px; cursor: pointer; white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform 100ms ease;
}
.consent-btn:active { transform: scale(.96); }
.consent-btn.ghost { background: transparent; color: var(--text-soft); }
.consent-btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.consent-btn.primary { background: var(--accent); color: var(--bg-elev); border-color: var(--accent); }
.consent-btn.primary:hover { filter: brightness(1.08); }
@media (min-width: 580px) {
  .consent-inner { flex-direction: row; align-items: center; gap: 16px; }
  .consent-text { flex: 1; }
  .consent-actions { flex: none; }
}
html.embed .consent { padding-bottom: calc(12px + env(safe-area-inset-bottom) + var(--embed-safe-b, 0px)); }

/* ---------- Pulsante "Installa app" ---------- */
.install-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin: 2px 0 12px; padding: 12px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: var(--bg-elev);
  font-family: var(--sans); font-size: 14.5px; font-weight: 600;
  box-shadow: var(--shadow-soft);
  transition: filter var(--transition), transform 100ms ease;
}
.install-cta:hover { filter: brightness(1.08); }
.install-cta:active { transform: scale(.985); }

/* ---------- Glossario ---------- */
.gloss-intro { margin: 0 0 12px; line-height: 1.5; }
.glossary { display: flex; flex-direction: column; gap: 8px; }
.gloss-item {
  padding: 11px 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent-soft);
  border-radius: var(--radius-s);
}
.gloss-item p { margin: 0; }
.gloss-term { font-family: var(--serif); font-weight: 600; font-size: 16px; color: var(--text); }
.gloss-or { margin-top: 3px; font-size: 13px; }
.gloss-or [lang='grc'] { font-family: var(--greek); color: var(--text-soft); font-size: 15.5px; }
.gloss-tr { font-style: italic; color: var(--text-muted); margin-inline-start: 5px; }
.gloss-mean { margin-top: 5px; font-size: 13.5px; color: var(--text-soft); line-height: 1.5; }
.gloss-usual { margin-top: 5px; font-family: var(--sans); font-size: 12px; color: var(--text-muted); }

/* ============================================================
   Tablet ≥720px
   ============================================================ */
@media (min-width: 720px) {
  :root { --gutter: 32px; }

  /* Panels become right-side drawers */
  .panel {
    inset-block: 0; inset-inline: auto 0;
    width: var(--panel-w); max-width: 92vw; max-height: none;
    border-radius: 0;
    border: 0; border-inline-start: 1px solid var(--border);
    transform: translateX(104%);
  }
  .panel.open { transform: translateX(0); }
  .panel-inner { padding: 20px 26px 30px; }
  .panel-inner::before { display: none; }

  /* Word popup + verse actions become centered dialogs */
  .word-popup, .verse-actions {
    inset: 0;
    align-items: center; justify-content: center;
    padding: 24px;
    transform: none;
    opacity: 0;
    transition: opacity var(--transition);
  }
  .word-popup .word-popup-inner { transform: translateY(8px) scale(.98); transition: transform var(--transition); }
  .word-popup.open, .verse-actions.open { opacity: 1; }
  .word-popup.open .word-popup-inner { transform: none; }
  .verse-actions { flex-direction: column; }

  .goto { top: calc(var(--topbar-h) + 40px); }
}

/* ============================================================
   Desktop ≥1160px — lettura centrata, più aria ai lati
   ============================================================ */
@media (min-width: 1160px) {
  .reader { padding-inline: clamp(32px, 5vw, 72px); }
}

/* ============================================================
   Embed (iframe, es. Wix) — flusso naturale, mai collassare
   ============================================================ */
html.embed { height: auto; }
html.embed body { height: auto; min-height: 0; }
html.embed.auto-height .reader { min-height: 0; }
html.embed.auto-height .topbar { position: static; }

/* Zona di rispetto inferiore (--embed-safe-b, impostata da JS o ?safebottom=NN):
   negli embed a tutta pagina la GUI inferiore del browser mobile copre la
   parte bassa dell'iframe; teniamo contenuti e controlli sopra quella fascia.
   Gli sfondi dei fogli continuano fin sotto la barra (effetto naturale). */
html.embed .reader { padding-bottom: calc(56px + var(--embed-safe-b, 0px)); }
html.embed .toast { bottom: calc(22px + env(safe-area-inset-bottom) + var(--embed-safe-b, 0px)); }
@media (max-width: 719px) {
  html.embed .panel-inner {
    padding-bottom: calc(26px + env(safe-area-inset-bottom) + var(--embed-safe-b, 0px));
  }
  html.embed .panel { max-height: calc(100% - var(--embed-safe-b, 0px) - 12px); }
  html.embed .word-popup,
  html.embed .verse-actions {
    padding-bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--embed-safe-b, 0px));
  }
}
/* ---------- Evidenziazioni ---------- */
:root {
  --hl-y: #eab308;
  --hl-g: #22c55e;
  --hl-b: #3b82f6;
  --hl-p: #ec4899;
}
.verse[data-hl='y'] { background: color-mix(in srgb, var(--hl-y) 16%, transparent); }
.verse[data-hl='g'] { background: color-mix(in srgb, var(--hl-g) 14%, transparent); }
.verse[data-hl='b'] { background: color-mix(in srgb, var(--hl-b) 13%, transparent); }
.verse[data-hl='p'] { background: color-mix(in srgb, var(--hl-p) 13%, transparent); }

/* Riga colori nella scheda azioni */
.va-card {
  width: 100%; max-width: 430px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.va-card .va-ref {
  margin: 0; width: auto; max-width: none;
  border-radius: 0; box-shadow: none;
}
.va-hl {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.va-hl-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted);
  margin-inline-end: 2px;
}
.va-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 100ms ease, border-color var(--transition), box-shadow var(--transition);
}
.va-dot[data-hl='y'] { background: var(--hl-y); }
.va-dot[data-hl='g'] { background: var(--hl-g); }
.va-dot[data-hl='b'] { background: var(--hl-b); }
.va-dot[data-hl='p'] { background: var(--hl-p); }
.va-dot.none { background: var(--bg-soft); color: var(--text-muted); border-color: var(--border); }
.va-dot:hover { transform: scale(1.12); }
.va-dot.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-elev) inset; }
.va-card .va-buttons {
  max-width: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
}
.va-card .va-buttons button {
  border: 0; border-radius: 0;
  box-shadow: none;
  background: var(--bg-elev);
  padding: 13px 6px;
}
.va-card .va-buttons button:hover { background: var(--bg-soft); }
.va-card .va-buttons.va3 #vaCopyLink { grid-column: span 2; }
#vaSave.saved { color: var(--accent); }

/* Pallino colore nelle liste */
.hl-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%;
  margin-inline-end: 7px;
  vertical-align: 1px;
}
.hl-dot.y { background: var(--hl-y); }
.hl-dot.g { background: var(--hl-g); }
.hl-dot.b { background: var(--hl-b); }
.hl-dot.p { background: var(--hl-p); }

/* Salva capitolo (accanto al titolo) */
.chapter-heading .heading-row { display: flex; align-items: center; gap: 12px; }
.chapter-save {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text-muted);
  transition: color var(--transition), border-color var(--transition), transform 100ms ease;
}
.chapter-save:hover { color: var(--accent); border-color: var(--accent-soft); }
.chapter-save:active { transform: scale(.92); }
.chapter-save.saved { color: var(--accent); border-color: var(--accent-soft); }
.chapter-save.saved svg { fill: currentColor; }

/* Pannello salvati */
.saved-section { padding: 14px 0; border-top: 1px solid var(--border); }
.saved-section:first-child { border-top: 0; }
.saved-section h3 {
  margin: 0 0 10px;
  font-size: 11.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted);
}
.saved-empty { color: var(--text-muted); font-size: 14px; margin: 4px 0; }
.saved-chapters { display: flex; flex-wrap: wrap; gap: 6px; }
.saved-chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 6px 7px 6px 13px;
  font-size: 13.5px; font-weight: 600; color: var(--text-soft);
  transition: border-color var(--transition), color var(--transition);
}
.saved-chip:hover { border-color: var(--accent-soft); color: var(--text); }
.saved-chip .x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  border: 0; border-radius: 50%;
  background: var(--bg-elev);
  color: var(--text-muted);
  padding: 0;
  transition: background var(--transition), color var(--transition);
}
.saved-chip .x:hover { background: var(--danger); color: #fff; }
.saved-item {
  position: relative;
  width: 100%;
  text-align: start;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: transparent;
  padding: 10px 38px 10px 12px;
  transition: background var(--transition), border-color var(--transition);
  display: block;
}
.saved-item:hover { background: var(--bg-soft); border-color: var(--border); }
.saved-item .ref { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.saved-item .snippet { font-family: var(--serif); font-size: 14.5px; line-height: 1.5; color: var(--text-soft); }
.saved-item .x {
  position: absolute; top: 8px; inset-inline-end: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  padding: 0;
  transition: background var(--transition), color var(--transition);
}
.saved-item .x:hover { background: var(--danger); color: #fff; }
.saved-list { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Schermi molto stretti: topbar più densa ---------- */
@media (max-width: 400px) {
  /* Solo i margini laterali: padding-inline NON tocca il padding-top dell'inset
     (con lo shorthand `padding: 0 6px` l'inset spariva e i tasti finivano
     sotto la barra delle notifiche su tutti i telefoni ≤400px). */
  .topbar-inner { padding-inline: 6px; gap: 2px; }
  .iconbtn { width: 37px; height: 37px; }
  .ref-chip { padding: 5px 9px; font-size: 12px; gap: 4px; }
  .topbar-title { font-size: 17px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Forced colors (Windows High Contrast) ----------
   Gli indicatori basati solo su colore di sfondo/ombra spariscono: li
   rendiamo percepibili anche con un bordo/contorno di sistema. */
@media (forced-colors: active) {
  .segmented input:checked + label { outline: 2px solid Highlight; outline-offset: -2px; }
  .segmented input:focus-visible + label { outline: 2px solid Highlight; }
  .switch input:checked + .track { background: Highlight; }
  .term-note { outline: 1px solid ButtonText; }
  .ref-chip, .navcard, .va-buttons button { border-color: ButtonText; }
}

/* ---------- Print ---------- */
@media print {
  .topbar, .panel, .overlay, .prevnext, .reader-footer,
  .goto, .word-popup, .verse-actions, .toast, .progress { display: none !important; }
  .shell { display: block; }
  .reader { padding: 0; min-height: 0; }
  .verse-text { font-size: 12pt; line-height: 1.6; }
  body { background: #fff; color: #000; }
}
