:root {
  --radius: 8px;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* ===== BEIGE — vélin crème (thème principal par défaut) ===== */
  --bg: #ece2cb;
  --bg-2: #e6dabd;
  --panel: #f7efdc;
  --panel-2: #efe4cb;
  --border: #d8c8a4;
  --border-strong: #c4b083;
  --text: #38301f;
  --text-dim: #6a5d44;
  --text-faint: #998a6c;
  --accent: #8a5a1e;
  --accent-ink: #6f4716;
  --good: #5f7a32;
  --bad: #a8472c;
  --corner: var(--accent); /* couleur des coins d'encadrement (héritée par thème) */
  --shadow: 0 1px 2px rgba(80,55,20,.08), 0 12px 30px rgba(80,55,20,.10);
  --shadow-sm: 0 1px 2px rgba(80,55,20,.09);
  --paper: none;            /* fonds strictement unis (tous thèmes) */
  --vignette: none;
}

/* ===== MARRON — encre brune à la chandelle, parchemin vieilli ===== */
html[data-theme="marron"], html[data-theme="dark"] {
  --bg: #1a160f;
  --bg-2: #211c13;
  --panel: #221d14;
  --panel-2: #2a2418;
  --border: #38301f;
  --border-strong: #4a4029;
  --text: #ece2cd;
  --text-dim: #b6a988;
  --text-faint: #8a7d60;
  --accent: #c2913f;
  --accent-ink: #d8a850;
  --good: #7a9b54;
  --bad: #c9714f;
  --shadow: 0 1px 2px rgba(0,0,0,.32), 0 14px 34px rgba(0,0,0,.34);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.28);
  --paper: none;
  --vignette: none;
}

/* ===== NOIR — noir profond, encre dorée ===== */
html[data-theme="noir"] {
  --bg: #000000;
  --bg-2: #070707;
  --panel: #0d0d0d;
  --panel-2: #161616;
  --border: #262626;
  --border-strong: #3a3a3a;
  --text: #ece7da;
  --text-dim: #b3ac9b;
  --text-faint: #7e7768;
  --accent: #cf9c44;
  --accent-ink: #e2b258;
  --good: #84a85c;
  --bad: #d1744f;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.6);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.45);
  --paper: none;
  --vignette: none;
}

/* ===== BLANC — épuré, accompagné de bleu ===== */
html[data-theme="blanc"] {
  --bg: #f7f9fc;
  --bg-2: #eef2f8;
  --panel: #ffffff;
  --panel-2: #f3f6fb;
  --border: #e2e7f0;
  --border-strong: #c8d1e0;
  --text: #15233b;
  --text-dim: #4a5365;
  --text-faint: #8a93a6;
  --accent: #2563eb;        /* bleu — couleur d'accompagnement */
  --accent-ink: #1d4ed8;
  --good: #1f9d57;
  --bad: #dc2626;
  --corner: var(--accent);  /* coins du même bleu que les boutons (mode Blanc) */
  --shadow: 0 1px 2px rgba(30,50,90,.06), 0 12px 30px rgba(30,50,90,.10);
  --shadow-sm: 0 1px 2px rgba(30,50,90,.07);
  --paper: none;
  --vignette: none;
}

/* ===== BLEU — bleu marine & gris acier, bouton orange vif ===== */
html[data-theme="primaires"] {
  --bg: #0e1c33;            /* bleu marine profond, uni */
  --bg-2: #0a1525;
  --panel: #172a45;        /* bleu acier */
  --panel-2: #21364f;
  --border: #324a6b;       /* gris acier */
  --border-strong: #486488;
  --text: #e8eef6;          /* blanc acier */
  --text-dim: #aebccf;      /* gris acier clair */
  --text-faint: #7d8ba2;    /* gris acier */
  --accent: #ff7a18;        /* orange vif — boutons / conversion / accents */
  --accent-ink: #ff944a;    /* orange clair — survols / liens */
  --good: #34a877;          /* vert — succès */
  --bad: #e2533a;           /* rouge-orangé — erreurs */
  --corner: var(--accent);  /* coins orange (accent) */
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 18px 44px rgba(0,0,0,.55);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.45);
  --paper: none;            /* fond strictement uni */
  --vignette: none;
}
/* jaune vif réservé aux accents typographiques (sous-titres / liens) */
html[data-theme="primaires"] .hero h2 .grad,
html[data-theme="primaires"] .grad { color: var(--accent-ink); }
html[data-theme="primaires"] .content a { color: var(--accent-ink); }
html[data-theme="primaires"] .content a:hover { text-decoration-color: var(--accent-ink); }

/* ---- messagerie (thème primaires) : standards en jaune, rouge réservé aux bulles ---- */
/* messages standards (DM + communauté, envoyés/reçus) → bordure jaune, sans rouge */
html[data-theme="primaires"] .bubble:not(.bulle) .bub-in { border-color: var(--accent-ink); box-shadow: none; }
html[data-theme="primaires"] .bubble.me:not(.bulle) .bub-in { background: color-mix(in srgb, var(--accent-ink) 9%, var(--panel-2)); }
/* éléments secondaires internes neutres (heure d'envoi, bouton Citer/Répondre) */
html[data-theme="primaires"] .bub-time,
html[data-theme="primaires"] .bubble.me .bub-time { color: var(--text-faint); }
html[data-theme="primaires"] .bub-reply { color: var(--text-dim); opacity: 1; }
html[data-theme="primaires"] .bub-reply:hover { color: var(--accent-ink); }
/* la bulle conserve son glow accentué (désormais jaune vif, plus de rouge) */
html[data-theme="primaires"] .bubble.comm.bulle .bub-in {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent),
              0 0 26px -2px color-mix(in srgb, var(--accent) 90%, transparent),
              0 0 60px -10px color-mix(in srgb, var(--accent) 75%, transparent);
}
/* boutons jaunes → texte sombre pour la lisibilité */
html[data-theme="primaires"] .btn-primary { color: #14213a; }
html[data-theme="primaires"] .btn-primary svg { color: #14213a; }

/* ============================================================
   FONDS STRICTEMENT UNIS — aucun dégradé / texture (tous les thèmes)
   ============================================================ */
:root, html[data-theme] { --paper: none; --vignette: none; }
html { background-image: none; }

* { box-sizing: border-box; margin: 0; padding: 0; }
/* masqué visuellement mais lisible par les moteurs de recherche / lecteurs d'écran */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
html, body { height: 100%; }
/* fond porté par l'élément racine : couvre toujours toute la zone → pas de couture */
html {
  background-color: var(--bg);
  background-image: var(--paper), var(--vignette);
  background-repeat: no-repeat;
  min-height: 100%;
  transition: background-color .3s;
}
body {
  font-family: var(--sans);
  background: transparent;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: color .3s;
}

/* ============================================================
   BARRE LATÉRALE (navigation gauche) + HAMBURGER + MINI-PROFIL
   ============================================================ */
:root { --sb-w: 264px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer;
  display: grid; place-items: center; transition: .18s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-2); }
.icon-btn svg { width: 18px; height: 18px; }

/* bouton hamburger (visible en mobile uniquement) */
.hamburger {
  display: none; position: fixed; top: 14px; left: 14px; z-index: 60;
  width: 42px; height: 42px; border-radius: 9px;
  background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border-strong); color: var(--text); cursor: pointer;
  align-items: center; justify-content: center;
}
.hamburger svg { width: 22px; height: 22px; }
/* bouton de fermeture (croix) dans la sidebar — visible seulement en mode tiroir mobile */
.sb-close { display: none; position: absolute; top: 12px; right: 12px; z-index: 5; width: 38px; height: 38px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--border-strong); color: var(--text-dim); cursor: pointer; align-items: center; justify-content: center; }
.sb-close:hover { color: var(--text); border-color: var(--accent); }
.sb-close svg { width: 20px; height: 20px; }

/* fond sombre derrière le menu mobile */
.sb-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,11,5,.5); backdrop-filter: blur(2px); z-index: 49; }

/* la sidebar — colonne flex : nav en haut, mini-profil ancré en bas */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sb-w); z-index: 50;
  display: flex; flex-direction: column;
  background: var(--panel); background-image: var(--paper);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.sb-top { flex: 1 1 auto; overflow-y: auto; padding: 22px 16px 12px; display: flex; flex-direction: column; }
.sb-bottom { flex: 0 0 auto; padding: 12px 16px 16px; border-top: 1px solid var(--border); }

/* marque */
.sidebar .brand { display: block; text-decoration: none; padding: 4px 8px 18px; }
.sidebar .brand h1 {
  font-family: var(--serif); font-size: 26px; font-weight: 600;
  letter-spacing: 5px; text-transform: uppercase; font-variant: small-caps; color: var(--text);
}
.sidebar .brand .tag { font-size: 12px; color: var(--text-faint); font-style: italic; font-family: var(--serif); letter-spacing: .3px; margin-top: 2px; }

/* navigation */
.sb-nav { display: flex; flex-direction: column; gap: 3px; }
.sb-link {
  display: flex; align-items: center; gap: 12px; text-decoration: none;
  font-family: var(--serif); font-size: 15px; color: var(--text-dim);
  padding: 10px 12px; border-radius: 9px; transition: .15s; letter-spacing: .2px;
}
.sb-link:hover { color: var(--text); background: var(--panel-2); }
.sb-link.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.sb-ic { display: grid; place-items: center; flex: 0 0 auto; }
.sb-ic svg { width: 19px; height: 19px; }

/* groupe génération (modèle / langue) */
.sb-group { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.sb-group-title { font-family: var(--serif); font-variant: small-caps; letter-spacing: 1px; font-size: 13px; color: var(--text-faint); margin-bottom: 10px; padding: 0 4px; }
.sb-label { display: block; font-size: 11.5px; color: var(--text-dim); margin: 12px 0 5px; padding: 0 4px; letter-spacing: .3px; }
.sb-group select { font-size: 13px; padding: 9px 11px; }

/* bouton thème */
.sb-theme {
  margin-top: 10px; display: flex; align-items: center; gap: 10px;
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  padding: 10px 12px; border-radius: 9px; cursor: pointer; font-family: var(--sans);
  font-size: 13.5px; transition: .15s;
}
.sb-theme:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-2); }
.sb-theme svg { width: 17px; height: 17px; flex: 0 0 auto; }
.sb-theme .sb-ic { display: inline-flex; }
.sb-theme select { flex: 1; min-width: 0; background-color: transparent; border: 0; color: var(--text); font-family: var(--sans); font-size: 13.5px; cursor: pointer; padding: 0 22px 0 0; background-position: right 2px center; box-shadow: none; }
.sb-theme select:focus { outline: none; box-shadow: none; }
.sb-theme select option { background: var(--panel); color: var(--text); }

/* bouton notifications dans la sidebar + badge non lus */
.sb-notif {
  position: relative; display: flex; align-items: center; gap: 10px; margin-top: 10px;
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  padding: 10px 12px; border-radius: 9px; cursor: pointer; font-family: var(--sans);
  font-size: 13.5px; transition: .15s;
}
.sb-notif:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-2); }
.sb-notif .sb-ic svg { width: 17px; height: 17px; }
.notif-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 11px; background: var(--bad, #c0392b); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--panel); }

/* panneau de notifications (modale) */
.notif-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; margin: 4px 0; }
.notif-item { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); text-decoration: none; color: var(--text); transition: .12s; }
.notif-item:hover { border-color: var(--border-strong); background: var(--panel-2); }
.notif-item.unread { background: color-mix(in srgb, var(--accent) 9%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.notif-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: transparent; }
.notif-item.unread .notif-dot { background: var(--accent); box-shadow: 0 0 8px -1px var(--accent); }
.notif-body { display: flex; flex-direction: column; gap: 2px; }
.notif-text { font-size: 13px; line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-faint); }

/* mini-profil ancré en bas */
.mini-profile { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); padding: 8px; border-radius: 10px; transition: .15s; }
.mini-profile:hover { background: var(--panel-2); }
.mp-info { min-width: 0; flex: 1; }
.mp-name { font-family: var(--serif); font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-sub { font-size: 11.5px; color: var(--text-faint); }
.mini-logout {
  display: inline-flex; align-items: center; justify-content: center; margin-top: 8px;
  width: 100%; gap: 8px; background: transparent; border: 1px solid var(--border);
  color: var(--text-faint); padding: 8px; border-radius: 9px; cursor: pointer; transition: .15s;
}
.mini-logout:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.sb-bottom .mini-profile + .mini-logout { margin-top: 6px; }

/* ---- Layout : le contenu laisse la place à la sidebar ---- */
main { max-width: 940px; margin: 0 auto; padding: 38px 32px 96px; }
body[data-page="home"] main { max-width: 1180px; }
body[data-page] { padding-left: var(--sb-w); transition: padding-left .25s; }

/* ---- Champs de formulaire (global) ---- */
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%; padding: 11px 13px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; font-family: var(--sans);
  transition: .18s; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
/* menus déroulants intégrés au thème : chevron maison + liste aux couleurs du site */
select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 34px; cursor: pointer;
  background-color: var(--bg-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9382' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 15px 15px;
}
select::-ms-expand { display: none; }
select:hover { border-color: var(--border-strong); }
option, optgroup { background: var(--panel); color: var(--text); }

/* ============================================================
   AUTH — UX e-mail + validation dynamique du mot de passe
   ============================================================ */
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > svg { position: absolute; left: 12px; color: var(--text-faint); pointer-events: none; }
.input-icon input { padding-left: 38px; padding-right: 38px; }
.input-icon input.ok { border-color: var(--good); }
.input-valid { position: absolute; right: 12px; color: var(--good); font-weight: 700; opacity: 0; transform: scale(.6); transition: .18s; }
.input-valid.show { opacity: 1; transform: scale(1); }
.field-hint { font-size: 12px; margin-top: 5px; color: var(--text-faint); min-height: 14px; }
.field-hint.good { color: var(--good); }
.field-hint.bad { color: var(--bad); }

.pw-checklist { list-style: none; margin: 4px 0 14px; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px; display: grid; gap: 7px; }
.pw-checklist li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-faint); transition: color .15s; }
.pw-dot { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong); position: relative; transition: .18s; }
.pw-checklist li.ok { color: var(--good); }
.pw-checklist li.ok .pw-dot { background: var(--good); border-color: var(--good); }
.pw-checklist li.ok .pw-dot::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; }

/* page d'accès réservé (non connecté) */
.auth-gate { max-width: 460px; margin: 60px auto; text-align: center; background: var(--panel); background-image: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px 28px; box-shadow: var(--shadow-sm); }
.auth-gate h2 { font-family: var(--serif); font-size: 26px; font-variant: small-caps; letter-spacing: .5px; margin-bottom: 10px; }
.auth-gate p { color: var(--text-dim); margin-bottom: 20px; }

/* ---- Hero / generator ---- */
.hero { padding: 14px 0 6px; }
.hero h2 { font-family: var(--serif); font-size: clamp(28px, 4vw, 38px); font-weight: 600; line-height: 1.2; letter-spacing: -.2px; margin-bottom: 12px; }
.hero h2 .grad { color: var(--accent); font-style: italic; }
.hero p { color: var(--text-dim); max-width: 560px; margin: 0 0 26px; font-size: 16px; }
.gen-box {
  background: var(--panel); background-image: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm);
}
.gen-box textarea { resize: vertical; min-height: 70px; font-size: 15px; line-height: 1.55; }
.gen-controls { display: flex; gap: 14px; margin-top: 14px; flex-wrap: wrap; align-items: flex-end; }
.gen-controls .sel { flex: 0 0 auto; min-width: 150px; }
.gen-controls .sel label { display:block; font-size: 11px; color: var(--text-faint); margin-bottom: 5px; letter-spacing:.3px; }
.btn {
  border: none; cursor: pointer; font-family: var(--sans); font-weight: 600;
  border-radius: 8px; padding: 12px 22px; font-size: 14px; letter-spacing: .2px;
  transition: .18s; display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); margin-left: auto; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-2); }
.btn svg { width: 16px; height: 16px; }

.examples-label { margin-top: 20px; font-size: 13px; color: var(--text-faint); display: flex; align-items: baseline; gap: 10px; }
.dice-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; font-family: var(--sans); padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.dice-btn:hover { color: var(--accent-ink); }
.examples { margin-top: 11px; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 13.5px; color: var(--text-dim); background: var(--panel); border: 1px solid var(--border); padding: 6px 13px; border-radius: 6px; cursor: pointer; transition: .15s; }
.chip:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-2); }

/* ---- Progress ---- */
.progress-wrap { margin: 30px 0; display: none; }
.progress-wrap.show { display: block; }
.pbar { height: 5px; background: var(--panel-2); border-radius: 20px; overflow: hidden; border: 1px solid var(--border); }
.pbar > div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.pstatus { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--text-dim); font-size: 13px; }
.spinner { width: 15px; height: 15px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Course ---- */
.course-head { display: none; margin: 10px 0 28px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.course-head.show { display: block; }
.course-head h2 { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.25; font-variant: small-caps; letter-spacing: .5px; }
.course-meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--text-faint); font-size: 13px; margin-top: 10px; }
.course-meta span { display: inline-flex; align-items: center; gap: 6px; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.toc a { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); background: transparent; border: 1px solid var(--border); padding: 6px 12px; border-radius: 6px; text-decoration: none; transition: .15s; }
.toc a .toc-num { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; opacity: .85; }
.toc a:hover { color: var(--text); border-color: var(--mc, var(--border-strong)); }

.module {
  background: var(--panel); background-image: var(--paper);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 18px; overflow: hidden; box-shadow: var(--shadow-sm); scroll-margin-top: 90px;
}
.mod-head {
  display: flex; align-items: center; gap: 16px; padding: 20px 24px;
  border-bottom: 1px solid transparent; cursor: pointer; user-select: none;
}
.module.open .mod-head { border-bottom-color: var(--border); }
.mod-num {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 8px;
  background: color-mix(in srgb, var(--mc, var(--accent)) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--mc, var(--accent)) 45%, transparent);
  color: var(--mc, var(--accent)); font-weight: 700; font-size: 15px; display: grid; place-items: center;
  font-family: var(--serif);
}
.mod-title { flex: 1; }
.mod-title h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: .3px; }
.mod-title .mod-kicker { display: block; font-family: var(--serif); font-style: italic; font-size: 12px; color: var(--text-faint); letter-spacing: .5px; margin-bottom: 2px; }
.mod-title p { font-size: 13.5px; color: var(--text-faint); margin-top: 3px; }
.mod-chev { color: var(--text-faint); transition: transform .3s; width: 20px; height: 20px; flex: 0 0 auto; }
.module.open .mod-chev { transform: rotate(180deg); }
.mod-body { display: none; padding: 10px 24px 28px; }
/* ouverture : le contenu se déroule comme un parchemin (de haut en bas) */
.module.open .mod-body {
  display: flex; gap: 30px; align-items: flex-start; position: relative;
  transform-origin: top center;
  animation: unroll .55s cubic-bezier(.2,.7,.25,1) both;
}
/* (l'ombre dégradée du rouleau a été retirée — fonds unis ; l'effet de déroulé reste via scaleY) */
.mod-main { flex: 1 1 auto; min-width: 0; }
.mod-side { flex: 0 0 320px; max-width: 320px; }
@media (max-width: 920px){
  .module.open .mod-body { flex-direction: column; }
  .mod-side { flex-basis: auto; max-width: none; width: 100%; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes unroll {
  0%   { transform: scaleY(.02); opacity: .35; filter: brightness(.92); }
  55%  { opacity: 1; }
  100% { transform: scaleY(1); opacity: 1; filter: none; }
}
@keyframes unrollEdge {
  0%   { top: -34px; opacity: 0; }
  18%  { opacity: .65; }
  100% { top: 100%; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .module.open .mod-body { animation: fade .25s both; }
  .module.open .mod-body::before { display: none; }
}

.mod-loading { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 13px; padding: 16px 0; }

/* content typography — registre manuscrit */
.content { font-size: 16.5px; line-height: 1.78; font-family: var(--serif); }
.content h2 { font-family: var(--serif); font-size: 21px; margin: 30px 0 13px; font-weight: 600; color: var(--text); padding-bottom: 6px; letter-spacing: .6px; font-variant: small-caps; border-bottom: 1px solid color-mix(in srgb, var(--mc, var(--accent)) 35%, var(--border)); }
.content h3 { font-family: var(--serif); font-size: 18px; margin: 22px 0 10px; font-weight: 600; color: var(--text); font-style: italic; }
.content p { margin: 14px 0; color: var(--text); text-align: justify; hyphens: auto; }
/* lettrine — première lettre du module enluminée */
.mod-main .content > p:first-of-type::first-letter {
  float: left; font-family: var(--serif); font-weight: 700;
  font-size: 3.4em; line-height: .82; padding: 4px 10px 0 0;
  color: var(--mc, var(--accent));
}
.content ul, .content ol { margin: 13px 0 13px 8px; padding-left: 24px; }
.content li { margin: 7px 0; }
.content li::marker { color: var(--mc, var(--accent)); }
.content strong { color: var(--text); font-weight: 700; }
.content em { font-style: italic; }
.content code { font-family: var(--mono); background: var(--bg-2); padding: 1px 6px; border-radius: 4px; font-size: 13.5px; color: var(--accent-ink); }
.content pre { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 15px; overflow-x: auto; margin: 15px 0; }
.content pre code { background: none; padding: 0; color: var(--text); }
.content blockquote { border-left: 3px solid var(--mc, var(--accent)); background: var(--panel-2); padding: 11px 16px; border-radius: 0 6px 6px 0; margin: 15px 0; color: var(--text-dim); font-style: italic; }
.content table { width:100%; border-collapse: collapse; margin: 15px 0; font-size: 14px; }
.content th, .content td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; }
.content th { background: var(--panel-2); color: var(--text); font-weight: 600; }
.content hr { border: none; height: 22px; margin: 26px 0; background: none; text-align: center; }
.content hr::before { content: "❧"; color: var(--mc, var(--accent)); font-size: 18px; opacity: .8; }

/* sub-cards */
.sub-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; margin-top: 22px; overflow: hidden; }
.mod-side .sub-card { margin-top: 0; margin-bottom: 16px; }
.mod-side .sub-card:last-child { margin-bottom: 0; }
.mod-side .sub-head { padding: 12px 14px; font-size: 13px; }
.mod-side .sub-body { padding: 0 14px 16px; }
.mod-side .quiz-q .qtext { font-size: 13.5px; }
.mod-side .opt { font-size: 13px; padding: 9px 11px; gap: 9px; }
.mod-side .opt .mark { width: 20px; height: 20px; font-size: 11px; }
.mod-side .quiz-explain { font-size: 12.5px; }
.mod-side .quiz-actions .btn { padding: 8px 12px; font-size: 12.5px; }
.mod-side .video-fallback { padding: 12px; font-size: 12.5px; }
.sub-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-weight: 600; font-size: 14px; cursor: pointer; user-select: none; }
.sub-head svg.ic { width: 17px; height: 17px; color: var(--mc, var(--accent)); flex: 0 0 auto; }
.sub-head .chev { margin-left: auto; color: var(--text-faint); transition: transform .3s; width: 18px; height: 18px; flex: 0 0 auto; }
.sub-card.open .sub-head .chev { transform: rotate(180deg); }
.sub-body { display: none; padding: 0 18px 20px; }
.sub-card.open .sub-body { display: block; }

/* video */
.video-frame { position: relative; padding-top: 56.25%; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); margin-top: 6px; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.video-fallback { padding: 18px; color: var(--text-dim); font-size: 13px; }
.video-fallback a { color: var(--accent); }

/* quiz */
.quiz-q { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.quiz-q:first-child { border-top: none; padding-top: 6px; }
.quiz-q .qtext { font-weight: 600; font-size: 14.5px; margin-bottom: 12px; display: flex; gap: 9px; }
.quiz-q .qtext .qn { color: var(--text-faint); font-family: var(--serif); font-weight: 700; flex: 0 0 auto; }
.opt {
  display: flex; align-items: center; gap: 11px; padding: 10px 14px; margin: 7px 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 7px;
  cursor: pointer; transition: .12s; font-size: 14px;
}
.opt:hover { border-color: var(--border-strong); }
.opt .mark { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--text-faint); font-family: var(--serif); }
.opt.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); }
.opt.correct .mark { border-color: var(--good); color: var(--good); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.opt.wrong .mark { border-color: var(--bad); color: var(--bad); }
.opt.disabled { cursor: default; }
.quiz-explain { font-size: 13px; color: var(--text-dim); margin-top: 8px; padding: 10px 14px; background: var(--panel-2); border-radius: 6px; border-left: 3px solid var(--good); display: none; }
.quiz-explain.show { display: block; }
.quiz-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; align-items: center; }
.quiz-score { font-size: 13px; color: var(--text-dim); margin-left: auto; }
.quiz-score b { color: var(--text); }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px);
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--text);
  padding: 13px 18px; border-radius: 8px; box-shadow: var(--shadow); z-index: 100;
  font-size: 14px; max-width: 90vw; transition: transform .3s; display: flex; align-items: center; gap: 10px;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--bad); }
.toast .ic { color: var(--accent); flex: 0 0 auto; }
.toast.err .ic { color: var(--bad); }

footer { text-align: center; color: var(--text-faint); font-size: 12.5px; padding: 32px; font-family: var(--serif); font-style: italic; }
.empty { text-align: center; color: var(--text-faint); padding: 40px 0; font-size: 14px; }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================
   COUCHE SOCIALE — nav, compte, modales, vues, chat, profil
   ============================================================ */

/* ---- Boutons (variantes de taille) ---- */
.btn.sm { padding: 8px 14px; font-size: 13px; }
.btn.xs { padding: 5px 11px; font-size: 12px; }
.btn.wide { width: 100%; justify-content: center; margin-top: 6px; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }

/* ---- Avatars & badges utilisateur ---- */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; overflow: hidden; flex: 0 0 auto; border: 1px solid var(--border); background: var(--panel-2); font-family: var(--serif); font-weight: 700; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.ph { color: #fff; background: hsl(var(--ah, 30), 38%, 45%); border-color: transparent; }
/* drapeaux via flag-icons (SVG) — rendu identique sur tous les OS */
/* drapeaux : « cachet de cire » — bords asymétriques en relief, double ombre interne/externe,
   léger voile sepia(0.2) pour l'intégration au thème « Antiquité ». Lisibilité préservée. */
.fi.flag {
  display: inline-block; width: 1.4em; height: 1em; vertical-align: -2px; background-size: cover;
  border: 1px solid color-mix(in srgb, #7a5a2e 65%, var(--border));
  border-radius: 5px 7px 4px 8px / 7px 4px 8px 5px;
  filter: sepia(0.2);
  box-shadow:
    inset 0 0 2px color-mix(in srgb, #fff4dd 30%, transparent),
    inset 0 0 0 1px color-mix(in srgb, #3c2810 14%, transparent),
    1px 1px 0 color-mix(in srgb, #5c4220 38%, transparent),
    0 2px 5px -1px color-mix(in srgb, #3c2810 48%, transparent);
}
.fi.flag.lg {
  width: 34px; height: 24px; vertical-align: middle;
  border-radius: 6px 9px 5px 10px / 9px 5px 10px 6px;
  box-shadow:
    inset 0 1px 3px color-mix(in srgb, #fff4dd 32%, transparent),
    inset 0 0 0 1px color-mix(in srgb, #3c2810 16%, transparent),
    1px 2px 0 color-mix(in srgb, #5c4220 40%, transparent),
    0 4px 9px -2px color-mix(in srgb, #3c2810 52%, transparent);
}

/* ---- Vues ---- */
.view { display: none; animation: fade .25s; }
.view.active { display: block; }
.page-head { margin-bottom: 22px; }
.page-head h2 { font-family: var(--serif); font-size: 28px; font-weight: 600; font-variant: small-caps; letter-spacing: .5px; }
.page-head p { color: var(--text-dim); margin-top: 6px; max-width: 620px; }
.page-head .btn { margin-top: 14px; }

/* ---- Bouton sauvegarder un cours ---- */
.course-actions { margin-top: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.saved-badge { font-family: var(--serif); font-style: italic; color: var(--good); font-size: 14px; }

/* ---- Grille de cartes de cours ---- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.course-card {
  background: var(--panel); background-image: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; cursor: pointer; transition: .16s; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; min-height: 150px;
}
.course-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.cc-top { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-faint); letter-spacing: .3px; margin-bottom: 8px; }
.cc-modules { color: var(--accent); }
.course-card h4 { font-family: var(--serif); font-size: 17.5px; font-weight: 600; line-height: 1.3; margin-bottom: 6px; }
.course-card p { font-size: 13px; color: var(--text-dim); flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.cc-date { font-size: 12px; color: var(--text-faint); font-style: italic; font-family: var(--serif); }
.cc-del { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 4px; border-radius: 6px; transition: .15s; }
.cc-del:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }

/* ---- Blocs vides / indices ---- */
.empty-block { color: var(--text-faint); padding: 32px 18px; text-align: center; font-size: 14px; background: var(--panel); border: 1px dashed var(--border-strong); border-radius: var(--radius); grid-column: 1 / -1; }
.empty-block.sm { padding: 16px; font-size: 13px; }
.hint-block { color: var(--text-faint); font-size: 13px; padding: 10px 2px; font-style: italic; }

/* ---- Amis / communautés : disposition 2 colonnes ---- */
.friends-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.friends-col { min-width: 0; }
.search-row { margin-bottom: 16px; }
.list-title { font-family: var(--serif); font-size: 15px; font-weight: 600; margin: 22px 0 10px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.list-title .count { font-size: 11px; background: var(--accent); color: #fff; min-width: 18px; height: 18px; border-radius: 9px; display: inline-grid; place-items: center; padding: 0 5px; font-family: var(--sans); }
.list-block { display: flex; flex-direction: column; gap: 8px; }

.urow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; }
.urow .uinfo { flex: 1; min-width: 0; }
.urow .uname { font-family: var(--serif); font-size: 14.5px; font-weight: 600; }
.urow .ureal { font-size: 12px; color: var(--text-faint); }
.urow .uact { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.tag-pill { font-size: 11.5px; color: var(--text-dim); background: var(--panel-2); border: 1px solid var(--border); padding: 4px 9px; border-radius: 20px; }
.tag-pill.muted { color: var(--text-faint); }
.icon-btn.xs { width: 28px; height: 28px; font-size: 16px; }

/* ---- Chat (DM + communautés) ---- */
.chat-col { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; height: 560px; overflow: hidden; box-shadow: var(--shadow-sm); }
.chat-empty { margin: auto; color: var(--text-faint); font-style: italic; font-family: var(--serif); padding: 30px; text-align: center; }
.chat-empty.sm { margin: auto; font-size: 13px; }
.chat-head { display: flex; align-items: center; gap: 11px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--panel-2); position: sticky; top: 0; z-index: 6; }
.com-prof-leave { width: 100%; justify-content: center; margin-top: 4px; }
.com-prof-leave:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }

/* Résumé de document (Chiron) (#2) */
.chiron-summary { max-width: 820px; margin: 22px auto 0; background: var(--panel); background-image: var(--paper); border: 1px solid var(--border-strong); border-radius: 14px; padding: 20px 24px; text-align: left; }
.chiron-summary[hidden] { display: none; }
.chiron-summary-h { font-family: var(--serif); font-size: 19px; margin-bottom: 10px; color: var(--accent); }

/* messages des tuteurs (Chiron/Dédale) : code et débordements maîtrisés */
.ctut-msg { overflow-wrap: anywhere; }
.ctut-msg p { margin: 6px 0; }
.ctut-msg h2, .ctut-msg h3, .ctut-msg h4 { font-family: var(--serif); margin: 9px 0 4px; font-size: 15px; }
.ctut-msg ul, .ctut-msg ol { margin: 6px 0; padding-left: 20px; }
.ctut-msg li { margin: 3px 0; }
.ctut-msg code { font-family: var(--mono); background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.ctut-msg pre { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 8px 0; font-size: 12.5px; line-height: 1.5; }
.ctut-msg pre code { white-space: pre; background: none; padding: 0; }
.dedale-plan .content pre, .dedale-plan pre { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Dédale — barre d'outils + plan d'action */
.dedale-tools { padding: 10px 16px 0; }
.dedale-plan { margin: 8px 16px 0; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: 12px; background: color-mix(in srgb, var(--accent) 5%, var(--panel)); text-align: left; }
.dedale-plan[hidden] { display: none; }
.dedale-plan-h { font-family: var(--serif); font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.chat-title { font-family: var(--serif); font-weight: 600; font-size: 15.5px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub, .chat-title .chat-sub { font-weight: 400; font-style: italic; font-size: 13px; color: var(--text-faint); }
.chat-close { margin-left: auto; background: none; border: none; color: var(--text-faint); font-size: 22px; line-height: 1; cursor: pointer; }
.chat-close:hover { color: var(--text); }
.com-desc { padding: 10px 16px; font-size: 13px; color: var(--text-dim); border-bottom: 1px solid var(--border); font-style: italic; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--panel-2); align-items: flex-end; }
.chat-input input { flex: 1; }
.chat-input textarea { flex: 1; min-width: 0; resize: none; min-height: 40px; max-height: 120px; line-height: 1.4; padding: 9px 12px; font-family: var(--sans); }
/* bouton d'envoi en icône carrée (toutes tailles) */
.chat-send { width: 42px; min-width: 42px; padding: 0; justify-content: center; flex: 0 0 auto; }
.chat-send svg { margin: 0; }
.chat-locked { padding: 14px 16px; text-align: center; color: var(--text-faint); font-size: 13px; font-style: italic; border-top: 1px solid var(--border); }

.bubble { display: flex; gap: 8px; max-width: 82%; align-items: flex-end; }
.bubble.me { margin-left: auto; flex-direction: row-reverse; }
.bub-in { background: var(--panel-2); border: 1px solid var(--border); padding: 8px 12px; border-radius: 12px; }
.bubble.me .bub-in { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.bub-name { font-size: 11.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; font-family: var(--serif); }
.bub-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.bub-time { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; text-align: right; }

/* ---- Communautés : liste ---- */
.com-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; cursor: pointer; transition: .15s; }
.com-item:hover { border-color: var(--border-strong); }
.com-item.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.com-main { flex: 1; min-width: 0; }
.com-name { font-family: var(--serif); font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.com-meta { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.com-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.com-av img { width: 100%; height: 100%; object-fit: cover; }
.com-lock { display: inline-flex; color: var(--text-faint); }

/* rôles + invitations */
.tag-pill.mod { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); font-weight: 700; }
.tag-pill.invite { color: var(--warn, #b8860b); background: color-mix(in srgb, #c8951e 16%, var(--panel)); border-color: color-mix(in srgb, #c8951e 45%, var(--border)); }

/* pastilles non-lus : nav globale + entités locales */
.nav-badge, .ent-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; font-weight: 800; line-height: 1; color: #fff; background: var(--bad); border-radius: 10px; }
.sb-link { position: relative; }
.nav-badge { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.ent-badge { margin-left: 6px; vertical-align: middle; }
.dm-btn .ent-badge, .bub-open .ent-badge { background: var(--accent); }

/* en-tête de chat : groupe d'actions */
.chat-head-act { display: flex; align-items: center; gap: 7px; margin-left: auto; }

/* choix de visibilité (création de communauté) */
.vis-choice { display: flex; gap: 10px; }
.vis-opt { flex: 1; cursor: pointer; }
.vis-opt input { position: absolute; opacity: 0; }
.vis-card { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; transition: .15s; }
.vis-card b { font-size: 13.5px; }
.vis-card small { font-size: 11.5px; color: var(--text-faint); line-height: 1.4; }
.vis-opt input:checked + .vis-card { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); box-shadow: 0 0 0 1px var(--accent); }

/* bannière invitation à modérer */
.invite-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin: 0 2px 8px; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: 9px; font-size: 13px; }
.ib-btns { display: flex; gap: 6px; margin-left: auto; }

/* panneau de modération */
.mod-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; max-height: 240px; overflow-y: auto; }
.sub-title .count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; background: var(--accent); color: #fff; border-radius: 10px; margin-left: 4px; }
.optional { font-weight: 400; font-size: 12px; }

/* ---- Modales ---- */
.modal-root { position: fixed; inset: 0; z-index: 200; display: none; }
.modal-root.show { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,11,5,.55); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 60px 18px; overflow-y: auto; }
.modal { background: var(--panel); background-image: var(--paper); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 440px; padding: 22px 24px 26px; animation: pop .2s; }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font-family: var(--serif); font-size: 21px; font-weight: 600; font-variant: small-caps; letter-spacing: .4px; }
.modal-x { background: none; border: none; font-size: 26px; line-height: 1; color: var(--text-faint); cursor: pointer; }
.modal-x:hover { color: var(--text); }
.modal-text { color: var(--text-dim); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px; padding: 4px; margin-bottom: 18px; }
.auth-tab { flex: 1; background: none; border: none; cursor: pointer; padding: 9px; border-radius: 6px; font-family: var(--serif); font-size: 14px; color: var(--text-dim); transition: .15s; }
.auth-tab.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }

.fld { margin-bottom: 13px; }
.fld label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; letter-spacing: .3px; }
.fld textarea { min-height: 70px; resize: vertical; }
.form-err { color: var(--bad); font-size: 12.5px; min-height: 16px; margin: 2px 0 8px; }

/* ---- Profil ---- */
.profile-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 26px; align-items: start; }
.profile-card { background: var(--panel); background-image: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.profile-id { display: flex; gap: 16px; align-items: center; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.profile-name { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.profile-real { color: var(--text-dim); font-size: 14px; margin-top: 2px; }
.profile-mail { color: var(--text-faint); font-size: 12.5px; margin-top: 3px; }
.avatar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-btn { cursor: pointer; }
.flag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; max-height: 240px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2); }
/* sélecteur de drapeaux : chaque option est un petit cadre manuscrit */
.flag-opt { line-height: 1; padding: 5px; background: color-mix(in srgb, #7a5a2e 8%, var(--panel)); border: 1px solid color-mix(in srgb, #7a5a2e 35%, var(--border)); border-radius: 6px 9px 5px 8px / 8px 5px 9px 6px; cursor: pointer; transition: .12s; box-shadow: 1px 1px 0 color-mix(in srgb, #5c4220 22%, transparent); }
.flag-opt .fi { display: block; width: 100%; height: 20px; border-radius: 3px 5px 3px 5px; background-size: cover; box-shadow: inset 0 0 0 1px color-mix(in srgb, #3c2810 18%, transparent); }
.flag-opt:hover { border-color: var(--border-strong); transform: translateY(-1px) rotate(-.5deg); }
.flag-opt.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent), 1px 1px 0 color-mix(in srgb, #5c4220 22%, transparent); }
.flag-current-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.flag-current { display: inline-flex; align-items: center; min-height: 24px; }
.flag-filter { width: 100%; margin-bottom: 8px; }
.profile-sep { border: none; border-top: 1px solid var(--border); margin: 22px 0 18px; }
.sub-title { font-family: var(--serif); font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.profile-courses { min-width: 0; }
.profile-card .btn { margin-top: 4px; }

/* ---- Profil : lecture seule + révélation des formulaires ---- */
.profile-read { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.pr-row { display: flex; gap: 14px; padding: 11px 2px; border-bottom: 1px dashed var(--border); }
.pr-row:last-child { border-bottom: none; }
.pr-row dt { flex: 0 0 150px; font-size: 12.5px; color: var(--text-faint); letter-spacing: .3px; padding-top: 1px; }
.pr-row dd { flex: 1; font-size: 14.5px; color: var(--text); font-family: var(--serif); }
.pr-row dd .muted, .muted { color: var(--text-faint); font-style: italic; font-family: var(--sans, inherit); }
.pr-row dd .flag { font-size: 20px; }
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ============================================================
   MESSAGERIE PLEINE PAGE (DM + communautés)
   ============================================================ */
.view.chat-active .page-head { display: none; }
.view.chat-active .friends-layout { grid-template-columns: 1fr; gap: 0; }
.view.chat-active .friends-col { display: none; }
/* full-page (repli) : la conversation occupe toute la hauteur dispo */
.view.chat-active .chat-col { height: calc(100vh - 76px); min-height: 420px; border-radius: 0; box-shadow: none; }
/* full-page (navigateurs modernes) : on libère la colonne centrée → bord à bord */
@supports selector(:has(*)) {
  main:has(.view.chat-active) { max-width: none; margin: 0; padding: 0; }
  .view.chat-active .chat-col { height: 100vh; border: 0; border-radius: 0; }
  .view.chat-active + footer, main:has(.view.chat-active) ~ footer { display: none; }
}
.chat-back { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 34px; height: 34px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--border); color: var(--text-dim); cursor: pointer; flex: 0 0 auto; transition: .15s; }
.chat-back:hover { color: var(--text); border-color: var(--border-strong); }
.chat-back .cb-label { display: none; font-size: 13.5px; font-weight: 600; }
/* sur petit écran : bouton retour clairement libellé pour sortir de la messagerie */
@media (max-width: 760px) {
  .chat-back { width: auto; padding: 0 12px; }
  .chat-back .cb-label { display: inline; }
}

/* ---- Threading communautaire + bulles avec effet lumineux ---- */
.bubble.comm { max-width: 82%; }
/* distinction nette envoyés (droite, primaire) vs reçus (gauche, secondaire) */
.bubble:not(.me) .bub-in { background: var(--panel-2); border-color: var(--border); border-bottom-left-radius: 4px; }
.bubble.me .bub-in { border-bottom-right-radius: 4px; }
.bubble.me .bub-time { color: color-mix(in srgb, var(--accent) 55%, var(--text-faint)); }
@media (max-width: 640px) { .bubble.comm { max-width: 92%; } }
/* message BULLE : mise en avant maximale, immanquable face au standard */
.bubble.comm.bulle .bub-in {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  border: 2px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent),
              0 0 28px -2px color-mix(in srgb, var(--accent) 85%, transparent),
              0 0 60px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.bubble.comm.bulle .bub-text { font-weight: 600; }
.bubble.comm.standard .bub-in { box-shadow: none; }
.bub-badge { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 20px; padding: 2px 9px; margin-bottom: 6px; }
/* sélecteur de type de message */
.msg-kind-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; }
.mkr-label { font-size: 12px; color: var(--text-faint); }
.msg-kind { font-size: 12px; padding: 5px 11px; border-radius: 20px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text-dim); cursor: pointer; font-family: var(--serif); transition: .15s; }
.msg-kind:hover { border-color: var(--border-strong); }
.msg-kind.on { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); border-color: var(--accent); color: var(--text); }
.msg-kind.bulle.on { background: color-mix(in srgb, var(--accent) 22%, var(--panel)); box-shadow: 0 0 16px -2px color-mix(in srgb, var(--accent) 80%, transparent); }

/* ---- bouton « Voir les réponses » à l'intérieur de la bulle ---- */
.bub-open { font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 20px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); cursor: pointer; transition: .15s; }
.bub-open:hover { background: color-mix(in srgb, var(--accent) 28%, transparent); box-shadow: 0 0 14px -3px color-mix(in srgb, var(--accent) 80%, transparent); }
.bub-reply { font-size: 11.5px; padding: 3px 10px; border-radius: 16px; border: 1px solid var(--border); background: transparent; color: var(--text-dim); cursor: pointer; transition: .15s; }
.bub-reply:hover { border-color: var(--border-strong); color: var(--text); }

/* ---- citation dans une bulle ---- */
.bub-quote { border-left: 3px solid color-mix(in srgb, var(--accent) 55%, var(--border)); background: color-mix(in srgb, var(--accent) 6%, transparent); padding: 5px 10px; border-radius: 4px 8px 8px 4px; margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; }
.bq-name { font-size: 11px; font-weight: 800; color: var(--accent); }
.bq-text { font-size: 12.5px; color: var(--text-dim); font-style: italic; }

/* ---- mentions @ ---- */
.mention { color: var(--accent); font-weight: 700; }
.mention-pop { position: absolute; bottom: calc(100% + 6px); left: 12px; right: 12px; max-height: 220px; overflow-y: auto; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 8px 28px -6px rgba(0,0,0,.5); z-index: 40; padding: 4px; }
.mention-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 6px 8px; border-radius: 7px; background: transparent; border: 0; color: var(--text); cursor: pointer; font-family: var(--sans); font-size: 13.5px; }
.mention-item:hover, .mention-item.on { background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); }

/* ---- pièces jointes ---- */
.attach-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 9px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text-dim); cursor: pointer; transition: .15s; }
.attach-btn:hover { color: var(--accent); border-color: var(--accent); }
.att-pending:not(:empty) { padding: 6px 12px 0; }
.att-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); background: var(--panel-2); border: 1px solid var(--border); border-radius: 18px; padding: 4px 6px 4px 11px; }
.att-chip button { border: 0; background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); width: 18px; height: 18px; border-radius: 50%; cursor: pointer; line-height: 1; }
.bub-atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 2px; }
.att-img img { max-width: 220px; max-height: 200px; border-radius: 8px; border: 1px solid var(--border); display: block; }
.att-doc { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; color: var(--text); transition: .15s; }
.att-doc:hover { border-color: var(--accent); }
.att-ic { font-size: 18px; }
.att-meta { display: flex; flex-direction: column; line-height: 1.25; }
.att-name { font-size: 13px; font-weight: 600; }
.att-size { font-size: 11px; color: var(--text-faint); }

/* ---- tiroir latéral (offcanvas) d'une bulle ---- */
.offcanvas { position: fixed; inset: 0; z-index: 90; }
.oc-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); animation: ocFade .18s ease; }
.oc-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(480px, 94vw); display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--border-strong); box-shadow: -12px 0 40px -10px rgba(0,0,0,.55); animation: ocSlide .22s cubic-bezier(.2,.7,.3,1); }
[dir="rtl"] .oc-panel { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--border-strong); animation: ocSlideL .22s cubic-bezier(.2,.7,.3,1); }
.oc-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.oc-body { flex: 1 1 auto; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.oc-root { padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.oc-thread { display: flex; flex-direction: column; gap: 12px; }
@keyframes ocFade { from { opacity: 0; } }
@keyframes ocSlide { from { transform: translateX(100%); } }
@keyframes ocSlideL { from { transform: translateX(-100%); } }
/* zone de danger */
.danger-zone { margin-top: 4px; }
.sub-title.danger { color: var(--bad); }
.danger-text { font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.5; }
.thread-node { display: flex; flex-direction: column; gap: 10px; }
.thread-children { margin-left: 26px; padding-left: 14px; border-left: 2px solid color-mix(in srgb, var(--accent) 30%, var(--border)); display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.thread-children[hidden] { display: none; }
/* accordéon des bulles : réponses masquées par défaut, dépliables au clic */
.thread-accordion { margin-top: 2px; }
.thread-toggle { display: inline-flex; align-items: center; gap: 7px; background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border)); border-radius: 20px; padding: 4px 12px; font-family: var(--serif); font-size: 12px; font-weight: 600; color: var(--accent); cursor: pointer; transition: .15s; }
.thread-toggle:hover { background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); }
.thread-toggle .tt-caret { display: inline-block; transition: transform .18s; font-size: 10px; }
.thread-toggle.open .tt-caret { transform: rotate(90deg); }
.thread-toggle .tt-count { background: var(--accent); color: var(--panel); border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.bub-foot { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.bub-foot .bub-time { margin-top: 0; }
/* marquer une réponse « utile » (entraide) — auteur de la bulle uniquement */
.bub-mark { background: none; border: 1px solid color-mix(in srgb, var(--good) 45%, transparent); color: var(--good); padding: 2px 9px; border-radius: 14px; font-size: 11.5px; font-weight: 700; font-family: var(--serif); cursor: pointer; transition: .15s; }
.bub-mark:hover { background: color-mix(in srgb, var(--good) 16%, transparent); }
.bub-useful { color: var(--good); font-size: 11.5px; font-weight: 800; font-family: var(--serif); }
.bub-reply { background: none; border: none; padding: 0; font-size: 11.5px; font-weight: 600; color: var(--accent); cursor: pointer; font-family: var(--serif); opacity: .85; }
.bub-reply:hover { opacity: 1; text-decoration: underline; }
.reply-banner { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: 12.5px; color: var(--text-dim); background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); border-top: 1px solid var(--border); }
.reply-banner b { color: var(--text); }
.reply-cancel { margin-left: auto; background: none; border: none; font-size: 18px; line-height: 1; color: var(--text-faint); cursor: pointer; }
.reply-cancel:hover { color: var(--text); }

/* ---- Vidéo inline (sans accordéon) ---- */
.sub-body.open { display: block; }
.sub-head.static { cursor: default; }
.video-card { border-color: color-mix(in srgb, var(--mc, var(--accent)) 30%, var(--border)); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1040px) {
  .friends-layout { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .chat-col { height: 460px; }
}

/* --- Bascule en menu hamburger : la sidebar devient un tiroir hors-écran --- */
@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  body[data-page] { padding-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  body.sb-open .sidebar { transform: translateX(0); }
  body.sb-open .sb-backdrop { display: block; }
  body.sb-open .hamburger { display: none; }   /* sandwich caché quand le menu est ouvert */
  .sb-close { display: inline-flex; }           /* croix de fermeture dans le tiroir */
  .sb-top { position: relative; }
  main { padding: 64px 18px 80px; }
  /* en messagerie pleine page, décale l'en-tête pour que le bouton retour ne soit pas masqué par le menu ☰ */
  main:has(.view.chat-active) .chat-head { padding-left: 64px; }
}
@media (max-width: 520px) {
  :root { --sb-w: 86vw; }
  .cards-grid { grid-template-columns: 1fr; }
  .gen-controls { gap: 10px; }
  .gen-controls .sel { min-width: 100%; }
  /* pleine largeur RÉSERVÉE au bouton du générateur (ne touche pas les boutons d'envoi des messageries) */
  .gen-controls .btn-primary { margin-left: 0; width: 100%; justify-content: center; }
  .modal-backdrop { padding: 30px 12px; }
  .page-head h2 { font-size: 24px; }
  .bubble { max-width: 92%; }
  .mod-main .content > p:first-of-type::first-letter { font-size: 2.8em; }
}

/* ============================================================
   SKILL TREE — bascule de mode + carte au trésor + quiz de validation
   ============================================================ */
/* bascule de mode */
.home-modes { display: flex; width: max-content; max-width: 100%; gap: 4px; padding: 4px; margin: 0 auto 22px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 30px; }
.home-mode { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border: 0; background: none; color: var(--text-dim); font-family: var(--serif); font-size: 14px; font-weight: 600; border-radius: 24px; cursor: pointer; transition: .15s; }
.home-mode:hover { color: var(--text); }
.home-mode.active { background: color-mix(in srgb, var(--accent) 18%, var(--panel)); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }

/* progression de l'arbre */
.tree-progress { max-width: 760px; margin: 0 auto 18px; padding: 14px 18px; background: var(--panel); background-image: var(--paper); border: 1px solid var(--border); border-radius: 12px; text-align: left; }
.tp-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.tp-label { font-family: var(--serif); font-weight: 600; font-size: 15px; }
.tp-count { font-size: 13px; color: var(--accent); font-weight: 700; white-space: nowrap; }
.tp-bar { height: 9px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.tp-fill { height: 100%; background: var(--accent); transition: width .4s ease; }
.tree-progress .btn { margin-top: 10px; }

/* carte au trésor */
.treasure-map { position: relative; max-width: 880px; margin: 0 auto; min-height: 120px; background-color: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-sm); overflow: hidden; }
.treasure-map:empty { display: none; }
.tm-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tm-link { fill: none; stroke: var(--border-strong); stroke-width: 3; stroke-dasharray: 3 9; stroke-linecap: round; opacity: .6; }
.tm-link.on { stroke: var(--accent); opacity: .85; }

/* nœud : carte au trésor */
.tm-node { position: absolute; transform: translate(-50%, -50%); width: 124px; min-height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 12px 10px; background: var(--panel-2); border: 2px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; font-family: var(--serif); }
.tm-node .tm-step { position: absolute; top: -10px; left: -10px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: var(--panel); background: var(--border-strong); border-radius: 50%; box-shadow: var(--shadow-sm); }
.tm-node .tm-ic { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; }
.tm-node .tm-title { font-size: 12px; line-height: 1.25; font-weight: 600; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tm-node .tm-x { font-size: 20px; font-weight: 800; color: var(--bad); }

/* états stricts */
.tm-node.locked { background: var(--bg-2); border-color: var(--border); opacity: .6; cursor: not-allowed; color: var(--text-faint); }
.tm-node.locked .tm-title { color: var(--text-faint); }
.tm-node.locked .tm-ic { color: var(--text-faint); }
.tm-node.unlocked { border-color: var(--accent); }
.tm-node.unlocked .tm-step { background: var(--accent); }
.tm-node.unlocked .tm-ic { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.tm-node.unlocked:hover { transform: translate(-50%, -50%) translateY(-3px); box-shadow: 0 8px 22px -6px color-mix(in srgb, var(--accent) 60%, transparent); }
.tm-node.completed { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--panel-2)); }
.tm-node.completed .tm-step { background: var(--good); }
.tm-node.completed .tm-ic { color: #fff; background: var(--good); }
.tm-node.completed:hover { transform: translate(-50%, -50%) translateY(-3px); }
.tm-node.goal { border-style: dashed; }
.tm-node.goal.unlocked { box-shadow: 0 0 0 1px var(--accent), 0 0 22px -4px color-mix(in srgb, var(--accent) 70%, transparent); }
.tm-node.active { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* quiz de validation (gating) — STRICTEMENT réservé au mode Prométhée */
body:not([data-homemode="tree"]) #nodeGate { display: none !important; }
.node-gate { max-width: 880px; margin: 22px auto 0; padding: 20px 22px; background: var(--panel); background-image: var(--paper); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-sm); text-align: left; }
.gate-head h3 { font-family: var(--serif); font-size: 19px; margin: 0 0 4px; }
.gate-head p { font-size: 13px; color: var(--text-dim); margin: 0 0 14px; }
.node-gate .quiz-q { margin-bottom: 14px; }
.node-gate .opt.chosen { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel-2)); }
.gate-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.gate-score { font-size: 14px; }
.gate-score .ok { color: var(--good); font-weight: 700; }
.gate-score .bad { color: var(--bad); font-weight: 700; }
/* ============================================================
   OUTILS DE COURS — Flashcards (flip) + Podcast
   ============================================================ */
.course-tools:empty { display: none; }
.course-tools { margin: 16px 0 4px; }
.ct-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.ct-btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text); font-family: var(--serif); font-size: 14px; font-weight: 600; border-radius: 10px; cursor: pointer; transition: .15s; }
.ct-btn:hover { border-color: var(--accent); color: var(--accent); }
.ct-panel { margin-bottom: 16px; }

/* flashcards — flip-card parchemin */
.flash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.flash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.flash-card { perspective: 1200px; height: 168px; cursor: pointer; outline: none; }
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform .6s cubic-bezier(.4,.2,.2,1); transform-style: preserve-3d; }
.flash-card.flipped .flash-inner { transform: rotateY(180deg); }
.flash-card:focus-visible .flash-inner { box-shadow: 0 0 0 2px var(--accent); border-radius: 14px; }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px; text-align: center; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--panel); background-image: var(--paper); box-shadow: var(--shadow-sm); }
.flash-front { background-color: var(--panel); }
.flash-back { transform: rotateY(180deg); background-color: color-mix(in srgb, var(--accent) 9%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 40%, var(--border-strong)); }
.flash-tag { font-size: 10.5px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 14px; padding: 2px 10px; }
.flash-text { font-family: var(--serif); font-size: 16px; line-height: 1.4; color: var(--text); }
.flash-front .flash-text { font-weight: 700; }
.flash-hint { position: absolute; bottom: 10px; font-size: 10.5px; color: var(--text-faint); font-style: italic; }

/* podcast */
.pod-player { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--panel); }
.pod-controls { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pod-status { font-size: 12.5px; color: var(--text-faint); margin-left: auto; }
.pod-script { max-height: 340px; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.pod-line { display: flex; gap: 10px; padding: 9px 12px; border-radius: 10px; font-size: 14px; line-height: 1.5; background: var(--panel-2); border: 1px solid transparent; }
.pod-line .pod-who { flex: 0 0 auto; font-family: var(--serif); font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 12px; height: fit-content; }
.pod-line.a { background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); }
.pod-line.a .pod-who { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.pod-line.b .pod-who { color: var(--good); background: color-mix(in srgb, var(--good) 16%, transparent); }
.pod-line.on { border-color: var(--accent); box-shadow: 0 0 12px -3px color-mix(in srgb, var(--accent) 70%, transparent); }

/* ============================================================
   CHIRON — upload PDF + tuteur RAG
   ============================================================ */
.chiron-drop { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 20px; border: 2px dashed var(--border-strong); border-radius: 14px; background: var(--panel-2); color: var(--text-dim); cursor: pointer; transition: .15s; }
.chiron-drop:hover, .chiron-drop.over { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); }
.chiron-drop b { color: var(--text); }
.chiron-status { margin-top: 12px; padding: 11px 14px; font-size: 13px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, var(--panel)); border: 1px solid var(--border); text-align: left; }
.chiron-status.loading { color: var(--text-dim); }
.chiron-tutor { max-width: 820px; margin: 22px auto 0; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--panel); overflow: visible; text-align: left; }
/* avatar IA schématique au-dessus de l'en-tête du tuteur */
.chiron-face { display: flex; justify-content: center; margin-top: -30px; margin-bottom: 6px; color: var(--accent); }
.chiron-face svg {
  width: 68px; height: 68px; padding: 13px; box-sizing: border-box;
  background: color-mix(in srgb, var(--accent) 6%, var(--panel)); border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 80%, transparent);
  box-shadow: 0 0 22px -2px color-mix(in srgb, var(--accent) 70%, transparent),
              inset 0 0 16px -4px color-mix(in srgb, var(--accent) 55%, transparent);
}
.chiron-face .cf-eye { animation: cfBlink 4.2s infinite; transform-origin: center; }
@keyframes cfBlink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.chiron-tutor .ctut-head { border-top-left-radius: 14px; border-top-right-radius: 14px; }
.ctut-head { display: flex; align-items: center; gap: 9px; padding: 13px 16px; border-bottom: 1px solid var(--border); font-family: var(--serif); font-weight: 600; font-size: 14.5px; color: var(--accent); }
.ctut-body { max-height: 420px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ctut-msg { max-width: 88%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.55; }
.ctut-msg.user { align-self: flex-end; background: color-mix(in srgb, var(--accent) 16%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); border-bottom-right-radius: 4px; }
.ctut-msg.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ctut-msg.bot p:first-child { margin-top: 0; } .ctut-msg.bot p:last-child { margin-bottom: 0; }
.ctut-msg .err { color: var(--bad); }
.ctut-input { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.ctut-input input { flex: 1; }

/* ============================================================
   SYMBOLES ARCHÉTYPAUX — titres visuels majestueux (Muses/Prométhée/Chiron)
   ============================================================ */
.mode-sym-home, .content-sym { display: flex; justify-content: center; margin: 24px 0 8px; }
.content-sym { margin: 6px 0 16px; }
.mode-sym-home[hidden], .content-sym[hidden] { display: none; }
/* anneau circulaire tracé + halo (sur l'anneau ET sur le symbole) */
.mode-sym {
  display: inline-flex; align-items: center; justify-content: center;
  width: 80px; height: 80px; border-radius: 50%; color: var(--accent);
  border: 2px solid color-mix(in srgb, var(--accent) 80%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
  box-shadow: 0 0 20px -2px color-mix(in srgb, var(--accent) 70%, transparent),
              inset 0 0 16px -4px color-mix(in srgb, var(--accent) 55%, transparent);
}
.mode-sym svg {
  width: 44px; height: 44px;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 75%, transparent));
}
.mode-sym-name { display: none; } /* noms retirés */
@media (max-width: 560px) { .mode-sym { width: 70px; height: 70px; } .mode-sym svg { width: 38px; height: 38px; } }
/* références strictes (Page/Section/Ligne) sous une réponse du tuteur */
.ctut-refs { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 11.5px; color: var(--text-faint); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cr-label { font-weight: 700; }
.cr-chip { background: color-mix(in srgb, var(--accent) 10%, var(--panel-2)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); color: var(--text-dim); border-radius: 12px; padding: 2px 9px; }

/* podcast : réplique cliquable (saut à la phrase) */
.pod-line { cursor: pointer; }
.pod-line:hover { outline: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }

/* ============================================================
   DASHBOARD PROFIL — 3 colonnes (Cours / Arbres / Tuteur)
   ============================================================ */
.profile-dash { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1040px) { .profile-dash { grid-template-columns: repeat(2, 1fr); } }
.dash-col { min-width: 0; }
.dash-col .list-title { display: flex; align-items: center; gap: 7px; }
.dash-list { display: flex; flex-direction: column; gap: 10px; }
.dash-card { position: relative; padding: 12px 13px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: .15s; }
.dash-card:hover { border-color: var(--accent); }
.dash-card h4 { font-family: var(--serif); font-size: 14.5px; margin: 0 28px 4px 0; line-height: 1.3; }
.dash-meta { font-size: 11.5px; color: var(--text-faint); }
.dash-card .cc-del { position: absolute; top: 8px; right: 8px; }
.tp-bar.sm { height: 6px; margin-top: 8px; }

/* cartes compactes & paysage (largeur > hauteur), texte jamais débordant */
.dash-card, .dash-list .course-card {
  min-height: 0; padding: 10px 12px; border-radius: 9px;
  overflow: hidden; transform: none !important;
}
.dash-list .course-card { display: block; box-shadow: var(--shadow-sm); }
.dash-list .course-card:hover, .dash-card:hover { box-shadow: var(--shadow-sm); }
.dash-card h4, .dash-list .course-card h4 {
  font-size: 13.5px; line-height: 1.25; margin: 0 26px 4px 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.dash-list .course-card .cc-top { margin-bottom: 4px; font-size: 10.5px; }
.dash-list .course-card p {
  font-size: 12px; -webkit-line-clamp: 1; flex: none; margin: 0;
  overflow-wrap: anywhere;
}
.dash-list .course-card .cc-foot { margin-top: 8px; }
.dash-list .course-card .cc-date { font-size: 11px; }
.dash-meta, .ts-q, .ts-a { overflow-wrap: anywhere; }
.dash-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   CHARGEMENT : curseur de streaming + squelettes (shimmer)
   ============================================================ */
.stream-caret { display: inline-block; width: 8px; height: 1.05em; vertical-align: -2px; margin-left: 2px; background: var(--accent); border-radius: 1px; animation: caretBlink 1s steps(2, start) infinite; }
@keyframes caretBlink { 50% { opacity: 0; } }
.skeleton-block { display: flex; flex-direction: column; gap: 11px; padding: 4px 0; }
.sk-line { height: 12px; border-radius: 6px; background-color: color-mix(in srgb, var(--text-faint) 20%, transparent); animation: skPulse 1.2s ease-in-out infinite; }
.sk-line.short { width: 55%; } .sk-line.med { width: 78%; }
@keyframes skPulse { 0%, 100% { opacity: .55; } 50% { opacity: .25; } }

/* ============================================================
   NAVIGATION UI — FAB back-to-top, pagination modules, accordéons <details>
   ============================================================ */
.fab-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 120;
  width: 46px; height: 46px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border: 1px solid color-mix(in srgb, var(--accent) 70%, #000);
  box-shadow: 0 6px 20px -4px rgba(0,0,0,.5); cursor: pointer;
  opacity: 0; transform: translateY(14px) scale(.9); pointer-events: none; transition: opacity .2s, transform .2s;
}
.fab-top.show { opacity: 1; transform: none; pointer-events: auto; }
.fab-top:hover { background: var(--accent-ink); }
@media (max-width: 900px) { .fab-top { right: 16px; bottom: 16px; } }

/* pagination interne des modules — collante : elle nous accompagne pendant la navigation */
.mod-pager { position: sticky; top: 10px; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 16px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.mp-label { font-size: 12px; color: var(--text-faint); font-family: var(--serif); margin-right: 4px; }
.mp-num { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text-dim); font-family: var(--serif); font-weight: 600; font-size: 13px; cursor: pointer; transition: .15s; }
.mp-num:hover { border-color: var(--border-strong); color: var(--text); }
.mp-num.on { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); border-color: var(--accent); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }
@media (max-width: 900px) { .mod-pager { top: 60px; } }

/* accordéons <details> pour Flashcards / Podcast */
.ct-acc { border: 1px solid var(--border-strong); border-radius: 11px; background: var(--panel); margin-bottom: 12px; overflow: hidden; }
.ct-acc > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 9px; padding: 12px 15px; font-family: var(--serif); font-weight: 600; font-size: 14.5px; color: var(--text); user-select: none; }
.ct-acc > summary::-webkit-details-marker { display: none; }
.ct-acc > summary:hover { color: var(--accent); }
.ct-acc > summary .ct-chev { margin-left: auto; transition: transform .2s; color: var(--text-faint); }
.ct-acc[open] > summary { border-bottom: 1px solid var(--border); }
.ct-acc[open] > summary .ct-chev { transform: rotate(180deg); }
.ct-acc .ct-panel { padding: 14px 15px; margin: 0; }

/* indice du dépôt Chiron + badge autosave */
.chiron-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.saved-badge.muted { color: var(--text-faint); font-style: italic; }
.saved-badge.flash { color: var(--good); transition: color .2s; }
/* historique d'une session de tuteur (modale) */
.ts-history { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; }
.ts-qa { border-left: 3px solid color-mix(in srgb, var(--accent) 45%, var(--border)); padding-left: 12px; }
.ts-q { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.ts-a { font-size: 13.5px; color: var(--text-dim); line-height: 1.5; white-space: pre-wrap; }
.ts-refs { margin-top: 6px; font-size: 11px; color: var(--text-faint); }
@media (max-width: 720px) { .profile-dash { grid-template-columns: 1fr; } }

@media (max-width: 560px) {
  .flash-grid { grid-template-columns: 1fr 1fr; }
  .tm-node { width: 104px; min-height: 84px; }
  .tm-node .tm-title { font-size: 11px; }
  .home-mode { padding: 8px 12px; font-size: 13px; }
}

/* ============================================================
   CUSTOM SELECT — menus déroulants maison thématisés (vieux manuscrit)
   ============================================================ */
/* <select> natif conservé pour la valeur/les events, mais masqué visuellement */
select.cs-native { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; opacity: 0; pointer-events: none; clip: rect(0 0 0 0); overflow: hidden; }
.cselect { position: relative; width: 100%; }
.cs-trigger {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
  padding: 11px 13px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.3; cursor: pointer; transition: .15s;
}
.cs-trigger:hover { border-color: var(--border-strong); background: color-mix(in srgb, var(--accent) 6%, var(--bg-2)); }
.cselect.open .cs-trigger, .cs-trigger:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); outline: none; }
.cs-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-chev { width: 15px; height: 15px; flex: 0 0 auto; color: var(--text-faint); transition: transform .2s, color .2s; }
.cselect.open .cs-chev { transform: rotate(180deg); color: var(--accent); }
.cs-list {
  position: absolute; z-index: 130; top: calc(100% + 5px); left: 0; right: 0; margin: 0; padding: 5px; list-style: none;
  background: var(--panel); background-image: var(--paper);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 264px; overflow-y: auto; animation: csPop .14s ease;
}
@keyframes csPop { from { opacity: 0; transform: translateY(-4px); } }
.cs-opt {
  position: relative; padding: 8px 26px 8px 11px; border-radius: 7px;
  font-family: var(--serif); font-size: 13.5px; color: var(--text-dim); cursor: pointer; transition: .12s;
}
.cs-opt:hover { background: color-mix(in srgb, var(--accent) 12%, var(--panel-2)); color: var(--text); }
.cs-opt:active { background: color-mix(in srgb, var(--accent) 22%, var(--panel-2)); }
.cs-opt[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); color: var(--text); font-weight: 600; }
.cs-opt[aria-selected="true"]::after { content: '✓'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--accent); font-size: 12px; }
/* contexte : groupe « Génération » de la barre latérale (plus compact) */
.sb-group .cs-trigger { font-size: 13px; padding: 9px 11px; }
/* contexte : sélecteur de thème (transparent, à côté de l'icône palette) */
.sb-theme .cselect { flex: 1; min-width: 0; }
.sb-theme .cs-trigger { background: transparent; border: 0; padding: 2px 18px 2px 0; }
.sb-theme .cs-trigger:hover { background: transparent; }
.sb-theme .cselect.open .cs-trigger, .sb-theme .cs-trigger:focus-visible { box-shadow: none; }

/* ============================================================
   PATINE « VIEUX MANUSCRIT » — couche d'enluminure globale
   ============================================================ */
/* (le grain plein écran a été retiré : la texture parchemin suffit et évite
   un calque fixe en mix-blend-mode coûteux pendant le défilement) */

/* sélection de texte à l'encre */
::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); color: var(--text); }

/* grands titres : léger relief de presse typographique */
.hero h2, .page-head h2, #courseTitle, .profile-name { text-shadow: 0 1px 0 color-mix(in srgb, var(--bg) 60%, transparent), 0 2px 3px rgba(40,28,10,.12); }

/* lettrine enluminée : capitale encadrée façon manuscrit */
.mod-main .content > p:first-of-type::first-letter {
  float: left; font-family: var(--serif); font-weight: 700;
  font-size: 3em; line-height: .72; margin: 6px 12px 0 0; padding: 10px 12px 8px;
  color: var(--mc, var(--accent));
  background: color-mix(in srgb, var(--mc, var(--accent)) 12%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--mc, var(--accent)) 38%, var(--border));
  border-radius: 6px 9px 5px 10px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #fff4dd 18%, transparent), 1px 1px 0 color-mix(in srgb, #5c4220 22%, transparent);
  text-shadow: 0 1px 0 rgba(0,0,0,.12);
}

/* séparateur sobre dans le contenu (sans fleuron) */
.content hr {
  border: 0; height: 1px; width: 72%; margin: 28px auto;
  background-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

/* coins en équerre (sans point) encadrant le contenu des panneaux majeurs */
.course-head, .modal, .profile-card, .node-gate, .auth-gate { position: relative; }
.course-head::before, .modal::before, .profile-card::before, .node-gate::before, .auth-gate::before {
  content: ''; position: absolute; inset: 5px; pointer-events: none; z-index: 0; border-radius: inherit;
  /* couleur des coins = variable de thème (héritée dynamiquement) */
  background-color: var(--corner, var(--accent));
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: left top, right top, right bottom, left bottom;
  mask-position: left top, right top, right bottom, left bottom;
  -webkit-mask-size: 22px 22px; mask-size: 22px 22px;
  -webkit-mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M21 2 H7 Q2 2 2 7 V21' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cg transform='rotate(90 11 11)'%3E%3Cpath d='M21 2 H7 Q2 2 2 7 V21' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cg transform='rotate(180 11 11)'%3E%3Cpath d='M21 2 H7 Q2 2 2 7 V21' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cg transform='rotate(270 11 11)'%3E%3Cpath d='M21 2 H7 Q2 2 2 7 V21' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E");
  mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M21 2 H7 Q2 2 2 7 V21' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cg transform='rotate(90 11 11)'%3E%3Cpath d='M21 2 H7 Q2 2 2 7 V21' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cg transform='rotate(180 11 11)'%3E%3Cpath d='M21 2 H7 Q2 2 2 7 V21' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cg transform='rotate(270 11 11)'%3E%3Cpath d='M21 2 H7 Q2 2 2 7 V21' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/g%3E%3C/svg%3E");
}
/* le contenu des panneaux passe au-dessus des équerres et reste à l'intérieur */
.course-head > *, .modal > *, .profile-card > *, .node-gate > *, .auth-gate > * { position: relative; z-index: 1; }
.course-head, .modal, .profile-card, .node-gate, .auth-gate { padding: 22px 26px; }

/* boutons : encre pressée */
.btn-primary { text-shadow: 0 1px 1px rgba(50,32,8,.35); }

/* liens dans les leçons : soulignement à l'encre */
.content a { color: var(--accent-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 2px; }
.content a:hover { text-decoration-color: var(--accent); }

/* quiz de nœud verrouillé tant que les modules ne sont pas générés */
.gate-locked { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.gate-progress { display: flex; flex-direction: column; gap: 6px; }
.gate-progress-lbl { font-size: 12.5px; color: var(--text-faint); }
.gate-locked .btn { align-self: flex-start; }

/* schémas / dessins (SVG inline) dans les leçons */
.content .md-figure {
  margin: 18px auto; padding: 14px; max-width: 560px; text-align: center;
  background: color-mix(in srgb, var(--accent) 5%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: 12px; overflow-x: auto;
}
.content .md-figure svg { max-width: 100%; height: auto; display: inline-block; }

/* ============================================================
   BORDURE GRECQUE (méandre / Greek key) — séparateur décoratif léger
   Motif SVG en mask → prend la couleur du thème (var(--accent)).
   ============================================================ */
.meander {
  width: 100%; height: 16px; flex: 0 0 auto; margin: 4px 0; opacity: .8;
  background-color: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='16'%3E%3Cg fill='none' stroke='%23000' stroke-width='2'%3E%3Cpath d='M0 15H24'/%3E%3Cpath d='M2 15V3H18V15'/%3E%3Cpath d='M7 15V8H13V12'/%3E%3C/g%3E%3C/svg%3E") repeat-x left center / auto 16px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='16'%3E%3Cg fill='none' stroke='%23000' stroke-width='2'%3E%3Cpath d='M0 15H24'/%3E%3Cpath d='M2 15V3H18V15'/%3E%3Cpath d='M7 15V8H13V12'/%3E%3C/g%3E%3C/svg%3E") repeat-x left center / auto 16px;
}
.meander.sm { height: 13px; -webkit-mask-size: auto 13px; mask-size: auto 13px; }
/* méandre au-dessus du pied de page (toutes les pages) */
footer { position: relative; }
footer::before {
  content: ''; display: block; height: 14px; max-width: 520px; margin: 0 auto 16px; opacity: .55;
  background-color: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='16'%3E%3Cg fill='none' stroke='%23000' stroke-width='2'%3E%3Cpath d='M0 15H24'/%3E%3Cpath d='M2 15V3H18V15'/%3E%3Cpath d='M7 15V8H13V12'/%3E%3C/g%3E%3C/svg%3E") repeat-x center / auto 14px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='16'%3E%3Cg fill='none' stroke='%23000' stroke-width='2'%3E%3Cpath d='M0 15H24'/%3E%3Cpath d='M2 15V3H18V15'/%3E%3Cpath d='M7 15V8H13V12'/%3E%3C/g%3E%3C/svg%3E") repeat-x center / auto 14px;
}

/* ============================================================
   GAMIFICATION — panneau XP (profil) + pop-up de gain (toast)
   ============================================================ */
/* panneau XP sur la page Profil — teinté par la couleur du rang (--rank) */
.xp-panel {
  --rank: var(--accent);
  margin: 4px 0 18px; padding: 14px 16px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--rank) 50%, var(--border));
  background: color-mix(in srgb, var(--rank) 10%, var(--panel));
}
.xp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.xp-rank { display: inline-flex; align-items: center; gap: 8px; }
.xp-rank-sym {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; font-size: 16px; line-height: 1;
  background: color-mix(in srgb, var(--rank) 22%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--rank) 75%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--rank) 45%, transparent);
}
.xp-rank-name {
  font-family: var(--serif); font-variant: small-caps; letter-spacing: .6px;
  font-size: 16px; font-weight: 700; color: var(--rank);
}
.xp-rank-lvl { font-size: 11px; color: var(--text-faint); padding: 2px 7px; border-radius: 999px; background: color-mix(in srgb, var(--text-faint) 16%, transparent); }
.xp-total { font-size: 14px; color: var(--text-dim); white-space: nowrap; }
.xp-total b { font-size: 19px; color: var(--text); font-family: var(--serif); }
.xp-bar {
  margin: 11px 0 7px; height: 9px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--text-faint) 28%, transparent);
}
.xp-bar-fill {
  display: block; height: 100%; border-radius: 999px; min-width: 2px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--rank) 65%, #fff) 0%, var(--rank) 100%);
  transition: width .5s cubic-bezier(.22,1,.36,1);
}
.xp-next { font-size: 12px; color: var(--text-faint); }
.xp-next b { color: var(--text-dim); }

/* Feu sacré d'Hestia — indicateur de série */
.xp-streak {
  display: flex; align-items: center; gap: 9px; margin-top: 11px; padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--rank) 22%, var(--border));
  font-size: 12.5px; color: var(--text-dim);
}
.xp-streak .xp-fire { font-size: 18px; line-height: 1; filter: grayscale(1) opacity(.4); transition: .3s; }
.xp-streak .xp-streak-info b { color: var(--text); }
.xp-streak-mult { color: #ff7a18; font-weight: 800; }
.xp-freeze { margin-left: auto; font-size: 14px; }
/* intensité du feu selon le palier de série */
.xp-streak.s1 .xp-fire { filter: none; font-size: 15px; color: #ffd166; }
.xp-streak.s2 .xp-fire { filter: none; font-size: 17px; }
.xp-streak.s3 .xp-fire { filter: none; font-size: 20px; text-shadow: 0 0 8px rgba(255,140,20,.6); }
.xp-streak.s4 .xp-fire { filter: none; font-size: 23px; text-shadow: 0 0 12px rgba(255,120,10,.8); animation: fireFlick 1.4s ease-in-out infinite; }
.xp-streak.s5 .xp-fire { filter: none; font-size: 27px; text-shadow: 0 0 16px rgba(255,90,0,.95), 0 0 30px rgba(255,160,30,.7); animation: fireFlick 1s ease-in-out infinite; }
@keyframes fireFlick { 0%,100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.12) rotate(2deg); } }
.xp-toast .xp-mult { font-weight: 800; font-size: 13px; color: #b3300a; }

/* bouton « Voir plus » sous une colonne du tableau de bord profil */
.dash-more { width: 100%; margin-top: 4px; justify-content: center; }
/* mini-page de liste : modale élargie */
.modal:has(.modal-list) { max-width: 620px; }
/* liste complète d'une colonne, dans la mini-page (modale) : cartes pleines + défilement */
.modal-list {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 70vh; overflow-y: auto; margin-top: 8px; padding-right: 6px;
}
/* empêche l'écrasement des cartes (sinon le titre déborde de la case) */
.modal-list > * { flex: 0 0 auto; }
/* cartes de cours plus courtes */
.modal-list .course-card { min-height: 0; overflow: hidden; padding: 13px 16px; }
.modal-list .course-card h4 { font-size: 16px; margin-bottom: 3px; }
.modal-list .course-card p { -webkit-line-clamp: 2; font-size: 12.5px; }
.modal-list .course-card p:empty { display: none; }
.modal-list .cc-foot { margin-top: 9px; }
/* bouton de suppression bien visible dans chaque case de la mini-page */
.modal-list .cc-del {
  opacity: 1; color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  background: color-mix(in srgb, var(--bad) 8%, transparent);
}
.modal-list .cc-del:hover { background: color-mix(in srgb, var(--bad) 18%, transparent); }
/* le bouton de suppression des arbres/sessions reste visible en haut à droite */
.modal-list .dash-card { padding-right: 40px; }

/* ===== Mes bulles (profil) — grille 3×3 + voir plus ===== */
.profile-bulles { margin-top: 26px; }
.bulle-title { display: flex; align-items: center; gap: 8px; }
.bulle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.bulle-card {
  display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: .15s; padding: 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 7%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
}
.bulle-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 0 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.bulle-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bulle-com { font-size: 11.5px; color: var(--text-faint); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulle-card-text { font-size: 13.5px; color: var(--text); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 1.45em; }
.bulle-card-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; font-size: 11.5px; color: var(--text-faint); }
.bulle-card-foot .bulle-date { margin-left: auto; }
.bulle-card-foot .bulle-useful { color: var(--good); font-weight: 800; }
.bulle-grid .bulle-more { grid-column: 1 / -1; justify-self: center; }
.modal:has(.modal-bulles) { max-width: 720px; }
.modal-bulles { max-height: 64vh; overflow-y: auto; padding-right: 6px; margin-top: 8px; }
@media (max-width: 760px) { .bulle-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .bulle-grid { grid-template-columns: 1fr; } }

/* ===== Panthéon (classement général par XP) ===== */
.pth-sub { font-size: 13.5px; color: var(--text-dim); margin: -6px 0 16px; }
.pth-self {
  --rank: var(--accent); display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 18px; border-radius: 12px;
  background: color-mix(in srgb, var(--rank) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--rank) 50%, var(--border));
}
.pth-self-pos { font-family: var(--serif); font-weight: 800; font-size: 26px; color: var(--rank); line-height: 1; white-space: nowrap; }
.pth-self-pos span { font-size: 12px; color: var(--text-faint); font-weight: 600; margin-left: 4px; }
.pth-self-id { flex: 1; min-width: 0; }
.pth-self-name { font-family: var(--serif); font-weight: 700; font-size: 15px; }
.pth-list { display: flex; flex-direction: column; gap: 6px; }
.pth-row {
  --rank: var(--accent); display: flex; align-items: center; gap: 12px; padding: 9px 13px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border);
}
.pth-row.me { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--panel)); }
.pth-row.top { border-color: color-mix(in srgb, var(--rank) 45%, var(--border)); }
.pth-pos { width: 42px; flex: 0 0 auto; text-align: center; font-family: var(--serif); font-weight: 700; font-size: 15px; color: var(--text-dim); }
.pth-row.top .pth-pos { font-size: 20px; }
.pth-id { flex: 1; min-width: 0; }
.pth-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pth-you { font-size: 10.5px; font-weight: 700; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 999px; padding: 1px 7px; margin-left: 4px; vertical-align: 1px; }
.pth-rank { font-size: 12px; color: var(--rank); display: flex; align-items: center; gap: 5px; }
.pth-rank-sym { font-size: 13px; }
.pth-xp { flex: 0 0 auto; font-size: 12.5px; color: var(--text-faint); white-space: nowrap; }
.pth-xp b { font-family: var(--serif); font-size: 15px; color: var(--text); }
.pth-gap { text-align: center; color: var(--text-faint); letter-spacing: 4px; margin: 10px 0; }
.pth-note { font-size: 12.5px; color: var(--text-faint); text-align: center; margin-top: 10px; }

/* ===== Œil de visibilité du mot de passe ===== */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 42px; }
.pw-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 4px; color: var(--text-faint); cursor: pointer; display: inline-flex; border-radius: 6px; }
.pw-eye:hover { color: var(--text); }
.del-confirm { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; color: var(--text-dim); margin: 10px 0; cursor: pointer; }
.del-confirm input { margin-top: 2px; }

/* ===== Bouton Google (OAuth) ===== */
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); font-family: var(--sans); font-size: 14.5px; font-weight: 600; cursor: pointer; transition: .15s; }
.btn-google:hover { background: var(--panel-2); border-color: var(--text-faint); }
.btn-google svg { width: 18px; height: 18px; flex: 0 0 auto; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--text-faint); font-size: 12px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ===== Logo dans l'en-tête de la barre latérale ===== */
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 30px; height: 30px; flex: 0 0 auto; color: var(--accent); }
.brand-logo svg { width: 100%; height: 100%; display: block; }

/* ============================================================
   MONTÉE DE NIVEAU — overlay plein écran + fanfare
   ============================================================ */
#levelUpRoot { position: fixed; inset: 0; z-index: 10000; pointer-events: none; }
.levelup-overlay {
  --rank: #d9a520;
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--rank) 30%, rgba(8,10,18,.78)) 0%, rgba(8,10,18,.9) 70%);
  opacity: 0; transition: opacity .45s ease; pointer-events: auto; cursor: pointer;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.levelup-overlay.show { opacity: 1; }
.levelup-overlay.out { opacity: 0; }
.levelup-burst {
  position: absolute; width: 120vmax; height: 120vmax; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 8deg, color-mix(in srgb, var(--rank) 35%, transparent) 8deg 12deg, transparent 12deg 20deg);
  opacity: 0; animation: none;
}
.levelup-overlay.show .levelup-burst { opacity: .5; animation: burstSpin 9s linear infinite; }
@keyframes burstSpin { to { transform: rotate(360deg); } }
.levelup-card {
  position: relative; text-align: center; color: #fff; padding: 24px 30px;
  transform: scale(.6); opacity: 0; transition: transform .55s cubic-bezier(.18,1.5,.4,1), opacity .4s ease;
}
.levelup-overlay.show .levelup-card { transform: scale(1); opacity: 1; }
.levelup-kicker {
  font-family: var(--serif); font-variant: small-caps; letter-spacing: 4px; font-size: 16px;
  color: var(--rank); margin-bottom: 10px; text-shadow: 0 0 16px color-mix(in srgb, var(--rank) 70%, transparent);
}
.levelup-sym {
  font-size: 84px; line-height: 1; margin: 6px 0 4px;
  filter: drop-shadow(0 0 24px color-mix(in srgb, var(--rank) 85%, transparent));
  animation: lvlPulse 1.6s ease-in-out infinite;
}
@keyframes lvlPulse { 0%,100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.1) rotate(2deg); } }
.levelup-rank {
  font-family: var(--serif); font-weight: 800; font-size: 52px; line-height: 1.05; color: var(--rank);
  text-shadow: 0 2px 30px color-mix(in srgb, var(--rank) 60%, transparent), 0 1px 2px rgba(0,0,0,.5);
}
.levelup-lvl { font-size: 22px; font-weight: 700; margin-top: 8px; letter-spacing: 1px; }
.levelup-xp { font-size: 17px; color: rgba(255,255,255,.82); margin-top: 4px; font-family: var(--serif); }
.levelup-hint { margin-top: 22px; font-size: 12px; letter-spacing: 1px; color: rgba(255,255,255,.5); }
@media (max-width: 600px) { .levelup-rank { font-size: 38px; } .levelup-sym { font-size: 64px; } }

/* ============================================================
   MODES D'APPRENTISSAGE ACTIF — boutons + chat (Feynman / Simulation)
   ============================================================ */
.ct-feynman { margin-top: 12px; }
.active-btn { display: flex; align-items: center; gap: 10px; justify-content: flex-start; text-align: left; }
.active-btn .active-bic { display: inline-flex; flex: 0 0 auto; }
.active-btn .active-btxt { flex: 1; }
.active-btn[disabled] { opacity: .5; cursor: not-allowed; }
.active-btn .active-done { color: var(--good); font-weight: 800; margin-left: auto; }
.active-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; text-align: center; }
/* photos d'illustration dans les mises en situation de Simulation */
.sim-photo { margin: 10px 0 4px; }
.sim-photo img { width: 100%; max-width: 420px; border-radius: 10px; display: block; border: 1px solid var(--border); }
.sim-photo figcaption { font-size: 11px; color: var(--text-faint); font-style: italic; margin-top: 4px; }
.tp-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

.active-overlay {
  position: fixed; inset: 0; z-index: 9998; display: flex; align-items: center; justify-content: center;
  background: rgba(15,11,5,.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); padding: 18px;
}
.active-panel {
  width: 100%; max-width: 640px; height: min(80vh, 760px); display: flex; flex-direction: column;
  background: var(--panel); background-image: var(--paper); border: 1px solid var(--border-strong);
  border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: pop .2s;
}
.active-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.active-title { font-family: var(--serif); font-size: 19px; font-weight: 700; font-variant: small-caps; letter-spacing: .4px; display: inline-flex; align-items: center; gap: 8px; }
.active-ic { font-size: 20px; }
.active-x { background: none; border: none; font-size: 26px; line-height: 1; color: var(--text-faint); cursor: pointer; padding: 0 4px; }
.active-x:hover { color: var(--text); }
.active-sub { padding: 0 18px 12px; font-size: 12.5px; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.active-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.am-row { display: flex; }
.am-row.me { justify-content: flex-end; }
.am-row.bot { justify-content: flex-start; }
.am-bubble {
  max-width: 82%; padding: 10px 13px; border-radius: 13px; font-size: 14px; line-height: 1.5;
  background: var(--panel-2); border: 1px solid var(--border);
}
.am-row.me .am-bubble { background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.am-bubble p { margin: 0 0 6px; } .am-bubble p:last-child { margin: 0; }
.am-bubble h2, .am-bubble h3, .am-bubble h4 { font-size: 14.5px; margin: 4px 0; }
.am-typing { display: inline-flex; gap: 4px; align-items: center; }
.am-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); animation: acDot 1s infinite ease-in-out; }
.am-typing span:nth-child(2) { animation-delay: .15s; } .am-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes acDot { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.active-foot { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.active-foot textarea {
  flex: 1; resize: vertical; max-height: 220px; min-height: 84px; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.45;
}
.active-foot textarea:focus { outline: none; border-color: var(--accent); }
.active-foot .btn { white-space: nowrap; }

/* carte de résultat / évaluation */
.am-row.result { justify-content: center; }
.ac-result {
  width: 100%; text-align: center; padding: 18px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}
.ac-score { display: inline-flex; flex-direction: column; align-items: center; margin-bottom: 10px; }
.ac-score span { font-family: var(--serif); font-size: 44px; font-weight: 800; line-height: 1; color: var(--accent-ink); }
.ac-score small { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); margin-top: 2px; }
.ac-fb { font-size: 13.5px; color: var(--text-dim); line-height: 1.55; text-align: left; margin: 0 auto 12px; max-width: 460px; }
.ac-xp { font-family: var(--serif); font-weight: 800; font-size: 17px; color: var(--good); margin-bottom: 12px; }
.ac-xp.muted { color: var(--text-faint); font-weight: 600; font-size: 13px; }
body.active-open { overflow: hidden; }

/* ============================================================
   TUTORIELS SOBRES (coachmarks one-shot)
   ============================================================ */
#tutoRoot:empty { display: none; }
.tuto-overlay { position: fixed; inset: 0; z-index: 10001; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(15,11,5,.5); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); animation: tutoFade .2s ease; }
@keyframes tutoFade { from { opacity: 0; } to { opacity: 1; } }
.tuto-card { width: 100%; max-width: 420px; background: var(--panel); background-image: var(--paper); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); padding: 22px 24px; animation: pop .2s; }
.tuto-kicker { font-family: var(--serif); font-variant: small-caps; letter-spacing: 1px; font-size: 12px; color: var(--text-faint); margin-bottom: 8px; }
.tuto-h { font-family: var(--serif); font-size: 19px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.tuto-t { font-size: 14px; line-height: 1.6; color: var(--text-dim); margin: 0; }
.tuto-dots { display: flex; gap: 6px; margin: 16px 0; }
.tuto-dots span { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, var(--text-faint) 40%, transparent); }
.tuto-dots span.on { background: var(--accent); }
.tuto-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tuto-nav { display: flex; gap: 8px; }
@media (max-width: 600px) { .active-panel { height: 88vh; max-width: 100%; } .am-bubble { max-width: 90%; } }

/* pop-up (toast) déclenché à chaque gain d'XP */
#xpToastHost {
  position: fixed; right: 22px; bottom: 22px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none;
}
.xp-toast {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 16px 11px 13px; border-radius: 12px;
  color: #2a1c05; font-family: var(--sans); white-space: nowrap;
  background: linear-gradient(135deg, #ffd770 0%, #ff9d2e 100%);
  border: 1px solid rgba(255,255,255,.5);
  box-shadow: 0 8px 26px rgba(180,110,10,.45), 0 1px 0 rgba(255,255,255,.6) inset;
  opacity: 0; transform: translateY(14px) scale(.94);
  transition: opacity .32s ease, transform .32s cubic-bezier(.22,1.4,.4,1);
}
.xp-toast.show { opacity: 1; transform: translateY(0) scale(1); }
.xp-toast.out { opacity: 0; transform: translateY(-8px) scale(.97); }
.xp-toast .xp-spark { font-size: 17px; line-height: 1; color: #fff; text-shadow: 0 1px 3px rgba(180,110,10,.7); animation: xpSpark .6s ease; }
.xp-toast .xp-amt { font-weight: 800; font-size: 15px; letter-spacing: .3px; }
.xp-toast .xp-lbl { font-size: 12.5px; font-weight: 600; opacity: .8; border-left: 1px solid rgba(60,35,5,.3); padding-left: 9px; }
@keyframes xpSpark { 0% { transform: scale(.3) rotate(-25deg); opacity: 0; } 60% { transform: scale(1.35) rotate(8deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@media (max-width: 600px) { #xpToastHost { right: 12px; left: 12px; bottom: 14px; align-items: stretch; } .xp-toast { white-space: normal; } }

/* ============================================================
   AFFINAGE MOBILE (≤ 480px) — confort de lecture & anti-débordement
   Bloc placé en fin de feuille : il prime sur les règles précédentes.
   ============================================================ */
@media (max-width: 480px) {
  /* marges générales un peu plus serrées → plus de largeur utile */
  main { padding: 64px 14px 72px; }

  /* panneaux majeurs : moins de rembourrage latéral (les équerres suivent l'inset) */
  .course-head, .modal, .profile-card, .node-gate, .auth-gate { padding: 20px 16px; }
  .modal { border-radius: 12px; }
  .modal-backdrop { padding: 22px 10px; }
  .auth-gate { margin: 36px auto; }

  /* modules de cours : plus de largeur pour le texte */
  .mod-head { padding: 16px 15px; gap: 12px; }
  .mod-body { padding: 8px 15px 22px; }
  .mod-num { width: 32px; height: 32px; font-size: 14px; }
  .mod-title h3 { font-size: 17px; }
  .content { font-size: 16px; line-height: 1.7; }
  /* texte aligné à gauche : évite les « rivières » béantes du justifié sur écran étroit */
  .content p { text-align: left; hyphens: manual; }
  /* lettrine plus discrète */
  .mod-main .content > p:first-of-type::first-letter { font-size: 2.4em; margin: 4px 8px 0 0; padding: 6px 8px 4px; }
  /* tableaux de leçon : défilement horizontal au lieu d'un débordement de page */
  .content table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* en-têtes / titres */
  .course-head h2 { font-size: 24px; }
  .hero p { font-size: 15px; }

  /* bascule de mode (Muses / Prométhée / Chiron) : défilement plutôt que clipping */
  .home-modes { overflow-x: auto; -webkit-overflow-scrolling: touch; justify-content: flex-start; }

  /* profil : libellé/valeur empilés au lieu d'un libellé figé à 150px */
  .pr-row { flex-direction: column; gap: 2px; padding: 9px 2px; }
  .pr-row dt { flex-basis: auto; }
  .profile-id { gap: 12px; }
  .profile-name { font-size: 20px; }
  .xp-head { flex-wrap: wrap; gap: 6px; }

  /* panthéon : rangée compacte, sans débordement (le rang reste visible sur la fiche profil) */
  .pth-self { gap: 10px; padding: 12px; }
  .pth-self-pos { font-size: 22px; }
  .pth-row { gap: 9px; padding: 8px 10px; }
  .pth-pos { width: 26px; font-size: 14px; }
  .pth-row.top .pth-pos { font-size: 17px; }
  .pth-rank { display: none; }
  .pth-xp b { font-size: 14px; }

  /* arbre Prométhée : nœuds plus petits → moins de chevauchements */
  .tm-node { width: 92px; min-height: 76px; padding: 9px 7px; }
  .tm-node .tm-title { font-size: 10.5px; -webkit-line-clamp: 2; }
  .tm-node .tm-ic { width: 26px; height: 26px; }

  /* flashcards : une colonne pour la lisibilité */
  .flash-grid { grid-template-columns: 1fr; }

  /* outils de cours : boutons pleine largeur, faciles à toucher */
  .ct-bar { gap: 8px; }
  .ct-btn { flex: 1 1 100%; justify-content: center; }

  /* messagerie : bulles un peu plus larges */
  .bubble, .bubble.comm { max-width: 94%; }
  .am-bubble { max-width: 92%; }

  /* modales-listes (cours / bulles) : pleine largeur */
  .modal:has(.modal-list), .modal:has(.modal-bulles) { max-width: 100%; }

  /* actions de quiz / gates : empilage propre */
  .quiz-actions .btn, .gate-actions .btn { flex: 1 1 auto; }

  /* --- barre de pagination des modules : TOUJOURS sur une seule ligne, défilable --- */
  .mod-pager { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 5px; padding: 7px 8px; scrollbar-width: none; }
  .mod-pager::-webkit-scrollbar { display: none; }
  .mod-pager .mp-label, .mod-pager .mp-num { flex: 0 0 auto; }
  .mp-num { min-width: 30px; height: 30px; }
  /* le module courant ressort nettement dans la barre */
  .mp-num.on { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }

  /* champs de saisie >=16px -> empeche l'auto-zoom iOS au focus (et le decoupage du contenu) */
  input, textarea, select, .cs-trigger { font-size: 16px; }

  /* messagerie : champ extensible + bouton d'envoi compact en icone */
  .chat-input { align-items: flex-end; gap: 8px; padding: 10px; }
  .chat-input textarea { flex: 1 1 auto; min-width: 0; }
  .chat-send { width: 44px; min-width: 44px; height: 44px; margin-left: 0; flex: 0 0 auto; }

  /* Chiron : champ + bouton empiles pour une saisie confortable */
  .ctut-input { flex-direction: column; gap: 8px; }
  .ctut-input input, .ctut-input .btn { width: 100%; }
  /* modes actifs : zone de texte large, bouton a droite */
  .active-foot { gap: 8px; }
  .active-foot textarea { min-height: 64px; }
  .active-foot .btn { width: auto; margin-left: 0; flex: 0 0 auto; }

  /* en-tete de messagerie : compact, lisible, sans chevauchement */
  .chat-head { gap: 8px; padding: 10px 12px; }
  main:has(.view.chat-active) .chat-head { padding-left: 56px; }
  .chat-name { font-size: 14.5px; line-height: 1.2; }
  .chat-sub { font-size: 11px; line-height: 1.2; }
  .chat-back { width: 34px; padding: 0; height: 34px; }
  .chat-back .cb-label { display: none; }   /* fleche seule : empreinte minimale */
  .chat-head .avatar { width: 28px !important; height: 28px !important; }
}

/* ============================================================
   RENFORCEMENTS MESSAGERIE & GARDE-FOUS VIEWPORT (toutes tailles)
   ============================================================ */
html, body { overflow-x: hidden; }                       /* aucun debordement horizontal de page */
body:has(.view.chat-active) .fab-top { display: none !important; }  /* la fleche "haut" n'ecrase plus la saisie du chat */
@supports (height: 100dvh) {
  .view.chat-active .chat-col { height: 100dvh; }         /* hauteur = zone visible (clavier inclus) */
}

/* mode Bulle actif : surbrillance accentuée de la zone de saisie (#9) */
.chat-input.bulle-active { box-shadow: inset 0 0 0 2px var(--accent), 0 -2px 20px -6px color-mix(in srgb, var(--accent) 80%, transparent); }
.chat-input.bulle-active textarea { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); }

/* invitation communautaire dans les DM (#7) */
.inv-card { min-width: 220px; border-color: color-mix(in srgb, var(--accent) 40%, var(--border)) !important; }
.inv-body { font-size: 13.5px; line-height: 1.4; }
.inv-ic { color: var(--accent); font-weight: 800; }
.inv-priv { font-size: 11px; color: var(--text-faint); font-style: italic; }
.inv-actions { display: flex; gap: 8px; margin-top: 8px; }
.inv-status { font-size: 12px; font-weight: 600; margin-top: 6px; color: var(--text-faint); }
.inv-status.ok { color: var(--good); }

/* profil de communauté (modale) (#6) */
.com-prof { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.com-prof-name { font-family: var(--serif); font-size: 21px; font-weight: 700; overflow-wrap: anywhere; }
.com-prof-meta { font-size: 12.5px; color: var(--text-faint); }
.com-prof-desc { font-size: 14px; color: var(--text-dim); line-height: 1.55; margin: 4px 0; }
.com-prof-desc.muted { color: var(--text-faint); font-style: italic; }
.com-prof-mods { font-size: 12.5px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.cpm-label { color: var(--text-faint); }
.com-prof-edit { margin-top: 8px; width: 100%; justify-content: center; }

/* scores moyens sur les cartes de cours (#10) */
.cc-scores { display: flex; gap: 6px; margin: 6px 0 2px; flex-wrap: wrap; }
.cc-score { font-size: 11px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: 20px; padding: 2px 9px; white-space: nowrap; }
.cc-score.best { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); border-color: color-mix(in srgb, var(--good) 35%, var(--border)); }

/* ============================================================
   PROFILS PUBLICS, CONFIDENTIALITÉ (toggles) & ACCORDÉON BULLES
   ============================================================ */
/* noms / avatars cliquables */
.name-link { cursor: pointer; }
.name-link:hover { text-decoration: underline; text-underline-offset: 2px; color: var(--accent); }
.av-link { cursor: pointer; }

/* interrupteurs de confidentialité (paramètres profil) */
/* .fld label.pf-toggle : surclasse la règle globale « .fld label { display:block } » */
.fld label.pf-toggle { display: flex; align-items: center; gap: 14px; padding: 11px 12px; margin-bottom: 6px; font-size: 13.5px; color: var(--text); cursor: pointer; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; transition: border-color .15s; }
.fld label.pf-toggle:hover { border-color: var(--border-strong); }
.pf-toggle > span:first-child { flex: 1; min-width: 0; line-height: 1.35; }
.pf-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
/* bascule : piste pleine et contrastée — gris au repos, accent du thème quand activé */
.pf-switch { position: relative; flex: 0 0 auto; width: 52px; height: 28px; border-radius: 999px; background: var(--text-faint); border: 1px solid color-mix(in srgb, var(--text) 28%, transparent); box-shadow: inset 0 1px 2px rgba(0,0,0,.3); transition: background .25s, border-color .25s; }
.pf-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.45); transition: transform .25s cubic-bezier(.22,1,.36,1); }
.pf-toggle input:checked + .pf-switch { background: var(--accent); border-color: color-mix(in srgb, var(--accent) 70%, #000); }
.pf-toggle input:checked + .pf-switch::after { transform: translateX(22px); }
.pf-toggle input:focus-visible + .pf-switch { box-shadow: inset 0 1px 2px rgba(0,0,0,.3), 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

/* rang complet sur le profil public (nom + couleur + emblème) */
.pub-rank { display: inline-flex; align-items: center; gap: 8px; margin-top: 7px; }
.pub-rank .xp-rank-name { font-family: var(--serif); font-variant: small-caps; letter-spacing: .6px; font-size: 16px; font-weight: 700; color: var(--rank); }
.pub-rank .xp-rank-lvl { font-size: 11px; color: var(--text-faint); padding: 2px 7px; border-radius: 999px; background: color-mix(in srgb, var(--text-faint) 16%, transparent); }
.pub-id-info .xp-streak { margin-top: 8px; }

/* modale de profil public */
.modal:has(#pubProfBody) { max-width: 600px; }
.pub-id { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.pub-id-info { min-width: 0; }
.pub-name { font-family: var(--serif); font-size: 21px; font-weight: 700; overflow-wrap: anywhere; }
.pub-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: 12.5px; }
.pub-stats span { background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.pub-lvl { color: var(--accent); font-weight: 600; }
.pub-bio { font-size: 14px; color: var(--text-dim); line-height: 1.55; margin: 6px 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pub-action { margin-bottom: 16px; }
.pub-action .btn { width: 100%; justify-content: center; }
.pub-sec { font-family: var(--serif); font-size: 15px; margin: 16px 0 10px; display: flex; align-items: center; gap: 8px; }
.pub-courses { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pub-card { cursor: default; }
.pub-card:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--border); }
.pub-bulles { display: flex; flex-direction: column; gap: 8px; }
.pub-bulle { border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: 10px; background: color-mix(in srgb, var(--accent) 6%, var(--panel)); overflow: hidden; }
.pub-bulle-head { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; padding: 11px 12px; cursor: pointer; color: var(--text); font-family: var(--sans); }
.pub-bulle-head .tt-caret { transition: transform .18s; color: var(--accent); flex: 0 0 auto; font-size: 12px; }
.pub-bulle.open .pub-bulle-head .tt-caret { transform: rotate(90deg); }
.pub-bulle-main { flex: 1; min-width: 0; }
.pub-bulle-com { display: block; font-size: 11px; color: var(--text-faint); font-style: italic; }
.pub-bulle-text { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-bulle-meta { flex: 0 0 auto; font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.pub-bulle-body { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 8px; border-top: 1px dashed var(--border); }
.pub-reply { font-size: 13px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.pub-reply-date { font-size: 10.5px; color: var(--text-faint); }

/* écran de blocage d'une communauté pour un non-membre (#5) */
.com-gate { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin: auto; padding: 40px 24px; max-width: 420px; }
.com-gate .avatar { margin-bottom: 4px; }
.com-gate-name { font-family: var(--serif); font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.com-gate-meta { font-size: 12.5px; color: var(--text-faint); }
.com-gate-desc { font-size: 14px; color: var(--text-dim); line-height: 1.55; }
.com-gate-lock { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-faint); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-top: 6px; }

/* responsive profil public (téléphone) */
@media (max-width: 480px) {
  .modal:has(#pubProfBody) { max-width: 100%; }
  .pub-courses { grid-template-columns: 1fr; }
  .pub-id { gap: 12px; }
  .pub-name { font-size: 19px; }
  .pub-bulle-meta { display: none; }   /* évite le tassement de la ligne sur petit écran */
  .pf-toggle { font-size: 13px; }
}
