/* ================================================
   SITE SPÉ MATHS TERMINALE — Feuille de style v2
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800;900&family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600&display=swap');

/* ────────────────────────────────────────────────
   Variables
──────────────────────────────────────────────── */
:root {
  --primary:        #1565C0;
  --primary-dark:   #0D47A1;
  --primary-light:  #E3F2FD;
  --accent:         #FF6F00;
  --accent-light:   #FFF3E0;

  /* Polices */
  --font-heading: 'Poppins', 'Inter', sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', 'Fira Code', monospace;

  /* Boîtes de contenu pédagogique */
  --def-bg:  #E8F5E9; --def-bd:  #2E7D32; --def-tx:  #1B5E20;   /* Vert - Définition */
  --prop-bg: #E3F2FD; --prop-bd: #1565C0; --prop-tx: #0D47A1;   /* Bleu - Propriété */
  --meth-bg: #FFF8E1; --meth-bd: #F9A825; --meth-tx: #5D4037;   /* Jaune - Méthode */
  --ex-bg:   #FFF3E0; --ex-bd:   #E65100; --ex-tx:   #BF360C;   /* Orange - Exemple */
  --exo-bg:  #F3E5F5; --exo-bd:  #6A1B9A; --exo-tx:  #4A148C;   /* Violet - Exercice */
  --cor-bg:  #E0F2F1; --cor-bd:  #00695C; --cor-tx:  #004D40;   /* Teal - Correction */
  --warn-bg: #FFEBEE; --warn-bd: #B71C1C; --warn-tx: #B71C1C;   /* Rouge - Attention */
  --tip-bg:  #FFFDE7; --tip-bd:  #F57F17; --tip-tx:  #5D4037;   /* Doré - Conseil */

  /* Progression */
  --progress-100: #2E7D32; --progress-75: #7CB342;
  --progress-50:  #FBC02D; --progress-25: #FB8C00; --progress-0: #D32F2F;

  /* Base */
  --text:      #1a1a2e;
  --text-sec:  #64748b;
  --bg:        #F0F4FB;
  --card-bg:   #FFFFFF;
  --border:    #DDE4F0;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 2px 16px rgba(21,101,192,.10);
  --shadow-lg: 0 8px 32px rgba(21,101,192,.18);

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
}

/* ────── Dark mode ────── */
[data-theme="dark"] {
  --primary:       #5B8DF6;
  --primary-dark:  #3B6FE0;
  --primary-light: #1a2744;
  --accent:        #FFB74D;
  --def-bg:  #1a2a1a; --def-bd:  #4CAF50;
  --prop-bg: #162035; --prop-bd: #5B8DF6;
  --meth-bg: #2a2415; --meth-bd: #FFC107;
  --ex-bg:   #2a1b10; --ex-bd:   #FF7043;
  --exo-bg:  #20152a; --exo-bd:  #AB47BC;
  --cor-bg:  #102020; --cor-bd:  #26A69A;
  --warn-bg: #2a1010; --warn-bd: #EF5350;
  --tip-bg:  #2a2510; --tip-bd:  #FFD54F;
  --text:      #E2E8F0;
  --text-sec:  #94A3B8;
  --bg:        #0F172A;
  --card-bg:   #1E293B;
  --border:    #334155;
  --shadow:    0 2px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}

/* ────────────────────────────────────────────────
   Reset & Base
──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  transition: background .3s var(--ease), color .3s var(--ease);
}

/* Typographie - Titres modernes */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 { font-size: 2.5rem; font-weight: 800; margin: 1.5rem 0 1rem; }
h2 { font-size: 2rem; font-weight: 700; margin: 1.25rem 0 0.75rem; }
h3 { font-size: 1.5rem; font-weight: 700; margin: 1rem 0 0.5rem; }
h4 { font-size: 1.2rem; font-weight: 600; margin: 0.75rem 0 0.4rem; }
h5 { font-size: 1.1rem; font-weight: 600; margin: 0.65rem 0 0.3rem; }
h6 { font-size: 1rem; font-weight: 600; margin: 0.5rem 0 0.25rem; }

/* Code et formules */
code, pre, .formula {
  font-family: var(--font-code);
  font-size: 0.9em;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Sélection de texte ── */
::selection { background: var(--primary); color: #fff; }

/* ────────────────────────────────────────────────
   Barre de progression de lecture
──────────────────────────────────────────────── */
#reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #42A5F5, #7C4DFF, #FF6D00);
  z-index: 9999;
  transition: width .1s linear;
}

/* ────────────────────────────────────────────────
   Typography
──────────────────────────────────────────────── */
h1, h2, h3, h4, h5 { line-height: 1.3; font-weight: 700; }
h1 { font-size: 2.2rem; }
h2 {
  font-size: 1.6rem; margin: 2.5rem 0 1rem;
  color: var(--primary-dark);
  padding-bottom: .5rem;
  border-bottom: 3px solid var(--primary-light);
  display: flex; align-items: center; gap: .5rem;
}
[data-theme="dark"] h2 { color: var(--primary); }
h3 { font-size: 1.2rem; margin: 1.8rem 0 .6rem; color: var(--primary); }
h4 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; color: var(--text); }
p  { margin-bottom: .9rem; }
ul, ol { padding-left: 1.5rem; margin-bottom: .9rem; }
li { margin-bottom: .3rem; }

code:not(.py) {
  font-family: 'Fira Code', monospace;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: .1em .4em; border-radius: 4px; font-size: .88em;
}
[data-theme="dark"] code:not(.py) {
  background: #1E3A5F;
  color: #90CAF9;
}

/* ────────────────────────────────────────────────
   Navbar
──────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(13, 71, 161, .96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  height: 58px;
  box-shadow: 0 2px 20px rgba(0,0,0,.3);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.navbar .logo {
  font-size: 1.15rem; font-weight: 900;
  letter-spacing: -.5px; white-space: nowrap;
  display: flex; align-items: center; gap: .4rem;
}
.navbar .logo span { color: #FFD54F; }
.navbar .logo a { color: inherit; display: flex; align-items: center; gap: .4rem; }

.nav-links {
  display: flex; gap: .25rem;
  flex-wrap: wrap; flex: 1;
  justify-content: flex-end;
}
.nav-links a {
  color: rgba(255,255,255,.75);
  font-size: .78rem; font-weight: 500;
  padding: .3rem .55rem;
  border-radius: 6px;
  transition: background .2s var(--ease), color .2s var(--ease);
  white-space: nowrap;
}
.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  text-decoration: none;
}
.nav-links a.active {
  background: rgba(255,255,255,.22);
  font-weight: 600;
}

/* ── Boutons navbar droite ── */
.navbar-actions {
  display: flex; align-items: center; gap: .5rem; margin-left: .5rem;
}

/* Bouton dark mode */
#dark-toggle {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s var(--ease);
  flex-shrink: 0;
}
#dark-toggle:hover { background: rgba(255,255,255,.28); }

/* ── Hamburger (mobile) ── */
#nav-toggle {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  background: none; border: none;
  cursor: pointer; padding: .4rem; margin-left: auto;
}
#nav-toggle span {
  display: block; width: 22px; height: 2px;
  background: #fff; border-radius: 2px;
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}
#nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#nav-toggle.open span:nth-child(2) { opacity: 0; }
#nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ────────────────────────────────────────────────
   Page Layout
──────────────────────────────────────────────── */
.page-wrapper {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* ── Fade-in au scroll ── */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ────────────────────────────────────────────────
   Chapter Header
──────────────────────────────────────────────── */
.chapter-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #1976D2 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 2.8rem 2.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

/* Cercles décoratifs */
.chapter-header::before,
.chapter-header::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  pointer-events: none;
}
.chapter-header::before {
  width: 300px; height: 300px;
  right: -80px; top: -100px;
}
.chapter-header::after {
  width: 180px; height: 180px;
  right: 100px; bottom: -80px;
}

.chapter-header .num {
  font-size: .8rem; text-transform: uppercase;
  letter-spacing: 2.5px; opacity: .75;
  font-weight: 600; margin-bottom: .4rem;
}
.chapter-header h1 {
  font-size: 2.4rem; margin: 0 0 .6rem;
  font-weight: 900; letter-spacing: -.5px;
  position: relative;
}
.chapter-header .tagline {
  font-size: 1rem; opacity: .85;
  max-width: 600px; line-height: 1.6;
  position: relative;
}

/* ────────────────────────────────────────────────
   TOC (Sommaire)
──────────────────────────────────────────────── */
.toc {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.2rem 1.6rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  transition: background .3s, border-color .3s;
}
.toc h3 {
  color: var(--primary);
  margin-top: 0; margin-bottom: .7rem;
  font-size: .95rem; text-transform: uppercase;
  letter-spacing: 1px;
}
.toc ol { margin: 0; counter-reset: toc-item; }
.toc > ol > li {
  counter-increment: toc-item;
  margin-bottom: .25rem; font-size: .9rem;
  font-weight: 600;
}
.toc a { color: var(--primary); font-weight: 500; }
.toc a:hover { color: var(--accent); text-decoration: none; }

/* ────────────────────────────────────────────────
   Page "J'entre en Terminale"
──────────────────────────────────────────────── */
.transition-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 1.5rem;
  align-items: stretch;
  background: linear-gradient(135deg, #0D47A1 0%, #1565C0 55%, #00796B 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 2.4rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
}

.transition-kicker {
  color: #FFE082;
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .14em;
  margin-bottom: .55rem;
  text-transform: uppercase;
}

.transition-hero h1 {
  font-size: 2.55rem;
  font-weight: 900;
  margin-bottom: .75rem;
}

.transition-lead {
  color: rgba(255,255,255,.88);
  font-size: 1.05rem;
  max-width: 650px;
}

.transition-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin-top: 1.35rem;
}

.transition-main-action,
.transition-secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: .65rem 1rem;
  font-weight: 800;
}

.transition-secondary-action {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.34);
  color: #fff;
}

.transition-secondary-action:hover {
  background: rgba(255,255,255,.22);
  color: #fff;
  text-decoration: none;
}

.transition-hero-panel {
  display: grid;
  align-content: center;
  gap: .3rem;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 10px;
  background: rgba(255,255,255,.12);
  padding: 1.2rem;
}

.transition-hero-panel strong {
  color: #FFE082;
  font-size: 1.45rem;
  line-height: 1.1;
}

.transition-hero-panel span {
  color: rgba(255,255,255,.84);
  margin-bottom: .7rem;
}

.transition-priority-grid,
.transition-topic-grid {
  display: grid;
  gap: 1rem;
}

.transition-priority-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.transition-priority-grid article,
.transition-topic-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.transition-priority-grid article {
  padding: 1rem;
}

.transition-priority-grid h3,
.transition-topic-grid h3 {
  margin-top: 0;
}

.transition-topic-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.transition-topic-card {
  overflow: hidden;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}

.transition-topic-card[open] {
  border-color: rgba(21,101,192,.45);
  box-shadow: var(--shadow-lg);
}

.transition-topic-card:hover {
  transform: translateY(-1px);
}

.transition-topic-card summary {
  position: relative;
  display: grid;
  grid-template-columns: 2.35rem minmax(0, 1fr) auto;
  gap: .9rem;
  align-items: start;
  cursor: pointer;
  list-style: none;
  padding: 1rem;
}

.transition-topic-card summary::-webkit-details-marker {
  display: none;
}

.transition-topic-card summary span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 900;
}

.transition-topic-card summary strong {
  align-self: center;
  color: var(--primary);
  font-size: .8rem;
  font-weight: 850;
  white-space: nowrap;
}

.transition-topic-card summary strong::after {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-left: .45rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.transition-topic-card[open] summary strong::after {
  content: "-";
}

.transition-topic-card h3 {
  margin-bottom: .35rem;
}

.transition-topic-grid p,
.transition-priority-grid p {
  color: var(--text-sec);
  margin-bottom: 0;
}

.transition-course {
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(227,242,253,.42), rgba(255,255,255,0));
  margin: 0;
  padding: 1rem 1rem 1.1rem 4.25rem;
}

.transition-course h4 {
  color: var(--primary-dark);
  font-size: .88rem;
  font-weight: 850;
  margin: 0 0 .45rem;
}

.transition-course ul {
  margin: 0;
  padding-left: 1.05rem;
}

.transition-course li {
  color: var(--text-sec);
  font-size: .92rem;
  line-height: 1.55;
  margin-bottom: .28rem;
}

.transition-course li:last-child {
  margin-bottom: 0;
}

.transition-course-grid.cards-grid {
  margin-top: 1.4rem;
}

.transition-course-grid .card-footer .btn-secondary {
  width: 100%;
  justify-content: center;
}

.transition-course-summary {
  display: grid;
  gap: 1.25rem;
  margin-top: 2rem;
}

.transition-course-accordion {
  margin-top: 1.4rem;
}

.course-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem;
  scroll-margin-top: 80px;
}

.course-panel-toggle {
  padding: 0;
  overflow: hidden;
}

.course-panel-toggle summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.15rem;
}

.course-panel-toggle summary::-webkit-details-marker {
  display: none;
}

.course-panel-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}

.course-panel-toggle .course-panel-header {
  margin-bottom: 0;
}

.course-panel-header span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.course-panel-header h3 {
  color: var(--primary-dark);
  font-size: 1.25rem;
  margin: 0;
}

.course-panel-header p {
  color: var(--text-sec);
  font-size: .92rem;
  margin: .2rem 0 0;
}

.course-panel-header strong {
  margin-left: auto;
  color: var(--primary);
  font-size: .82rem;
  font-weight: 850;
  white-space: nowrap;
}

.course-panel-header strong::after {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-left: .45rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.course-panel-toggle[open] .course-panel-header strong::after {
  content: "-";
}

.course-panel-content {
  border-top: 1px solid var(--border);
  padding: 1.15rem 1.35rem 1.35rem;
}

.course-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  margin: 0 0 .75rem;
  padding: .22rem .65rem;
  text-transform: uppercase;
}

.course-panel > p {
  color: var(--text-sec);
}

.course-panel-content > p {
  color: var(--text-sec);
}

.course-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.course-columns > div,
.course-warning,
.course-formula {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #F8FAFC;
  padding: 1rem;
}

.course-columns h4 {
  color: var(--primary-dark);
  font-size: .95rem;
  font-weight: 850;
  margin-top: 0;
}

.course-columns ul,
.course-columns ol {
  margin-bottom: 0;
}

.course-columns li {
  color: var(--text-sec);
  line-height: 1.65;
}

.course-warning {
  border-left: 5px solid var(--accent);
  color: var(--text);
  margin-top: 1rem;
}

.course-formula {
  overflow-x: auto;
  color: var(--primary-dark);
  margin-top: 1rem;
}

.course-solution-card {
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  margin-top: 1rem;
  padding: 1rem;
}

.course-solution-card h4 {
  color: var(--primary-dark);
  font-size: 1rem;
  font-weight: 850;
  margin: 0 0 .45rem;
}

.course-solution-card > p {
  color: var(--text-sec);
}

.solution-cases {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
  margin-top: .9rem;
}

.solution-cases article {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #F8FAFC;
  padding: .85rem;
}

.solution-cases strong {
  color: var(--primary-dark);
  display: block;
  font-size: .9rem;
  margin-bottom: .35rem;
}

.solution-cases p {
  color: var(--text-sec);
  font-size: .88rem;
  line-height: 1.55;
  margin-bottom: .45rem;
}

.solution-cases p:last-child {
  margin-bottom: 0;
}

.solution-formula {
  color: var(--primary-dark) !important;
  overflow-x: auto;
}

.course-sign-table {
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  margin-top: 1rem;
  overflow-x: auto;
  padding: 1rem;
}

.course-sign-table h4 {
  color: var(--primary-dark);
  font-size: 1rem;
  font-weight: 850;
  margin: 0 0 .45rem;
}

.course-sign-table p {
  color: var(--text-sec);
}

.course-sign-table table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

.course-sign-table th,
.course-sign-table td {
  border: 1px solid var(--border);
  padding: .75rem;
  text-align: left;
  vertical-align: top;
}

.course-sign-table th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: .86rem;
  font-weight: 850;
}

.course-sign-table td {
  color: var(--text-sec);
  font-size: .9rem;
  line-height: 1.55;
}

.sequence-course-card {
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  margin-top: 1rem;
  overflow-x: auto;
  padding: 1rem;
}

.sequence-course-card h4 {
  color: var(--primary-dark);
  font-size: 1rem;
  font-weight: 850;
  margin: 0 0 .65rem;
}

.sequence-cases {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .8rem;
}

.sequence-cases.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sequence-cases article {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #F8FAFC;
  padding: .85rem;
}

.sequence-cases strong {
  color: var(--primary-dark);
  display: block;
  font-size: .9rem;
  margin-bottom: .35rem;
}

.sequence-cases p {
  color: var(--text-sec);
  font-size: .88rem;
  line-height: 1.55;
  margin-bottom: .45rem;
}

.sequence-cases p:last-child {
  margin-bottom: 0;
}

.sequence-formula {
  color: var(--primary-dark) !important;
  overflow-x: auto;
}

.sequence-course-card table {
  border-collapse: collapse;
  min-width: 820px;
  width: 100%;
}

.sequence-course-card th,
.sequence-course-card td {
  border: 1px solid var(--border);
  padding: .75rem;
  text-align: left;
  vertical-align: top;
}

.sequence-course-card th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: .86rem;
  font-weight: 850;
}

.sequence-course-card td {
  color: var(--text-sec);
  font-size: .9rem;
  line-height: 1.55;
}

.probability-tree-figure {
  align-items: center;
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  margin: 1rem 0;
  overflow-x: auto;
  padding: 1rem;
}

.probability-tree-figure img {
  display: block;
  height: auto;
  max-width: 820px;
  min-width: 520px;
  width: 100%;
}

.trig-course-card {
  background: linear-gradient(180deg, #fff 0%, #F8FAFC 100%);
}

.trig-course-card > p {
  color: var(--text-sec);
  max-width: 760px;
}

.trig-values-table {
  margin-top: .85rem;
  min-width: 720px !important;
}

.trig-values-table th,
.trig-values-table td {
  text-align: center;
  vertical-align: middle;
}

.trig-values-table thead th {
  background: var(--primary-dark);
  color: #fff;
}

.trig-values-table tbody th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: .96rem;
  font-weight: 900;
  min-width: 5.2rem;
}

.trig-values-table td {
  background: #fff;
  color: var(--text);
  font-size: .96rem;
  font-weight: 750;
}

.trig-memory {
  display: grid;
  gap: .55rem;
  margin-top: .85rem;
}

.trig-memory span {
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: block;
  font-size: .9rem;
  font-weight: 800;
  overflow-x: auto;
  padding: .65rem .8rem;
}

.probability-tree {
  display: grid;
  grid-template-columns: 5rem 5.5rem 6rem 5.5rem minmax(7rem, 1fr);
  grid-template-rows: repeat(4, 3.2rem);
  gap: .45rem .25rem;
  min-width: 760px;
  margin: 1rem 0;
  padding: .6rem .25rem;
}

.tree-root,
.tree-node,
.tree-leaf {
  align-items: center;
  align-self: center;
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--primary-dark);
  display: inline-flex;
  font-weight: 850;
  justify-content: center;
  min-height: 2.35rem;
  padding: .35rem .6rem;
  text-align: center;
}

.tree-root {
  grid-column: 1;
  grid-row: 2 / 4;
}

.node-a { grid-column: 3; grid-row: 1 / 3; }
.node-not-a { grid-column: 3; grid-row: 3 / 5; }
.leaf-a-b { grid-column: 5; grid-row: 1; }
.leaf-a-not-b { grid-column: 5; grid-row: 2; }
.leaf-not-a-b { grid-column: 5; grid-row: 3; }
.leaf-not-a-not-b { grid-column: 5; grid-row: 4; }

.tree-branch {
  align-self: center;
  border-top: 2px solid var(--primary);
  height: 0;
  position: relative;
}

.tree-branch span {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-sec);
  font-size: .78rem;
  font-weight: 800;
  left: 50%;
  padding: .08rem .42rem;
  position: absolute;
  top: -.95rem;
  transform: translateX(-50%);
  white-space: nowrap;
}

.branch-a {
  grid-column: 2;
  grid-row: 2;
  transform: rotate(-18deg);
}

.branch-not-a {
  grid-column: 2;
  grid-row: 3;
  transform: rotate(18deg);
}

.branch-a-b {
  grid-column: 4;
  grid-row: 1;
  transform: rotate(-12deg);
}

.branch-a-not-b {
  grid-column: 4;
  grid-row: 2;
  transform: rotate(12deg);
}

.branch-not-a-b {
  grid-column: 4;
  grid-row: 3;
  transform: rotate(-12deg);
}

.branch-not-a-not-b {
  grid-column: 4;
  grid-row: 4;
  transform: rotate(12deg);
}

.course-deep-dive {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 1rem;
}

.course-deep-dive h4 {
  color: var(--primary-dark);
  font-size: 1rem;
  font-weight: 850;
  margin: 0 0 .55rem;
}

.course-deep-dive p,
.course-deep-dive li {
  color: var(--text-sec);
  line-height: 1.7;
}

.course-deep-dive ul,
.course-deep-dive ol {
  margin-bottom: 0;
}

.course-example {
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  background: var(--primary-light);
  margin: .85rem 0;
  padding: .85rem 1rem;
}

.course-example strong {
  color: var(--primary-dark);
  display: block;
  font-size: .9rem;
  margin-bottom: .35rem;
}

.course-example p {
  margin-bottom: 0;
}

.transition-download {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.transition-inline-action {
  margin-top: 1rem;
}

.transition-interactive-header .btn-secondary {
  margin-right: .5rem;
}

.transition-interactive-exercise {
  border-left-color: var(--primary);
}

.transition-correction-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 1rem;
  align-items: start;
}

.transition-correction-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.transition-correction-card h3 {
  margin-top: 0;
}

.transition-correction-card-main {
  border-left: 5px solid var(--cor-bd);
}

.transition-correction-pending {
  border: 1px dashed #CBD5E1;
  border-radius: 8px;
  background: #F8FAFC;
  color: #475569;
  padding: .9rem;
}

.transition-correction-body {
  display: grid;
  gap: .7rem;
}

.correction-mathjax {
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(224,242,241,.55), rgba(255,255,255,0));
  padding: .95rem;
}

.correction-mathjax ol {
  display: grid;
  gap: .6rem;
  margin: 0;
  padding-left: 1.35rem;
}

.correction-mathjax li {
  color: var(--text);
  line-height: 1.7;
  padding-left: .15rem;
}

.correction-mathjax p {
  color: var(--text);
}

.correction-mathjax mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

.variation-table-figure {
  margin: .9rem 0 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: .9rem;
  text-align: center;
  overflow-x: auto;
}

.variation-table-figure img {
  display: block;
  width: min(100%, 620px);
  height: auto;
  margin: 0 auto;
}

.variation-table-figure figcaption {
  color: var(--text-sec);
  font-size: .82rem;
  font-weight: 700;
  margin-top: .55rem;
}

.transition-correction-pdf {
  display: grid;
  gap: .8rem;
}

.transition-correction-pdf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}

.transition-correction-pdf-viewer {
  width: 100%;
  min-height: 680px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.transition-correction-fallback {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #F8FAFC;
}

.transition-correction-fallback summary {
  cursor: pointer;
  color: var(--primary-dark);
  font-weight: 800;
  padding: .75rem .9rem;
}

.transition-correction-fallback .transition-correction-body {
  border-top: 1px solid var(--border);
}

.transition-correction-body p,
.transition-correction-card p {
  margin-bottom: .65rem;
}

.correction-math {
  overflow-x: auto;
  margin: .7rem 0;
  padding: .7rem;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* ────────────────────────────────────────────────
   Boîtes de contenu
──────────────────────────────────────────────── */
.definition, .propriete, .methode, .exemple,
.exercice, .corrige, .attention, .astuce, .synthese-box {
  border-left: 5px solid;
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem 1.1rem 1.4rem;
  margin: 1.3rem 0;
  position: relative;
  transition: background .3s, border-color .3s;
  box-shadow: 0 1px 6px rgba(0,0,0,.05);
}

/* Labels des boîtes */
.definition::before, .propriete::before, .methode::before,
.exemple::before, .exercice::before, .corrige::before,
.attention::before, .astuce::before {
  display: block;
  font-size: .68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1.8px;
  margin-bottom: .55rem;
  font-family: 'Inter', sans-serif;
}

.definition  { background: var(--def-bg);  border-color: var(--def-bd);  }
.definition::before  { content: "📘 Définition";  color: var(--def-bd);  }

.propriete   { background: var(--prop-bg); border-color: var(--prop-bd); }
.propriete::before   { content: "📐 Propriété";  color: var(--prop-bd); }

.methode     { background: var(--meth-bg); border-color: var(--meth-bd); }
.methode::before     { content: "🔧 Méthode";    color: var(--meth-bd); }

.exemple     { background: var(--ex-bg);   border-color: var(--ex-bd);   }
.exemple::before     { content: "✏️ Exemple";    color: var(--ex-bd);   }

.exercice    { background: var(--exo-bg);  border-color: var(--exo-bd);  }
.exercice::before    { content: "🎯 Exercice";   color: var(--exo-bd);  }

.corrige     { background: var(--cor-bg);  border-color: var(--cor-bd);  }
.corrige::before     { content: "✅ Corrigé";    color: var(--cor-bd);  }

.attention   { background: var(--warn-bg); border-color: var(--warn-bd); }
.attention::before   { content: "⚠️ À retenir";  color: var(--warn-bd); }

.astuce      { background: var(--tip-bg);  border-color: var(--tip-bd);  }
.astuce::before      { content: "💡 Astuce";     color: var(--tip-bd);  }

/* Titre optionnel dans une boîte */
.definition b.titre, .propriete b.titre, .exemple b.titre,
.exercice b.titre, .corrige b.titre {
  display: block; font-size: 1rem; margin-bottom: .4rem;
}

/* ── Difficulté des exercices ── */
.diff {
  display: inline-block; font-size: .72rem;
  font-weight: 700; padding: .18rem .6rem;
  border-radius: 20px; margin-bottom: .5rem;
  letter-spacing: .5px;
}
.diff-1 { background: #C8E6C9; color: #1B5E20; }
.diff-2 { background: #FFF9C4; color: #E65100; }
.diff-3 { background: #FFCDD2; color: #B71C1C; }

/* ── Suivi de maîtrise des exercices d'application ── */
.application-assessment-panel {
  background: color-mix(in srgb, var(--primary) 8%, white);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-top: 1rem;
}

.application-assessment-panel h3 {
  margin: 0 0 .35rem;
  font-size: 1.05rem;
}

.application-assessment-panel p {
  margin: 0 0 .8rem;
}

.assessment-legend,
.exercise-assessment {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.assessment-pill,
.assessment-option span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: .34rem .75rem;
  font-size: .78rem;
  font-weight: 750;
}

.exercise-assessment {
  border: 0;
  margin: .75rem 0 .85rem;
  padding: 0;
}

.exercise-assessment legend {
  width: 100%;
  margin-bottom: .25rem;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.assessment-option {
  cursor: pointer;
}

.assessment-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.assessment-pill.acquired,
.assessment-option.acquired span {
  background: #DCFCE7;
  color: #166534;
  border: 1px solid #86EFAC;
}

.assessment-pill.progress,
.assessment-option.progress span {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
}

.assessment-pill.missing,
.assessment-option.missing span {
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #FCA5A5;
}

.assessment-option input:checked + span {
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent);
  transform: translateY(-1px);
}

.assessment-option input:focus-visible + span {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.application-correction {
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
  overflow: hidden;
  border: 1.5px solid rgba(108, 99, 255, .45);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(79, 70, 229, .14);
}

.application-correction:focus-within {
  border-color: #6C63FF;
  box-shadow: 0 0 0 3px rgba(108, 99, 255, .12), 0 18px 42px rgba(79, 70, 229, .18);
}

.application-open-editor {
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  font-weight: 850;
  padding: .68rem 1rem;
  margin-bottom: .85rem;
}

.application-open-editor:hover {
  background: var(--primary-dark);
}

.application-editor-panel[hidden] {
  display: none;
}

.application-exercise-layout {
  display: grid;
  gap: 1.1rem;
  align-items: start;
}

.application-exercise-statement {
  min-width: 0;
}

.application-variant-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .55rem;
  margin: .75rem 0 1rem;
  padding: .65rem .75rem;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 6%, white);
}

.application-variant-label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.application-next-variant {
  border: 0;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: .82rem;
  font-weight: 850;
  padding: .52rem .85rem;
}

.application-next-variant:hover {
  background: var(--primary-dark);
}

.application-variant-body {
  min-width: 0;
}

.application-skill-tags {
  display: grid;
  gap: .35rem;
  margin-bottom: .85rem;
  border: 1px solid #D7DDF2;
  border-left: 4px solid #6C63FF;
  border-radius: 10px;
  background: #F8FAFF;
  padding: .75rem .85rem;
}

.application-skill-tags p {
  margin: 0;
  color: #334155;
}

.application-skill-tags strong {
  color: #3730A3;
}

.application-model-correction {
  margin-top: 1rem;
  border: 1px solid #D7DDF2;
  border-radius: 12px;
  background: #F8FAFF;
  overflow: hidden;
}

.application-model-correction summary {
  cursor: pointer;
  color: #3730A3;
  font-weight: 850;
  padding: .75rem .9rem;
}

.application-model-correction[open] summary {
  border-bottom: 1px solid #E1E7F7;
  background: #EEF2FF;
}

.application-model-body {
  display: grid;
  gap: .7rem;
  padding: .85rem .95rem 1rem;
}

.application-model-level {
  width: fit-content;
  border: 1px solid #A7F3D0;
  border-radius: 999px;
  background: #ECFDF5;
  color: #065F46;
  font-size: .78rem;
  font-weight: 850;
  padding: .35rem .65rem;
}

.application-model-body p {
  margin: 0;
}

.application-model-body pre {
  margin: 0;
  overflow-x: auto;
  border: 1px solid #D7DDF2;
  border-radius: 10px;
  background: #111827;
  color: #F8FAFC;
  padding: .8rem;
}

.application-model-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86rem;
}

.application-exercise-sidebar {
  min-width: 0;
}

.application-exercise-sidebar .exercise-assessment {
  margin-top: 0;
}

.application-editor-toolbar {
  border-top: 1px solid #E4E7F4;
  background: linear-gradient(180deg, #F8F9FF 0%, #F2F4FD 100%);
}

.application-toolbar-quick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .34rem;
  padding: .5rem .75rem;
}

.application-key {
  min-width: 44px;
  height: 36px;
  border: 1px solid #C4CBEF;
  border-bottom: 2.5px solid #9BA6E0;
  border-radius: 8px;
  background: linear-gradient(165deg, #fff 0%, #EEF0FB 100%);
  box-shadow: 0 1px 2px rgba(67, 56, 202, .07);
  color: #3730A3;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: .82rem;
  font-weight: 800;
  padding: 0 .55rem;
  transition: background 120ms, border-color 120ms, box-shadow 120ms, transform 80ms, color 120ms;
  user-select: none;
}

.application-key:hover {
  border-color: #818CF8;
  border-bottom-color: #6366F1;
  background: linear-gradient(165deg, #F5F3FF 0%, #EDE9FE 100%);
  color: #4F46E5;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(99, 102, 241, .18);
}

.application-key:active {
  transform: translateY(1px);
  border-bottom-width: 1px;
  box-shadow: none;
  background: linear-gradient(165deg, #EDE9FE 0%, #DDD6FE 100%);
}

.application-symbol-tab:hover {
  border-color: #7C3AED;
  transform: translateY(-1px);
}

.application-formula-open,
.application-symbol-more {
  min-width: 78px;
  color: #fff;
  background: linear-gradient(165deg, #6366F1 0%, #4F46E5 100%);
  border-color: #4338CA;
  border-bottom-color: #3730A3;
  box-shadow: 0 1px 2px rgba(67, 56, 202, .2);
}

.application-formula-open:hover,
.application-symbol-more:hover {
  color: #fff;
  background: linear-gradient(165deg, #818CF8 0%, #6366F1 100%);
  border-color: #6366F1;
  border-bottom-color: #4F46E5;
  box-shadow: 0 3px 8px rgba(99, 102, 241, .35);
}

.application-formula-open:active,
.application-symbol-more:active {
  background: linear-gradient(165deg, #4F46E5 0%, #3730A3 100%);
}

.application-symbol-panel {
  display: grid;
  gap: .55rem;
  border-top: 1px solid #E1E7F7;
  background: #FFFFFF;
  padding: .65rem .75rem .75rem;
}

.application-symbol-panel[hidden] {
  display: none;
}

.application-symbol-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.application-symbol-tab {
  border: 1px solid #D1D9EF;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: .78rem;
  font-weight: 700;
  padding: .36rem .75rem;
  transition: background 120ms, border-color 120ms, color 120ms, box-shadow 120ms;
}

.application-symbol-tab.active {
  border-color: #6366F1;
  background: linear-gradient(165deg, #EEF2FF 0%, #E0E7FF 100%);
  color: #4338CA;
  box-shadow: 0 1px 3px rgba(99, 102, 241, .15);
}

.application-symbol-grid {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(64px, max-content));
  gap: .38rem;
}

.application-symbol-grid.active {
  display: grid;
}

.application-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  border-top: 1px solid #E9EAF0;
  background: #F8F9FF;
  padding: .6rem .9rem;
}

.application-bottom-left,
.application-bottom-right {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}

.application-answer {
  min-height: 180px;
  max-height: 420px;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  outline: none;
  color: var(--text);
  font-family: Inter, sans-serif;
  font-size: 1rem;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
}

.application-answer:empty::before {
  content: attr(data-placeholder);
  color: #98A2B8;
  pointer-events: none;
}

.application-answer[data-empty="true"]::before {
  content: attr(data-placeholder);
  color: #98A2B8;
  pointer-events: none;
}

.application-writing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  border-bottom: 1px solid #E9EAF0;
  background: #fff;
  padding: .55rem .75rem;
}

.application-writing-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  min-width: 0;
}

.application-writing-tools button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 34px;
  border: 1px solid #D9DEEA;
  border-radius: 8px;
  background: #F8FAFC;
  color: #1F2937;
  font: inherit;
  font-size: .86rem;
  font-weight: 800;
  line-height: 1;
  padding: .35rem .55rem;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.application-writing-tools button:hover,
.application-writing-tools button:focus-visible {
  border-color: #93A4C8;
  background: #EEF2FF;
  color: #3730A3;
}

.application-writing-tools button:active {
  transform: translateY(1px);
}

.application-word-info {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #F1F5F9;
  color: #64748B;
  font-size: .78rem;
  font-weight: 850;
  padding: .32rem .58rem;
  white-space: nowrap;
}

.application-math-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 0 .12rem;
  border: 1px solid #C7D2FE;
  border-radius: 8px;
  background: #F8FAFC;
  color: #111827;
  padding: .05rem .35rem;
  vertical-align: middle;
}

.application-math-chip math-field {
  pointer-events: none;
  min-width: 32px;
  border: 0;
  background: transparent;
  font-size: 1rem;
}

.application-inline-formula {
  display: inline-grid;
  align-items: center;
  justify-items: center;
  gap: .16rem;
  margin: 0 .16rem;
  border: 1px solid #C7D2FE;
  border-radius: 10px;
  background: #F8FAFF;
  color: #111827;
  padding: .25rem .32rem;
  vertical-align: middle;
}

.application-inline-formula input {
  width: 68px;
  min-height: 28px;
  border: 1px solid #CBD5E1;
  border-radius: 7px;
  background: #fff;
  color: #111827;
  font: 800 .86rem Inter, sans-serif;
  text-align: center;
  padding: .2rem .3rem;
}

.application-inline-formula input:focus {
  outline: 3px solid rgba(108, 99, 255, .16);
  border-color: #6C63FF;
}

.application-inline-fraction {
  grid-template-rows: minmax(28px, auto) 2px minmax(28px, auto);
  min-width: 82px;
}

.inline-fraction-bar {
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: #111827;
}

.application-inline-sqrt {
  grid-template-columns: auto minmax(74px, 1fr);
  align-items: end;
  font-size: 1.55rem;
  font-weight: 850;
}

.application-inline-sqrt input {
  border-top: 2px solid #111827;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.application-inline-power {
  grid-template-columns: minmax(58px, auto) minmax(44px, auto);
  align-items: start;
}

.inline-power-exponent {
  width: 48px;
  min-height: 24px;
  font-size: .76rem;
  transform: translateY(-.38rem);
}

.application-inline-absolute {
  grid-template-columns: auto minmax(68px, auto) auto;
  font-size: 1.45rem;
  font-weight: 850;
}

.application-inline-limit {
  grid-template-columns: auto 42px auto 52px 72px;
  font-weight: 850;
}

.application-inline-limit input,
.application-inline-integral input {
  width: 52px;
}

.inline-limit-expression,
.inline-integral-expression {
  width: 78px !important;
}

.application-inline-integral {
  grid-template-columns: auto 44px 78px auto 42px;
  font-weight: 850;
}

.inline-integral-symbol {
  font-size: 1.8rem;
  line-height: 1;
}

.inline-integral-bounds {
  display: grid;
  gap: .12rem;
}

.inline-integral-bounds input {
  min-height: 22px;
  font-size: .72rem;
}

.application-formula-zone {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: .55rem;
  border-top: 1px solid #E9EAF0;
  background: #FFFFFF;
  padding: .8rem .9rem;
}

.application-formula-zone[hidden] {
  display: none;
}

.application-fml-mathfield {
  width: 100%;
  min-height: 74px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid #C7D2FE;
  border-radius: 12px;
  background: #fff;
  color: #111827;
  font-size: 1.16rem;
  padding: .55rem .7rem;
}

.application-fml-mathfield:focus-within {
  outline: 3px solid rgba(108, 99, 255, .16);
  border-color: #6C63FF;
}

.application-mf-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: .4rem;
}

.application-mf-bar button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: .82rem;
  font-weight: 850;
  padding: .45rem .7rem;
}

.application-mf-backspace,
.application-formula-cancel {
  background: #E2E8F0;
  color: #334155;
}

.application-formula-choices {
  display: flex;
  flex-wrap: wrap;
  gap: .38rem;
}

.application-formula-choice {
  min-height: 34px;
  border: 1px solid #CBD5E1;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: .78rem;
  font-weight: 850;
  padding: .35rem .7rem;
}

.application-formula-choice.active {
  border-color: #6C63FF;
  background: #EEF2FF;
  color: #4338CA;
}

.application-formula-fields {
  display: grid;
  gap: .25rem;
}

.application-formula-fields label {
  color: #475569;
  font-size: .74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.application-formula-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #C7D2FE;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  font-family: Inter, sans-serif;
  font-size: .9rem;
  padding: .45rem .65rem;
}

.application-formula-input:focus {
  outline: 3px solid rgba(108, 99, 255, .16);
  border-color: #6C63FF;
}

.application-formula-input[hidden] {
  display: none;
}

.application-graphic-editor {
  width: min(240px, 100%);
  margin: 0 auto;
}

.application-graphic-editor[hidden] {
  display: none !important;
}

.application-graphic-editor input {
  min-height: 34px;
  border: 1px solid #C7D2FE;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-family: Inter, sans-serif;
  font-size: .9rem;
  text-align: center;
  padding: .35rem .45rem;
}

.application-graphic-editor input:focus {
  outline: 3px solid rgba(108, 99, 255, .16);
  border-color: #6C63FF;
}

.application-fraction-editor {
  display: inline-grid;
  grid-template-rows: minmax(34px, auto) 2px minmax(34px, auto);
  align-items: center;
  justify-items: center;
  width: min(180px, 100%);
}

.application-fraction-editor span {
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: #111827;
}

.application-fraction-editor input {
  width: 100%;
}

.application-root-editor {
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr);
  align-items: end;
  gap: .25rem;
  font-size: 1.8rem;
  font-weight: 800;
}

.application-root-editor input {
  border-top: 2px solid #111827;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.application-power-editor {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(54px, .65fr);
  align-items: start;
  gap: .25rem;
}

.application-power-exponent {
  min-height: 28px;
  font-size: .78rem;
  transform: translateY(-.42rem);
}

.application-absolute-editor {
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr) auto;
  align-items: center;
  gap: .35rem;
  font-size: 1.7rem;
  font-weight: 800;
}

.application-limit-editor {
  display: grid;
  grid-template-columns: auto minmax(42px, .45fr) auto minmax(52px, .55fr) minmax(82px, 1fr);
  align-items: center;
  gap: .28rem;
  font-weight: 850;
}

.application-integral-editor {
  display: grid;
  grid-template-columns: auto minmax(46px, .45fr) minmax(86px, 1fr) auto minmax(42px, .42fr);
  align-items: center;
  gap: .28rem;
  font-weight: 850;
}

.application-integral-editor > span:first-child {
  font-size: 2rem;
  line-height: 1;
}

.application-integral-bounds {
  display: grid;
  gap: .16rem;
}

.application-integral-bounds input {
  min-height: 26px;
  font-size: .76rem;
}

.application-formula-preview {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #C7D2FE;
  border-radius: 10px;
  background: #F8F9FF;
  color: #334155;
  font-size: 1rem;
  padding: .35rem .65rem;
}

.application-formula-actions {
  display: flex;
  gap: .4rem;
}

.application-formula-actions button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: .82rem;
  font-weight: 850;
  padding: .45rem .7rem;
}

.application-formula-insert {
  background: #6C63FF;
  color: #fff;
}

.application-formula-insert:disabled {
  background: #C7D2FE;
  cursor: not-allowed;
}

.application-tool-btn,
.application-mode-pill,
.application-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 10px;
  font-family: Inter, sans-serif;
  font-size: .82rem;
  font-weight: 850;
  padding: .35rem .8rem;
}

.application-tool-btn {
  border: 1px solid #C7D2FE;
  background: #EEF2FF;
  color: #4F46E5;
  cursor: pointer;
}

.application-mode-pill {
  background: #F0EDFF;
  color: #6D5DFB;
}

.application-char-info {
  border-radius: 999px;
  background: #EEF0FF;
  color: #8B93AD;
  font-size: .78rem;
  font-weight: 800;
  padding: .35rem .6rem;
}

.application-char-info.is-over-limit {
  background: #FEF2F2;
  color: #B91C1C;
}

.application-send-btn {
  border: 0;
  background: #BDB9F4;
  color: #fff;
  cursor: pointer;
}

.application-send-btn:not(:disabled) {
  background: #6C63FF;
}

.application-send-btn:disabled {
  cursor: not-allowed;
}

.application-attachments {
  display: grid;
  gap: .35rem;
}

.application-attachment {
  border: 1px solid #DFE6F5;
  border-radius: 10px;
  background: #FAFBFF;
  margin: 0;
  padding: .55rem;
}

.application-attachment-preview {
  display: grid;
  gap: .5rem;
  border-bottom: 1px solid #E9EAF0;
  background: #F8F9FF;
  padding: .65rem .8rem;
}

.application-attachment-preview[hidden] {
  display: none;
}

.application-attachment-head,
.application-attachment-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.application-attachment-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.application-attachment-remove,
.application-remove-attachments {
  border: 0;
  border-radius: 999px;
  background: #FEE2E2;
  color: #991B1B;
  cursor: pointer;
  font: inherit;
  font-size: .78rem;
  font-weight: 800;
  padding: .3rem .65rem;
}

.application-attachment-image {
  display: block;
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
  margin-top: .5rem;
}

.application-scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .78);
  padding: 1rem;
}

.application-scan-modal {
  width: min(720px, 100%);
  overflow: hidden;
  border-radius: 16px;
  background: #111827;
}

.application-scan-modal video {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #000;
}

.application-scan-actions {
  display: flex;
  justify-content: flex-end;
  gap: .55rem;
  padding: .75rem;
}

.application-scan-actions button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: .55rem .95rem;
}

.application-scan-actions .scan-capture {
  background: var(--primary);
  color: #fff;
}

.application-scan-actions .scan-close {
  background: #E5E7EB;
  color: #111827;
}

.application-feedback {
  display: none;
  border-radius: 10px;
  padding: .75rem .9rem;
  font-size: .9rem;
  line-height: 1.55;
}

.application-feedback.loading,
.application-feedback.success,
.application-feedback.error {
  display: block;
}

.application-feedback.loading {
  background: #EEF2FF;
  color: #3730A3;
}

.application-feedback.success {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.application-feedback .ai-correction-html {
  display: grid;
  gap: .55rem;
}

.application-feedback .ai-correction-html h4 {
  margin: .35rem 0 0;
  color: #064E3B;
  font-size: .92rem;
  font-weight: 900;
}

.application-feedback .ai-correction-html p,
.application-feedback .ai-correction-html ul,
.application-feedback .ai-correction-html ol {
  margin: 0;
}

.application-feedback .ai-correction-html ul,
.application-feedback .ai-correction-html ol {
  padding-left: 1.15rem;
}

.application-feedback .ai-correction-html code,
.application-feedback .ai-correction-html pre {
  border-radius: 6px;
  background: rgba(6, 95, 70, .08);
  color: #064E3B;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.application-feedback .ai-correction-html code {
  padding: .08rem .25rem;
}

.application-feedback .ai-correction-html pre {
  overflow-x: auto;
  padding: .65rem;
}

.application-feedback.error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

@media (min-width: 1100px) {
  .application-exercise-layout {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 36%);
  }

  .application-exercise-layout.application-editor-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .application-exercise-layout::before {
    grid-column: 1 / -1;
  }

  .application-exercise-statement {
    grid-column: 1;
  }

  .application-exercise-sidebar {
    grid-column: 2;
    position: sticky;
    top: 5.5rem;
  }

  .application-exercise-layout.application-editor-open .application-exercise-sidebar {
    grid-column: 1;
    position: static;
  }
}

@media (max-width: 760px) {
  .application-formula-zone {
    grid-template-columns: 1fr;
  }

  .application-formula-actions,
  .application-bottom-bar {
    flex-wrap: wrap;
  }

  .application-bottom-right {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ────────────────────────────────────────────────
   Fiche synthèse
──────────────────────────────────────────────── */
.synthese {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #1565C0 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 2.2rem 2rem;
  margin-top: 2.5rem;
  box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.synthese::before {
  content: '';
  position: absolute;
  width: 250px; height: 250px;
  right: -60px; bottom: -80px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  pointer-events: none;
}
.synthese h2 {
  color: #FFD54F;
  border-color: rgba(255,213,79,.3);
  font-size: 1.4rem;
}
.synthese h3 { color: #90CAF9; margin-top: 1.4rem; font-size: 1.05rem; }
.synthese ul li { margin-bottom: .4rem; }
.synthese ul li::marker { color: #FFD54F; }
.synthese p, .synthese li { color: rgba(255,255,255,.88); }
.synthese .item {
  background: rgba(255,255,255,.1);
  border-radius: 8px;
  padding: .8rem 1rem; margin: .7rem 0;
}
.synthese .definition,
.synthese .propriete,
.synthese .methode,
.synthese .exercice,
.synthese .corrige,
.synthese .attention,
.synthese .astuce,
.synthese .synthese-box {
  color: var(--text);
}
.synthese .definition p,
.synthese .definition li,
.synthese .definition strong,
.synthese .definition mjx-container,
.synthese .propriete p,
.synthese .propriete li,
.synthese .propriete strong,
.synthese .propriete mjx-container,
.synthese .methode p,
.synthese .methode li,
.synthese .methode strong,
.synthese .methode mjx-container,
.synthese .exercice p,
.synthese .exercice li,
.synthese .exercice strong,
.synthese .exercice mjx-container,
.synthese .corrige p,
.synthese .corrige li,
.synthese .corrige strong,
.synthese .corrige mjx-container,
.synthese .attention p,
.synthese .attention li,
.synthese .attention strong,
.synthese .attention mjx-container,
.synthese .astuce p,
.synthese .astuce li,
.synthese .astuce strong,
.synthese .astuce mjx-container,
.synthese .synthese-box p,
.synthese .synthese-box li,
.synthese .synthese-box strong,
.synthese .synthese-box mjx-container {
  color: inherit;
}
.synthese .definition h3,
.synthese .propriete h3,
.synthese .methode h3,
.synthese .exercice h3,
.synthese .corrige h3,
.synthese .attention h3,
.synthese .astuce h3,
.synthese .synthese-box h3 {
  color: var(--primary);
}
.synthese table {
  width: 100%;
  overflow: hidden;
  border-collapse: collapse;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.synthese table th {
  background: var(--primary);
  color: #fff;
}
.synthese table td {
  background: #fff;
  color: var(--text);
}
.synthese table tr:nth-child(even) td {
  background: #f8fafc;
}
.synthese table mjx-container,
.synthese table strong {
  color: inherit;
}

/* ────────────────────────────────────────────────
   Bouton corrigé toggle
──────────────────────────────────────────────── */
.btn-toggle {
  display: inline-flex; align-items: center; gap: .4rem;
  cursor: pointer;
  background: var(--cor-bd); color: #fff;
  padding: .42rem 1.1rem;
  border-radius: 20px;
  font-size: .82rem; font-weight: 600;
  border: none;
  margin: .6rem 0;
  transition: background .2s var(--ease), transform .1s;
  font-family: 'Inter', sans-serif;
}
.btn-toggle:hover { background: #00897B; transform: translateY(-1px); }
.btn-toggle:active { transform: translateY(0); }

.corrige-content { display: none; margin-top: .8rem; }
.corrige-content.open { display: block; }

/* ────────────────────────────────────────────────
   Étapes numérotées
──────────────────────────────────────────────── */
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li {
  counter-increment: step;
  padding: .55rem .6rem .55rem 3rem;
  position: relative; margin-bottom: .55rem;
  background: rgba(255,255,255,.6);
  border-radius: 8px;
  border: 1px solid var(--border);
}
[data-theme="dark"] .steps li {
  background: rgba(255,255,255,.04);
}
.steps li::before {
  content: counter(step);
  position: absolute; left: .6rem; top: 50%; transform: translateY(-50%);
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 800;
}

/* ────────────────────────────────────────────────
   Index — Hero
──────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #0D47A1 0%, #1E88E5 60%, #7C4DFF 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 3.5rem 2rem 3rem;
  margin-bottom: 2.5rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
/* Décoration hero */
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.hero h1 {
  font-size: 3rem; margin-bottom: .6rem;
  font-weight: 900; letter-spacing: -1px;
  position: relative;
}
.hero h1 span { color: #FFD54F; }
.hero p {
  font-size: 1.15rem; opacity: .9;
  max-width: 580px; margin: 0 auto 1.8rem;
  position: relative;
}
.search-bar {
  display: flex; max-width: 420px; margin: 0 auto;
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  border-radius: 30px; overflow: hidden;
}
.search-bar input {
  flex: 1; padding: .75rem 1.2rem;
  border: none; font-size: 1rem; outline: none;
  font-family: 'Inter', sans-serif;
  background: rgba(255,255,255,.95);
}
.search-bar button {
  background: #FFD54F; color: #1a1a2e;
  border: none; padding: .75rem 1.4rem;
  font-weight: 800; font-size: 1rem;
  cursor: pointer; transition: background .2s;
  font-family: 'Inter', sans-serif;
}
.search-bar button:hover { background: #FFC107; }

/* ── Stats hero ── */
.hero-stats {
  display: flex; justify-content: center; gap: 2rem;
  margin-top: 2rem; flex-wrap: wrap;
  position: relative;
}
.hero-stat {
  text-align: center;
}
.hero-stat strong {
  display: block; font-size: 2rem; font-weight: 900;
  color: #FFD54F; line-height: 1;
}
.hero-stat span { font-size: .85rem; opacity: .8; }

/* ────────────────────────────────────────────────
   Cards Grid (index)
──────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.5rem; margin-top: 2rem;
}
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
  border: 1px solid var(--border);
}
.card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: var(--shadow-lg);
}
.card-header {
  padding: 1.4rem 1.5rem;
  color: #fff; position: relative; overflow: hidden;
}
.card-header::after {
  content: '';
  position: absolute;
  right: -20px; top: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  pointer-events: none;
}
.card-body { padding: 1.2rem 1.4rem; flex: 1; }
.card-body p { font-size: .88rem; color: var(--text-sec); margin-bottom: .8rem; line-height: 1.65; }
.card-footer { padding: .85rem 1.4rem; border-top: 1px solid var(--border); }
.card .num-ch { font-size: .72rem; opacity: .8; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600; }
.card h3 { font-size: 1.05rem; margin: .25rem 0 0; font-weight: 700; }
.card .card-header h3 { color: #fff; }

.exercise-level-index {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2.5rem;
}

.exercise-level-summary {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.exercise-level-summary .ut-nav-badge {
  width: max-content;
}

.exercise-level-summary h3 {
  font-size: 1.25rem;
  margin: 0;
}

.exercise-level-summary p {
  color: var(--text-sec);
  margin: 0 0 .35rem;
  line-height: 1.55;
}

.exercise-level-summary--seconde .ut-nav-badge { background: #2e7d32; }
.exercise-level-summary--premiere .ut-nav-badge { background: #1565c0; }
.exercise-level-summary--terminale .ut-nav-badge { background: #6a1b9a; }

.exercise-level-section {
  scroll-margin-top: 96px;
}

.exercise-level-card--pending {
  opacity: .92;
}

.exercise-level-card--pending .btn-secondary {
  width: 100%;
  justify-content: center;
}

@media (max-width: 900px) {
  .exercise-level-index {
    grid-template-columns: 1fr;
  }
}

/* ── Tags ── */
.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .7rem; }
.tag {
  font-size: .67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  padding: .18rem .55rem; border-radius: 10px;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid rgba(21,101,192,.15);
}
[data-theme="dark"] .tag {
  background: rgba(91,141,246,.15);
  color: var(--primary);
  border-color: rgba(91,141,246,.2);
}

/* ── Couleurs des cartes ── */
.c1  .card-header { background: linear-gradient(135deg,#1565C0,#1E88E5); }
.c2  .card-header { background: linear-gradient(135deg,#00695C,#00ACC1); }
.c3  .card-header { background: linear-gradient(135deg,#6A1B9A,#9C27B0); }
.c4  .card-header { background: linear-gradient(135deg,#BF360C,#EF5350); }
.c5  .card-header { background: linear-gradient(135deg,#01579B,#039BE5); }
.c6  .card-header { background: linear-gradient(135deg,#33691E,#7CB342); }
.c7  .card-header { background: linear-gradient(135deg,#E65100,#FF8F00); }
.c8  .card-header { background: linear-gradient(135deg,#880E4F,#E91E63); }
.c9  .card-header { background: linear-gradient(135deg,#006064,#00ACC1); }
.c10 .card-header { background: linear-gradient(135deg,#263238,#546E7A); }
.c11 .card-header { background: linear-gradient(135deg,#311B92,#673AB7); }
.c12 .card-header { background: linear-gradient(135deg,#1A237E,#3949AB); }

/* ── Bouton principal (cartes) ── */
.btn-primary {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--primary); color: #fff;
  padding: .48rem 1.2rem; border-radius: 20px;
  font-size: .83rem; font-weight: 600;
  transition: background .2s var(--ease), transform .15s, box-shadow .2s;
  box-shadow: 0 2px 8px rgba(21,101,192,.25);
}
.btn-primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(21,101,192,.35);
}

/* ────────────────────────────────────────────────
   Bouton PDF
──────────────────────────────────────────────── */
.btn-pdf {
  display: inline-flex; align-items: center; gap: .5rem;
  background: linear-gradient(135deg, #C62828, #E53935);
  color: #fff;
  border: none; border-radius: 22px;
  padding: .55rem 1.5rem;
  font-size: .88rem; font-weight: 600;
  text-decoration: none;
  margin: .6rem 0 1.4rem;
  box-shadow: 0 3px 12px rgba(211,47,47,.3);
  transition: all .2s var(--ease);
  font-family: 'Inter', sans-serif;
}
.btn-pdf:hover {
  background: linear-gradient(135deg, #B71C1C, #C62828);
  text-decoration: none; color: #fff;
  box-shadow: 0 5px 18px rgba(183,28,28,.4);
  transform: translateY(-2px);
}
.btn-pdf svg { flex-shrink: 0; }

/* ────────────────────────────────────────────────
   Bouton retour
──────────────────────────────────────────────── */
.btn-back {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--primary);
  padding: .4rem 1rem; border-radius: 20px;
  font-size: .83rem; margin-bottom: 1.5rem;
  transition: all .2s var(--ease);
  font-weight: 500;
}
.btn-back:hover {
  background: var(--primary-light);
  text-decoration: none;
  transform: translateX(-2px);
}

/* ────────────────────────────────────────────────
   Navigation bas de page
──────────────────────────────────────────────── */
.chapter-nav {
  display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
  margin-top: 3rem; padding-top: 1.5rem;
  border-top: 2px solid var(--border);
}
.chapter-nav a {
  display: flex; align-items: center; gap: .5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: .75rem 1.4rem;
  border-radius: var(--radius);
  font-weight: 600; color: var(--primary);
  font-size: .88rem;
  transition: all .2s var(--ease);
  box-shadow: var(--shadow);
}
.chapter-nav a:hover {
  background: var(--primary-light);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ────────────────────────────────────────────────
   Footer
──────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-sec);
  font-size: .83rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ────────────────────────────────────────────────
   Back to top
──────────────────────────────────────────────── */
#back-top {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  font-size: 1.1rem; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 3px 14px rgba(21,101,192,.4);
  z-index: 500;
  transition: background .2s, transform .2s, opacity .3s;
  font-family: 'Inter', sans-serif;
}
#back-top.visible { display: flex; }
#back-top:hover {
  background: var(--primary-dark);
  transform: translateY(-3px);
}

/* ────────────────────────────────────────────────
   Tables
──────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th {
  background: var(--primary); color: #fff;
  padding: .65rem 1rem; text-align: left;
  font-size: .85rem; font-weight: 700;
  letter-spacing: .3px;
}
td { padding: .58rem 1rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
tr:nth-child(even) td { background: var(--primary-light); }
[data-theme="dark"] tr:nth-child(even) td { background: rgba(91,141,246,.08); }

/* ── Tableau de valeurs remarquables ── */
.tableau-valeurs {
  border-collapse: collapse;
  width: auto; min-width: 340px;
  margin: 1rem auto;
  font-size: .95rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.10);
  border-radius: var(--radius-sm); overflow: hidden;
}
.tableau-valeurs th, .tableau-valeurs td {
  border: 1.5px solid #9FA8DA;
  padding: .58rem .9rem;
  text-align: center; white-space: nowrap;
}
.tableau-valeurs thead th {
  background: #3F51B5; color: #fff;
  font-weight: 700; letter-spacing: .04em;
}
.tableau-valeurs tbody tr:first-child td  { background: #E8EAF6; color: #283593; font-weight: 600; }
.tableau-valeurs tbody tr:last-child  td  { background: #FCE4EC; color: #880E4F; font-weight: 600; }

/* ── Tableau de variations ── */
.tableau-variations { overflow-x: auto; margin: 1rem 0 1.5rem; }
.tableau-variations table {
  border-collapse: separate; border-spacing: 0;
  min-width: 360px; font-size: .95rem;
  background: var(--card-bg);
  border: 2px solid #1565C0;
  border-radius: var(--radius-sm); overflow: hidden;
  box-shadow: 0 2px 10px rgba(21,101,192,.12);
  margin: 0;
}
.tableau-variations th, .tableau-variations td {
  border: 1px solid #90CAF9;
  padding: .48rem .8rem;
  text-align: center; min-width: 58px;
}
.tableau-variations thead th {
  background: #1565C0; color: #fff;
  font-weight: 700; font-size: 1rem;
  border-bottom: 2px solid #0D47A1;
}
.tableau-variations tbody tr:nth-child(1) td { background: #F5F5F5; color: #555; font-size: .9rem; }
.tableau-variations tbody tr:nth-child(2) td { background: var(--card-bg); font-size: 1.15rem; font-weight: 700; }
.tableau-variations .max-val { color: #1565C0; font-weight: 800; }
.tableau-variations .min-val { color: #C62828; font-weight: 800; }
.tableau-variations .pos { color: #2E7D32; font-weight: 700; }
.tableau-variations .neg { color: #C62828; font-weight: 700; }

/* ── tkztab (LaTeX PNG) ── */
.tkztab-wrap { overflow-x: auto; margin: 1rem 0 1.8rem; }
.tkztab {
  border-collapse: collapse; font-size: .97rem;
  background: var(--card-bg);
  border: 2.5px solid #1565C0;
  border-radius: 7px; overflow: hidden;
  box-shadow: 0 3px 12px rgba(21,101,192,.16);
}
.tkztab td { border: 1px solid #90CAF9; text-align: center; min-width: 62px; padding: .1rem .55rem; }
.tkztab .col-label {
  background: #E3F2FD; color: #0D47A1;
  font-weight: 600; text-align: left;
  padding: .45rem 1rem !important;
  white-space: nowrap; font-size: .92rem;
  border-right: 2px solid #1565C0;
}
.tkztab .row-x td { background: #1565C0; color: #fff; font-weight: 700; padding: .5rem .55rem; border-color: #0D47A1; }
.tkztab .row-x .col-label { background: #0D47A1; }
.tkztab .row-sign td { background: #EEF6FF; height: 40px; font-size: 1.1rem; font-weight: 700; border-top: 2.5px solid #1565C0; border-bottom: 2.5px solid #1565C0; }
.tkztab .row-sign .col-label { background: #D4ECFF; }
.tkztab .row-sign .s-pos  { color: #2E7D32; }
.tkztab .row-sign .s-neg  { color: #C62828; }
.tkztab .row-sign .s-zero { color: #555; font-weight: 500; font-size: .88rem; }
.tkztab .row-var td { height: 74px; padding: 0; }
.tkztab .row-var .col-label { padding: .45rem 1rem !important; }
.tkztab .v-top { vertical-align: top; padding-top: 7px !important; color: #1565C0; font-weight: 800; font-size: 1.05rem; }
.tkztab .v-bot { vertical-align: bottom; padding-bottom: 7px !important; color: #C62828; font-weight: 800; font-size: 1.05rem; }
.tkztab .c-arr { padding: 0 !important; overflow: hidden; }
.tkztab .c-arr svg { display: block; width: 100%; height: 74px; min-width: 64px; }

/* ── GeoGebra ── */
.ggb-wrap {
  margin: 1.2rem 0 1.8rem;
  border-radius: var(--radius); overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  background: #fff;
}
.ggb-wrap iframe { display: block; width: 100%; border: none; min-height: 380px; }

/* ────────────────────────────────────────────────
   Python editor (chapitre 15)
──────────────────────────────────────────────── */
code.py {
  background: #1e1e2e; color: #a6e3a1;
  padding: .1em .4em; border-radius: 4px;
  font-size: .9em;
  font-family: 'Fira Code', 'Consolas', 'Courier New', monospace;
}

.py-code {
  display: block;
  width: 100%;
  min-height: 180px;
  margin: .75rem 0 0;
  padding: 1rem 1.1rem;
  resize: vertical;
  border: 1px solid #26324a;
  border-radius: var(--radius-sm);
  background: #111827;
  color: #d8f3dc;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), var(--shadow);
  font: 500 .92rem/1.55 'Fira Code', 'SFMono-Regular', Consolas, monospace;
  tab-size: 2;
  outline: none;
}
.py-code:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,101,192,.18), inset 0 1px 0 rgba(255,255,255,.04);
}

.btn-run {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  margin: .7rem 0 .55rem;
  padding: .48rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(21,101,192,.28);
  cursor: pointer;
  font: 700 .86rem/1 'Inter', system-ui, sans-serif;
  transition: background .2s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease);
}
.btn-run:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(21,101,192,.34);
}
.btn-run:active {
  transform: translateY(0);
}

.py-output {
  display: block;
  width: 100%;
  min-height: 90px;
  margin: .35rem 0 1.4rem;
  padding: .95rem 1.1rem;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid #203047;
  border-left: 4px solid #26a69a;
  border-radius: var(--radius-sm);
  background: #0b1220;
  color: #e5eefc;
  box-shadow: var(--shadow);
  font: 500 .9rem/1.55 'Fira Code', 'SFMono-Regular', Consolas, monospace;
}
.py-output:empty::before {
  content: "La sortie du programme apparaitra ici.";
  color: #8ba3c7;
  font-family: 'Inter', system-ui, sans-serif;
}
.py-output.error {
  border-left-color: var(--warn-bd);
  background: #fff1f2;
  color: var(--warn-tx);
}

[data-theme="dark"] .py-code {
  border-color: #334155;
  background: #020617;
}
[data-theme="dark"] .py-output {
  background: #020617;
  border-color: #263449;
  color: #dbeafe;
}
[data-theme="dark"] .py-output.error {
  background: #2a1010;
  color: #fecaca;
}

/* ────────────────────────────────────────────────
   Responsive — Mobile
──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .nav-links { display: none; position: absolute; }

  .navbar { flex-wrap: wrap; height: auto; padding: .75rem 1rem; }
  .navbar-actions { order: 2; }
  #nav-toggle { display: flex; order: 3; margin-left: .5rem; }

  /* Menu mobile déployé */
  .nav-links.open {
    display: flex;
    position: absolute;
    top: 58px; left: 0; right: 0;
    flex-direction: column;
    background: rgba(13,71,161,.98);
    backdrop-filter: blur(12px);
    padding: .8rem 1rem;
    gap: .2rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    z-index: 999;
    border-top: 1px solid rgba(255,255,255,.1);
  }
  .nav-links.open a {
    padding: .6rem .9rem;
    font-size: .9rem;
    border-radius: 8px;
  }

  .transition-hero {
    grid-template-columns: 1fr;
  }

  .transition-priority-grid,
  .transition-topic-grid {
    grid-template-columns: 1fr;
  }

  .course-columns {
    grid-template-columns: 1fr;
  }

  .solution-cases {
    grid-template-columns: 1fr;
  }

  .sequence-cases,
  .sequence-cases.three {
    grid-template-columns: 1fr;
  }

  .course-panel-header {
    align-items: flex-start;
  }

  .course-panel-header strong {
    margin-left: 0;
  }

  .transition-download {
    align-items: flex-start;
    flex-direction: column;
  }

  .transition-correction-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  h1 { font-size: 1.65rem; }
  .hero h1 { font-size: 2.1rem; }
  .chapter-header h1 { font-size: 1.8rem; }
  .chapter-header { padding: 2rem 1.5rem; }
  .page-wrapper { padding: 1.5rem 1rem 2rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 1.2rem; }
  .hero-stat strong { font-size: 1.6rem; }
  .chapter-nav { flex-direction: column; }
  .chapter-nav a { justify-content: center; }
  .transition-hero {
    padding: 1.5rem;
  }
  .transition-hero h1 {
    font-size: 2rem;
  }
  .transition-actions a {
    width: 100%;
  }
  .transition-topic-card summary {
    grid-template-columns: 2.35rem minmax(0, 1fr);
  }
  .transition-topic-card summary strong {
    grid-column: 2;
    justify-self: start;
  }
  .transition-course {
    padding-left: 1rem;
  }
}

/* ────────────────────────────────────────────────
   Print
──────────────────────────────────────────────── */
@media print {
  .navbar, .btn-back, #back-top, .chapter-nav,
  #reading-progress, #dark-toggle, #nav-toggle { display: none !important; }
  .corrige-content { display: block !important; }
  body { background: #fff; color: #000; }
  .chapter-header { box-shadow: none; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ────────────────────────────────────────────────
   Overrides Drupal — intégration thème Spé Maths
──────────────────────────────────────────────── */
#skip-link { display: none; }
.layout-container { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; }

/* Messages Drupal */
.messages--status { background: var(--cor-bg); border-left: 5px solid var(--cor-bd); color: var(--cor-tx); padding: .8rem 1.2rem; border-radius: var(--radius-sm); margin: 1rem 0; }
.messages--warning { background: var(--warn-bg); border-left: 5px solid var(--warn-bd); color: var(--warn-tx); padding: .8rem 1.2rem; border-radius: var(--radius-sm); margin: 1rem 0; }
.messages--error { background: var(--warn-bg); border-left: 5px solid var(--warn-bd); color: var(--warn-tx); padding: .8rem 1.2rem; border-radius: var(--radius-sm); margin: 1rem 0; }

/* Node article */
.node--type-chapitre .node__content { max-width: 1080px; margin: 0 auto; padding: 0 1.5rem 3rem; }
.node--type-page .node__content { max-width: 1080px; margin: 0 auto; padding: 0 1.5rem 3rem; }

/* Views liste chapitres */
.view-chapitres .view-content { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px,1fr)); gap: 1.5rem; margin-top: 1.5rem; }

/* Pager */
.pager { text-align: center; margin: 2rem 0; }
.pager__item a { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: var(--card-bg); border: 1px solid var(--border); color: var(--primary); font-weight: 600; margin: 0 2px; transition: all .2s; }
.pager__item--current a, .pager__item a:hover { background: var(--primary); color: #fff; text-decoration: none; }

/* Breadcrumb */
.breadcrumb { font-size: .82rem; padding: .5rem 0 1rem; color: var(--text-sec); }
.breadcrumb a { color: var(--primary); }

.page-exercices-applications .breadcrumb {
  display: none;
}

/* Admin toolbar override */
body.toolbar-fixed .navbar { top: 39px; }
body.toolbar-fixed.toolbar-tray-open .navbar { top: 79px; }

/* ── Navigation utilisateur ──────────────────────────────────────────────── */
.navbar { display: flex; align-items: center; gap: 1rem; }
.nav-user { display: flex; align-items: center; gap: .6rem; margin-left: auto; }

.nav-user-link {
  font-size: .875rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-connexion {
  display: inline-block;
  padding: .4rem 1rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--primary);
  color: #fff;
  transition: opacity .2s;
}
.btn-connexion:hover { opacity: .85; color: #fff; }

.btn-inscription {
  display: inline-block;
  padding: .4rem 1rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  transition: all .2s;
}
.btn-inscription:hover { background: var(--primary); color: #fff; }

.btn-deconnexion {
  background: #e53935;
}
.btn-deconnexion:hover { background: #c62828; opacity: 1; }

/* Formulaires connexion / inscription */
.page-user-login .layout-container main,
.page-user-register .layout-container main {
  max-width: 440px;
  margin: 3rem auto;
  padding: 0 1rem;
}

/* ── Programme officiel (BO) sections ────────────────────────────────────── */
.programme-bo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 1.5rem 0 2rem;
}
@media (max-width: 680px) {
  .programme-bo { grid-template-columns: 1fr; }
}

.programme-bo-capacites,
.programme-bo-demos {
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.programme-bo-capacites {
  background: #fff7ed;
  border: 2px solid #f97316;
}

.programme-bo-demos {
  background: #f0faf8;
  border: 2px solid #0f766e;
}

.programme-bo-capacites h3 {
  color: #c2410c;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 .75rem;
  font-weight: 700;
}

.programme-bo-demos h3 {
  color: #0f766e;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 .75rem;
  font-weight: 700;
}

.programme-bo-capacites ul,
.programme-bo-demos ul {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
}

.programme-bo-capacites li,
.programme-bo-demos li {
  margin-bottom: .4rem;
  line-height: 1.55;
  font-size: .92rem;
}

.programme-bo-demos--none {
  opacity: .75;
}
.programme-bo-none {
  font-style: italic;
  font-size: .88rem;
  color: #374151;
  margin: 0;
}

/* ── En-tête de la section BO avec liens ─────────────────────────────────── */
.programme-bo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px 6px 0 0;
  padding: .6rem 1rem;
  margin-bottom: -.25rem;
  font-size: .82rem;
}

.programme-bo-label {
  font-weight: 600;
  color: #334155;
  letter-spacing: .01em;
}

.programme-bo-links {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.programme-bo-link {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .65rem;
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 500;
  text-decoration: none;
  background: #fff;
  border: 1px solid #94a3b8;
  color: #0f172a;
  transition: background .15s, border-color .15s;
}
.programme-bo-link:hover {
  background: #e2e8f0;
  border-color: #64748b;
  text-decoration: none;
}
.programme-bo-link--ext {
  border-color: #0284c7;
  color: #0284c7;
}
.programme-bo-link--ext:hover {
  background: #e0f2fe;
}

/* ── Bloc algorithmes BO ──────────────────────────────────────────────────── */
.programme-bo-algos {
  background: #f5f3ff;
  border: 2px solid #7c3aed;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: .5rem;
  grid-column: 1 / -1;   /* pleine largeur sous les deux blocs */
}

.programme-bo-algos h3 {
  color: #5b21b6;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 .75rem;
  font-weight: 700;
}

.programme-bo-algos ul {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
  display: flex;
  flex-wrap: wrap;
  gap: .2rem 2rem;
}

.programme-bo-algos li {
  margin-bottom: .3rem;
  line-height: 1.55;
  font-size: .92rem;
  min-width: 220px;
}

/* grille 3 colonnes pour les blocs BO quand algos présent */
.programme-bo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 0 0 2rem;
}

/* ============================================================
   SECTIONS DÉMONSTRATIONS & ALGORITHMES
   ============================================================ */

/* ── En-têtes de section ─────────────────────────────────── */
section#demonstrations,
section#algorithmes {
  margin: 2.5rem 0 1rem;
  padding: 0;
}

section#demonstrations > h2,
section#algorithmes > h2 {
  font-size: 1.35rem;
  font-weight: 800;
  padding-bottom: 0.45rem;
  margin-bottom: 0.4rem;
  border-bottom: 3px solid;
}

section#demonstrations > h2 { border-color: #0f766e; color: #0f766e; }
section#algorithmes > h2    { border-color: #7c3aed; color: #7c3aed; }

.section-intro {
  color: #64748b;
  font-style: italic;
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

/* ── Boîte démonstration ─────────────────────────────────── */
.demonstration {
  border: 1px solid #0d9488;
  border-left: 4px solid #0f766e;
  border-radius: 7px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(15,118,110,.1);
}

.demonstration > h3 {
  background: #0f766e;
  color: #fff;
  margin: 0;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.demo-enonce {
  background: #f0fdfa;
  border-bottom: 1px solid #99f6e4;
  padding: 0.75rem 1rem;
}

.demo-preuve {
  background: #fff;
  padding: 0.75rem 1rem;
}

.demo-label {
  display: inline-block;
  background: #0d9488;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.1rem 0.55rem;
  border-radius: 3px;
  margin-bottom: 0.45rem;
  vertical-align: middle;
}

.demo-label--proof { background: #059669; }

.demo-enonce p,  .demo-preuve p,
.demo-enonce ul, .demo-preuve ul,
.demo-enonce ol, .demo-preuve ol {
  margin: 0.4rem 0;
  line-height: 1.75;
}

.demo-enonce ul, .demo-preuve ul,
.demo-enonce ol, .demo-preuve ol {
  padding-left: 1.4rem;
}

/* ── Boîte algorithme ────────────────────────────────────── */
.algorithme {
  border: 1px solid #a78bfa;
  border-left: 4px solid #7c3aed;
  border-radius: 7px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(124,58,237,.1);
}

.algorithme > h3 {
  background: #7c3aed;
  color: #fff;
  margin: 0;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.algorithme > p {
  background: #faf5ff;
  color: #4c1d95;
  margin: 0;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid #ddd6fe;
  line-height: 1.6;
}

/* ── Bloc de code Python ─────────────────────────────────── */
.algo-code {
  background: #1e1b2e;
  color: #e2e8f0;
  margin: 0;
  padding: 1rem 1.2rem;
  font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: 0.83rem;
  line-height: 1.65;
  overflow-x: auto;
  border-radius: 0 0 5px 5px;
  tab-size: 4;
  -moz-tab-size: 4;
}

.algo-code code {
  background: none;
  color: inherit;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  white-space: pre;
}

/* ── Animations algo ─────────────────────────────────────── */
.algo-anim {
  background: #0f172a;
  border-top: 1px solid #1e293b;
  padding: 0.75rem 1rem 0.5rem;
}
.anim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.anim-title {
  color: #64748b;
  font-size: 0.78rem;
  font-family: 'Fira Code', monospace;
  letter-spacing: 0.03em;
}
.anim-btns { display: flex; gap: 0.4rem; }
.anim-canvas {
  display: block;
  width: 100%;
  border-radius: 4px;
  background: #0f172a;
}
.anim-info {
  color: #475569;
  font-size: 0.75rem;
  font-family: 'Fira Code', monospace;
  text-align: center;
  margin-top: 0.4rem;
  min-height: 1.2em;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .demo-enonce,
  .demo-preuve,
  .algorithme > p {
    padding: 0.6rem 0.75rem;
  }
  .algo-code {
    font-size: 0.78rem;
    padding: 0.75rem;
  }
}

/* ── Région highlighted (messages flash Drupal) ───────────── */
.highlighted {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Masquer les onglets de navigation dans highlighted (local tasks) */
.highlighted #block-spemath-primary-local-tasks {
  display: none;
}

/* Messages de statut */
.highlighted .messages {
  margin: 1rem 0 0;
  padding: .85rem 1.2rem .85rem 1rem;
  border-radius: 8px;
  border-left: 4px solid;
  font-size: .95rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}

.highlighted .messages--status {
  background: #f0fdf4;
  border-color: #16a34a;
  color: #15803d;
}

.highlighted .messages--warning {
  background: #fffbeb;
  border-color: #d97706;
  color: #92400e;
}

.highlighted .messages--error {
  background: #fef2f2;
  border-color: #dc2626;
  color: #991b1b;
}

.highlighted .messages__list {
  margin: 0; padding: 0; list-style: none;
}

/* Icônes automatiques */
.highlighted .messages--status::before { content: '✓ '; font-weight: 700; }
.highlighted .messages--warning::before { content: '⚠ '; font-weight: 700; }
.highlighted .messages--error::before   { content: '✕ '; font-weight: 700; }

/* ═══════════════════════════════════════════════════════════════════════
   PAGE CONTACT
   ═══════════════════════════════════════════════════════════════════════ */

.contact-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.contact-hero {
  text-align: center;
  padding: 2.5rem 1rem 2rem;
}
.contact-hero-icon { font-size: 3rem; margin-bottom: .75rem; }
.contact-hero h1   { font-size: 2rem; font-weight: 800; margin: 0 0 .5rem; color: var(--text); }
.contact-hero p    { font-size: 1.05rem; color: var(--text-sec); max-width: 520px; margin: 0 auto; }

.contact-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
  margin-top: 2rem;
}
@media (max-width: 720px) {
  .contact-layout { grid-template-columns: 1fr; }
}

.contact-card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
  border: 1px solid var(--border);
}
.contact-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  color: var(--text);
}

/* ── Formulaire Drupal stylisé ── */
.spemath-contact-form .form-item {
  margin-bottom: 1.25rem;
}
.spemath-contact-form label {
  display: block;
  font-size: .87rem;
  font-weight: 650;
  color: var(--text);
  margin-bottom: .4rem;
}
.spemath-contact-form input[type="text"],
.spemath-contact-form input[type="email"],
.spemath-contact-form select,
.spemath-contact-form textarea {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color .18s, box-shadow .18s;
  box-sizing: border-box;
}
.spemath-contact-form input:focus,
.spemath-contact-form select:focus,
.spemath-contact-form textarea:focus {
  outline: none;
  border-color: #1565C0;
  box-shadow: 0 0 0 3px rgba(21,101,192,.1);
}
.spemath-contact-form textarea { resize: vertical; min-height: 130px; }
.spemath-contact-form .form-required { color: #e53935; margin-left: 2px; }

.btn-contact-submit,
.spemath-contact-form [type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: .8rem 1.5rem;
  background: linear-gradient(135deg, #1565C0, #0d47a1);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .18s, transform .12s, box-shadow .18s;
  box-shadow: 0 4px 14px rgba(21,101,192,.3);
  margin-top: .5rem;
}
.btn-contact-submit:hover,
.spemath-contact-form [type="submit"]:hover {
  opacity: .92;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(21,101,192,.38);
}

/* ── Barre latérale ── */
.contact-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.contact-info-block {
  display: flex;
  gap: .85rem;
  align-items: flex-start;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
}
.contact-info-icon { font-size: 1.5rem; flex-shrink: 0; margin-top: .1rem; }
.contact-info-block strong { display: block; font-size: .92rem; font-weight: 700; color: var(--text); margin-bottom: .2rem; }
.contact-info-block p { font-size: .82rem; color: var(--text-sec); margin: 0 0 .4rem; line-height: 1.5; }
.contact-faq-link {
  font-size: .82rem;
  font-weight: 650;
  color: #1565C0;
  text-decoration: none;
}
.contact-faq-link:hover { text-decoration: underline; }

/* footer links */
.footer-links { margin-top: .4rem; }
.footer-links a { color: rgba(255,255,255,.65); text-decoration: none; }
.footer-links a:hover { color: #fff; }

/* ═══════════════════════════════════════════════════════════════════════
   PAGE FAQ
   ═══════════════════════════════════════════════════════════════════════ */

.faq-page {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.faq-hero {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}
.faq-hero h1 { font-size: 2rem; font-weight: 800; margin: 0 0 .5rem; color: var(--text); }
.faq-hero p  { font-size: 1.05rem; color: var(--text-sec); }

/* ── Filtres catégories ── */
.faq-categories {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  justify-content: center;
  margin-bottom: 1.75rem;
}
.faq-cat {
  padding: .42rem 1rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-sec);
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.faq-cat:hover   { border-color: #1565C0; color: #1565C0; }
.faq-cat.active  { background: #1565C0; color: #fff; border-color: #1565C0; }

/* ── Items accordéon ── */
.faq-list { display: flex; flex-direction: column; gap: .6rem; }

.faq-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow .18s;
}
.faq-item:has([aria-expanded="true"]) {
  box-shadow: 0 4px 18px rgba(21,101,192,.1);
  border-color: rgba(21,101,192,.3);
}

.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .97rem;
  font-weight: 650;
  color: var(--text);
  text-align: left;
}
.faq-question:hover { color: #1565C0; }
.faq-question[aria-expanded="true"] { color: #1565C0; }

.faq-chevron {
  width: 20px; height: 20px;
  flex-shrink: 0;
  color: #aaa;
  transition: transform .22s ease;
}
.faq-question[aria-expanded="true"] .faq-chevron {
  transform: rotate(180deg);
  color: #1565C0;
}

.faq-answer {
  padding: 0 1.25rem 1.15rem;
  font-size: .9rem;
  color: var(--text-sec);
  line-height: 1.7;
}
.faq-answer p  { margin: 0 0 .6rem; }
.faq-answer ul { padding-left: 1.2rem; margin: .3rem 0 .6rem; }
.faq-answer li { margin-bottom: .25rem; }
.faq-answer a  { color: #1565C0; font-weight: 650; }
.faq-answer strong { color: var(--text); }

/* ── CTA bas de page ── */
.faq-cta {
  text-align: center;
  margin-top: 2.5rem;
  padding: 2rem;
  background: linear-gradient(135deg, #e8f0fe, #f0f4ff);
  border-radius: 18px;
}
.faq-cta p { font-size: 1rem; color: var(--text-sec); margin: 0 0 1rem; }
.faq-cta-btn {
  display: inline-flex;
  align-items: center;
  padding: .65rem 1.5rem;
  background: #1565C0;
  color: #fff;
  border-radius: 12px;
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
  transition: opacity .18s, transform .12s;
  box-shadow: 0 4px 14px rgba(21,101,192,.28);
}
.faq-cta-btn:hover { opacity: .9; transform: translateY(-1px); color: #fff; }

/* ── Modale de confirmation OCR ─────────────────────────────────────────── */
#ocr-confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  animation: fadeInOverlay .15s ease;
}
@keyframes fadeInOverlay { from { opacity: 0 } to { opacity: 1 } }

.ocr-modal-box {
  background: var(--surface, #fff);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 620px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUpModal .2s ease;
}
@keyframes slideUpModal { from { transform: translateY(24px); opacity: 0 } to { transform: none; opacity: 1 } }

.ocr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem .8rem;
  border-bottom: 1px solid var(--border, #e5e9f0);
}
.ocr-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #1a1a2e);
}
.ocr-modal-title em {
  color: var(--accent, #1565C0);
  font-style: normal;
}
.ocr-modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-sec, #666);
  padding: .2rem .4rem;
  border-radius: 6px;
  line-height: 1;
  transition: background .15s;
}
.ocr-modal-close:hover { background: var(--surface2, #f0f4ff); }

.ocr-modal-hint {
  font-size: .85rem;
  color: var(--text-sec, #666);
  margin: .7rem 1.4rem .3rem;
}

.ocr-modal-textarea {
  flex: 1;
  margin: 0 1rem .8rem;
  padding: .9rem 1rem;
  border: 1.5px solid var(--border, #dde3ee);
  border-radius: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .82rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 180px;
  max-height: 340px;
  background: var(--surface2, #f8faff);
  color: var(--text, #1a1a2e);
  transition: border-color .2s;
}
.ocr-modal-textarea:focus {
  outline: none;
  border-color: var(--accent, #1565C0);
  background: #fff;
}

.ocr-modal-actions {
  display: flex;
  gap: .7rem;
  justify-content: flex-end;
  padding: .8rem 1.2rem 1.2rem;
  border-top: 1px solid var(--border, #e5e9f0);
}
.ocr-modal-cancel {
  padding: .55rem 1.2rem;
  border: 1.5px solid var(--border, #dde3ee);
  border-radius: 10px;
  background: none;
  color: var(--text-sec, #666);
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s;
}
.ocr-modal-cancel:hover { background: var(--surface2, #f0f4ff); }

.ocr-modal-confirm {
  padding: .55rem 1.4rem;
  border: none;
  border-radius: 10px;
  background: var(--accent, #1565C0);
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  box-shadow: 0 4px 14px rgba(21,101,192,.3);
}
.ocr-modal-confirm:hover { opacity: .88; transform: translateY(-1px); }

[data-theme="dark"] .ocr-modal-box { background: #1e2235; }
[data-theme="dark"] .ocr-modal-textarea { background: #161929; color: #e8eaf6; border-color: #333a55; }
[data-theme="dark"] .ocr-modal-textarea:focus { background: #1a1f35; border-color: #5c8df6; }

@media (max-width: 600px) {
  .ocr-modal-box { border-radius: 14px 14px 0 0; max-height: 90vh; align-self: flex-end; }
  #ocr-confirm-modal { align-items: flex-end; padding: 0; }
}

/* ── Modale de choix de scan (webcam / QR) ──────────────────────────────── */
#scan-choice-modal, #qr-scan-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.52);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  animation: fadeInOverlay .15s ease;
}
.scan-choice-box, .qr-modal-box {
  background: var(--surface, #fff);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  width: 100%;
  max-width: 480px;
  animation: slideUpModal .2s ease;
  overflow: hidden;
}
.scan-choice-header, .qr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem .9rem;
  border-bottom: 1px solid var(--border, #e5e9f0);
}
.scan-choice-title, .qr-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #1a1a2e);
}
.scan-choice-close, .qr-modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-sec, #666);
  padding: .2rem .4rem;
  border-radius: 6px;
  transition: background .15s;
}
.scan-choice-close:hover, .qr-modal-close:hover { background: var(--surface2, #f0f4ff); }

.scan-choice-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.2rem;
}
.scan-choice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 1.3rem 1rem;
  border: 2px solid var(--border, #dde3ee);
  border-radius: 14px;
  background: var(--surface2, #f8faff);
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .1s;
  text-align: center;
}
.scan-choice-btn:hover {
  border-color: var(--accent, #1565C0);
  background: #eef4ff;
  transform: translateY(-2px);
}
.scan-choice-icon { font-size: 2rem; line-height: 1; }
.scan-choice-btn strong { font-size: .95rem; color: var(--text, #1a1a2e); }
.scan-choice-btn span { font-size: .78rem; color: var(--text-sec, #666); line-height: 1.3; }

/* QR code modal */
.qr-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.4rem 1.2rem 1.6rem;
  text-align: center;
}
.qr-modal-img {
  border-radius: 12px;
  border: 3px solid var(--accent, #1565C0);
  display: block;
}
.qr-modal-hint {
  font-size: .87rem;
  color: var(--text-sec, #555);
  line-height: 1.7;
  margin: 0;
}
.qr-modal-status {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-sec, #555);
  margin: 0;
}

[data-theme="dark"] .scan-choice-box,
[data-theme="dark"] .qr-modal-box { background: #1e2235; }
[data-theme="dark"] .scan-choice-btn { background: #161929; border-color: #333a55; }
[data-theme="dark"] .scan-choice-btn:hover { background: #1a1f35; border-color: #5c8df6; }

@media (max-width: 480px) {
  .scan-choice-options { grid-template-columns: 1fr; }
  .scan-choice-box, .qr-modal-box { border-radius: 14px 14px 0 0; align-self: flex-end; }
  #scan-choice-modal, #qr-scan-modal { align-items: flex-end; padding: 0; }
}

/* ── Outil de recadrage graphique ───────────────────────────────────────── */
#crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
  animation: fadeInOverlay .15s ease;
}
.crop-box {
  background: var(--surface, #fff);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow: hidden;
  animation: slideUpModal .18s ease;
}
.crop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.2rem;
  border-bottom: 1px solid var(--border, #e5e9f0);
  flex-shrink: 0;
}
.crop-title { font-weight: 700; font-size: .95rem; color: var(--text, #1a1a2e); }
.crop-header-actions { display: flex; align-items: center; gap: .6rem; }
.crop-btn-reset {
  font-size: .78rem;
  padding: .3rem .8rem;
  border: 1.5px solid var(--border, #dde3ee);
  border-radius: 8px;
  background: none;
  color: var(--text-sec, #555);
  cursor: pointer;
  transition: background .15s;
}
.crop-btn-reset:hover { background: var(--surface2, #f0f4ff); }
.crop-close {
  background: none; border: none; font-size: 1rem;
  cursor: pointer; color: var(--text-sec, #666);
  padding: .2rem .4rem; border-radius: 6px;
  transition: background .15s;
}
.crop-close:hover { background: var(--surface2, #f0f4ff); }

.crop-canvas-wrap {
  position: relative;
  overflow: auto;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  padding: 16px;
  min-height: 0;
}
#crop-canvas {
  display: block;
  border-radius: 4px;
  user-select: none;
  -webkit-user-select: none;
}
.crop-canvas-container {
  position: relative;
  display: inline-block;
  line-height: 0;
}
#crop-overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  touch-action: none;
}
.crop-hint-text {
  text-align: center;
  font-size: .8rem;
  color: var(--text-sec, #666);
  margin: .5rem 0 0;
  padding: 0 1rem;
  flex-shrink: 0;
}
.crop-hint-text strong { color: #3b82f6; }

.crop-footer {
  display: flex;
  gap: .7rem;
  justify-content: flex-end;
  padding: .9rem 1.2rem;
  border-top: 1px solid var(--border, #e5e9f0);
  flex-shrink: 0;
}
.crop-btn-cancel {
  padding: .55rem 1.1rem;
  border: 1.5px solid var(--border, #dde3ee);
  border-radius: 10px;
  background: none;
  color: var(--text-sec, #666);
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s;
}
.crop-btn-cancel:hover { background: var(--surface2, #f0f4ff); }
.crop-btn-confirm {
  padding: .55rem 1.4rem;
  border: none;
  border-radius: 10px;
  background: var(--accent, #1565C0);
  color: #fff;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(21,101,192,.3);
  transition: opacity .15s, transform .1s;
}
.crop-btn-confirm:hover { opacity: .88; transform: translateY(-1px); }

[data-theme="dark"] .crop-box { background: #1e2235; }
[data-theme="dark"] .crop-canvas-wrap { background: #0a0c14; }

@media (max-width: 600px) {
  .crop-box { border-radius: 14px 14px 0 0; max-height: 95vh; align-self: flex-end; }
  #crop-modal { align-items: flex-end; padding: 0; }
  .crop-canvas-wrap { padding: 8px; }
}

/* ── Bouton Indice dans les exercices ───────────────────────────────── */
.btn-application-hint {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .35rem .75rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  transition: opacity .15s, transform .1s;
}
.btn-application-hint:hover:not(:disabled) { opacity: .88; transform: translateY(-1px); }
.btn-application-hint:disabled { opacity: .5; cursor: not-allowed; }
.btn-application-hint.active { filter: brightness(.88); box-shadow: inset 0 2px 5px rgba(0,0,0,.2); }

/* ── Panneau d'indice ───────────────────────────────────────────────── */
.application-hint-panel {
  margin-top: .9rem;
  border-left: 4px solid #f59e0b;
  border-radius: 0 10px 10px 0;
  background: #fffbeb;
  padding: .85rem 1rem;
  font-size: .88rem;
  line-height: 1.6;
  animation: fadeInOverlay .2s ease;
}
.hint-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .5rem;
  font-size: .9rem;
}
.hint-icon { font-size: 1.1rem; }
.hint-header strong { flex: 1; }
.hint-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #9a7a1a;
  font-size: .85rem;
  padding: .15rem .35rem;
  border-radius: 4px;
  transition: background .12s;
}
.hint-close:hover { background: rgba(0,0,0,.07); }
.hint-body { color: #44330a; }
.hint-loading { color: #92680a; font-style: italic; }
.hint-error { color: #b45309; }

[data-theme="dark"] .application-hint-panel {
  background: #2d2410;
  border-color: #d97706;
}
[data-theme="dark"] .hint-body { color: #fde68a; }
[data-theme="dark"] .hint-loading,
[data-theme="dark"] .hint-error { color: #fbbf24; }

/* ── Bouton Tuteur IA ─────────────────────────────────────────────────── */
.btn-application-tutor {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .35rem .75rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  transition: opacity .15s, transform .15s, box-shadow .15s;
}
.btn-application-tutor:hover { opacity: .88; transform: translateY(-1px); }
.btn-application-tutor.active {
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .35);
  filter: brightness(.9);
}

/* ── Tiroir Tuteur IA ─────────────────────────────────────────────────── */
.application-tutor-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 46vw;
  min-width: 360px;
  max-width: 700px;
  height: 100vh;
  background: #fff;
  box-shadow: -6px 0 32px rgba(0, 0, 0, .16);
  z-index: 9100;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 10px));
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}
.application-tutor-drawer.open {
  transform: translateX(0);
}
.application-tutor-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  flex-shrink: 0;
  gap: .5rem;
}
.tutor-drawer-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tutor-drawer-title {
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
}
.tutor-drawer-exercise-label {
  font-size: .72rem;
  opacity: .82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.tutor-drawer-close {
  background: rgba(255, 255, 255, .15);
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  padding: .3rem .55rem;
  border-radius: 6px;
  line-height: 1;
  flex-shrink: 0;
  transition: background .15s;
}
.tutor-drawer-close:hover { background: rgba(255, 255, 255, .28); }
.application-tutor-iframe {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
}

/* Mobile : tiroir depuis le bas */
@media (max-width: 680px) {
  .application-tutor-drawer {
    width: 100vw;
    max-width: none;
    top: auto;
    bottom: 0;
    right: 0;
    height: 88vh;
    transform: translateY(calc(100% + 10px));
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 32px rgba(0, 0, 0, .18);
  }
  .application-tutor-drawer.open {
    transform: translateY(0);
  }
}

[data-theme="dark"] .application-tutor-drawer {
  background: #1e1e2e;
  box-shadow: -6px 0 32px rgba(0, 0, 0, .5);
}

/* ============================================================
   REDESIGN ÉDITEUR — nouveau design (2025)
   ============================================================ */

/* Toggle button — style rectangle avec icône */
.application-open-editor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: 12px !important;
  font-size: .92rem !important;
  padding: .75rem 1.2rem !important;
  letter-spacing: .01em;
}

/* Labels de section */
.application-section-label {
  padding: .7rem .95rem .35rem;
  color: #1E3A5F;
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: #fff;
}

/* ── Suivi de compétence ── */
.exercise-assessment {
  border: 0 !important;
  border-bottom: 1px solid #E9EAF0 !important;
  margin: 0 !important;
  padding: .7rem .95rem .9rem !important;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.exercise-assessment legend {
  width: 100%;
  margin-bottom: .6rem;
  color: #1E3A5F;
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: .35rem;
}

.exercise-assessment legend::after {
  content: 'ℹ';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1.5px solid #94A3B8;
  border-radius: 50%;
  color: #94A3B8;
  font-size: .65rem;
  font-style: normal;
  cursor: help;
}

/* Les labels d'option en grille 3 colonnes */
.exercise-assessment .assessment-option {
  flex: 0 0 auto;
}

.exercise-assessment {
  flex-direction: row !important;
  flex-wrap: nowrap;
  gap: .55rem;
}

.assessment-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1rem !important;
  border-radius: 12px !important;
  min-height: 48px !important;
  font-size: .82rem !important;
  font-weight: 700 !important;
  white-space: nowrap;
  transition: all .14s ease;
}

.assessment-option.acquired span { background: #DCFCE7; color: #166534; border: 1.5px solid #86EFAC; }
.assessment-option.progress span { background: #FEF3C7; color: #92400E; border: 1.5px solid #FCD34D; }
.assessment-option.missing  span { background: #FEE2E2; color: #991B1B; border: 1.5px solid #FCA5A5; }

.assessment-option.acquired  input:checked + span { background: #16A34A; color: #fff; border-color: #16A34A; box-shadow: 0 0 0 3px rgba(22,163,74,.2); transform: translateY(-1px); }
.assessment-option.progress  input:checked + span { background: #D97706; color: #fff; border-color: #D97706; box-shadow: 0 0 0 3px rgba(217,119,6,.2);  transform: translateY(-1px); }
.assessment-option.missing   input:checked + span { background: #DC2626; color: #fff; border-color: #DC2626; box-shadow: 0 0 0 3px rgba(220,38,38,.2);   transform: translateY(-1px); }

/* Icônes via ::before */
.assessment-option.acquired  span::before { content: '✓'; font-weight: 900; }
.assessment-option.progress  span::before { content: '⏳'; font-size: .85em; }
.assessment-option.missing   span::before { content: '✕'; font-weight: 900; }

/* ── Zone de réponse ── */
.application-answer {
  border-bottom: 1px solid #E9EAF0;
  min-height: 160px !important;
}

/* ── Barre d'outils mathématiques redesignée ── */
.application-symbol-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: .28rem;
  overflow-x: auto;
  padding: .55rem .75rem .5rem !important;
  background: #fff;
  border-bottom: 1px solid #E9EAF0 !important;
  scrollbar-width: none;
}
.application-symbol-tabs::-webkit-scrollbar { display: none; }

.application-symbol-tab {
  flex-shrink: 0;
  border: 1.5px solid #E2E8F0 !important;
  border-radius: 8px !important;
  background: #fff !important;
  color: #64748B !important;
  font-size: .76rem !important;
  font-weight: 700 !important;
  padding: .32rem .62rem !important;
  margin-right: 0 !important;
  transition: border-color .12s, background .12s, color .12s;
}
.application-symbol-tab:hover {
  border-color: #6C63FF !important;
  transform: none !important;
  background: #F5F3FF !important;
  color: #4F46E5 !important;
}
.application-symbol-tab.active {
  border-color: #4F46E5 !important;
  background: #4F46E5 !important;
  color: #fff !important;
}

/* ── Tuteur IA : clavier math compact ──────────────────────────────────── */
.application-correction[data-tutor-mode="1"] .application-editor-toolbar {
  overflow: hidden;
}

.application-correction[data-tutor-mode="1"] .application-symbol-panel {
  gap: .45rem;
  max-height: 220px;
  overflow-y: auto;
  padding: .55rem .6rem .65rem !important;
}

.application-correction[data-tutor-mode="1"] .application-toolbar-quick.application-symbol-grid,
.application-correction[data-tutor-mode="1"] .application-symbol-grid {
  grid-template-columns: repeat(auto-fill, minmax(54px, 68px)) !important;
  justify-content: start;
  align-items: stretch;
  gap: .32rem !important;
}

.application-correction[data-tutor-mode="1"] .application-key {
  width: auto !important;
  min-width: 0 !important;
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  padding: 0 .35rem !important;
  font-size: .78rem !important;
  line-height: 1 !important;
  white-space: nowrap;
}

.application-correction[data-tutor-mode="1"] .application-formula-open {
  grid-column: span 2;
}

.application-correction[data-tutor-mode="1"] .application-answer {
  min-height: 120px !important;
  max-height: 220px;
}

/* Panel de symboles — toujours visible quand ouvert */
.application-symbol-panel--open,
.application-symbol-panel--open[hidden] {
  display: grid !important;
}

/* ── Section Documents joints ── */
.application-docs-section {
  border-top: 1px solid #E9EAF0;
  background: #fff;
  padding-bottom: .9rem;
}

.application-docs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .45rem;
  padding: .4rem .9rem 0;
}

@media (max-width: 680px) {
  .application-docs-grid { grid-template-columns: 1fr; }
}

.application-doc-btn {
  display: flex !important;
  align-items: center;
  gap: .55rem;
  padding: .65rem .7rem !important;
  border: 1.5px solid #E2E8F0 !important;
  border-radius: 12px !important;
  background: #FAFBFF !important;
  color: #334155 !important;
  cursor: pointer;
  font-family: Inter, sans-serif;
  text-align: left;
  min-height: auto !important;
  transition: border-color .12s, background .12s;
}
.application-doc-btn:hover {
  border-color: #6C63FF !important;
  background: #F0EDFF !important;
}

.doc-btn-icon { font-size: 1.15rem; flex-shrink: 0; }

.doc-btn-body {
  display: flex;
  flex-direction: column;
  gap: .08rem;
}
.doc-btn-body strong { color: #1E293B; font-size: .8rem; font-weight: 750; display: block; }
.doc-btn-body small  { color: #94A3B8; font-size: .72rem; font-weight: 500; }

.application-docs-formats {
  padding: .45rem .9rem 0;
  color: #94A3B8;
  font-size: .72rem;
  margin: 0;
  line-height: 1.4;
}

/* ── Barre du bas redesignée ── */
.application-bottom-bar {
  border-top: 1px solid #E9EAF0 !important;
  background: #F8F9FF !important;
  padding: .6rem .9rem !important;
}

/* Bouton Effacer tout */
.application-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border: 0;
  background: transparent;
  color: #EF4444;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: .82rem;
  font-weight: 750;
  padding: .3rem .5rem;
  border-radius: 8px;
  transition: background .12s;
}
.application-clear-btn:hover { background: #FEE2E2; }

/* Bouton envoyer — vert */
.application-send-btn:not(:disabled) {
  background: #16A34A !important;
  color: #fff !important;
}
.application-send-btn:not(:disabled):hover {
  background: #15803D !important;
}

/* Bouton Corriger exercice — vert (primary action) */
.btn-application-correction:not(:disabled) {
  background: #16A34A !important;
  border: 0 !important;
}
.btn-application-correction:not(:disabled):hover {
  background: #15803D !important;
}

/* ── Layout 2 colonnes : éditeur + sidebar ── */
.application-editor-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 276px;
  gap: 1.1rem;
  align-items: start;
}

@media (max-width: 960px) {
  .application-editor-with-sidebar {
    grid-template-columns: 1fr;
  }
  .application-editor-sidebar { display: none; }
}

.application-editor-main {
  min-width: 0;
}

/* ── Sidebar ── */
.application-editor-sidebar {
  display: grid;
  gap: .85rem;
  position: sticky;
  top: 1rem;
}

.editor-sidebar-card {
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  background: #fff;
  padding: .85rem .95rem;
}

.editor-sidebar-card-label {
  color: #1E3A5F;
  font-size: .67rem;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: .5rem;
}

.editor-sidebar-hint {
  color: #64748B;
  font-size: .8rem;
  margin: 0 0 .7rem;
  line-height: 1.5;
}

.editor-sidebar-symbols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .3rem;
}

.editor-symbol-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  background: #F8F9FF;
  font-size: .95rem;
  cursor: default;
  padding: .3rem;
}

.editor-shortcuts { display: grid; gap: .5rem; margin-top: .1rem; }

.editor-shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
}

.shortcut-keys { display: flex; align-items: center; gap: .18rem; }

.shortcut-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  border: 1px solid #CBD5E1;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #F1F5F9;
  color: #334155;
  font-family: Inter, sans-serif;
  font-size: .72rem;
  font-weight: 750;
  padding: 0 .35rem;
}

.editor-shortcut > span:last-child { color: #475569; }

.editor-sidebar-btn {
  width: 100%;
  margin-top: .75rem;
  border: 1.5px solid #E2E8F0;
  border-radius: 8px;
  background: #fff;
  color: #4F46E5;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: .78rem;
  font-weight: 750;
  padding: .45rem .7rem;
  text-align: center;
  transition: background .12s;
}
.editor-sidebar-btn:hover { background: #F5F3FF; }

/* ============================================================
   UTSPE Dashboard shell
   ============================================================ */
.ut-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  background:
    radial-gradient(circle at 15% 8%, rgba(99, 102, 241, .08), transparent 28%),
    linear-gradient(180deg, #fbfcff 0%, #f6f8fc 100%);
  color: #071436;
}

.ut-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  overflow-y: auto;
  padding: 1.45rem 1rem;
  background: linear-gradient(180deg, #081c3d 0%, #0a2447 45%, #09203d 100%);
  color: #fff;
  box-shadow: 12px 0 36px rgba(8, 28, 61, .18);
}

.ut-brand {
  display: flex;
  align-items: center;
  gap: .85rem;
  color: #fff;
  text-decoration: none;
  padding: 0 .35rem .8rem;
}

.ut-brand:hover { text-decoration: none; }

.ut-brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: conic-gradient(from 110deg, #7c4dff, #38bdf8, #7c4dff);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 22px rgba(99, 102, 241, .35);
}

.ut-brand strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: .03em;
}

.ut-brand small {
  display: block;
  margin-top: .2rem;
  color: rgba(255,255,255,.82);
  font-size: .82rem;
  font-weight: 700;
}

.ut-nav {
  display: grid;
  gap: .38rem;
}

.ut-nav a {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: .9rem;
  border-radius: 8px;
  color: rgba(255,255,255,.9);
  font-size: 1rem;
  font-weight: 750;
  padding: 0 .85rem;
  text-decoration: none;
  transition: background .18s, color .18s, transform .18s;
}

.ut-nav a span {
  width: 26px;
  display: inline-grid;
  place-items: center;
  font-size: 1.2rem;
}

.ut-nav a:hover,
.ut-nav a.active {
  background: linear-gradient(135deg, #7c5cff 0%, #5a49f2 100%);
  color: #fff;
  text-decoration: none;
  transform: translateX(2px);
}

/* ── Libellés de section dans la nav ── */
.ut-nav-label {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  padding: .9rem .85rem .25rem;
  pointer-events: none;
  user-select: none;
}

/* ── Liens de niveau (2de / 1re / Tle) ── */
.ut-nav-level {
  position: relative;
  overflow: hidden;
}

.ut-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 24px;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .02em;
  flex-shrink: 0;
  color: #fff;
}

.ut-nav-level--seconde .ut-nav-badge  { background: #2e7d32; }
.ut-nav-level--premiere .ut-nav-badge { background: #1565c0; }
.ut-nav-level--terminale .ut-nav-badge{ background: #6a1b9a; }

.ut-nav-level--seconde:hover,
.ut-nav-level--seconde.active  { background: linear-gradient(135deg,#2e7d32,#43a047) !important; }
.ut-nav-level--premiere:hover,
.ut-nav-level--premiere.active { background: linear-gradient(135deg,#1565c0,#1976d2) !important; }
.ut-nav-level--terminale:hover,
.ut-nav-level--terminale.active{ background: linear-gradient(135deg,#6a1b9a,#8e24aa) !important; }

/* ── Séparateur léger entre les deux groupes ── */
.ut-nav-label:not(:first-of-type) {
  border-top: 1px solid rgba(255,255,255,.10);
}

.ut-goal-card {
  margin-top: auto;
  display: grid;
  gap: .75rem;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.06));
  padding: 1.05rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}

.ut-goal-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255,255,255,.12);
}

.ut-goal-card p {
  margin: 0;
  color: rgba(255,255,255,.84);
  font-size: .92rem;
}

.ut-goal-card small {
  color: rgba(255,255,255,.68);
  font-size: .78rem;
  font-weight: 700;
}

.ut-goal-card a {
  display: inline-flex;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  padding: .72rem;
}

.ut-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ut-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: 82px;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid #e5eaf3;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(18px);
  padding: 0 2.1rem;
}

.ut-menu-btn,
.ut-icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #26345d;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

.ut-menu-btn { display: none; }

.ut-search {
  max-width: 760px;
  flex: 1;
  height: 48px;
  display: flex;
  align-items: center;
  gap: .65rem;
  border: 1px solid #dfe5f1;
  border-radius: 10px;
  background: #fff;
  color: #8b96b1;
  padding: 0 .85rem;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .05);
}

.ut-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: #071436;
  font: inherit;
}

.ut-search kbd {
  border: 1px solid #e3e7f0;
  border-radius: 6px;
  background: #f7f9fd;
  color: #66708f;
  font-size: .75rem;
  padding: .15rem .45rem;
}

.ut-top-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.ut-streak,
.ut-user-pill {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: #071436;
  text-decoration: none;
}

.ut-streak strong,
.ut-user-pill strong { display: block; font-size: .9rem; line-height: 1.1; }
.ut-streak small,
.ut-user-pill small { display: block; color: #66708f; font-size: .78rem; }

.ut-logout-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border: 1px solid #dfe5f1;
  border-radius: 999px;
  background: #fff;
  color: #425071;
  padding: 0 .82rem;
  text-decoration: none;
  font-size: .84rem;
  font-weight: 850;
}

.ut-logout-btn span {
  color: #ef4444;
  font-weight: 950;
}

.ut-logout-btn:hover {
  border-color: #fca5a5;
  color: #b91c1c;
}

.ut-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe6c7, #c9d7ff);
  color: #071436;
  font-weight: 900;
}

.ut-content,
.ut-dashboard {
  min-width: 0;
  width: 100%;
  padding: 1.5rem 2rem 2.5rem;
}

.ut-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.55rem;
  align-items: start;
}

.ut-dashboard-main,
.ut-right-rail {
  min-width: 0;
  display: grid;
  gap: 1.45rem;
}

.ut-welcome h1 {
  margin: 0 0 .15rem;
  color: #071436;
  font-size: 2rem;
  letter-spacing: 0;
}

.ut-welcome p {
  margin: 0;
  color: #425071;
}

.ut-welcome-public {
  max-width: 920px;
}

.ut-eyebrow {
  margin: 0 0 .35rem !important;
  color: #5b4df2 !important;
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.ut-welcome-public h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
}

.ut-welcome-public > p:not(.ut-eyebrow) {
  max-width: 760px;
  font-size: 1.05rem;
}

/* ── Coach banner compact ── */
.ut-coach-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(135deg, #1565c0 0%, #1976d2 100%);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: #fff;
  margin-bottom: 1.5rem;
}
.ut-coach-banner-left {
  display: flex;
  align-items: center;
  gap: .85rem;
}
.ut-coach-icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.ut-coach-banner-left strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}
.ut-coach-banner-left p {
  margin: .15rem 0 0;
  font-size: .85rem;
  color: rgba(255,255,255,.8);
}
.ut-coach-banner-actions {
  display: flex;
  gap: .6rem;
  flex-shrink: 0;
}
.ut-coach-banner .ut-primary-action {
  background: rgba(255,255,255,.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  padding: .45rem 1rem;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 700;
  text-decoration: none;
  transition: background .18s;
}
.ut-coach-banner .ut-primary-action:hover { background: rgba(255,255,255,.35); }
.ut-coach-banner .ut-secondary-action {
  color: rgba(255,255,255,.75);
  font-size: .82rem;
  align-self: center;
  text-decoration: none;
  white-space: nowrap;
}
.ut-coach-banner .ut-secondary-action:hover { color: #fff; }

/* ── Trois niveaux en ligne ── */
.ut-levels-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.ut-level-card {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: #fff;
  font-weight: 600;
  transition: transform .18s, box-shadow .18s;
}
.ut-level-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}
.ut-level--seconde  { background: linear-gradient(135deg,#2e7d32,#43a047); }
.ut-level--premiere { background: linear-gradient(135deg,#1565c0,#1976d2); }
.ut-level--terminale{ background: linear-gradient(135deg,#6a1b9a,#8e24aa); }

/* Onglets de niveau — état actif */
button.ut-level-card { border: none; cursor: pointer; text-align: left; }
.ut-level-card.ut-level--active { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,.22); outline: 3px solid rgba(255,255,255,.55); outline-offset: 2px; }
.ut-level-card:not(.ut-level--active) { opacity: .72; }
.ut-level-card:not(.ut-level--active):hover { opacity: 1; }

.ut-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255,255,255,.2);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .03em;
  color: #fff;
  margin-bottom: .25rem;
}
.ut-level-card strong {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}
.ut-level-card p {
  font-size: .82rem;
  color: rgba(255,255,255,.85);
  font-weight: 400;
  line-height: 1.45;
  flex: 1;
}
.ut-level-cta {
  font-size: .8rem;
  font-weight: 700;
  color: rgba(255,255,255,.9);
  margin-top: .25rem;
}

/* ── Ancien coach (conservé pour rétrocompat, caché) ── */
.ut-home-coach {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 1rem;
  align-items: stretch;
  border: 1px solid #dfe5f1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .06);
  padding: 1.35rem;
}

.ut-home-coach-title-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.ut-home-coach h1 {
  margin: 0;
  color: #071436;
  font-size: clamp(1.65rem, 2.5vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.ut-home-coach-copy {
  max-width: 680px;
  margin: .45rem 0 0;
  color: #425071;
  font-size: 1rem;
}

.ut-home-coach-score {
  flex: 0 0 auto;
  border-radius: 9px;
  background: rgba(91, 77, 242, .1);
  color: #5b4df2;
  padding: .42rem .65rem;
  font-weight: 950;
}

.ut-home-coach-plan {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  margin-top: 1rem;
}

.ut-home-coach-plan-link {
  color: inherit;
  text-decoration: none;
}

.ut-home-coach-plan div,
.ut-home-coach-side {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
  padding: .75rem .85rem;
}

.ut-home-coach-plan-link div {
  transition: border-color .15s, background .15s, transform .15s, box-shadow .15s;
}

.ut-home-coach-plan-link:hover div {
  border-color: #a5b4fc;
  background: #eef2ff;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .12);
  transform: translateY(-1px);
}

.ut-home-coach-plan span,
.ut-home-coach-side span {
  display: block;
  color: #64748b;
  font-size: .74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.ut-home-coach-plan strong {
  display: block;
  margin-top: .25rem;
  color: #111827;
}

.ut-home-coach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.05rem;
}

.ut-home-coach-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ut-home-coach-side strong {
  display: block;
  margin-top: .2rem;
  color: #071436;
  font-size: 2rem;
  line-height: 1;
}

.ut-home-coach-side p {
  margin: .6rem 0 0;
  color: #425071;
}

.ut-coach-float {
  position: fixed;
  right: 1.35rem;
  bottom: 1.35rem;
  z-index: 10020;
  width: min(310px, calc(100vw - 2rem));
  border-radius: 14px;
  background: #fff;
  border: 1px solid #dfe5f1;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .18);
  padding: .85rem;
  color: #071436;
  pointer-events: auto;
}

.ut-coach-float.is-hidden {
  display: none;
}

.ut-coach-float-top {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 28px;
  gap: .65rem;
  align-items: start;
}

.ut-coach-float-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(91, 77, 242, .1);
  font-size: 1.1rem;
}

.ut-coach-float strong {
  display: block;
  font-size: .9rem;
  line-height: 1.2;
}

.ut-coach-float p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin: .25rem 0 0;
  color: #425071;
  font-size: .78rem;
  line-height: 1.35;
}

.ut-coach-float-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
}

.ut-coach-float-action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin-top: .8rem;
  border-radius: 8px;
  background: #5b4df2;
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

.ut-coach-float-action:hover {
  background: #493adf;
  color: #fff;
}

.ut-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.1rem;
}

.ut-secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid #6957f6;
  border-radius: 7px;
  background: #fff;
  color: #5b4df2;
  font-weight: 850;
  padding: 0 1.15rem;
  text-decoration: none;
}

.ut-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.ut-stat-card,
.ut-continue-card,
.ut-objectives article,
.ut-side-card,
.ut-page-card {
  border: 1px solid #dfe5f1;
  border-radius: 8px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 12px 34px rgba(15, 23, 42, .06);
}

.ut-stat-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  column-gap: .9rem;
  align-items: center;
  min-height: 130px;
  padding: 1.25rem;
}

.ut-stat-card span {
  grid-row: span 2;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 900;
}

.ut-stat-card strong { font-size: 1.25rem; }
.ut-stat-card small { color: #425071; font-weight: 650; }
.ut-stat-card i {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
}
.ut-stat-card i::before {
  content: "";
  display: block;
  width: 70%;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
}
.ut-stat-card.purple { color: #6957f6; }
.ut-stat-card.blue { color: #2187f5; }
.ut-stat-card.green { color: #36c363; }
.ut-stat-card.orange { color: #ff7324; }
.ut-stat-card.purple span { background: linear-gradient(135deg, #7c5cff, #5b4df2); }
.ut-stat-card.blue span { background: linear-gradient(135deg, #27a7ff, #2563eb); }
.ut-stat-card.green span { background: linear-gradient(135deg, #4ade80, #22a852); }
.ut-stat-card.orange span { background: linear-gradient(135deg, #ff9b3d, #f15a24); }

.ut-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.ut-section-head h2 {
  margin: 0;
  padding: 0;
  border: 0;
  color: #071436;
  font-size: 1.05rem;
}
.ut-section-head a { color: #5b4df2; font-weight: 800; }

.ut-continue-card {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 2rem;
  padding: 1rem;
}

.ut-continue-visual {
  min-height: 210px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(124, 92, 255, .18), rgba(124, 92, 255, .03)),
    #ebe7ff;
  color: #5b4df2;
}

.ut-continue-visual::before,
.ut-continue-visual::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(91, 77, 242, .14);
}

.ut-continue-visual::before {
  width: 170px;
  height: 170px;
  left: -42px;
  bottom: -52px;
}

.ut-continue-visual::after {
  width: 95px;
  height: 95px;
  right: 24px;
  top: 26px;
}

.ut-continue-visual span,
.ut-continue-visual small,
.ut-continue-visual b {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(91, 77, 242, .18);
  font-weight: 950;
}

.ut-continue-visual span {
  width: 74px;
  height: 74px;
  font-size: 3rem;
}

.ut-continue-visual small {
  width: 46px;
  height: 46px;
  margin: -82px 0 0 118px;
  color: #2187f5;
  font-size: 1.4rem;
}

.ut-continue-visual b {
  width: 42px;
  height: 42px;
  margin: -54px 112px 0 0;
  color: #ff7324;
  font-size: 1.7rem;
}

.ut-seconde-card {
  border-color: rgba(20, 184, 166, .35);
  background:
    linear-gradient(135deg, rgba(240, 253, 250, .96), rgba(255, 255, 255, .94)),
    #fff;
}

.ut-seconde-visual {
  background:
    linear-gradient(135deg, rgba(20, 184, 166, .18), rgba(34, 197, 94, .06)),
    #e8fbf7;
  color: #0f766e;
}

.ut-seconde-visual::before,
.ut-seconde-visual::after {
  background: rgba(20, 184, 166, .14);
}

.ut-seconde-visual span {
  color: #0f766e;
  box-shadow: 0 18px 40px rgba(20, 184, 166, .2);
}

.ut-seconde-visual small {
  color: #2187f5;
}

.ut-seconde-visual b {
  color: #36a852;
}

.ut-seconde-progress span,
.ut-seconde-action {
  background: #0f766e;
}

.ut-seconde-action:hover {
  background: #115e59;
  color: #fff;
}

.ut-continue-card h3 {
  margin: .25rem 0 .95rem;
  color: #071436;
  font-size: 1.55rem;
}

.ut-progress {
  width: min(420px, 100%);
  height: 8px;
  border-radius: 999px;
  background: #e9edf5;
  overflow: hidden;
}
.ut-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #6957f6;
}
.ut-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin: 1.1rem 0;
}
.ut-quick-links a { color: #5b4df2; font-weight: 800; }

.ut-primary-action,
.ut-objectives a,
.ut-side-card a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 7px;
  background: #6957f6;
  color: #fff;
  font-weight: 850;
  padding: 0 1.15rem;
  text-decoration: none;
}

.ut-objectives {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.ut-objectives article {
  display: grid;
  gap: .45rem;
  padding: 1rem;
}
.ut-objectives span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #f3f1ff;
  color: #6957f6;
}
.ut-objectives small { color: #425071; }
.ut-objectives a {
  min-height: 34px;
  border: 1px solid #6957f6;
  background: #fff;
  color: #5b4df2;
}

.ut-chapter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
}

.ut-chapters-panel {
  display: grid;
  gap: 1rem;
  border: 1px solid #dfe5f1;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.96), rgba(247,249,255,.92)),
    #f7f9ff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .07);
  padding: 1.15rem;
}

.ut-chapters-panel .ut-section-head {
  padding: 0 .1rem;
}

.ut-chapter-card {
  min-height: 190px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .6rem;
  align-content: start;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--chapter-color) 22%, #dfe5f1);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.18), rgba(255,255,255,0) 48%),
    radial-gradient(circle at 82% 13%, color-mix(in srgb, var(--chapter-color) 18%, transparent), transparent 38%),
    var(--chapter-card-bg, #fff);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
  position: relative;
  overflow: hidden;
  --chapter-color: #5b4df2;
  --chapter-soft: #f0edff;
}

.ut-chapter-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--chapter-color) 8%, transparent), transparent 72%);
  pointer-events: none;
}

.ut-chapter-card > * {
  position: relative;
  z-index: 1;
}

.ut-chapter-top {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}

.ut-chapter-number {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--chapter-soft);
  color: var(--chapter-color);
  font-weight: 900;
}

.ut-chapter-logo {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.78), rgba(255,255,255,.35)),
    var(--chapter-soft);
  color: var(--chapter-color);
  box-shadow: 0 16px 34px color-mix(in srgb, var(--chapter-color) 24%, transparent);
}

.ut-chapter-logo svg {
  width: 38px;
  height: 38px;
  display: block;
}

.ut-chapter-card strong {
  grid-column: 1 / -1;
  min-height: 48px;
  color: #071436;
  line-height: 1.2;
}

.ut-chapter-card small {
  justify-self: end;
  color: #425071;
  font-weight: 800;
}

.ut-chapter-card i {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
}

.ut-chapter-card b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--chapter-color);
}

.ut-chapter-card a {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #6957f6;
  border-radius: 7px;
  color: #5b4df2;
  font-weight: 850;
  text-decoration: none;
}

.ut-chapter-card.theme-sequence { --chapter-color: #5b4df2; --chapter-soft: #f0edff; }
.ut-chapter-card.theme-sequence { --chapter-card-bg: #f3f0ff; }
.ut-chapter-card.theme-limit { --chapter-color: #2187f5; --chapter-soft: #e8f3ff; --chapter-card-bg: #eaf6ff; }
.ut-chapter-card.theme-space { --chapter-color: #24a35a; --chapter-soft: #e9f8ef; --chapter-card-bg: #ecf9f0; }
.ut-chapter-card.theme-function { --chapter-color: #f97316; --chapter-soft: #fff0e5; --chapter-card-bg: #fff2e8; }
.ut-chapter-card.theme-derivee { --chapter-color: #dc3f65; --chapter-soft: #ffeaf0; --chapter-card-bg: #fff0f4; }
.ut-chapter-card.theme-continuity { --chapter-color: #0f9f8f; --chapter-soft: #e4fbf7; --chapter-card-bg: #e8fbf7; }
.ut-chapter-card.theme-orthogonal { --chapter-color: #5661e8; --chapter-soft: #eef0ff; --chapter-card-bg: #eef1ff; }
.ut-chapter-card.theme-binomial { --chapter-color: #b35adf; --chapter-soft: #f8ecff; --chapter-card-bg: #f9efff; }
.ut-chapter-card.theme-log { --chapter-color: #0d9488; --chapter-soft: #e5f8f5; --chapter-card-bg: #eaf9f5; }
.ut-chapter-card.theme-equation { --chapter-color: #2563eb; --chapter-soft: #eaf0ff; --chapter-card-bg: #edf4ff; }
.ut-chapter-card.theme-count { --chapter-color: #db8b10; --chapter-soft: #fff6df; --chapter-card-bg: #fff7e2; }
.ut-chapter-card.theme-trigo { --chapter-color: #8b5cf6; --chapter-soft: #f3edff; --chapter-card-bg: #f5f0ff; }
.ut-chapter-card.theme-integral { --chapter-color: #16a34a; --chapter-soft: #e8f8ee; --chapter-card-bg: #eef9ec; }
.ut-chapter-card.theme-law { --chapter-color: #ef4444; --chapter-soft: #ffeded; --chapter-card-bg: #fff0ef; }
.ut-chapter-card.theme-python { --chapter-color: #0f766e; --chapter-soft: #e7f7f4; --chapter-card-bg: #e8f7f5; }

.ut-right-rail {
  position: sticky;
  top: 104px;
}

.ut-side-card {
  padding: 1.25rem;
}
.ut-side-card h3 {
  margin: 0 0 .6rem;
  color: #071436;
  font-size: 1rem;
}
.ut-side-card > strong {
  display: block;
  color: #071436;
  font-size: 1.8rem;
  margin: .2rem 0;
}
.ut-side-card p { color: #425071; margin: 0 0 1rem; }

.ut-week {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .45rem;
  margin-top: 1rem;
}
.ut-week span {
  display: grid;
  place-items: center;
  color: #ff7324;
  font-size: 1.2rem;
}
.ut-week small {
  color: #425071;
  font-size: .7rem;
}

.ut-flash-card {
  background:
    radial-gradient(circle at 84% 50%, rgba(105,87,246,.16), transparent 28%),
    rgba(255,255,255,.9);
}

.ut-activity {
  display: grid;
  gap: .8rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.ut-activity li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: .65rem;
  align-items: center;
  margin: 0;
}
.ut-activity span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eafbea;
  color: #36a852;
}
.ut-activity p {
  margin: 0;
  color: #26345d;
  font-size: .84rem;
}
.ut-activity small,
.ut-activity time {
  display: block;
  color: #66708f;
  font-size: .76rem;
}

.ut-ai-card {
  background:
    radial-gradient(circle at 82% 65%, rgba(91,141,246,.2), transparent 26%),
    rgba(255,255,255,.9);
}

.ut-seconde-side-card {
  border-color: rgba(20, 184, 166, .34);
  background:
    linear-gradient(135deg, rgba(240, 253, 250, .96), rgba(255,255,255,.9)),
    #fff;
}

.ut-seconde-side-card a {
  background: #0f766e;
}

.ut-seconde-side-card a:hover {
  background: #115e59;
  color: #fff;
}

.ut-page-card {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.8rem;
}

.ut-breadcrumb {
  max-width: 1180px;
  margin: 0 auto 1rem;
}

.ut-shell footer { display: none; }

[data-theme="dark"] .ut-shell {
  background: #0f172a;
  color: #e2e8f0;
}
[data-theme="dark"] .ut-topbar,
[data-theme="dark"] .ut-stat-card,
[data-theme="dark"] .ut-continue-card,
[data-theme="dark"] .ut-objectives article,
[data-theme="dark"] .ut-side-card,
[data-theme="dark"] .ut-page-card {
  background: rgba(30, 41, 59, .92);
  border-color: #334155;
}
[data-theme="dark"] .ut-welcome h1,
[data-theme="dark"] .ut-section-head h2,
[data-theme="dark"] .ut-continue-card h3,
[data-theme="dark"] .ut-side-card h3,
[data-theme="dark"] .ut-side-card > strong {
  color: #f8fafc;
}
[data-theme="dark"] .ut-search,
[data-theme="dark"] .ut-menu-btn,
[data-theme="dark"] .ut-icon-btn {
  background: #162033;
  border-color: #334155;
}
[data-theme="dark"] .ut-search input {
  background: transparent;
  color: #e2e8f0;
}

@media (max-width: 1180px) {
  .ut-shell { grid-template-columns: 86px minmax(0, 1fr); }
  .ut-sidebar { padding: 1rem .65rem; }
  .ut-brand span:not(.ut-brand-mark),
  .ut-nav a:not(:hover) { font-size: 0; }
  .ut-nav a { justify-content: center; padding: 0; }
  .ut-nav a span { font-size: 1.25rem; }
  .ut-goal-card { display: none; }
  .ut-dashboard { grid-template-columns: 1fr; }
  .ut-right-rail { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ut-chapter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .ut-shell { grid-template-columns: 1fr; }
  .ut-sidebar {
    position: static;
    height: auto;
    display: block;
  }
  .ut-menu-btn { display: grid; }
  .ut-nav {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    padding-bottom: .3rem;
  }
  .ut-nav a {
    flex: 0 0 auto;
    min-height: 44px;
    min-width: 48px;
    padding: 0 .8rem;
    font-size: .9rem;
  }
  .ut-topbar {
    height: auto;
    flex-wrap: wrap;
    padding: .9rem 1rem;
  }
  .ut-top-actions { width: 100%; justify-content: space-between; }
  .ut-logout-btn strong { display: none; }
  .ut-logout-btn { min-width: 40px; justify-content: center; padding: 0 .65rem; }
  .ut-content,
  .ut-dashboard { padding: 1rem; }
  .ut-home-coach,
  .ut-home-coach-plan {
    grid-template-columns: 1fr;
  }
  .ut-home-coach-title-row {
    display: grid;
  }
  .ut-coach-float {
    right: .75rem;
    bottom: .75rem;
    width: calc(100vw - 1.5rem);
  }
  .ut-stats-grid,
  .ut-objectives,
  .ut-chapter-grid,
  .ut-right-rail { grid-template-columns: 1fr; }
  .ut-continue-card { grid-template-columns: 1fr; }
  .ut-continue-visual { min-height: 150px; }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN - FORMULES MATHÉMATIQUES & CONTENU
   ════════════════════════════════════════════════════════════ */

/* Formules mathématiques - Configuration de base */
.course-formula,
.solution-formula,
.sequence-formula,
.correction-mathjax mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* Conteneur pour les formules */
.formula-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin: 1.2rem 0;
  padding: 0.8rem;
  background: var(--primary-light);
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.formula-container mjx-container {
  max-width: 100% !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* MathJax container global */
.correction-mathjax mjx-container,
.formula-container mjx-container {
  max-width: 100% !important;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ── Tablettes (768px - 1024px) ── */
@media (max-width: 1024px) {
  .course-formula,
  .solution-formula,
  .sequence-formula {
    font-size: 0.95em;
  }

  .formula-container {
    padding: 0.6rem;
    margin: 1rem 0;
  }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.35rem; }
}

/* ── Téléphones moyens (480px - 768px) ── */
@media (max-width: 768px) {
  .course-formula,
  .solution-formula,
  .sequence-formula {
    font-size: 0.9em;
  }

  .formula-container {
    padding: 0.5rem;
    margin: 0.9rem 0;
  }

  article p {
    line-height: 1.6;
    font-size: 0.95rem;
  }

  h1 { font-size: 1.75rem; margin: 0.9rem 0 0.6rem; }
  h2 { font-size: 1.5rem; margin: 0.8rem 0 0.5rem; }
  h3 { font-size: 1.2rem; margin: 0.7rem 0 0.4rem; }
  h4 { font-size: 1.05rem; }
}

/* ── Petits téléphones (< 480px) ── */
@media (max-width: 480px) {
  .course-formula,
  .solution-formula,
  .sequence-formula,
  .correction-mathjax {
    font-size: 0.85em !important;
  }

  .correction-mathjax mjx-container,
  .formula-container mjx-container {
    font-size: 0.85em;
    padding: 0.4rem 0;
  }

  .formula-container {
    padding: 0.4rem;
    margin: 0.8rem 0;
    border-radius: 6px;
  }

  .correction-mathjax p {
    margin: 0.4rem 0;
  }

  .correction-mathjax ol,
  .correction-mathjax ul {
    padding-left: 1.2rem;
    margin: 0.4rem 0;
  }

  .correction-mathjax li {
    margin: 0.2rem 0;
  }

  /* Boîtes de contenu pédagogique */
  .definition-box,
  .property-box,
  .method-box,
  .example-box,
  .exercise-box,
  .correction-box,
  .warning-box,
  .tip-box {
    padding: 0.8rem;
    margin: 0.8rem 0;
    border-radius: 8px;
    border-left-width: 4px;
  }

  .definition-box h4,
  .property-box h4,
  .method-box h4 {
    font-size: 0.95rem;
    margin-top: 0;
  }

  .definition-box p,
  .property-box p,
  .method-box p {
    font-size: 0.9rem;
    margin: 0.3rem 0;
  }

  article p {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  h1 { font-size: 1.5rem; margin: 0.75rem 0 0.5rem; }
  h2 { font-size: 1.25rem; margin: 0.65rem 0 0.4rem; }
  h3 { font-size: 1.05rem; margin: 0.55rem 0 0.35rem; }
  h4 { font-size: 0.95rem; }

  code, pre {
    font-size: 0.8em;
  }
}

/* ── Très petits écrans (< 360px) ── */
@media (max-width: 360px) {
  .course-formula,
  .solution-formula,
  .sequence-formula {
    font-size: 0.75em !important;
  }

  .formula-container {
    padding: 0.3rem;
    margin: 0.6rem 0;
  }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.1rem; }
  h3 { font-size: 0.95rem; }

  .definition-box,
  .property-box,
  .example-box {
    padding: 0.6rem;
  }
}

/* Clases pour boîtes de contenu pédagogique */
.definition-box,
.property-box,
.method-box,
.example-box,
.exercise-box,
.correction-box,
.warning-box,
.tip-box {
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 8px;
  border-left-width: 4px;
  border-left-style: solid;
}

.definition-box {
  background: var(--def-bg);
  border-left-color: var(--def-bd);
  color: var(--def-tx);
}

.property-box,
.theorem-box {
  background: var(--prop-bg);
  border-left-color: var(--prop-bd);
  color: var(--prop-tx);
}

.method-box {
  background: var(--meth-bg);
  border-left-color: var(--meth-bd);
  color: var(--meth-tx);
}

.example-box {
  background: var(--ex-bg);
  border-left-color: var(--ex-bd);
  color: var(--ex-tx);
}

.exercise-box {
  background: var(--exo-bg);
  border-left-color: var(--exo-bd);
  color: var(--exo-tx);
}

.correction-box {
  background: var(--cor-bg);
  border-left-color: var(--cor-bd);
  color: var(--cor-tx);
}

.warning-box {
  background: var(--warn-bg);
  border-left-color: var(--warn-bd);
  color: var(--warn-tx);
}

.tip-box {
  background: var(--tip-bg);
  border-left-color: var(--tip-bd);
  color: var(--tip-tx);
}

.definition-box h4,
.property-box h4,
.method-box h4,
.example-box h4 {
  margin-top: 0;
  font-weight: 700;
  font-size: 1.1rem;
}

.definition-box p,
.property-box p,
.method-box p,
.example-box p {
  margin-bottom: 0.5rem;
}

/* ── Inline math chip — editing state (NumWorks-style) ── */
.application-math-chip--editing {
  border-color: #6366F1;
  background: #EEF2FF;
  box-shadow: 0 0 0 2px rgba(99,102,241,.25);
}

.application-math-chip--editing math-field {
  pointer-events: auto;
  outline: none;
}

.application-inline-mf-active {
  min-width: 48px;
  font-size: 1rem;
  border: none;
  background: transparent;
}
