/* Menus déroulants par niveau (barre du haut) + listes dépliables */
.megabar{position:sticky;top:8px;z-index:40;display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:0 0 6px;padding:8px;border-radius:18px;
  background:color-mix(in srgb,var(--card) 90%,transparent);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid var(--line);box-shadow:var(--shadow);font:700 .95rem var(--f-body,system-ui,sans-serif)}
.megabar .brand{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:0 12px 0 6px;font:800 1.05rem var(--f-display,system-ui,sans-serif);color:var(--fg);text-decoration:none}
.megabar .brand i{font-style:normal;display:grid;place-items:center;width:32px;height:32px;border-radius:10px;background:var(--new);color:#fff}
:root[data-theme="dark"] .megabar .brand i{color:#10131b}
@media(prefers-color-scheme:dark){:root:not([data-theme="light"]) .megabar .brand i{color:#10131b}}
.mega-list{list-style:none;margin:0;padding:0;display:flex;gap:4px;flex-wrap:wrap}
.mega-list>li{position:static}
.mega-btn,.mega-link{display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:0 14px;border-radius:999px;border:1.5px solid transparent;background:transparent;color:var(--fg);font:inherit;cursor:pointer;text-decoration:none}
.mega-btn:hover,.mega-link:hover{background:var(--bg);border-color:var(--line)}
.mega-btn[aria-expanded="true"]{background:var(--new-bg);border-color:var(--new);color:var(--new)}
.mega-btn .chev{width:.55em;height:.55em;border-right:2.5px solid currentColor;border-bottom:2.5px solid currentColor;transform:rotate(45deg) translateY(-20%);transition:transform .15s}
.mega-btn[aria-expanded="true"] .chev{transform:rotate(-135deg) translateY(-20%)}
.mega-btn .dot{width:8px;height:8px;border-radius:50%;background:var(--vit)}
.mega-btn .dot.soon{background:var(--line);box-shadow:inset 0 0 0 1.5px var(--muted)}
.mega-panel{position:absolute;left:0;right:0;top:calc(100% + 10px);z-index:50;max-height:min(72vh,640px);overflow:auto;background:var(--card);color:var(--fg);border:1px solid var(--line);border-radius:18px;box-shadow:var(--shadow),0 24px 50px rgba(0,0,0,.28);padding:18px;font:500 .95rem var(--f-body,system-ui,sans-serif)}
.mega-panel[hidden]{display:none}
.mega-head{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin:0 0 12px}
.mega-head h2{margin:0;font:800 1.2rem var(--f-display,system-ui,sans-serif)}
.mega-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px 22px}
.mega-col h3{margin:0 0 6px;font:700 .8rem var(--f-body,system-ui,sans-serif);letter-spacing:.07em;text-transform:uppercase;color:var(--muted)}
.mega-col ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}
.mega-item{display:flex;align-items:center;gap:8px;min-height:44px;padding:4px 8px;border-radius:10px;color:var(--fg);text-decoration:none;line-height:1.3}
a.mega-item:hover{background:var(--bg)}
.mega-item .n{flex:none;display:grid;place-items:center;width:28px;height:28px;border-radius:50%;background:var(--pos-bg);color:var(--pos);font:800 .8rem var(--f-display,system-ui,sans-serif)}
.mega-item .t{flex:1;min-width:0}
.mega-item .go{flex:none;font-size:.8rem;color:var(--muted)}
.mega-item[aria-disabled="true"]{color:var(--muted);cursor:default}
.mega-item[aria-disabled="true"] .n{background:var(--bg);color:var(--muted)}
.mega-empty{margin:0;color:var(--muted);font-size:.9rem}
.pill{display:inline-block;border-radius:999px;padding:2px 10px;font:700 .75rem var(--f-body,system-ui,sans-serif);white-space:nowrap}
.pill.live{background:var(--vit-bg);color:var(--vit)}
.pill.soon{background:var(--acc-bg);color:var(--acc)}
.pill.ref{background:var(--pos-bg);color:var(--pos)}
.mega-foot{margin:14px 0 0;padding-top:12px;border-top:1px solid var(--line);display:flex;gap:10px;flex-wrap:wrap}
.mega-foot a{display:inline-flex;align-items:center;min-height:44px;padding:0 14px;border-radius:12px;border:1.5px solid var(--line);color:var(--fg);text-decoration:none;font-weight:700}
.mega-foot a:hover{background:var(--bg)}
.mega-toggle{display:none;margin-left:auto;min-height:44px;padding:0 14px;border-radius:999px;border:1.5px solid var(--line);background:var(--card);color:var(--fg);font:700 .95rem var(--f-body,system-ui,sans-serif);cursor:pointer}

/* mobile : bouton Menu, panneaux en accordéon */
@media(max-width:820px){
  .mega-toggle{display:inline-flex;align-items:center}
  .megabar .mega-list,.megabar .mega-tools{display:none;width:100%}
  .megabar.open .mega-list,.megabar.open .mega-tools{display:flex}
  .mega-list{flex-direction:column;gap:2px}
  .mega-btn,.mega-link{width:100%;justify-content:space-between;border-radius:12px}
  .mega-panel{position:static;width:auto;max-height:none;box-shadow:none;margin:4px 0 8px;border-radius:12px}
}
.mega-tools{display:flex;gap:4px;flex-wrap:wrap;margin-left:auto}

/* listes dépliables (page d'accueil et pages de niveau) */
.lvl-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:14px}
.lvl-card{display:flex;flex-direction:column;gap:10px;padding:18px;border-radius:18px;background:var(--card);border:1px solid var(--line);box-shadow:var(--shadow);text-decoration:none;color:var(--fg)}
.lvl-card:hover{border-color:var(--new)}
.lvl-card h3{margin:0;font:800 1.25rem var(--f-display,system-ui,sans-serif)}
.lvl-card p{margin:0;color:var(--muted);font-size:.95rem}
.lvl-card .go{margin-top:auto;font-weight:700;color:var(--new)}
.acc{display:flex;flex-direction:column;gap:10px}
.acc details{background:var(--bg);border:1px solid var(--line);border-radius:14px}
.acc summary{padding:12px 16px;font-weight:700;display:flex;align-items:center;gap:10px;min-height:48px;cursor:pointer;list-style:none}
.acc summary::-webkit-details-marker{display:none}
.acc summary::before{content:"";flex:none;width:.6em;height:.6em;border-right:2.5px solid var(--new);border-bottom:2.5px solid var(--new);transform:rotate(-45deg);transition:transform .15s}
.acc details[open]>summary::before{transform:rotate(45deg)}
.acc summary .count{margin-left:auto;color:var(--muted);font-weight:500;font-size:.85rem}
.acc .list{list-style:none;margin:0;padding:0 10px 12px;display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:2px 12px}
.acc .row{display:flex;align-items:center;gap:10px;min-height:48px;padding:4px 8px;border-radius:10px}
.acc .row .n{flex:none;display:grid;place-items:center;width:30px;height:30px;border-radius:50%;background:var(--pos-bg);color:var(--pos);font:800 .85rem var(--f-display,system-ui,sans-serif)}
.acc .row .t{flex:1;min-width:0;line-height:1.3}
.acc .row .links{display:flex;gap:6px;flex:none}
.acc .row .links a{display:inline-flex;align-items:center;min-height:36px;padding:0 10px;border-radius:999px;border:1.5px solid var(--line);background:var(--card);color:var(--fg);text-decoration:none;font-size:.85rem;font-weight:700}
.acc .row .links a:hover{border-color:var(--new);color:var(--new)}
.acc .row.off{color:var(--muted)}
.acc .row.off .n{background:var(--card);color:var(--muted)}
@media print{.megabar{display:none!important}}
.megabar .acct-btn{margin-left:0}
.wrap .mega-panel li a,.wrap .acc li a,.wrap .lvl-card,.wrap .mega-foot a{text-decoration:none}

/* page courante */
.mega-link[aria-current="page"]{background:var(--new);color:#fff;border-color:var(--new)}
:root[data-theme="dark"] .mega-link[aria-current="page"]{color:#10131b}
@media(prefers-color-scheme:dark){:root:not([data-theme="light"]) .mega-link[aria-current="page"]{color:#10131b}}
.mega-btn.here:not([aria-expanded="true"]){border-color:var(--new);color:var(--new)}
.megabar .brand[aria-current="page"]{text-decoration:none}

/* sous-navigation d'un chapitre (Fiche / Exercices) */
nav.chapnav{position:static;box-shadow:none;background:transparent;border:0;padding:0;margin:0;backdrop-filter:none;-webkit-backdrop-filter:none}
nav.chapnav a{border-color:var(--line);background:var(--card)}
nav.chapnav a.on,nav.chapnav a[aria-current]{background:var(--new);color:#fff;border-color:var(--new)}
:root[data-theme="dark"] nav.chapnav a.on{color:#10131b}
@media(prefers-color-scheme:dark){:root:not([data-theme="light"]) nav.chapnav a.on{color:#10131b}}

/* colonnes alignees : titres de themes sur 2 lignes reservees (grand ecran) */
@media(min-width:821px){.mega-col h3{min-height:2.7em}}

/* en-tete de page de niveau (partage par toutes les pages de niveau) */
.hero{margin:12px 0 0;text-align:center;display:flex;flex-direction:column;gap:16px;align-items:center}
.hero .tag{display:inline-block;padding:4px 14px;border-radius:999px;background:var(--new-bg);color:var(--new);font-weight:700;font-size:.85rem}
.hero h1{margin:0;font-size:clamp(1.7rem,5vw,2.8rem);font-weight:800}
.hero p{margin:0;max-width:62ch;color:var(--muted);font-size:1.05rem}
.note{background:var(--acc-bg);border-left:6px solid var(--acc);border-radius:12px;padding:12px 16px;color:var(--fg)}
.note b{color:var(--acc)}

/* chapitres du plan : lignes plus larges (2 colonnes au maximum), boutons sous le titre si place manquante */
.acc .list{grid-template-columns:repeat(auto-fit,minmax(min(100%,400px),1fr))}
.acc .row{flex-wrap:wrap}
.acc .row .t{flex:1 1 200px}

/* chapitres : une ligne par chapitre, les uns apres les autres, une couleur de fond par chapitre */
.acc .list{grid-template-columns:1fr;gap:8px;padding:8px 12px 14px}
.acc .row{border-radius:14px;padding:8px 14px;border:1px solid transparent;font-weight:600}
.acc .row.c0{background:var(--pos-bg)} .acc .row.c1{background:var(--vit-bg)} .acc .row.c2{background:var(--acc-bg)} .acc .row.c3{background:var(--new-bg)}
.acc .row .n{color:#fff;width:34px;height:34px;font-size:.95rem}
.acc .row.c0 .n{background:var(--pos)} .acc .row.c1 .n{background:var(--vit)} .acc .row.c2 .n{background:var(--acc)} .acc .row.c3 .n{background:var(--new)}
:root[data-theme="dark"] .acc .row .n{color:#10131b}
@media(prefers-color-scheme:dark){:root:not([data-theme="light"]) .acc .row .n{color:#10131b}}
.acc .row.off{background:var(--card);border:1px dashed var(--line);font-weight:500}
.acc .row.off .n{background:var(--bg);color:var(--muted)}
.acc .row .links a{background:var(--card);border-color:transparent;box-shadow:0 1px 2px rgba(20,28,50,.12)}
.acc .row .links a:hover{border-color:currentColor}
