/* =========================================================================
   CardioÉcho — Système de design
   Thème cardiologie · clair par défaut · accessible (WCAG 2.1 AA)
   Auteur du site : Pr Ag Yosra Messaoudi — Développement : Mohamed EL AFRIT
   ========================================================================= */

:root {
  /* Palette cardiologie ------------------------------------------------- */
  --brand:        #b81d3a;   /* rouge cardiaque */
  --brand-dark:   #8a1530;
  --brand-darker: #6d1026;
  --brand-soft:   #fdeef1;
  --brand-tint:   #f7d9df;

  --accent:       #0e7c7b;   /* teal clinique */
  --accent-dark:  #0a5d5c;
  --accent-soft:  #e4f4f4;

  --ink:          #16202a;   /* texte principal */
  --ink-2:        #3c4a57;   /* texte secondaire */
  --muted:        #64748b;   /* texte discret */
  --line:         #e2e8ef;   /* bordures */
  --line-strong:  #cbd5e1;

  --bg:           #ffffff;
  --surface:      #f7f9fb;
  --surface-2:    #eef2f6;

  --ok:           #1a7f4b;
  --ok-soft:      #e7f6ee;
  --warn:         #b7791f;
  --warn-soft:    #fdf3e2;
  --danger:       #c02636;
  --danger-soft:  #fdeaec;
  --info:         #1b6ca8;
  --info-soft:    #e7f1f9;

  /* Typographie --------------------------------------------------------- */
  --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Segoe UI", system-ui, -apple-system, Georgia, serif;
  --fs-base: 1rem;
  --lh: 1.65;

  /* Espacement & formes ------------------------------------------------- */
  --sp-1: .35rem;  --sp-2: .6rem;  --sp-3: 1rem;  --sp-4: 1.5rem;
  --sp-5: 2.25rem; --sp-6: 3.5rem;
  --radius: 12px;  --radius-sm: 8px;  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16,32,42,.06), 0 1px 3px rgba(16,32,42,.08);
  --shadow:    0 4px 16px rgba(16,32,42,.08);
  --shadow-lg: 0 12px 40px rgba(16,32,42,.14);
  --container: 1120px;
  --header-h: 68px;
}

/* Mode sombre optionnel (le clair reste le défaut) */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --ink:#e7edf3; --ink-2:#c3cfda; --muted:#93a4b5;
    --line:#26333f; --line-strong:#33424f;
    --bg:#0f171e; --surface:#141f28; --surface-2:#1b2833;
    --brand-soft:#2a121a; --brand-tint:#3a1721; --accent-soft:#0c2626;
  }
}
:root[data-theme="dark"] {
  --ink:#e7edf3; --ink-2:#c3cfda; --muted:#93a4b5;
  --line:#26333f; --line-strong:#33424f;
  --bg:#0f171e; --surface:#141f28; --surface-2:#1b2833;
  --brand-soft:#2a121a; --brand-tint:#3a1721; --accent-soft:#0c2626;
}

/* Reset léger ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
body {
  margin: 0; font-family: var(--font-sans); font-size: var(--fs-base);
  line-height: var(--lh); color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
h1,h2,h3,h4 { font-family: var(--font-head); line-height: 1.2; color: var(--ink); margin: 0 0 var(--sp-2); }
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); letter-spacing:-.5px; }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 var(--sp-3); }
small { color: var(--muted); }

/* Accessibilité -------------------------------------------------------- */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 1000;
  background: var(--brand); color:#fff; padding: .7rem 1.1rem; border-radius: 0 0 8px 0; font-weight: 600;
}
.skip-link:focus { left: 0; color:#fff; }
.visually-hidden {
  position:absolute!important; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* Layout --------------------------------------------------------------- */
.container { width: min(100% - 2rem, var(--container)); margin-inline: auto; }
.section { padding: var(--sp-6) 0; }
.section--tight { padding: var(--sp-5) 0; }
.grid { display: grid; gap: var(--sp-4); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px){ .grid.cols-3,.grid.cols-4 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 620px){ .grid.cols-2,.grid.cols-3,.grid.cols-4 { grid-template-columns: 1fr;} }
.stack > * + * { margin-top: var(--sp-3); }
.flex { display:flex; gap: var(--sp-3); align-items:center; }
.flex.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.text-center { text-align:center; }
.muted { color: var(--muted); }
.lead { font-size: 1.15rem; color: var(--ink-2); }

/* En-tête / navigation -------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 200; background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--line);
}
:root[data-theme="dark"] .site-header { background: rgba(15,23,30,.92); }
.nav { display:flex; align-items:center; gap: var(--sp-4); height: var(--header-h); }
.brand { display:flex; align-items:center; gap:.6rem; font-weight:800; color:var(--ink); text-decoration:none; font-family:var(--font-head); }
.brand .logo { width:34px; height:34px; flex:0 0 auto; }
.brand b { color: var(--brand); }
.brand small { display:block; font-weight:500; font-size:.68rem; color:var(--muted); letter-spacing:.3px; }
.nav-menu { display:flex; gap: .3rem; margin-left:auto; align-items:center; list-style:none; padding:0; }
.nav-menu a {
  color: var(--ink-2); text-decoration:none; font-weight:600; font-size:.94rem;
  padding: .5rem .8rem; border-radius: var(--radius-sm); transition: background .15s, color .15s;
}
.nav-menu a:hover, .nav-menu a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-dark); }
.nav-toggle { display:none; background:none; border:1px solid var(--line-strong); border-radius:8px; padding:.4rem .55rem; cursor:pointer; }
.nav-toggle svg { width:22px; height:22px; }
@media (max-width: 860px){
  .nav-toggle{ display:inline-flex; margin-left:auto; }
  .nav-menu{
    position:absolute; top: var(--header-h); left:0; right:0; flex-direction:column; align-items:stretch;
    background: var(--bg); border-bottom:1px solid var(--line); padding:.6rem; gap:.2rem;
    box-shadow: var(--shadow); display:none;
  }
  .nav-menu.open{ display:flex; }
  .nav-menu a{ padding:.7rem .8rem; }
}

/* Boutons -------------------------------------------------------------- */
.btn {
  display:inline-flex; align-items:center; gap:.5rem; cursor:pointer;
  font: inherit; font-weight:700; line-height:1; text-decoration:none;
  padding: .75rem 1.2rem; border-radius: var(--radius-sm); border:1.5px solid transparent;
  transition: transform .08s ease, background .15s, box-shadow .15s; white-space:nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color:#fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-dark); color:#fff; }
.btn-accent { background: var(--accent); color:#fff; }
.btn-accent:hover { background: var(--accent-dark); color:#fff; }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-subtle { background: var(--surface-2); color: var(--ink); }
.btn-subtle:hover { background: var(--line); }
.btn-sm { padding:.45rem .8rem; font-size:.85rem; }
.btn-block { width:100%; justify-content:center; }
.btn[disabled] { opacity:.55; cursor:not-allowed; }

/* Cartes --------------------------------------------------------------- */
.card {
  background: var(--bg); border:1px solid var(--line); border-radius: var(--radius);
  padding: var(--sp-4); box-shadow: var(--shadow-sm);
}
.card--pad-lg { padding: var(--sp-5); }
.card-hover { transition: transform .16s ease, box-shadow .16s ease, border-color .16s; }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--brand-tint); }
a.card { text-decoration:none; color:inherit; display:block; }

/* Badges & pastilles ---------------------------------------------------- */
.badge {
  display:inline-flex; align-items:center; gap:.35rem; font-size:.75rem; font-weight:700;
  padding:.28rem .6rem; border-radius:999px; background: var(--surface-2); color: var(--ink-2);
  letter-spacing:.2px;
}
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge-accent{ background: var(--accent-soft); color: var(--accent-dark); }
.badge-ok    { background: var(--ok-soft); color: var(--ok); }
.badge-warn  { background: var(--warn-soft); color: var(--warn); }
.badge-danger{ background: var(--danger-soft); color: var(--danger); }
.badge-info  { background: var(--info-soft); color: var(--info); }
.badge-draft { background:#eef2f6; color:#5b6b7a; }

.dot { width:.55rem; height:.55rem; border-radius:50%; display:inline-block; }
.dot-ok{background:var(--ok);} .dot-warn{background:var(--warn);} .dot-danger{background:var(--danger);}

/* Héro ----------------------------------------------------------------- */
.hero { position:relative; overflow:hidden; background:
  radial-gradient(1200px 380px at 80% -10%, var(--brand-soft), transparent 60%),
  radial-gradient(900px 420px at 0% 0%, var(--accent-soft), transparent 55%);
  border-bottom:1px solid var(--line); }
.hero .container { padding: var(--sp-6) 0; }
.hero-grid { display:grid; grid-template-columns: 1.15fr .85fr; gap: var(--sp-5); align-items:center; }
@media (max-width: 860px){ .hero-grid{ grid-template-columns:1fr; } }
.hero h1 span { color: var(--brand); }
.ecg {
  width:100%; height:64px; color: var(--brand); opacity:.9;
}
.ecg path { stroke: currentColor; fill:none; stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round;
  stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: ecg-draw 3.2s ease-out forwards; }
@keyframes ecg-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce){ .ecg path{ stroke-dashoffset:0; animation:none; } }

/* Statistiques ---------------------------------------------------------- */
.stat { text-align:center; }
.stat .num { font-family:var(--font-head); font-size:2rem; font-weight:800; color:var(--brand); }
.stat .lbl { color: var(--muted); font-size:.85rem; font-weight:600; }

/* Rubriques thématiques ------------------------------------------------- */
.theme-card { display:flex; flex-direction:column; gap:.6rem; height:100%; }
.theme-card .ico { width:46px; height:46px; border-radius:12px; display:grid; place-items:center;
  background: var(--brand-soft); color: var(--brand); }
.theme-card .ico svg{ width:26px; height:26px; }
.theme-card h3 { margin:0; }
.theme-card .count { margin-top:auto; }

/* Fil d'Ariane ---------------------------------------------------------- */
.breadcrumb { list-style:none; display:flex; flex-wrap:wrap; gap:.4rem; padding:0; margin:0 0 var(--sp-3); font-size:.88rem; }
.breadcrumb li::after { content:"›"; margin-left:.4rem; color:var(--muted); }
.breadcrumb li:last-child::after { content:""; }
.breadcrumb a { color: var(--muted); text-decoration:none; }
.breadcrumb a:hover{ color: var(--brand); }

/* Fiche de cours (prose) ------------------------------------------------ */
.prose { max-width: 74ch; }
.prose h2 { margin-top: var(--sp-5); padding-bottom:.3rem; border-bottom:2px solid var(--brand-soft); }
.prose h3 { margin-top: var(--sp-4); color: var(--accent-dark); }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom:.35rem; }
.prose blockquote { border-left:4px solid var(--brand-tint); margin:0 0 var(--sp-3); padding:.4rem 0 .4rem 1rem; color:var(--ink-2); background:var(--surface); border-radius:0 8px 8px 0; }
.prose table { width:100%; border-collapse:collapse; margin: var(--sp-3) 0; font-size:.94rem; }
.prose th, .prose td { border:1px solid var(--line); padding:.55rem .7rem; text-align:left; vertical-align:top; }
.prose th { background: var(--surface-2); }
.callout { border:1px solid var(--line); border-left:4px solid var(--accent); background:var(--accent-soft);
  padding: var(--sp-3); border-radius: var(--radius-sm); margin: var(--sp-3) 0; }
.callout.key { border-left-color: var(--brand); background: var(--brand-soft); }
.callout .callout-title{ font-weight:800; display:block; margin-bottom:.2rem; }

/* Terme de glossaire (survol) ------------------------------------------- */
.gloss {
  border-bottom: 2px dotted var(--accent); cursor: help; color: inherit;
  background: linear-gradient(transparent 82%, var(--accent-soft) 0);
}
.gloss:focus-visible { outline: 2px solid var(--accent); }
.gloss-pop {
  position: absolute; z-index: 500; max-width: 340px; background: var(--bg);
  border:1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: .85rem 1rem; font-size:.9rem; line-height:1.5;
  opacity:0; transform: translateY(4px); pointer-events:none; transition: opacity .12s, transform .12s;
}
.gloss-pop.show { opacity:1; transform: translateY(0); pointer-events:auto; }
.gloss-pop .term { font-weight:800; color: var(--brand-dark); }
.gloss-pop .en { font-style:italic; color: var(--muted); font-size:.85rem; }
.gloss-pop .def { margin:.35rem 0 0; }
.gloss-pop .ex { margin:.4rem 0 0; padding-top:.4rem; border-top:1px dashed var(--line); color: var(--ink-2); }
.gloss-pop .ex b { color: var(--accent-dark); }

/* QCM ------------------------------------------------------------------- */
.qcm-progress { height:8px; background:var(--surface-2); border-radius:999px; overflow:hidden; }
.qcm-progress > i { display:block; height:100%; background:linear-gradient(90deg,var(--brand),var(--accent)); width:0; transition:width .3s; }
.qcm-q { border:1px solid var(--line); border-radius: var(--radius); padding: var(--sp-4); background:var(--bg); box-shadow:var(--shadow-sm); }
.qcm-q .qhead { display:flex; gap:.6rem; align-items:flex-start; justify-content:space-between; margin-bottom: var(--sp-2); }
.qcm-q .stem { font-weight:700; font-size:1.08rem; color:var(--ink); }
.qcm-schema { margin: var(--sp-3) 0; text-align:center; }
.qcm-schema img { border:1px solid var(--line); border-radius:8px; background:#fff; padding:6px; }
.qcm-schema figcaption { font-size:.82rem; color:var(--muted); margin-top:.3rem; }
.opts { list-style:none; margin: var(--sp-3) 0 0; padding:0; display:grid; gap:.55rem; }
.opt {
  display:flex; gap:.7rem; align-items:flex-start; border:1.5px solid var(--line); border-radius:10px;
  padding:.75rem .9rem; cursor:pointer; transition:border-color .12s, background .12s; background:var(--bg);
}
.opt:hover { border-color: var(--brand-tint); background: var(--surface); }
.opt input { margin-top:.2rem; width:1.1rem; height:1.1rem; accent-color: var(--brand); flex:0 0 auto; }
.opt .lettre { font-weight:800; color:var(--muted); min-width:1.3rem; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.incorrect { border-color: var(--danger); background: var(--danger-soft); }
.opt.missed { border-color: var(--warn); background: var(--warn-soft); }
.opt .mark { margin-left:auto; font-weight:800; }
.opt.correct .mark { color: var(--ok); }
.opt.incorrect .mark { color: var(--danger); }
.opt.missed .mark { color: var(--warn); }
.qcm-feedback { margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--radius-sm); border:1px solid var(--line); display:none; }
.qcm-feedback.show { display:block; }
.qcm-feedback.good { background: var(--ok-soft); border-color: var(--ok); }
.qcm-feedback.bad  { background: var(--danger-soft); border-color: var(--danger); }
.qcm-feedback .verdict { font-weight:800; display:flex; align-items:center; gap:.4rem; margin-bottom:.3rem; }
.qcm-feedback .expl { color: var(--ink-2); }
.qcm-actions { display:flex; gap:.7rem; margin-top: var(--sp-4); flex-wrap:wrap; }
.qcm-type-hint { font-size:.8rem; }
.score-ring { --p:0; width:130px; height:130px; border-radius:50%; display:grid; place-items:center;
  background: conic-gradient(var(--brand) calc(var(--p)*1%), var(--surface-2) 0); }
.score-ring > div { width:100px; height:100px; border-radius:50%; background:var(--bg); display:grid; place-items:center; }
.score-ring b { font-size:1.6rem; font-family:var(--font-head); color:var(--brand); }

/* Formulaires ----------------------------------------------------------- */
.form-row { display:flex; flex-direction:column; gap:.35rem; margin-bottom: var(--sp-3); }
.form-row label { font-weight:600; font-size:.92rem; }
.input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border:1.5px solid var(--line-strong);
  border-radius: var(--radius-sm); padding:.65rem .8rem; width:100%;
}
.input:focus, select:focus, textarea:focus { border-color: var(--accent); outline:none; box-shadow:0 0 0 3px var(--accent-soft); }
.form-hint { font-size:.8rem; color: var(--muted); }
.checkbox-inline { display:flex; align-items:flex-start; gap:.55rem; }
.checkbox-inline input { margin-top:.2rem; }

/* Alertes --------------------------------------------------------------- */
.alert { padding: var(--sp-3); border-radius: var(--radius-sm); border:1px solid var(--line); margin-bottom: var(--sp-3); }
.alert-ok { background: var(--ok-soft); border-color: var(--ok); color: #135e37; }
.alert-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--brand-darker); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn); color:#7a5311; }
.alert-info { background: var(--info-soft); border-color: var(--info); color:#124e78; }

/* Tableaux (admin/prof) ------------------------------------------------- */
.table-wrap { overflow-x:auto; border:1px solid var(--line); border-radius: var(--radius); }
table.data { width:100%; border-collapse:collapse; font-size:.92rem; }
table.data th, table.data td { padding:.65rem .8rem; text-align:left; border-bottom:1px solid var(--line); white-space:nowrap; }
table.data thead th { background: var(--surface-2); font-size:.8rem; text-transform:uppercase; letter-spacing:.4px; color:var(--ink-2); position:sticky; top:0; }
table.data tbody tr:hover { background: var(--surface); }
table.data td.wrap { white-space:normal; }

/* Barre latérale tableau de bord --------------------------------------- */
.dash { display:grid; grid-template-columns: 240px 1fr; gap: var(--sp-4); align-items:start; }
@media (max-width: 800px){ .dash { grid-template-columns:1fr; } }
.dash-nav { position:sticky; top: calc(var(--header-h) + 12px); display:flex; flex-direction:column; gap:.2rem; }
.dash-nav a { padding:.6rem .8rem; border-radius:8px; text-decoration:none; color:var(--ink-2); font-weight:600; }
.dash-nav a:hover, .dash-nav a[aria-current="page"]{ background:var(--brand-soft); color:var(--brand-dark); }

/* Progression ----------------------------------------------------------- */
.progress { height:10px; background:var(--surface-2); border-radius:999px; overflow:hidden; }
.progress > i { display:block; height:100%; background:linear-gradient(90deg,var(--accent),var(--brand)); }

/* Pied de page ---------------------------------------------------------- */
.site-footer { background: var(--ink); color:#cfd8e0; margin-top: var(--sp-6); }
:root[data-theme="dark"] .site-footer { background:#0a1017; }
.site-footer a { color:#fff; }
.site-footer .container { padding: var(--sp-5) 0 var(--sp-4); }
.footer-grid { display:grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--sp-4); }
@media (max-width: 760px){ .footer-grid{ grid-template-columns:1fr; } }
.footer-grid h4 { color:#fff; font-size:.95rem; margin-bottom:.6rem; }
.footer-grid ul { list-style:none; padding:0; margin:0; }
.footer-grid li { margin-bottom:.35rem; }
.footer-bottom { border-top:1px solid rgba(255,255,255,.12); margin-top: var(--sp-4); padding-top: var(--sp-3); font-size:.82rem; color:#9fb0be; display:flex; justify-content:space-between; flex-wrap:wrap; gap:.5rem; }

/* Bandeau cookies ------------------------------------------------------- */
.cookie-bar { position:fixed; bottom:0; left:0; right:0; z-index:400; background:var(--ink); color:#e6edf3;
  padding: var(--sp-3); box-shadow:0 -4px 20px rgba(0,0,0,.2); }
.cookie-bar .container{ display:flex; gap:var(--sp-3); align-items:center; flex-wrap:wrap; justify-content:space-between; }
.cookie-bar p { margin:0; font-size:.9rem; max-width:70ch; }

/* Ruban « mode démo » --------------------------------------------------- */
.demo-ribbon { background: var(--warn-soft); border-bottom:1px solid #f0dcae; color:#7a5311;
  font-size:.82rem; text-align:center; padding:.35rem; }

/* Utilitaires ----------------------------------------------------------- */
.mt-0{margin-top:0}.mb-0{margin-bottom:0}.mt-4{margin-top:var(--sp-4)}.mb-4{margin-bottom:var(--sp-4)}
.tag-list{display:flex;flex-wrap:wrap;gap:.4rem}
.divider{height:1px;background:var(--line);margin:var(--sp-4) 0;border:0}
.pill-nav{display:flex;gap:.4rem;flex-wrap:wrap;margin-bottom:var(--sp-4)}
.pill-nav button,.pill-nav a{border:1.5px solid var(--line-strong);background:var(--bg);color:var(--ink-2);
  border-radius:999px;padding:.4rem .9rem;cursor:pointer;font-weight:600;font-size:.9rem;text-decoration:none}
.pill-nav button.active,.pill-nav a.active{background:var(--brand);color:#fff;border-color:var(--brand)}

/* =========================================================================
   Ressources interactives : onglets, flashcards, mindmap
   ========================================================================= */

/* Onglets ---------------------------------------------------------------- */
.tabs { display:flex; gap:.3rem; border-bottom:2px solid var(--line); margin-bottom:1.4rem; flex-wrap:wrap; }
.tab {
  border:0; background:none; font:inherit; font-weight:700; color:var(--muted); cursor:pointer;
  padding:.7rem 1.1rem; border-radius:10px 10px 0 0; border-bottom:3px solid transparent; margin-bottom:-2px;
}
.tab:hover { color:var(--brand); background:var(--brand-soft); }
.tab[aria-selected="true"] { color:var(--brand-dark); border-bottom-color:var(--brand); }
.tab-panel { display:none; }
.tab-panel.active { display:block; animation:fade .2s ease; }
@keyframes fade { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:none} }

/* Flashcards ------------------------------------------------------------- */
.flashcard { perspective:1400px; width:100%; max-width:560px; margin:0 auto; height:280px; cursor:pointer; outline:none; }
.flashcard-inner { position:relative; width:100%; height:100%; transition:transform .5s cubic-bezier(.2,.7,.2,1); transform-style:preserve-3d; }
.flashcard.is-flipped .flashcard-inner { transform:rotateY(180deg); }
.flashcard-face {
  position:absolute; inset:0; backface-visibility:hidden; border-radius:var(--radius-lg);
  display:flex; flex-direction:column; justify-content:center; align-items:center; text-align:center;
  padding:1.8rem; box-shadow:var(--shadow); border:1px solid var(--line);
}
.flashcard-front { background:linear-gradient(135deg,#fff,var(--accent-soft)); }
:root[data-theme="dark"] .flashcard-front { background:linear-gradient(135deg,var(--surface),var(--accent-soft)); }
.flashcard-back { background:linear-gradient(135deg,#fff,var(--brand-soft)); transform:rotateY(180deg); }
:root[data-theme="dark"] .flashcard-back { background:linear-gradient(135deg,var(--surface),var(--brand-soft)); }
.flashcard .fc-text { font-size:1.18rem; font-weight:600; color:var(--ink); margin:.8rem 0; line-height:1.45; }
.flashcard .fc-hint { font-size:.78rem; margin-top:auto; }
@media (prefers-reduced-motion: reduce){ .flashcard-inner{ transition:none; } }

/* Mindmap (arbre repliable) --------------------------------------------- */
.mm-tree, .mm-ul { list-style:none; margin:0; padding:0; }
.mm-ul { margin-left:1.4rem; padding-left:1.1rem; border-left:2px solid var(--line); }
.mm-li { position:relative; margin:.35rem 0; }
.mm-ul > .mm-li::before {
  content:""; position:absolute; left:-1.1rem; top:1.15rem; width:.9rem; height:2px; background:var(--line);
}
.mm-collapsed > .mm-ul { display:none; }
.mm-node {
  display:inline-flex; align-items:center; gap:.5rem; padding:.4rem .8rem; border-radius:999px;
  background:var(--surface); border:1.5px solid var(--line-strong); font-size:.92rem; font-weight:600; color:var(--ink);
}
.mm-node.mm-root { font-size:1.1rem; font-weight:800; color:#fff; background:linear-gradient(120deg,var(--brand),var(--brand-dark)); border-color:var(--brand-dark); }
.mm-node.mm-branch { font-weight:800; color:#fff; }
.mm-c-brand.mm-branch { background:var(--brand); border-color:var(--brand-dark); }
.mm-c-accent.mm-branch { background:var(--accent); border-color:var(--accent-dark); }
.mm-c-info.mm-branch { background:var(--info); border-color:#124e78; }
.mm-c-warn.mm-branch { background:var(--warn); border-color:#7a5311; }
.mm-c-brand:not(.mm-branch):not(.mm-root) { border-left:3px solid var(--brand); }
.mm-c-accent:not(.mm-branch):not(.mm-root) { border-left:3px solid var(--accent); }
.mm-c-info:not(.mm-branch):not(.mm-root) { border-left:3px solid var(--info); }
.mm-c-warn:not(.mm-branch):not(.mm-root) { border-left:3px solid var(--warn); }
.mm-toggle {
  width:1.3rem; height:1.3rem; flex:0 0 auto; border-radius:50%; border:1.5px solid currentColor;
  background:rgba(255,255,255,.25); color:inherit; font-weight:800; line-height:1; cursor:pointer; font-size:.85rem;
  display:grid; place-items:center;
}
.mm-node:not(.mm-branch):not(.mm-root) .mm-toggle { background:var(--bg); color:var(--ink); }

/* =========================================================================
   Glossaire : navigateur A–Z + cartes + modale d'édition
   ========================================================================= */
.gl-tools { display:flex; flex-direction:column; gap:.8rem; margin-bottom:1rem; }
.gl-search { max-width:520px; }
.gl-cats { margin-bottom:0; }
.gl-cat-n { font-size:.75rem; opacity:.7; margin-left:.15rem; }
.gl-azbar { position:sticky; top:calc(var(--header-h) + 4px); z-index:50; display:flex; flex-wrap:wrap; gap:2px;
  background:var(--bg); padding:.4rem 0; border-bottom:1px solid var(--line); }
.gl-az { border:0; background:var(--surface-2); color:var(--ink-2); width:1.7rem; height:1.7rem; border-radius:6px;
  font-weight:700; font-size:.82rem; cursor:pointer; }
.gl-az:hover { background:var(--brand-soft); color:var(--brand-dark); }
.gl-az-off { opacity:.32; cursor:default; }
.gl-group { scroll-margin-top:calc(var(--header-h) + 48px); }
.gl-letter { font-family:var(--font-head); font-size:1.5rem; color:var(--brand); border-bottom:2px solid var(--brand-soft);
  padding-bottom:.15rem; margin:1.4rem 0 .9rem; }
.gl-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:1rem; }
@media (max-width:720px){ .gl-grid{ grid-template-columns:1fr; } }
.gl-card { border:1px solid var(--line); border-radius:var(--radius); padding:1rem 1.1rem; background:var(--bg); box-shadow:var(--shadow-sm);
  scroll-margin-top:calc(var(--header-h) + 56px); transition:box-shadow .15s, border-color .15s; }
.gl-card:hover { box-shadow:var(--shadow); }
.gl-flash { animation:glflash 1.4s ease; }
@keyframes glflash { 0%,100%{ box-shadow:var(--shadow-sm); } 25%{ box-shadow:0 0 0 3px var(--accent); border-color:var(--accent); } }
.gl-head { display:flex; justify-content:space-between; align-items:flex-start; gap:.6rem; flex-wrap:wrap; }
.gl-term { font-weight:800; font-size:1.08rem; color:var(--ink); }
.gl-abbr { vertical-align:middle; }
.gl-en { font-style:italic; color:var(--muted); font-size:.9rem; margin-top:.1rem; }
.gl-tags { display:flex; flex-wrap:wrap; gap:.3rem; justify-content:flex-end; }
.gl-course { background:var(--accent-soft); color:var(--accent-dark); }
.gl-schema { margin:.6rem 0; text-align:center; }
.gl-schema img { max-height:180px; border:1px solid var(--line); border-radius:8px; background:#fff; padding:4px; }
.gl-def { margin:.5rem 0 .4rem; }
.gl-ex { margin:0; font-size:.9rem; color:var(--ink-2); border-top:1px dashed var(--line); padding-top:.45rem; }
.gl-ex b { color:var(--accent-dark); }
.gl-related { margin-top:.55rem; display:flex; flex-wrap:wrap; gap:.35rem; align-items:center; }
.gl-related-lbl { font-size:.82rem; color:var(--muted); }
.gl-chip { border:1px solid var(--line-strong); background:var(--surface); color:var(--brand-dark); border-radius:999px;
  padding:.2rem .6rem; font-size:.8rem; font-weight:600; cursor:pointer; }
.gl-chip:hover { background:var(--brand-soft); }
.gl-foot { display:flex; gap:.8rem; margin-top:.6rem; padding-top:.5rem; border-top:1px solid var(--line); }
.gl-link { background:none; border:0; color:var(--muted); font-size:.8rem; font-weight:600; cursor:pointer; padding:0; }
.gl-link:hover { color:var(--brand); }
.gl-del:hover { color:var(--danger); }

/* Modale ---------------------------------------------------------------- */
.modal-overlay { position:fixed; inset:0; z-index:600; background:rgba(16,32,42,.55); display:none;
  align-items:flex-start; justify-content:center; padding:4vh 1rem; overflow-y:auto; }
.modal-overlay.open { display:flex; }
.modal { background:var(--bg); border-radius:var(--radius-lg); box-shadow:var(--shadow-lg); width:min(760px,100%);
  max-height:92vh; display:flex; flex-direction:column; }
.modal-head { display:flex; justify-content:space-between; align-items:center; padding:1rem 1.3rem; border-bottom:1px solid var(--line); }
.modal-body { padding:1.1rem 1.3rem; overflow-y:auto; }
.modal-foot { display:flex; gap:.6rem; padding:1rem 1.3rem; border-top:1px solid var(--line); position:sticky; bottom:0; background:var(--bg); }

/* Glossaire : filtre catégories multi-select (déroulant) ----------------- */
.gl-tools-row { display:flex; gap:.6rem; flex-wrap:wrap; align-items:center; }
.gl-tools-row .gl-search { flex:1 1 320px; max-width:520px; }
.gl-multi { position:relative; }
.gl-multi-btn { display:inline-flex; align-items:center; gap:.4rem; border:1.5px solid var(--line-strong); background:var(--bg);
  color:var(--ink); border-radius:var(--radius-sm); padding:.65rem .9rem; font:inherit; font-weight:600; cursor:pointer; }
.gl-multi-btn:hover { border-color:var(--brand-tint); }
.gl-multi-count:empty { display:none; }
.gl-multi-caret { color:var(--muted); }
.gl-multi.open .gl-multi-caret { transform:rotate(180deg); }
.gl-multi-panel { position:absolute; z-index:120; top:calc(100% + 6px); left:0; width:min(360px,90vw);
  background:var(--bg); border:1px solid var(--line-strong); border-radius:var(--radius); box-shadow:var(--shadow-lg);
  padding:.7rem; display:none; }
.gl-multi.open .gl-multi-panel { display:block; }
.gl-multi-search { margin-bottom:.5rem; }
.gl-multi-actions { display:flex; gap:.4rem; margin-bottom:.5rem; }
.gl-multi-list { max-height:320px; overflow-y:auto; display:flex; flex-direction:column; gap:.1rem; }
.gl-multi-item { display:flex; align-items:center; gap:.5rem; padding:.35rem .5rem; border-radius:6px; cursor:pointer; font-size:.92rem; }
.gl-multi-item:hover { background:var(--surface); }
.gl-multi-item input { width:1rem; height:1rem; accent-color:var(--brand); }
.gl-multi-name { flex:1; }
.gl-multi-n { color:var(--muted); font-size:.8rem; font-variant-numeric:tabular-nums; }

/* Glossaire : sélecteur de schéma dans la modale ------------------------ */
.gl-schema-pick { display:flex; flex-direction:column; gap:.5rem; }
.gl-schema-pick .gl-schema-row { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; }
.gl-schema-preview { max-height:120px; max-width:100%; border:1px solid var(--line); border-radius:8px; background:#fff; padding:4px; display:none; }
.gl-schema-preview.show { display:inline-block; }

/* =========================================================================
   Éditeur de pages (WYSIWYG) + bouton flottant
   ========================================================================= */
.wysiwyg-toolbar { display:flex; flex-wrap:wrap; gap:.2rem; padding:.5rem; border:1px solid var(--line-strong);
  border-bottom:0; border-radius:var(--radius-sm) var(--radius-sm) 0 0; background:var(--surface); position:sticky; top:calc(var(--header-h) + 2px); z-index:40; }
.wy-btn { min-width:2rem; height:2rem; border:1px solid var(--line); background:var(--bg); color:var(--ink); border-radius:6px;
  cursor:pointer; font-size:.9rem; font-weight:600; padding:0 .4rem; }
.wy-btn:hover { background:var(--brand-soft); border-color:var(--brand-tint); }
.wy-sep { width:1px; background:var(--line); margin:.15rem .25rem; }
.wysiwyg-area { border:1px solid var(--line-strong); border-radius:0 0 var(--radius-sm) var(--radius-sm);
  min-height:280px; padding:1rem 1.2rem; background:var(--bg); outline:none; max-width:none; }
.wysiwyg-area:focus { box-shadow:inset 0 0 0 2px var(--accent-soft); }
.wysiwyg-area img { max-width:100%; height:auto; border-radius:6px; }
.wy-uploading { color:var(--muted); font-style:italic; }

.edit-fab { position:fixed; right:1.1rem; bottom:1.1rem; z-index:450; background:var(--brand); color:#fff;
  padding:.7rem 1.1rem; border-radius:999px; font-weight:700; text-decoration:none; box-shadow:var(--shadow-lg);
  display:inline-flex; align-items:center; gap:.4rem; }
.edit-fab:hover { background:var(--brand-dark); color:#fff; }
@media print { .edit-fab { display:none; } }

/* =========================================================================
   Bloc média, médiathèque, édition « sur place »
   ========================================================================= */
figure.media { margin:1.2rem 0; text-align:center; }
figure.media img, figure.media video { max-width:100%; height:auto; border-radius:10px; border:1px solid var(--line); background:#000; }
figure.media img { background:#fff; }
figure.media figcaption { font-size:.85rem; color:var(--muted); margin-top:.4rem; }

.wy-btn-media { background:var(--accent-soft); border-color:var(--accent); color:var(--accent-dark); font-weight:700; }

/* Médiathèque ----------------------------------------------------------- */
.ml-overlay .modal { width:min(820px,100%); }
.ml-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:.6rem; max-height:44vh; overflow-y:auto; }
.ml-item { border:2px solid var(--line); border-radius:10px; background:var(--bg); cursor:pointer; padding:.3rem; display:flex; flex-direction:column; gap:.3rem; align-items:center; }
.ml-item:hover { border-color:var(--brand-tint); }
.ml-item.sel { border-color:var(--brand); box-shadow:0 0 0 2px var(--brand-soft); }
.ml-item img { width:100%; height:80px; object-fit:cover; border-radius:6px; }
.ml-vid { width:100%; height:80px; display:grid; place-items:center; background:var(--ink); color:#fff; border-radius:6px; font-size:1.6rem; }
.ml-name { font-size:.72rem; color:var(--ink-2); word-break:break-all; line-height:1.2; max-height:2.4em; overflow:hidden; }

/* Édition sur place ----------------------------------------------------- */
.editing-mode { padding-bottom:80px; }
.ie-block { outline:2px dashed var(--accent); outline-offset:4px; border-radius:6px; min-height:2.2em; transition:outline-color .15s; }
.ie-block:focus { outline:2px solid var(--brand); background:var(--brand-soft); }
.ie-toolbar-bar { position:sticky; top:0; z-index:450; background:var(--surface); border-bottom:1px solid var(--line-strong);
  box-shadow:var(--shadow); display:flex; align-items:center; gap:1rem; padding:.4rem .6rem; flex-wrap:wrap; }
.ie-toolbar-bar .wysiwyg-toolbar { position:static; border:0; background:none; padding:0; box-shadow:none; }
.ie-hint { font-size:.8rem; color:var(--muted); flex:1 1 auto; min-width:150px; }
.ie-save-bar { position:fixed; bottom:0; left:0; right:0; z-index:460; background:var(--ink); color:#fff;
  display:flex; align-items:center; gap:.8rem; padding:.7rem 1rem; box-shadow:0 -4px 20px rgba(0,0,0,.25); }
.ie-status { color:#cfe8d8; }
