/* ==========================================================================
   Lecteur numerique V3 — habillage "publication" (type Fluidbook)
   Couleurs Kogitas : orange du logo, bleu nuit, indigo des accents du site.
   ========================================================================== */

:root {
    --navy: #0b1d3a;
    --orange: #ff6b2c;
    --orange-dark: #e2561a;
    --orange-soft: #fff1ea;
    --indigo: #6366f1;
    --violet: #7c3aed;
    --bg: #f3f4f9;
    --ink: #0f172a;
    --text: #475569;
    --muted: #94a3b8;
    --line: #e2e8f0;
    --white: #ffffff;
    --surface: #ffffff;
    --track: #d7dbe7;
    --toast-bg: #0b1d3a;
    /* Composantes RVB des deux couleurs de marque, pour les rgba() ; couleur
       des surlignages de recherche ; couleur de la barre du navigateur mobile.
       Un theme de livre (plus bas) les redefinit toutes. */
    --accent-rgb: 255, 107, 44;
    --navy-rgb: 11, 29, 58;
    --mark: #ffe0cf;
    --theme-color: #0b1d3a;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -8px rgba(15, 23, 42, .18);
    --shadow-lg: 0 2px 4px rgba(15, 23, 42, .06), 0 28px 60px -20px rgba(var(--navy-rgb), .45);
    --top-h: 64px;
    --bottom-h: 44px;   /* 56 -> 44 le 06/11/2026 : livre a la taille de Fluidbook */
    --panel-w: 340px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Mode sombre : les surfaces et textes changent, les pages du livre restent blanches */
body.dark {
    --navy: #e8ecf4;
    --bg: #0f172a;
    --ink: #e2e8f0;
    --text: #a3b1c6;
    --muted: #6b7a90;
    --line: #243149;
    --surface: #16213a;
    --orange-soft: rgba(var(--accent-rgb), .16);
    --track: #2b3a55;
    --toast-bg: #1e293b;
    --theme-color: #0f172a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -8px rgba(0, 0, 0, .6);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 28px 60px -20px rgba(0, 0, 0, .85);
}

/* --------------------------------------------------------------------------
   Themes par livre — reglage « Theme » du catalogue (wp-admin > Lecteur
   Numerique). La classe theme-<nom> est posee sur <body> par le serveur
   (viewer-v3.html) et par reader-v3.js depuis VIEWER_DATA.theme (application).
   Un theme ne redefinit que des variables : aucune regle de mise en page.
   -------------------------------------------------------------------------- */

/* Region Occitanie — palette EXACTE de la publication Fluidbook du guide
   ID.Metiers (infographies.laregion.fr/guidesIDmetiers/Guide-voie-pro-2026,
   configuration data/datas.js lue le 16/10/2026) :
     rouge   #c10230  boutons, menu, marque-pages, infobulles, chargement
     jaune   #ffcd00  secondaire (etoile de marque-page), survol #dbb000
     liens   #fde805
     fond    #f5f5f5  numeros de page #656565, credits rgb(60, 60, 60) */
body.theme-occitanie {
    --navy: #3c3c3c;
    --navy-rgb: 60, 60, 60;
    --orange: #c10230;
    --orange-dark: #9c0027;
    --orange-soft: #f8e5e9;
    --accent-rgb: 193, 2, 48;
    --indigo: #dbb000;
    --violet: #ffcd00;
    --bg: #f5f5f5;
    --ink: #0c0c0c;
    --text: #656565;
    --muted: #a2a2a2;
    --line: #e3e3e3;
    --track: #d6d6d6;
    --toast-bg: #c10230;
    --mark: #fde805;
    --theme-color: #c10230;
}
body.theme-occitanie.dark {
    --navy: #f1f1f1;
    --navy-rgb: 0, 0, 0;
    --bg: #1b1b1b;
    --ink: #f1f1f1;
    --text: #c6c6c6;
    --muted: #8c8c8c;
    --line: #3a3a3a;
    --surface: #272727;
    --orange-soft: rgba(193, 2, 48, .22);
    --track: #474747;
    --toast-bg: #2e2e2e;
    --theme-color: #1b1b1b;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }
.hidden { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   Ecran de chargement
   -------------------------------------------------------------------------- */
#splash {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    transition: opacity .4s ease;
}
#splash.fade { opacity: 0; pointer-events: none; }
.splash-card {
    width: min(420px, 90vw); text-align: center;
    background: var(--surface); border-radius: 22px; padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}
.splash-logo { height: 56px; width: auto; }
.splash-title { font-size: 18px; font-weight: 700; margin: 18px 0 20px; color: var(--navy); }
.splash-progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
#load-progress { height: 100%; width: 0; background: linear-gradient(90deg, var(--orange), var(--violet)); transition: width .3s; }
#load-status { margin: 14px 0 0; color: var(--text); font-size: 13px; }

/* --------------------------------------------------------------------------
   Barre haute
   -------------------------------------------------------------------------- */
#topbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 30;
    display: flex; align-items: center; gap: 18px; padding: 0 16px;
}
#tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.tb {
    width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent;
    color: var(--navy); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s, transform .15s;
}
.tb svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tb:hover { background: var(--surface); box-shadow: var(--shadow); color: var(--orange); }
.tb:active { transform: scale(.94); }
.tb.active { color: var(--orange); background: var(--orange-soft); }
.tb:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.tb[disabled] { opacity: .35; cursor: not-allowed; }
#t-sound .ic-off { display: none; }
#t-theme .ic-sun { display: none; }
body.dark #t-theme .ic-moon { display: none; }
body.dark #t-theme .ic-sun { display: block; }
/* Pictos pleins repris de Fluidbook (plein ecran) */
.tb svg.ic-fill { fill: currentColor; stroke: none; }
#t-fullscreen .ic-fs-off, body.fullscreen #t-fullscreen .ic-fs-on { display: none; }
body.fullscreen #t-fullscreen .ic-fs-off { display: block; }
#t-sound.muted .ic-on { display: none; }
#t-sound.muted .ic-off { display: block; }
.tb.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), .5); } 50% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); } }

#pills { display: flex; align-items: center; gap: 10px; }
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--orange); color: var(--white); border: 0; border-radius: 5px;
    padding: 9px 14px; font-size: 12.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
    text-decoration: none; cursor: pointer; box-shadow: 0 2px 0 var(--orange-dark);
    transition: background .15s, transform .1s;
}
.pill .arrow { font-weight: 400; }
.pill:hover { background: var(--orange-dark); }
.pill:active { transform: translateY(1px); box-shadow: none; }

#logo {
    margin-left: auto; display: inline-flex; align-items: center;
    background: var(--white); border-radius: 10px; padding: 7px 14px; box-shadow: var(--shadow);
    transition: transform .15s;
}
#logo img { height: 36px; width: auto; display: block; }
#logo:hover { transform: translateY(-1px); }

/* --------------------------------------------------------------------------
   Scene
   -------------------------------------------------------------------------- */
#stage {
    position: fixed; top: var(--top-h); bottom: var(--bottom-h); left: 0; right: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    transition: right .3s ease;
}
body.panel-open #stage { right: var(--panel-w); }
body.zoomed #stage { overflow: auto; display: block; cursor: grab; }
body.zoomed.panning #stage { cursor: grabbing; }

/* padding-top : la place des onglets de marque-page qui depassent du livre */
#book-area { position: relative; display: flex; flex-direction: column; align-items: center; padding-top: 28px; }
body.zoomed #book-area { padding: 24px 90px; width: max-content; margin: 0 auto; min-height: 100%; justify-content: center; }

#flipbook-wrapper {
    position: relative;
    filter: drop-shadow(0 10px 22px rgba(var(--navy-rgb), .2));
}
#flipbook { position: relative; z-index: 1; }
.stf__parent { overflow: visible !important; }

/* Pas de reflet sur la page qui tourne : on garde l'ombre PORTEE sur la page
   du dessous (outerShadow), on retire l'ombre INTERIEURE de StPageFlip qui,
   sur une page blanche, ressemble a un reflet brillant. */
.stf__innerShadow, .stf__hardInnerShadow { display: none !important; }

/* Reliure : creux marque au centre de la double page */
#book-gutter {
    position: absolute; top: 0; bottom: 0; left: 50%; width: 110px; transform: translateX(-50%);
    z-index: 4; pointer-events: none; transition: opacity .2s;
    background: linear-gradient(90deg,
        rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .05) 28%, rgba(0, 0, 0, .15) 44%, rgba(0, 0, 0, .34) 50%,
        rgba(0, 0, 0, .15) 56%, rgba(0, 0, 0, .05) 72%, rgba(0, 0, 0, 0) 100%);
}
#book-gutter.off { opacity: 0; }

/* Epaisseur : tranches de pages empilees de chaque cote, proportionnelles
   aux pages deja lues (gauche) et restantes (droite). Tranche fine et ombre
   legere, comme Fluidbook (« un peu trop epais », mail d'Helene du 28/10/2026). */
.book-edge {
    position: absolute; top: 2px; bottom: -2px; width: 0; z-index: 0; pointer-events: none;
    background: repeating-linear-gradient(to right, #fbfaf7 0 1px, #dedad2 1px 2px);
    border: 1px solid #cdc8bf; transition: width .3s;
}
#edge-right { right: 0; transform: translateX(100%); border-left: 0; border-radius: 0 2px 2px 0; box-shadow: 2px 3px 6px rgba(var(--navy-rgb), .16); }
#edge-left { left: 0; transform: translateX(-100%); border-right: 0; border-radius: 2px 0 0 2px; box-shadow: -2px 3px 6px rgba(var(--navy-rgb), .16); }
body.dark .book-edge { background: repeating-linear-gradient(to right, #e9e6df 0 1px, #b9b4a9 1px 2px); border-color: #8f8a80; }

.page-content {
    position: relative; width: 100%; height: 100%; overflow: hidden;
    background: #ffffff;
    display: flex; align-items: center; justify-content: center;
}
.page-content canvas { display: block; max-width: 100%; max-height: 100%; }
.page-content.hard { background: #f4f1ea; }

/* Chaque feuillet sur sa propre couche de composition : StPageFlip anime
   transform et clip-path a chaque image, autant eviter de re-tramer le canvas */
.stf__item { will-change: transform; }

/* Couche de surlignage (recherche) et ruban marque-page, posés sur la page */
.hl-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
/* Liens du PDF : invisibles au repos, éclairés au survol, nouvel onglet au clic */
.lk {
    position: absolute; display: block; pointer-events: auto; cursor: pointer;
    border-radius: 3px; background: transparent; box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0);
    transition: background .15s, box-shadow .15s;
}
.lk:hover, .lk:focus-visible { background: rgba(var(--accent-rgb), .18); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .55); outline: 0; }
.hl { position: absolute; background: rgba(var(--accent-rgb), .38); border-radius: 2px; mix-blend-mode: multiply; }
.hl.current { background: rgba(99, 102, 241, .45); }
/* Coin de page cliquable : discret tant que la page n'est pas marquee, ruban orange sinon */
.bm-tab {
    position: absolute; top: -2px; right: 16px; width: 24px; height: 34px; z-index: 3;
    border: 0; padding: 0; cursor: pointer; pointer-events: auto;
    background: rgba(var(--navy-rgb), .16);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
    transition: background .15s, height .15s;
}
.bm-tab.left { right: auto; left: 16px; }
.bm-tab:hover, .bm-tab:focus-visible { background: rgba(var(--accent-rgb), .7); height: 40px; outline: none; }
.bm-tab.on { background: var(--orange); height: 40px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.bm-tab.on:hover { background: var(--orange-dark); }
#t-bookmarks.marked svg { fill: var(--orange); stroke: var(--orange); }
/* En mode defilement la page n'est pas rognee : le coin depasse directement */
.sv-page .bm-tab { top: -12px; }

/* Onglets qui depassent au-dessus du livre (un par page marquee) */
#bm-strip { position: absolute; left: 0; right: 0; top: 0; height: 0; z-index: 6; pointer-events: none; }
.bm-peek {
    position: absolute; bottom: 0; min-width: 24px; height: 18px; border: 0; padding: 0 5px 2px;
    cursor: pointer; pointer-events: auto;
    background: var(--orange); color: var(--white); font-size: 10px; font-weight: 800; line-height: 1;
    border-radius: 5px 5px 0 0; box-shadow: 0 -1px 3px rgba(var(--navy-rgb), .25);
    transition: height .15s, background .15s;
}
.bm-peek.visible { height: 22px; }
.bm-peek:hover, .bm-peek:focus-visible { height: 26px; background: var(--orange-dark); outline: none; }

/* Onglets de section sur la tranche droite (annuaire ID.Metiers : une
   academie par onglet), comme la publication de reference de la Region :
   empiles sur toute la hauteur du livre, derriere lui, celui de la section
   affichee sort un peu plus. Masques en page seule, au zoom et en defilement
   (le sommaire de cote donne les memes sections). Largeur et texte suivent
   la hauteur du livre (--tabs-h, posee par le script). */
#side-tabs {
    position: absolute; top: 0; bottom: 0; right: 0; width: 0; z-index: 0;
    --tab-w: calc(var(--tabs-h, 600px) * .058);
}
#side-tabs[hidden] { display: none; }
.side-tab {
    position: absolute; left: 0; width: var(--tab-w); margin: 0; padding: 0; border: 0;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    background: var(--tab-bg, #ef7a26); color: var(--tab-fg, #fff); cursor: pointer; pointer-events: auto;
    border-radius: 0 3px 3px 0; box-shadow: 2px 2px 5px rgba(var(--navy-rgb), .18);
    transition: width .4s, filter .15s;
}
.side-tab span {
    writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap;
    font-family: "Bebas Neue", "Oswald", "Roboto Condensed", "Arial Narrow", "Liberation Sans Narrow", var(--font);
    font-stretch: condensed; font-weight: 700; text-transform: uppercase; letter-spacing: .01em;
    font-size: calc(var(--tabs-h, 600px) * .03); line-height: 1;
}
/* Section affichee : l'onglet s'ELARGIT vers l'exterieur et reste colle a la
   page, comme Fluidbook (un decalage ouvrait un jour entre page et onglet,
   signalements Giblim 591/592 du 05/11/2026). */
.side-tab.active { width: calc(var(--tab-w) + var(--tabs-h, 600px) * .017); }
.side-tab:hover { filter: brightness(1.06); }
.side-tab:focus-visible { outline: 3px solid var(--focus-ring, #1d4ed8); outline-offset: 2px; }
body.zoomed #side-tabs { display: none; }

#pagenums { margin-top: 4px; color: var(--muted); font-size: 13px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }

/* Fleches de bord (bloc orange, comme la publication de reference) */
.edge-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 20;
    display: flex; flex-direction: column; background: var(--orange); color: var(--white);
    box-shadow: var(--shadow); overflow: hidden;
    transition: opacity .2s, transform .2s;
}
.edge-right { right: 0; border-radius: 8px 0 0 8px; }
.edge-left { left: 0; border-radius: 0 8px 8px 0; }
.edge-nav button {
    width: 48px; height: 60px; border: 0; background: transparent; color: inherit; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.edge-nav button.small { height: 36px; border-top: 1px solid rgba(255, 255, 255, .35); }
.edge-nav button svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.edge-nav button.small svg { width: 20px; height: 20px; }
.edge-nav button:hover { background: var(--orange-dark); }
.edge-nav.off { opacity: 0; pointer-events: none; }
.edge-right.off { transform: translate(100%, -50%); }
.edge-left.off { transform: translate(-100%, -50%); }

#zoomctl {
    position: absolute; right: 18px; bottom: 14px; z-index: 20;
    display: flex; align-items: center; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow);
    padding: 3px;
}
#zoomctl button {
    border: 0; background: transparent; color: var(--navy); cursor: pointer; height: 30px; min-width: 30px;
    border-radius: 999px; font-weight: 700; font-size: 16px;
}
#zoomctl #z-level { font-size: 12px; font-weight: 600; color: var(--text); padding: 0 6px; font-variant-numeric: tabular-nums; }
#zoomctl button:hover { background: var(--orange-soft); color: var(--orange); }

/* Mode defilement */
#scrollview {
    position: absolute; inset: 0; overflow: auto; padding: 24px 90px;
    display: flex; flex-direction: column; align-items: center; gap: 24px;
}
.sv-page { position: relative; background: #ffffff; box-shadow: var(--shadow-lg); flex-shrink: 0; }
.sv-page canvas { display: block; }
.sv-page .sv-num { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 12px; }

/* --------------------------------------------------------------------------
   Barre basse : curseur de pages
   -------------------------------------------------------------------------- */
#bottombar {
    position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-h); z-index: 30;
    display: flex; align-items: center; padding: 0 110px;
    transition: right .3s ease;
}
body.panel-open #bottombar { right: var(--panel-w); }
#scrubber { position: relative; flex: 1; max-width: 760px; margin: 0 auto; height: 30px; cursor: pointer; outline: none; }
#scrub-track { position: absolute; left: 0; right: 0; top: 13px; height: 4px; border-radius: 2px; background: var(--track); }
#scrub-fill { height: 100%; width: 0; border-radius: 2px; background: var(--orange); }
#scrub-handle {
    position: absolute; top: 5px; left: 0; width: 20px; height: 20px; margin-left: -10px;
    border-radius: 50%; background: var(--surface); border: 3px solid var(--orange); box-shadow: var(--shadow);
    transition: transform .1s;
}
#scrubber:hover #scrub-handle, #scrubber.drag #scrub-handle { transform: scale(1.15); }
#scrubber:focus-visible #scrub-handle { outline: 2px solid var(--indigo); outline-offset: 2px; }
#scrub-tip {
    position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
    background: var(--navy); color: var(--white); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px;
    white-space: nowrap; opacity: 0; transition: opacity .15s; pointer-events: none;
}
#scrubber:hover #scrub-tip, #scrubber.drag #scrub-tip { opacity: 1; }
#credit { position: absolute; right: 16px; bottom: 8px; color: var(--muted); font-size: 11px; }

/* --------------------------------------------------------------------------
   Narration
   -------------------------------------------------------------------------- */
#audiobar {
    position: fixed; bottom: calc(var(--bottom-h) + 6px); left: 50%; transform: translateX(-50%); z-index: 31;
    display: flex; align-items: center; gap: 6px; padding: 6px 10px;
    background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-lg);
}
.ab { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--navy); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.ab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.ab:hover { background: var(--orange-soft); color: var(--orange); }
.ab-main { background: var(--orange); color: var(--white); width: 40px; height: 40px; }
.ab-main:hover { background: var(--orange-dark); color: var(--white); }
#a-play .ic-pause { display: none; }
#a-play.playing .ic-play { display: none; }
#a-play.playing .ic-pause { display: block; }
#a-track { width: 140px; height: 6px; border-radius: 3px; background: var(--line); cursor: pointer; }
#a-fill { height: 100%; width: 0; border-radius: 3px; background: var(--indigo); }
#a-time { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; min-width: 36px; }
#a-voice { font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }

/* --------------------------------------------------------------------------
   Panneau lateral
   -------------------------------------------------------------------------- */
#panel {
    position: fixed; top: var(--top-h); right: 0; bottom: var(--bottom-h); width: var(--panel-w); z-index: 35;
    display: flex; flex-direction: column;
    background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(var(--navy-rgb), .08);
    transform: translateX(100%); transition: transform .3s ease;
}
#panel.open { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 800; color: var(--navy); text-transform: uppercase; letter-spacing: .05em; }
.panel-body { flex: 1; overflow: auto; padding: 14px 16px; }
.panel-hint { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; }
.panel-label { display: block; font-weight: 700; font-size: 13px; margin: 0 0 6px; color: var(--navy); }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row input[type="text"] { flex: 1; }
.btn {
    border: 0; border-radius: 8px; background: var(--orange); color: var(--white); font-weight: 700;
    padding: 9px 14px; cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--orange-dark); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-block { width: 100%; margin-bottom: 12px; }
input[type="search"], input[type="text"], textarea, input[type="number"] {
    font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); color: var(--ink);
}
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; }
#search-form { display: flex; gap: 8px; margin-bottom: 8px; }
#search-input { flex: 1; min-width: 0; }

.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.thumb { cursor: pointer; text-align: center; border: 0; background: transparent; padding: 0; font: inherit; color: var(--text); }
.thumb canvas { width: 100%; display: block; background: #ffffff; border: 3px solid transparent; border-radius: 4px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.thumb:hover canvas { transform: translateY(-2px); }
.thumb.active canvas { border-color: var(--orange); }
.thumb .lbl { display: block; margin-top: 5px; font-size: 12px; }
.thumb .lbl .bm { color: var(--orange); }

ol.toc, ol.results { list-style: none; margin: 0; padding: 0; }
.toc li button, .results li button {
    display: flex; width: 100%; gap: 10px; align-items: flex-start; text-align: left;
    border: 0; background: transparent; padding: 9px 8px; border-radius: 8px; cursor: pointer; color: var(--ink); font: inherit;
}
.toc li button:hover, .results li button:hover { background: var(--bg); }
.toc li.active button { background: var(--orange-soft); }
.toc .t { flex: 1; }
.toc .p, .results .p {
    flex-shrink: 0; min-width: 30px; text-align: center; font-size: 12px; font-weight: 800; color: var(--white);
    background: var(--orange); border-radius: 6px; padding: 2px 6px; font-variant-numeric: tabular-nums;
}
.results .s { flex: 1; font-size: 13px; color: var(--text); }
.results .s mark { background: var(--mark); color: #0f172a; border-radius: 2px; padding: 0 1px; }
/* width/flex : la croix est aussi un « .results li button » (width: 100 %) et prenait la moitie de la ligne */
.results .del { width: auto; flex: 0 0 auto; margin-left: auto; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.results .del:hover { color: var(--orange); background: var(--orange-soft); }
.results li { display: flex; align-items: center; }
.results li > button:first-child { flex: 1 1 auto; width: auto; min-width: 0; }
/* Marque-pages : miniature de la page marquee (demande du 20/10/2026) */
.results li.bm-item > button:first-child { flex: 1 1 100%; align-items: center; gap: 12px; padding: 8px 10px; }
.bm-thumb { flex: 0 0 64px; width: 64px; display: block; background: #ffffff; border-radius: 3px; box-shadow: var(--shadow); border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.results li.bm-item > button:first-child:hover .bm-thumb { border-color: var(--orange); transform: translateY(-1px); }
.bm-item .s { display: flex; flex-direction: column; gap: 2px; }
.bm-item .s strong { font-weight: 700; font-size: 14px; white-space: nowrap; }
.bm-item .s small { font-size: 12px; color: var(--muted); }

.textview { white-space: pre-wrap; font-size: 14px; line-height: 1.6; color: var(--ink); }

/* --------------------------------------------------------------------------
   Fenetres
   -------------------------------------------------------------------------- */
#overlay { position: fixed; inset: 0; z-index: 50; background: rgba(var(--navy-rgb), .45); backdrop-filter: blur(2px); }
.modal {
    position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(560px, 92vw); max-height: 88vh; overflow: auto;
    background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 12px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 800; color: var(--navy); }
.modal-body { padding: 18px 22px 22px; }
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.help h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--orange); }
.help ul { margin: 0 0 16px; padding-left: 18px; color: var(--text); }
.help li { margin: 4px 0; }
.help .keys { list-style: none; padding: 0; }
kbd {
    display: inline-block; min-width: 22px; text-align: center; padding: 1px 6px; border-radius: 5px;
    background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; font-family: inherit; font-size: 12px; font-weight: 700; color: var(--navy);
}

#toast {
    position: fixed; left: 50%; bottom: calc(var(--bottom-h) + 14px); transform: translateX(-50%); z-index: 60;
    background: var(--toast-bg); color: #ffffff; padding: 10px 18px; border-radius: 999px; font-weight: 600;
    box-shadow: var(--shadow-lg); transition: opacity .3s;
}
#toast.out { opacity: 0; }

/* --------------------------------------------------------------------------
   Ecrans etroits
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
    .pill { font-size: 11.5px; padding: 8px 10px; }
    #logo img { height: 30px; }
}
@media (max-width: 900px) {
    :root { --panel-w: 300px; }
    #topbar { gap: 10px; padding: 0 8px; }
    #tools { overflow-x: auto; scrollbar-width: none; }
    #tools::-webkit-scrollbar { display: none; }
    #pills { display: none; }
    #bottombar { padding: 0 70px; }
    .edge-nav button { width: 40px; height: 54px; }
}
@media (max-width: 640px) {
    :root { --top-h: 56px; --bottom-h: 50px; --panel-w: 100vw; }
    #logo { display: none; }
    .tb { width: 38px; height: 38px; }
    #bottombar { padding: 0 16px 0 16px; }
    #credit { display: none; }
    #zoomctl { right: 10px; bottom: 10px; }
    .help { grid-template-columns: 1fr; }
    body.panel-open #stage, body.panel-open #bottombar { right: 0; }
    .edge-nav button { width: 36px; height: 48px; }
    .edge-nav button.small { display: none; }
}

@media print {
    body * { display: none !important; }
}

/* ==========================================================================
   Accessibilite (16/10/2026) — reperes : WCAG 2.2 (2.3.3 animations declenchees
   par interaction, 1.4.3 / 1.4.11 contrastes, 2.4.7 focus visible, 2.5.8 taille
   des cibles >= 24 px), RGAA 4.1 (13.8 : tout contenu en mouvement est controlable).
   ========================================================================== */

/* Focus clavier visible partout, pas seulement sur les boutons de la barre */
a:focus-visible, button:focus-visible, select:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--indigo); outline-offset: 2px;
}

/* Mouvement reduit : technique C39 du W3C, aucune transition ni animation */
body.a11y-reduced *, body.a11y-reduced *::before, body.a11y-reduced *::after {
    transition: none !important; animation: none !important; scroll-behavior: auto !important;
}

/* Couleurs des pages : filtres sur les canvas, l'interface reste lisible */
body.a11y-contrast .page-content canvas, body.a11y-contrast .sv-page canvas { filter: contrast(1.3) saturate(1.1); }
body.a11y-contrast { --text: #1e293b; --muted: #475569; --line: #94a3b8; }
body.a11y-contrast.dark { --text: #e2e8f0; --muted: #cbd5e1; --line: #64748b; }
body.a11y-invert .page-content canvas, body.a11y-invert .sv-page canvas { filter: invert(1) hue-rotate(180deg); }
body.a11y-invert .page-content, body.a11y-invert .sv-page { background: #0f172a; }
body.a11y-cream .page-content canvas, body.a11y-cream .sv-page canvas { filter: sepia(.32) brightness(.98); }
body.a11y-cream .page-content, body.a11y-cream .sv-page { background: #f6efdd; }

/* Interface agrandie : cibles de 48 px, textes plus grands */
body.a11y-bigui { font-size: 17px; --top-h: 76px; --bottom-h: 64px; --panel-w: 400px; }
body.a11y-bigui .tb { width: 50px; height: 50px; }
body.a11y-bigui .tb svg { width: 28px; height: 28px; }
body.a11y-bigui .edge-nav button { width: 60px; height: 74px; }
body.a11y-bigui .edge-nav button.small { height: 46px; }
body.a11y-bigui .edge-nav svg { width: 30px; height: 30px; }
body.a11y-bigui #zoomctl button { min-width: 44px; height: 44px; font-size: 20px; }
body.a11y-bigui #zoomctl #z-level { font-size: 15px; }
body.a11y-bigui .ab { width: 44px; height: 44px; }
body.a11y-bigui .btn { padding: 12px 18px; font-size: 15px; }
body.a11y-bigui .panel-hint { font-size: 15px; }
body.a11y-bigui .panel-head h2 { font-size: 18px; }
body.a11y-bigui .textview, body.a11y-bigui .toc, body.a11y-bigui .results { font-size: 17px; line-height: 1.6; }
body.a11y-bigui #pagenums { font-size: 16px; }

/* Regle de lecture : bande claire qui suit le pointeur, tout le reste assombri */
#ruler {
    position: absolute; left: 0; right: 0; top: 40%; height: var(--ruler-h, 96px);
    pointer-events: none; z-index: 25;
    box-shadow: 0 0 0 200vmax rgba(10, 20, 40, .45);
    border-top: 2px solid rgba(var(--accent-rgb), .85); border-bottom: 2px solid rgba(var(--accent-rgb), .85);
}
body.a11y-ruler-s #ruler { --ruler-h: 44px; }
body.a11y-ruler-l #ruler { --ruler-h: 180px; }

/* Panneau */
.a11y fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; margin: 0 0 12px; }
.a11y legend { font-weight: 800; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--navy); padding: 0 6px; }
.a11y .opt { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; cursor: pointer; color: var(--ink); line-height: 1.35; }
.a11y .opt input { width: 20px; height: 20px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--orange); cursor: pointer; }
.a11y .opt small { display: block; color: var(--muted); font-size: 12px; }
.a11y .opt.a11y-sub { justify-content: space-between; align-items: center; padding-left: 30px; }
.a11y select { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface); color: var(--ink); min-height: 32px; }
.a11y .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.a11y .btn.on { background: var(--orange-dark); }

/* Page pas encore dessinee : anneau discret au centre, a la place du blanc.
   Retire des que le canvas est trace ; sans animation en mouvement reduit. */
.page-content.loading::after, .sv-page.loading::after {
    content: ''; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
    border-radius: 50%; border: 3px solid rgba(var(--navy-rgb), .12); border-top-color: var(--orange);
    animation: kog-spin .9s linear infinite; z-index: 1; pointer-events: none;
}
@keyframes kog-spin { to { transform: rotate(360deg); } }
body.a11y-reduced .page-content.loading::after, body.a11y-reduced .sv-page.loading::after {
    animation: none; border-color: rgba(var(--navy-rgb), .12); border-top-color: var(--orange);
}
body.a11y-invert .page-content.loading::after { border-color: rgba(255, 255, 255, .18); }

/* Version texte alimentee par le script de narration : vrais titres et paragraphes */
.textview h3 { margin: 14px 0 6px; font-size: 15px; font-weight: 800; color: var(--navy); }
.textview h3:first-child { margin-top: 0; }
.textview p { margin: 0 0 10px; line-height: 1.55; white-space: normal; }

/* Logo propre au livre (ex. Region Occitanie, carre) : plus haut que le logo Kogitas, sans deborder de la barre */
/* Incruste dans le fond, comme la reference (27/10/2026) : ni carte blanche, ni ombre, ni arrondi. */
#logo.book { background: none; padding: 0; border-radius: 0; box-shadow: none; }
#logo.book img { height: 52px; border-radius: 0; }
@media (max-width: 900px) { #logo.book img { height: 40px; } }

/* ==========================================================================
   LECTEUR DEV puis PUBLICATION — mise en conformite RGAA (23/10/2026)
   ========================================================================== */

/* Liens d'evitement : invisibles jusqu'a ce que la tabulation les atteigne (RGAA 12.7) */
.skip-links a {
    position: fixed; left: 12px; top: -60px; z-index: 200;
    padding: 10px 16px; border-radius: 8px; background: var(--navy); color: #fff;
    font-weight: 700; text-decoration: none; box-shadow: var(--shadow-lg);
}
body.dark .skip-links a { background: #0b1d3a; }
.skip-links a:focus { top: 12px; outline: 3px solid var(--orange); outline-offset: 2px; }

/* Texte accessible de la page : masque a l'ecran (lu par les lecteurs d'ecran)… */
#a11y-page {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
#a11y-page .a11y-page-nav { display: none; }
/* …mais visible des que le focus y entre (lien d'evitement, lien de la page) :
   un focus clavier ne doit jamais etre invisible (RGAA 10.7). */
#a11y-page:focus-within,
body.a11y-textmode #a11y-page {
    position: absolute; z-index: 25; width: auto; height: auto; margin: 0; clip: auto; white-space: normal;
    top: 16px; bottom: 16px; left: 50%; transform: translateX(-50%);
    width: min(760px, calc(100% - 140px)); overflow: auto;
    padding: 28px 36px; border-radius: 14px;
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
    font-size: 18px; line-height: 1.65;
}
#a11y-page:focus { outline: 3px solid var(--indigo); outline-offset: 2px; }
body.a11y-textmode #a11y-page .a11y-page-nav { display: flex; gap: 10px; justify-content: space-between; margin-top: 24px; }
body.a11y-textmode #book-area, body.a11y-textmode #scrollview, body.a11y-textmode #zoomctl,
body.a11y-textmode #ruler { display: none !important; }
body.a11y-textmode #stage { overflow: hidden; display: block; }
body.a11y-bigui #a11y-page { font-size: 21px; }
@media (max-width: 640px) {
    #a11y-page:focus-within, body.a11y-textmode #a11y-page { width: calc(100% - 90px); padding: 20px 18px; font-size: 17px; }
}

/* Mise en forme des blocs (region et panneau « Version texte ») */
.a11y-sheet + .a11y-sheet { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.a11y-sheet h2, .a11y-sheet h3, .a11y-sheet h4, .a11y-sheet h5, .a11y-sheet h6 { color: var(--navy); line-height: 1.25; margin: 1.1em 0 .45em; }
.a11y-sheet > h2:first-child, .a11y-sheet > h3:first-child {
    margin-top: 0; font-size: .8em; text-transform: uppercase; letter-spacing: .06em; color: var(--text);
}
.a11y-sheet h3 { font-size: 1.35em; }
.a11y-sheet h4 { font-size: 1.15em; }
.a11y-sheet h5, .a11y-sheet h6 { font-size: 1em; }
.textview .a11y-sheet h4 { font-size: 1.15em; }
.textview .a11y-sheet h5, .textview .a11y-sheet h6 { font-size: 1em; }
.a11y-sheet p { margin: 0 0 .8em; white-space: normal; }
.a11y-quote { margin: 0 0 1em; padding: .2em 0 .2em 1em; border-left: 4px solid var(--orange); }
.a11y-quote blockquote { margin: 0; font-style: italic; }
.a11y-quote figcaption { color: var(--text); font-size: .92em; }
.a11y-list { margin: 0 0 1em; padding-left: 1.4em; }
.a11y-list li { margin: .2em 0; }
.a11y-box { margin: 0 0 1em; padding: .8em 1em; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.a11y-box p:last-child { margin-bottom: 0; }
.a11y-box-title { font-weight: 800; color: var(--navy); }
.a11y-img { padding: .5em .8em; border-radius: 8px; background: var(--bg); color: var(--text); font-style: italic; }
.a11y-img-label { font-style: normal; font-weight: 700; color: var(--navy); }
.a11y-empty { color: var(--text); font-style: italic; }
.a11y-links-title { font-weight: 700; margin-top: 1.2em !important; }
.a11y-links a { color: var(--indigo); word-break: break-word; }
body.dark .a11y-links a { color: #a5b4fc; }

/* Barre basse : bouton « Aller a la page » */
#goto-open { position: absolute; left: 16px; bottom: 9px; padding: 6px 12px; font-size: 13px; background: var(--surface); }
@media (max-width: 640px) { #goto-open { display: none; } }

/* Aide : section accessibilite en tete, deux colonnes ensuite, tableau des touches */
.modal-wide { width: min(860px, 94vw); }
.modal-body.help { display: block; }
.help-a11y { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.help-a11y p, .help-a11y li { line-height: 1.5; }
.help-cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px; }
@media (max-width: 720px) { .help-cols { grid-template-columns: 1fr; } }
.help .help-note { color: var(--text); font-size: 13px; }
.help table.keys { width: 100%; border-collapse: collapse; font-size: 13px; color: var(--text); }
.help table.keys th { text-align: left; font-size: 12px; color: var(--navy); padding: 4px 6px; border-bottom: 1px solid var(--line); }
.help table.keys td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.help table.keys td:first-child { white-space: nowrap; }
.help a { color: var(--indigo); }
body.dark .help a { color: #a5b4fc; }

/* Fenetre « Aller a la page » */
#goto-input { flex: 1; font-size: 18px; }
#goto-range { font-weight: 400; color: var(--text); }
.form-error { color: #b91c1c; font-weight: 600; min-height: 1.2em; margin: 4px 0 0; }
body.dark .form-error { color: #fca5a5; }
input[aria-invalid="true"] { border-color: #b91c1c; }

/* Le titre du panneau recoit le focus a l'ouverture : pas de cadre au focus programme */
#panel-title:focus { outline: none; }
#panel-title:focus-visible { outline: 3px solid var(--indigo); outline-offset: 2px; }
#tools:focus { outline: none; }

/* --------------------------------------------------------------------------
   Contrastes (RGAA 3.2 / WCAG 1.4.3, 1.4.11) — mesures axe-core du 23/10/2026 :
   blanc sur orange #ff6b2c = 2,84:1 (pastilles, boutons, fleches de bord,
   numeros du sommaire), gris #94a3b8 sur fond = 2,33:1 (numeros de page,
   credit, aides des panneaux). L'orange vif reste pour les traits et surfaces
   sans texte ; tout ce qui PORTE du texte ou une icone passe sur --accent-strong.
   -------------------------------------------------------------------------- */
:root { --accent-strong: #c2410c; --accent-strong-dark: #9a3412; --muted-text: #556274; }
body.theme-occitanie { --accent-strong: #c10230; --accent-strong-dark: #9c0027; --muted-text: #5e5e5e; }
body.dark { --muted-text: #a9b4c4; }
body.theme-occitanie.dark { --muted-text: #b5b5b5; }

.pill, .btn, .edge-nav, .ab-main, .toc .p, .results .p { background: var(--accent-strong); }
.pill:hover, .btn:hover { background: var(--accent-strong-dark); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
#goto-open { background: var(--surface); }
.tb:hover, .tb.active, #zoomctl button:hover, .ab:hover, .results .del:hover, .thumb .lbl .bm { color: var(--accent-strong); }
body.dark .tb:hover, body.dark .tb.active { color: var(--orange); }
.help h3 { color: var(--accent-strong); }
body.dark .help h3 { color: var(--orange); }
#pagenums, .sv-page .sv-num, #credit, .panel-hint, .results .del, .bm-item .s small, .a11y .opt small, #goto-range { color: var(--muted-text); }

/* Telephone : la barre d'outils defile de cote (heritage V3) sans que rien ne
   le signale ; un fondu au bord droit montre qu'il reste des outils. */
@media (max-width: 900px) {
    #tools { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-right: 24px; }
}

/* Mention RGAA : section de l'aide et lien du pied de page */
.help-rgaa { margin-bottom: 18px; padding: 12px 16px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); color: var(--text); }
.help-rgaa p { margin: 0 0 6px; line-height: 1.5; }
.help-rgaa p:last-child { margin-bottom: 0; }
.help-rgaa:focus { outline: none; }
.help-rgaa:focus-visible { outline: 3px solid var(--indigo); outline-offset: 2px; }
#credit-a11y { border: 0; background: none; padding: 0; font: inherit; color: var(--muted-text); text-decoration: underline; cursor: pointer; }
#credit-a11y:hover { color: var(--accent-strong); }

/* Liens et anneau de focus : le theme Occitanie met --indigo en JAUNE (#dbb000),
   illisible sur blanc (1,9:1) pour un lien comme pour un focus clavier ; constat
   a l oeil sur l aide le 23/10/2026, invisible pour axe-core (fenetre fermee). */
:root { --link: var(--indigo); --focus-ring: var(--indigo); }
body.theme-occitanie { --link: #c10230; --focus-ring: #3c3c3c; }
body.theme-occitanie.dark { --link: #ff8fa8; --focus-ring: #ffcd00; }
.help a, .a11y-links a { color: var(--link); }
body.dark:not(.theme-occitanie) .help a, body.dark:not(.theme-occitanie) .a11y-links a { color: #a5b4fc; }
a:focus-visible, button:focus-visible, select:focus-visible, [tabindex]:focus-visible,
.tb:focus-visible, input:focus-visible, textarea:focus-visible, #a11y-page:focus, .help-rgaa:focus-visible,
#panel-title:focus-visible { outline-color: var(--focus-ring); }
#scrubber:focus-visible #scrub-handle { outline-color: var(--focus-ring); }

/* --------------------------------------------------------------------------
   Pre-audit RGAA du guide ID.Metiers (23/10/2026) — criteres que axe-core ne
   mesure pas :
   - 3.3 (contraste des composants, 3:1) : bordure des champs a 1,28:1 ;
   - 3.1 (information par la couleur seule) : entree active du sommaire et
     miniature active signalees seulement par une teinte ;
   - 10.11 (pas de defilement horizontal a 320 px) : boutons du mode texte
     cote a cote, barre d outils qui defilait de cote.
   -------------------------------------------------------------------------- */
:root { --field-border: #6b7789; }
body.theme-occitanie { --field-border: #767676; }
body.dark { --field-border: #8b98ab; }
input[type="search"], input[type="text"], textarea, input[type="number"], .a11y select { border-color: var(--field-border); }
.toc li.active button { font-weight: 700; box-shadow: inset 4px 0 0 var(--accent-strong); }
.thumb.active canvas { border-color: var(--accent-strong); border-width: 4px; }
.thumb.active .lbl { font-weight: 800; color: var(--ink); }
.thumb.active .lbl::after { content: " (affichée)"; font-weight: 400; }
body.a11y-textmode #a11y-page .a11y-page-nav { flex-wrap: wrap; }
@media (max-width: 480px) {
    :root { --top-h: 92px; }
    #topbar { align-items: center; }
    #tools { flex-wrap: wrap; justify-content: center; width: 100%; flex-shrink: 1; overflow: visible; padding-right: 0; -webkit-mask-image: none; mask-image: none; }
    .tb { width: 36px; height: 36px; }
}

/* Theme sombre : la couleur d accent de chaque theme est trop foncee sur fond
   sombre (Occitanie #c10230 sur #272727 = 2,1:1) ; titres de l aide et icones
   actives passent sur une variante claire (axe-core, aide ouverte, 23/10/2026). */
:root { --accent-on-dark: #ff8a50; }
body.theme-occitanie { --accent-on-dark: #ff8fa8; }
body.dark .help h3, body.dark .tb:hover, body.dark .tb.active, body.dark .thumb .lbl .bm { color: var(--accent-on-dark); }
body.dark .toc li.active button { box-shadow: inset 4px 0 0 var(--accent-on-dark); }
body.dark .thumb.active canvas { border-color: var(--accent-on-dark); }

/* Mention « Accessibilite : <etat> » de l export autonome (lien vers la declaration) :
   meme couleur contrastee que le bouton du site, en clair comme en sombre. */
#credit a { color: var(--muted-text); text-decoration: underline; }
#credit a:hover { color: var(--accent-strong); }
body.dark #credit a:hover { color: var(--accent-on-dark); }

/* ==========================================================================
   COMPARATIF FLUIDBOOK (23/10/2026)
   ========================================================================== */

/* Barre d'outils en groupes ; l'accessibilite a part */
#tools { gap: 0; }
.tb-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; }
.tb-group + .tb-group { border-left: 1px solid var(--line); }
.tb-group[hidden] { display: none; }
.tb-a11y { margin-left: 6px; border-left: 0 !important; }
.tb-a11y .tb { border: 2px solid var(--accent-strong); color: var(--accent-strong); border-radius: 50%; }
body.dark .tb-a11y .tb { border-color: var(--accent-on-dark); color: var(--accent-on-dark); }
a.tb { text-decoration: none; }
@media (max-width: 480px) {
    .tb-group { padding: 0 2px; }
    .tb-group + .tb-group { border-left: 0; }
}

/* Etiquette des boutons (survol, focus clavier) */
.tip {
    position: fixed; z-index: 60; max-width: 240px; padding: 6px 10px; border-radius: 6px;
    background: var(--toast-bg); color: #fff; font-size: 13px; font-weight: 600; line-height: 1.3;
    box-shadow: var(--shadow); pointer-events: auto;
}
.tip::before {
    content: ''; position: absolute; top: -5px; left: 50%; margin-left: -5px;
    border: 5px solid transparent; border-top: 0; border-bottom-color: var(--toast-bg);
}
.tip[hidden] { display: none; }

/* Boutons rouges : fleche jaune plus grosse (comme la reference) */
.pill .arrow { font-size: 18px; line-height: 1; font-weight: 900; color: #ffd84d; }
body.theme-occitanie .pill .arrow { color: #ffcd00; }

/* Liens de la page : affiches sur demande (K) ou brievement a l'arrivee d'une page */
body.show-links .lk, body.links-flash .lk {
    background: rgba(255, 205, 0, .35); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .75);
}
body.links-flash .lk { transition: background .4s, box-shadow .4s; }

/* Coin marque-page (comparatif du 27/10/2026) : le ruban a etoile de la reference,
   en biais dans le coin. Invisible tant que la souris n'est pas sur le coin lui-meme
   (avant : visible des qu'on survolait la page) ; reste affiche, etoile jaune, quand
   la page est marquee. Au clavier : touche B, panneau Marque-pages. */
.bm-tab {
    top: 0; right: 0; width: 56px; height: 56px; opacity: 0;
    background: none; clip-path: none; filter: none;
    transition: opacity .15s;
}
.bm-tab.left { right: auto; left: 0; }
.bm-tab svg { position: absolute; top: 0; right: 2px; width: 50px; height: 50px; overflow: visible; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.bm-tab.left svg { right: auto; left: 2px; transform: scaleX(-1); }
.bm-tab .bm-ribbon { fill: var(--accent-strong); }
.bm-tab .bm-star { fill: #fff; }
.bm-tab .bm-fold { fill: #000; opacity: .28; }
.bm-tab:hover, .bm-tab:focus-visible { opacity: 1; background: none; height: 56px; }
.bm-tab.on { opacity: 1; background: none; height: 56px; filter: none; }
.bm-tab.on .bm-star { fill: #ffcd00; }
.bm-tab.on:hover { background: none; }
.bm-tab.on:hover .bm-ribbon { fill: var(--accent-strong-dark); }
.sv-page .bm-tab { top: 0; }

/* Tour de page droit : la feuille pivote a plat autour de la reliure */
.flipfx { position: fixed; z-index: 19; perspective: 2400px; pointer-events: none; }
.flipfx .ff-still, .flipfx .ff-leaf { position: absolute; top: 0; height: 100%; }
.flipfx .ff-leaf { transform-style: preserve-3d; }
/* Ombre qui passe sur la feuille pendant le tour, plus marquee cote reliure */
.flipfx .ff-shade { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: linear-gradient(90deg, rgba(0, 0, 0, .55), rgba(0, 0, 0, .1) 60%, rgba(0, 0, 0, 0)); }
.flipfx .ff-shade.rev { background: linear-gradient(270deg, rgba(0, 0, 0, .55), rgba(0, 0, 0, .1) 60%, rgba(0, 0, 0, 0)); }
.flipfx .ff-face { position: absolute; inset: 0; background: #fff; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flipfx .ff-still { inset: auto; top: 0; }
.flipfx .ff-face canvas { display: block; width: 100%; height: 100%; }
.flipfx .ff-back { transform: rotateY(180deg); }
.flipfx .ff-empty { background: var(--bg); }
.flipfx .ff-front { box-shadow: 0 0 18px rgba(0, 0, 0, .18); }

/* Apercu de la page au survol de la barre de defilement */
#scrub-preview {
    position: absolute; bottom: 30px; transform: translateX(-50%); z-index: 5; pointer-events: none;
    background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 6px; text-align: center;
}
#scrub-preview[hidden] { display: none; }
#scrub-preview canvas { display: block; width: 110px; height: auto; border: 1px solid var(--line); background: #fff; }
#scrub-preview .sp-label { display: block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--ink); }

/* Sommaire hierarchique */
.toc li.lvl-1 > .toc-sec { display: block; padding: 9px 8px; }
.toc li.lvl-1 > button, .toc li.lvl-1 > .toc-sec { font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--accent-strong); }
body.dark .toc li.lvl-1 > button, body.dark .toc li.lvl-1 > .toc-sec { color: var(--accent-on-dark); }
.toc li.lvl-2 > button { padding-left: 18px; font-weight: 700; }
.toc li.lvl-3 > button { padding-left: 34px; font-size: 13px; }

/* Aide : les boutons d'abord, raccourcis repliables */
.help-buttons { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.help-btn-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; }
@media (max-width: 720px) { .help-btn-list { grid-template-columns: 1fr; } }
.help-btn-list li { display: flex; gap: 10px; align-items: flex-start; color: var(--text); line-height: 1.4; margin: 0; }
.hb-ico { flex: 0 0 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; background: var(--bg); color: var(--navy); font-weight: 800; }
.hb-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Icones pleines (index, marque-pages, plein ecran) : comme dans la barre, sinon
   elles sortent vides et paraissent grisees dans l'aide (mail du 02/11/2026). */
.hb-ico svg.ic-fill { fill: currentColor; stroke: none; }
.hb-ico.pill-ico { background: var(--accent-strong); color: #ffd84d; }
.help-keys > summary { cursor: pointer; list-style: none; }
.help-keys > summary::-webkit-details-marker { display: none; }
.help-keys > summary h3 { display: inline; }
.help-keys > summary::after { content: ' ▸'; color: var(--accent-strong); }
.help-keys[open] > summary::after { content: ' ▾'; }
.help-keys > summary:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* Fenetres Imprimer / Partager */
.choice { border: 0; padding: 0; margin: 0 0 10px; }
.choice legend { font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.choice .opt { display: flex; gap: 10px; align-items: center; padding: 5px 0; color: var(--ink); }
.choice .opt[hidden] { display: none; }
.choice .opt input { width: 18px; height: 18px; accent-color: var(--accent-strong); }
.choice small { color: var(--muted-text); }
.print-range { flex-wrap: wrap; padding-left: 28px; }
.print-range input { width: 64px; }
#share-url { flex: 1; min-width: 0; }
.share-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.share-list a { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--field-border); color: var(--ink); text-decoration: none; font-weight: 700; }
.share-list a:hover { border-color: var(--accent-strong); color: var(--accent-strong); }

/* Version « essentiel » (/lecteur/{slug}/essentiel/, 27/10/2026) : les
   fonctions de Fluidbook, plus notes, liens, feuilletage et mode sombre depuis
   le 29/10/2026 (barre rangee par applyVariant). Ici, ce qui n'est pas dans la
   barre. L'aide ne decrit que les boutons ; la mention RGAA vaut pour la
   version complete, auditee. */
body.variant-essentiel #goto-open,
body.variant-essentiel #credit,
body.variant-essentiel #audiobar,
body.variant-essentiel .help-a11y,
body.variant-essentiel .help-rgaa,
body.variant-essentiel .help-cols { display: none !important; }

/* ==========================================================================
   Comparatif Fluidbook du 27/10/2026 : etiquettes, recherche, impression,
   aide flechee, mode de lecture, apercu de la barre du bas.
   ========================================================================== */
/* Pose sur body : c'est la que le theme du livre redefinit --accent-strong. */
body { --fb-red: var(--accent-strong); --fb-yellow: #ffcd00; }

/* Etiquettes des boutons : les encarts rouges de la reference (plus grands) */
.tip {
    max-width: 300px; padding: 17px 24px; border-radius: 0;
    background: var(--fb-red); color: #fff; font-size: 14px; font-weight: 400; line-height: 1.35;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.tip::before { top: -9px; left: var(--arrow-x, 50%); margin-left: -9px; border-width: 0 9px 9px; border-style: solid; border-color: transparent transparent var(--fb-red); }

/* Boutons rouges : fleche jaune en trait, plus grosse */
.pill .arrow { display: inline-flex; color: var(--fb-yellow); }
.pill .arrow svg { width: 26px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* Recherche : bandeau rouge a gauche, sur toute la hauteur, champ blanc en haut */
#panel.left {
    left: 0; right: auto; top: 0; bottom: 0; z-index: 45; width: 320px;
    background: var(--fb-red); color: #fff; border: 0; box-shadow: 8px 0 30px rgba(0, 0, 0, .18);
    transform: translateX(-100%);
}
#panel.left.open { transform: none; }
#panel.left .panel-head { position: absolute; top: 0; right: 0; padding: 0; border: 0; z-index: 2; }
#panel.left .panel-head h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#panel.left #panel-close { width: 60px; height: 60px; border-radius: 0; background: var(--fb-yellow); color: #fff; }
#panel.left #panel-close svg { width: 26px; height: 26px; stroke-width: 2.6; }
#panel.left #panel-close:hover { background: #e6b800; }
#panel.left #panel-close:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }
#panel.left #p-search { padding: 0 0 20px; overflow-x: hidden; }
#panel.left #search-form { height: 60px; margin: 0 60px 0 0; gap: 0; background: #fff; align-items: center; }
#panel.left #search-input { height: 60px; border: 0; border-radius: 0; padding: 0 12px 0 4px; font-size: 16px; background: #fff; color: #0c0c0c; }
#panel.left #search-input::placeholder { color: #6b6b6b; }
#panel.left #search-input:focus-visible { outline: 2px solid var(--fb-red); outline-offset: -4px; }
.search-go { flex: 0 0 52px; height: 60px; border: 0; background: #fff; color: var(--fb-red); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.search-go svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#panel.left #search-status { color: #fff; opacity: .92; margin: 14px 20px 4px; font-size: 13px; }
body.panel-left #stage, body.panel-left #bottombar { left: 320px; right: 0; transition: left .3s ease; }
@media (max-width: 640px) {
    /* Telephone : la recherche prend l'ecran, le livre reste dessous. */
    #panel.left { width: 100%; }
    body.panel-left #stage, body.panel-left #bottombar { left: 0; }
}
#search-results { list-style: none; margin: 0; padding: 6px 20px 0; display: flex; flex-direction: column; gap: 26px; }
.hit-group { display: block; }
.hit-spread { display: block; width: 100%; border: 0; padding: 0; background: none; cursor: pointer; color: #fff; font: inherit; text-align: center; }
.hit-vig { position: relative; display: flex; justify-content: center; gap: 0; }
.hit-vig canvas { display: block; width: 100px; height: auto; background: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.hit-vig.cover canvas { margin-left: 100px; }
.hit-count {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: var(--fb-red); color: #fff; font-size: 14px; padding: 5px 7px; border-radius: 2px; white-space: nowrap;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .5);
}
.hit-pages { display: flex; justify-content: center; margin-top: 6px; font-size: 14px; }
.hit-pages span { width: 100px; }
.hit-pages.cover { padding-left: 100px; }
.hit-spread:hover canvas, .hit-group.active canvas { outline: 3px solid var(--fb-yellow); outline-offset: 0; }
.hit-spread:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

/* Fenetre rouge (Imprimer), comme la reference */
.modal-red { background: var(--fb-red); color: #fff; border-radius: 0; width: min(820px, 94vw); }
.modal-red .modal-head { border: 0; padding: 0 0 0 30px; }
.modal-red .modal-head h2 { color: #fff; font-weight: 400; font-size: 17px; }
.modal-red .modal-close { width: 60px; height: 60px; border-radius: 0; background: var(--fb-yellow); color: #fff; }
.modal-red .modal-close svg { width: 26px; height: 26px; stroke-width: 2.6; }
.modal-red .modal-close:hover { background: #e6b800; color: #fff; }
.modal-red .modal-close:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }
.modal-red .modal-body { padding: 20px 30px 30px; }
.print-choices { border: 0; margin: 0; padding: 0; }
.print-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px 20px; }
@media (max-width: 640px) { .print-options { grid-template-columns: 1fr 1fr; } }
.print-opt { display: flex; flex-direction: column; gap: 12px; cursor: pointer; }
.print-opt.disabled { cursor: not-allowed; opacity: .55; }
.print-vig { display: flex; height: 140px; }
.print-vig canvas { height: 140px; width: auto; background: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.print-vig canvas.empty { background: #7a2f12; box-shadow: none; }
.print-line { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.print-line input { width: 22px; height: 22px; margin: 0; accent-color: #e8590c; }
.print-line small { color: #fff; opacity: .85; font-size: 13px; }
.print-opt:hover canvas { outline: 3px solid var(--fb-yellow); }
.print-opt:focus-within .print-line { text-decoration: underline; text-underline-offset: 3px; }
.modal-red .form-error, .modal-red .panel-hint { color: #fff; }
.print-go-row { justify-content: flex-end; margin-top: 18px; }
.modal-red #print-go { background: var(--fb-yellow); color: #0c0c0c; border-radius: 0; padding: 13px 26px; text-transform: uppercase; font-weight: 600; letter-spacing: .03em; }
.modal-red #print-go:hover { background: #e6b800; }
.modal-red #print-go:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* Aide flechee : le lecteur assombri, un trait de chaque bouton vers son nom */
body.tour-open #overlay { background: transparent; backdrop-filter: none; }
.modal.tour {
    inset: 0; left: 0; top: 0; transform: none; width: auto; max-height: none; overflow: hidden;
    background: rgba(24, 24, 24, .82); border-radius: 0; box-shadow: none; color: #fff; cursor: pointer;
}
.tour-line { position: absolute; background: #fff; }
.tour-line.v { width: 1px; }
.tour-line.h { height: 1px; }
.tour-label { position: absolute; font-size: 14px; line-height: 1.2; white-space: nowrap; color: #fff; }
.tour-label.mid { transform: translateY(-50%); }
.tour-label.mid.end { transform: translate(-100%, -50%); }
.tour-ring { position: absolute; border: 1px solid #fff; border-radius: 50%; }
.tour-center {
    position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); max-width: 420px;
    text-align: center; font-size: 15px; line-height: 1.5; color: #fff;
}
.tour-foot { position: absolute; left: 50%; top: 52%; transform: translate(-50%, 60px); display: flex; gap: 10px; white-space: nowrap; }
.tour-foot .btn { cursor: pointer; }
.tour-foot .btn[hidden] { display: none; }
.tour-foot .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .6); }
.tour-foot .btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.tour-foot .btn:focus-visible { outline: 3px solid var(--fb-yellow); outline-offset: 3px; }

/* Mode de lecture (version complete) : petit encart sous le bouton */
.popover {
    position: fixed; z-index: 40; min-width: 240px; padding: 14px 18px 12px;
    background: var(--fb-red); color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
}
.popover[hidden] { display: none; }
.popover fieldset { border: 0; margin: 0 0 8px; padding: 0; }
.popover fieldset[disabled] { opacity: .55; }
.popover legend { font-weight: 700; font-size: 13px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.popover .opt { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 14px; cursor: pointer; }
.popover .opt input { width: 18px; height: 18px; margin: 0; accent-color: var(--fb-yellow); }
.popover .opt input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Apercu de la barre du bas : la double page dans l'encart rouge de la reference */
#scrub-preview { background: var(--fb-red); border-radius: 0; padding: 18px 22px 10px; bottom: 34px; }
#scrub-preview::after {
    content: ''; position: absolute; left: 50%; bottom: -12px; margin-left: -12px;
    border-width: 12px 12px 0; border-style: solid; border-color: var(--fb-red) transparent transparent;
}
#scrub-preview canvas { width: 100px; border: 0; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
#scrub-preview canvas.two { width: 200px; }
#scrub-preview .sp-label { display: flex; justify-content: center; color: #fff; font-weight: 400; font-size: 14px; margin-top: 6px; }
#scrub-preview .sp-label span { flex: 1; }

/* Coin marque-page des deux versions (mail du 28/10/2026) : celui de Fluidbook,
   54 px sur une page de 752 px chez lui, soit 7,2 % de la largeur de la page,
   colle au coin. Dessine pour le coin gauche : retourne sur une page de droite. */
.bm-tab.bm-flag { width: 7.2%; min-width: 30px; height: auto; aspect-ratio: 1; }
.bm-tab.bm-flag svg { top: 0; right: 0; width: 100%; height: 100%; filter: none; transform: scaleX(-1); }
.bm-tab.bm-flag.left svg { right: auto; left: 0; transform: none; }
.bm-tab.bm-flag .bm-ribbon { fill: #c10230; }
.bm-tab.bm-flag.on:hover .bm-ribbon { fill: #c10230; }
.bm-tab.bm-flag:hover, .bm-tab.bm-flag.on, .bm-tab.bm-flag.on:hover { height: auto; }

/* ==========================================================================
   Comparatif Fluidbook, 2e passe (27/10/2026) : index rouge sur tout l'ecran,
   marque-pages de la version essentielle au milieu, partage en rouge, aide
   avec un marque-page en exemple et la souris au centre.
   ========================================================================== */
/* Voile sous l'index et l'encart des marque-pages : un clic dessus les ferme. */
#panel-veil { display: none; position: fixed; inset: 0; z-index: 44; background: rgba(255, 255, 255, .72); }
body.panel-overlay #panel-veil { display: block; }

#panel.full, #panel.center { transform: none; transition: none; border: 0; background: var(--fb-red); color: #fff; }
#panel.full:not(.open), #panel.center:not(.open) { visibility: hidden; }
#panel.full { inset: 0; width: auto; z-index: 46; box-shadow: none; }
#panel.full .panel-head, #panel.center .panel-head { padding: 0 0 0 30px; border: 0; min-height: 60px; }
#panel.full .panel-head h2 { color: #fff; font-size: 17px; font-weight: 400; text-transform: none; letter-spacing: 0; }
#panel.center .panel-head { position: absolute; top: 0; right: 0; padding: 0; z-index: 2; }
#panel.center .panel-head h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#panel.full #panel-close, #panel.center #panel-close { width: 60px; height: 60px; border-radius: 0; background: var(--fb-yellow); color: #fff; }
#panel.full #panel-close svg, #panel.center #panel-close svg { width: 26px; height: 26px; stroke-width: 2.6; }
#panel.full #panel-close:hover, #panel.center #panel-close:hover { background: #e6b800; }
#panel.full #panel-close:focus-visible, #panel.center #panel-close:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }

/* Index : les doubles pages en grille, le folio sous chaque page */
#panel.full #p-index { padding: 10px 30px 40px; }
#panel.full .thumbs { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 30px 30px; max-width: 920px; margin: 0 auto; }
.thumb-spread { display: flex; justify-content: center; padding: 10px; }
.thumb-spread .thumb-cell { width: 50%; }
.thumb-cell .thumb { display: block; width: 100%; }
.thumb-spread.first { justify-content: flex-end; }
.thumb-spread.first .thumb-cell { margin-right: 0; }
.thumb-spread:not(.first) .thumb-cell:only-child { margin-right: 50%; }
#panel.full .thumb canvas { border: 0; border-radius: 0; box-shadow: 0 3px 10px rgba(0, 0, 0, .3); }
#panel.full .thumb:hover canvas { transform: none; outline: 3px solid var(--fb-yellow); outline-offset: -3px; }
#panel.full .thumb:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#panel.full .thumb .lbl { color: #fff; font-size: 14px; margin-top: 8px; }
#panel.full .thumb .lbl .bm { color: var(--fb-yellow); }
#panel.full .thumb.active canvas { border: 0; }
#panel.full .thumb.active .lbl { font-weight: 400; color: var(--fb-red); }
#panel.full .thumb.active .lbl::after { content: none; }
/* Double page affichee : sur fond blanc, comme la reference */
.thumb-spread:has(.thumb.active) { background: #fff; }
@media (max-width: 640px) {
    #panel.full #p-index { padding: 10px 16px 30px; }
    #panel.full .thumbs { grid-template-columns: 1fr 1fr; gap: 18px 12px; }
}

/* Marque-pages (les deux versions depuis le 29/10/2026) : encart rouge au
   milieu de la page, l'ecran de Fluidbook — titre en haut a gauche, vignettes
   des pages marquees, Envoyer et Telecharger en bas a droite. */
#panel.center {
    top: 50%; left: 50%; right: auto; bottom: auto; z-index: 46;
    width: min(1000px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 32px));
    transform: translate(-50%, -50%); box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
#panel.center:has(#bm-empty:not([hidden])) { width: min(420px, calc(100vw - 32px)); }
#panel.center .panel-head { left: 0; display: flex; justify-content: space-between; align-items: flex-start; padding-left: 40px; }
#panel.center .panel-head h2 {
    position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal;
    color: #fff; font-size: 20px; font-weight: 400; text-transform: none; letter-spacing: 0; margin: 18px 0 0;
}
#panel.center #p-bookmarks { padding: 84px 40px 30px; }
.bm-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 24px 38px; }
.bm-grid .bm-item { position: relative; }
.bm-grid .bm-go { display: block; width: 100%; border: 0; padding: 0; background: none; cursor: pointer; color: #fff; font: inherit; text-align: center; }
.bm-grid .bm-thumb { width: 100%; flex: none; border: 0; border-radius: 0; box-shadow: 0 3px 10px rgba(0, 0, 0, .3); }
.bm-grid .bm-go:hover .bm-thumb { transform: none; outline: 3px solid var(--fb-yellow); outline-offset: -3px; }
.bm-grid .bm-go:focus-visible, .bm-grid .del:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.bm-grid .lbl { display: block; margin-top: 8px; font-size: 16px; }
/* Coin a etoile de la vignette, comme Fluidbook : etoile jaune = page marquee,
   blanche = retiree (la vignette reste jusqu'a la prochaine ouverture) */
.bm-grid .del { position: absolute; top: 0; right: 0; width: 34%; aspect-ratio: 1; border: 0; padding: 0; background: none; cursor: pointer; }
.bm-grid .del svg, .th-bm svg { display: block; width: 100%; height: 100%; transform: scaleX(-1); }
.bm-grid .del .bm-ribbon, .th-bm .bm-ribbon { fill: #c10230; }
.bm-grid .del .bm-star, .th-bm .bm-star { fill: #fff; }
.bm-grid .del.on .bm-star, .th-bm.on .bm-star { fill: var(--fb-yellow); }
.bm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 14px; margin-top: 30px; }
.bm-actions .btn { background: var(--fb-yellow); color: #0c0c0c; border: 0; border-radius: 0; padding: 13px 30px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; text-decoration: none; }
.bm-actions .btn:hover { background: #e6b800; }
.bm-actions .btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.bm-actions .btn[hidden] { display: none; }
#panel.center:has(#bm-empty:not([hidden])) .bm-actions { justify-content: center; }
/* Index : coin a etoile de chaque vignette, comme Fluidbook (mail du 30/10/2026) :
   affiche sur une page marquee, au survol ou au focus sinon ; un clic l'ajoute
   ou le retire. */
.thumb-cell { position: relative; }
.th-bm { position: absolute; top: 0; right: 0; width: 26%; aspect-ratio: 1; border: 0; padding: 0; background: none; cursor: pointer; opacity: 0; }
.th-bm.on, .th-bm:hover, .th-bm:focus-visible { opacity: 1; }
.th-bm:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
/* Page de gauche : coin exterieur, comme dans le livre */
.thumb-spread:not(.first) .thumb-cell:first-child .th-bm { right: auto; left: 0; }
.thumb-spread:not(.first) .thumb-cell:first-child .th-bm svg { transform: none; }
@media (max-width: 640px) {
    #panel.center .panel-head { padding-left: 20px; }
    #panel.center #p-bookmarks { padding: 76px 20px 24px; }
    .bm-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 18px; }
}
#panel.center .panel-hint { color: #fff; opacity: .92; }
#panel.center #bm-empty { opacity: 1; font-size: 15px; line-height: 1.5; text-align: center; margin: 0 6px 18px; }
.bm-illus svg { display: block; width: 100%; max-width: 300px; margin: 0 auto; }
.bm-illus .pg { fill: #fff; }
.bm-illus .fold { stroke: rgba(0, 0, 0, .15); stroke-width: 1; }
.bm-illus circle { fill: var(--fb-red); stroke: #fff; stroke-width: 2; }
.bm-illus .st { fill: var(--fb-yellow); }
#bm-empty[hidden] + .bm-illus { display: none; }
/* Liste vide : le texte de la reference suffit, sans la phrase d'aide en double */
#panel.center #p-bookmarks:has(#bm-empty:not([hidden])) > .panel-hint:not(#bm-empty) { display: none; }
#panel:not(.center) .bm-illus { display: none; }

/* Partager : encart rouge, comme Imprimer */
#m-share.modal-red { width: min(480px, 94vw); }
.modal-red .choice legend, .modal-red .panel-label { color: #fff; }
.modal-red .choice .opt input { accent-color: var(--fb-yellow); }
.modal-red .choice small { color: #fff; opacity: .85; }
.modal-red #share-url { border: 0; border-radius: 0; color: #0c0c0c; background: #fff; }
.modal-red #share-copy { background: var(--fb-yellow); color: #0c0c0c; border-radius: 0; font-weight: 600; }
.modal-red #share-copy:hover { background: #e6b800; }
.modal-red .share-list { flex-direction: column; gap: 4px; margin-top: 18px; }
.modal-red .share-list a { border: 0; border-radius: 0; padding: 8px 4px; color: #fff; font-weight: 400; font-size: 16px; }
.modal-red .share-list a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.share-list a { display: inline-flex; align-items: center; gap: 14px; }
.share-list a svg { width: 26px; height: 26px; flex: none; fill: currentColor; }
/* Le menu Partager de Fluidbook, rien d'autre que les cinq entrees (mail du
   28/10/2026 pour la version essentielle, du 30/10/2026 pour la complete) */
#m-share .choice,
#m-share .panel-label,
#m-share .modal-body > .row,
#m-share #share-status,
#share-native-li { display: none !important; }
#m-share .share-list { margin-top: 0; gap: 10px; }
#m-share .share-list a { font-size: 18px; padding: 10px 4px; }
#m-share.modal-red { width: min(300px, 94vw); }
.modal-red .share-list a:focus-visible, .modal-red .choice input:focus-visible, .modal-red #share-copy:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.modal-red #share-native { color: #fff; border-color: rgba(255, 255, 255, .6); }

/* Aide flechee : le marque-page en exemple dans le cercle, la souris au centre */
.tour-ring { overflow: hidden; }
.tour-ring svg { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; transform: scaleX(-1); }
.tour-ring .bm-ribbon { fill: #c10230; }
.tour-ring .bm-star { fill: var(--fb-yellow); }
.tour-center { max-width: min(640px, 92vw); }
.tour-center span { display: block; }
.tour-mouse { display: block; width: 40px; height: 64px; margin: 0 auto 18px; fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; }
.tour-mouse path { stroke-width: 7; }
.modal.tour .tour-foot { transform: translate(-50%, 130px); }
