/* ================================================================
   Maths Maistre — style.css
   Charte unifiée avec OtoMaths
   Palette: navy #0D2B5E · vert #2ECC71 · bleu #1A6BB0 · bg #F4F6F9
   Police: Inter (même que OtoMaths)
   ================================================================ */

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

/* ── RESET ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* ── VARIABLES ────────────────────────────────────────────── */
:root {
  /* Palette OtoMaths */
  --navy:          #0D2B5E;
  --navy-deep:     #081729;
  --navy-mid:      #1A3A6E;
  --blue:          #1A6BB0;
  --green:         #2ECC71;
  --green-dark:    #1DA559;
  --green-hover:   #25B560;
  --accent:        #1A6BB0;

  /* Neutres */
  --bg:            #F4F6F9;
  --white:         #ffffff;
  --border:        #E2E8F0;
  --border-light:  #EEF1F6;
  --text:          #0D2B5E;
  --text-mid:      #7A8BA8;
  --text-light:    #9AAABB;
  --text-muted:    #B0BDC8;
  --grid:          rgba(13,43,94,0.06);

  /* Alertes */
  --amber:         #C47D0E;
  --amber-bg:      #FEF3DC;
  --red:           #B83232;
  --danger:        #B83232;
  --red-bg:        #FDE8E8;
  --ok:            #1DA559;

  /* Pastel BD (préservé pour sf-cards) */
  --p1: #FF6B6B;
  --p2: #FFD93D;
  --p3: #6BCB77;
  --p4: #4D96FF;

  /* Typo */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Rayons */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  14px;
  --r-xl:  16px;
  --r-2xl: 20px;
  --r-pill: 999px;

  /* Ombres */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(13,43,94,0.08);
  --shadow-lg: 0 8px 24px rgba(13,43,94,0.12);

  /* Transitions */
  --t-fast: 0.12s ease;
  --t-med:  0.2s ease;

  /* Layout chapitre */
  --content-w: 820px;
  --wrap-pad: 16px;
}

/* ── BASE ─────────────────────────────────────────────────── */
html {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  position: relative;
  overflow-x: hidden;
}

/* Supprime le voile grille hérité */
body::before { display: none !important; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button { font-family: var(--font); cursor: pointer; border: none; }
input, select, textarea { font-family: var(--font); }

h1, h2, h3 { margin: 8px 0 12px; }

/* ================================================================
   NAVIGATION — style OtoMaths pill
   ================================================================ */

nav.top {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem !important;
  height: 56px;
  background: var(--navy) !important;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 9999;
  width: 100%;
  overflow: visible !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: none !important;
}

/* Brand / logo */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.1;
  flex-shrink: 0;
}

nav.top .brand .pi {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--green);
  font-size: 15px;
  font-weight: 900;
  color: var(--white);
  flex-shrink: 0;
  line-height: 28px;
  border: none;
}

.brand .title {
  display: flex;
  flex-direction: column;
}

nav.top .brand .title span {
  font-family: var(--font);
  text-transform: none;
}

nav.top .brand .title span:first-child {
  font-size: 14px;
  font-weight: 800;
  color: var(--white) !important;
  letter-spacing: -0.2px;
}

nav.top .brand .title span:last-child {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.55) !important;
}

/* Menu links */
.menu, nav.top .menu {
  display: flex !important;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding-right: 12px;
}

nav.top .menu a,
.menu a,
.menu-btn {
  display: inline-block;
  padding: 6px 14px !important;
  border-radius: var(--r-sm) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: rgba(255,255,255,0.55) !important;
  text-decoration: none !important;
  transition: background var(--t-fast), color var(--t-fast);
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  white-space: nowrap;
}

nav.top .menu a:hover,
.menu a:hover,
.menu-btn:hover {
  color: rgba(255,255,255,0.9) !important;
  background: rgba(255,255,255,0.08) !important;
  text-decoration: none !important;
  border-radius: var(--r-sm) !important;
}

.menu-btn.active,
nav.top .menu a.active {
  background: rgba(255,255,255,0.12) !important;
  color: var(--white) !important;
  border-radius: var(--r-sm) !important;
}

/* Hover active : reste dans le bleu sombre, pas gris */
.menu-btn.active:hover,
nav.top .menu a.active:hover {
  background: rgba(255,255,255,0.16) !important;
  color: var(--white) !important;
}

/* ── Profil utilisateur dans la nav ── */
#menuArea {
  flex: 1;
  display: flex !important;
  align-items: center;
}

.user-profile-block {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  cursor: pointer;
  transition: background var(--t-fast);
}

.user-profile-block:hover {
  background: rgba(255,255,255,0.15);
  text-decoration: none !important;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255,255,255,0.3);
}

.user-name, .user-info {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
}

/* Bouton connexion/profil */
#userMenu button,
.btn-primary {
  background: var(--green) !important;
  color: var(--white) !important;
  font-weight: 700 !important;
  border-radius: 50px !important;
  padding: 7px 18px !important;
  display: inline-block;
  text-decoration: none !important;
  font-size: 13px !important;
  border: none !important;
  box-shadow: none !important;
  transition: background var(--t-fast) !important;
}

#userMenu button:hover,
.btn-primary:hover {
  background: var(--green-hover) !important;
  box-shadow: none !important;
  filter: none !important;
}

/* Déconnexion */
.logout-icon-btn {
  transition: background-color var(--t-med);
  text-decoration: none !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
}

.logout-icon-btn:hover {
  background-color: rgba(255,77,77,0.2) !important;
  border-radius: var(--r-sm) !important;
  text-decoration: none !important;
}

.logout-icon-btn::after,
.logout-icon-btn:hover::after,
.logout-icon-btn:focus::after,
.logout-icon-btn:active::after {
  display: none !important;
  content: none !important;
}

.logout-icon-btn img {
  width: 20px;
  height: 20px;
  display: block;
  border: none !important;
}

/* ── Dropdown ── */
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; }
.caret { display: inline-block; transform: translateY(1px); }

.dropdown {
  position: absolute;
  right: 0;
  top: 40px;
  min-width: 180px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px;
  display: none;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.user.open .dropdown { display: block; }
.dropdown a { display: block; padding: 8px; border-radius: var(--r-sm); color: var(--text); font-size: 13px; }
.dropdown a:hover { background: var(--bg); text-decoration: none; }

/* ================================================================
   HERO ACCUEIL — vague navy + vert OtoMaths
   ================================================================ */

.home-hero-wave {
  background: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy) 55%, var(--navy-deep) 100%) !important;
  clip-path: ellipse(110% 100% at 50% 0%);
  padding: 56px 0 100px;
  position: relative;
  margin-top: 0;
}

/* Étoiles décoratives légères */
.home-hero-wave::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px),
    radial-gradient(circle, rgba(46,204,113,0.08) 1px, transparent 1px);
  background-size: 40px 40px, 70px 70px;
  background-position: 0 0, 20px 20px;
  pointer-events: none;
}

.home-hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  position: relative;
  z-index: 1;
}

.home-hero-text {
  flex: 1 1 55%;
  color: var(--white);
}

.home-hero-title {
  font-size: clamp(24px, 3.5vw, 42px);
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 18px 0;
  font-style: italic;
  color: var(--white);
}

.home-hero-title-bold {
  font-weight: 900;
  font-style: normal;
  color: var(--green);
}

.home-hero-text p {
  font-size: 15px;
  line-height: 1.75;
  margin: 0 0 24px 0;
  color: rgba(255,255,255,0.72);
  font-style: normal;
}

.home-hero-cta { margin-top: 8px; }

.home-hero-btn {
  display: inline-block;
  background: var(--green);
  color: var(--white) !important;
  font-weight: 800;
  font-size: 15px;
  padding: 12px 30px;
  border-radius: var(--r-pill);
  text-decoration: none !important;
  transition: background var(--t-fast);
  box-shadow: 0 4px 16px rgba(46,204,113,0.3);
}

.home-hero-btn:hover {
  background: var(--green-hover);
  text-decoration: none !important;
}

.home-hero-img {
  flex: 1 1 42%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.home-hero-img img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,0.25));
}

/* Fond page accueil */
body:has(.home-hero-wave) { background: var(--bg) !important; }

@media (max-width: 768px) {
  .home-hero-wave { padding: 40px 0 90px; }
  .home-hero-inner { flex-direction: column; padding: 0 24px; }
  .home-hero-img { justify-content: center; }
}

/* ================================================================
   WAVES INTERNES (cours, login, profil, chapitres)
   ================================================================ */

.chap-wave-header,
.login-wave,
.profile-wave {
  background: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy) 60%, var(--navy-deep) 100%) !important;
  clip-path: ellipse(100% 80% at 50% 0%);
  padding: 40px 16px 64px;
  text-align: center;
  margin-bottom: 28px;
  width: 100%;
  margin-top: 0;
  position: relative;
}

.chap-wave-header::after,
.login-wave::after,
.profile-wave::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(46,204,113,0.07) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
}

.chap-wave-header h1,
.login-wave h1,
.profile-wave h1 {
  font-size: clamp(20px, 3vw, 30px) !important;
  font-weight: 800 !important;
  color: var(--white) !important;
  margin: 0;
  letter-spacing: -0.3px;
  position: relative;
  z-index: 1;
}

.login-wave h1 span,
.chap-wave-header h1 span { color: var(--green); }

.profile-wave .wave-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  font-weight: 500;
  margin: 6px 0 0;
  position: relative;
  z-index: 1;
}

/* Vague accueil dans les pages cours */
.login-wave,
.chap-wave-header {
  margin-left: calc(-1 * var(--wrap-pad, 16px));
  margin-right: calc(-1 * var(--wrap-pad, 16px));
}

/* ================================================================
   LAYOUT
   ================================================================ */

.wrap {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 var(--wrap-pad);
}

.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

.section {
  padding: 20px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--white);
}

.section h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: var(--navy);
}

.panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  margin: 8px 0;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.panel:has(#chaptersWrap) {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

/* Banner */
.banner {
  position: relative;
  height: 230px;
  border-bottom: 1px solid var(--border);
}

.banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.banner::after { content: ''; position: absolute; inset: 0; }

.banner .banner-text {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.banner-card {
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 30px;
  padding: 16px 18px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  background: rgba(13,43,94,0.7);
  backdrop-filter: blur(8px);
}

.banner-card h1 { margin: 0 0 4px 0; font-size: 28px; color: var(--white); }
.banner-card p  { margin: 0; color: rgba(255,255,255,0.7); }

/* Grids */
.grid   { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: 8px; }
#cours .row { justify-content: center; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.quick-grid a {
  display: block;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.quick-grid a:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

/* ================================================================
   BOUTONS GLOBAUX
   ================================================================ */

button, .btn, a.btn {
  color: var(--text) !important;
  text-decoration: none;
}

.btn, a.btn {
  background: var(--bg);
  border: 1.5px solid var(--border);
  padding: 7px 16px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  width: auto !important;
}

.btn:hover, a.btn:hover {
  background: var(--border);
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

/* Variantes */
.btn-primary, a.btn-primary {
  background: var(--navy) !important;
  color: var(--white) !important;
  border-color: var(--navy) !important;
}

.btn-primary:hover, a.btn-primary:hover {
  background: var(--navy-mid) !important;
  border-color: var(--navy-mid) !important;
}

.btn-green, a.btn-green {
  background: var(--green) !important;
  color: var(--white) !important;
  border-color: var(--green) !important;
}

.btn-green:hover, a.btn-green:hover {
  background: var(--green-hover) !important;
  border-color: var(--green-hover) !important;
}

.btn-danger {
  background: var(--red-bg) !important;
  color: var(--red) !important;
  border-color: #f0b0b0 !important;
}

.btn-danger:hover {
  background: #fcd5d5 !important;
}

.btn-secondary { margin-top: 10px; }

.btn-ico {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: var(--r-pill) !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  font-size: 15px;
  cursor: pointer;
  background: var(--bg);
  border: 1.5px solid var(--border);
}

.btn-mini {
  width: auto !important;
  padding: 4px 10px !important;
  font-size: 12px !important;
  line-height: 1.2;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

a.btn[disabled], .btn[disabled] { opacity: .5; pointer-events: none; }

/* ── Admin-only ── */
.admin-only  { display: none !important; gap: 8px; margin-top: 8px; }
body.is-admin .admin-only { display: flex !important; }

/* ── Bouton admin visible ── */
.btn-edit-welcome {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  margin-left: 8px;
  cursor: pointer;
}

.btn-edit-welcome:hover {
  background: rgba(255,255,255,0.25);
}

/* ================================================================
   FORMULAIRES
   ================================================================ */

input, select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  outline: none;
  font-size: 14px;
  background: var(--white);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

input:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46,204,113,0.12);
}

textarea {
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 14px;
  color: var(--text);
  outline: none;
}

textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46,204,113,0.12);
}

button:hover { filter: none; }

/* ── Table ── */
.table th, .table td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
}

/* ── Toolbar ── */
.toolbar { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.toolbar #addChap { padding: 6px 10px; font-size: 14px; }
.toolbar #chapCount {
  padding: 4px 12px;
  min-width: 140px;
  text-align: center;
  font-weight: 600;
  background: var(--border-light);
  border-radius: var(--r-sm);
  font-size: 13px;
}

/* ================================================================
   BADGES (labels)
   ================================================================ */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
}

.badge-green  { background: #D6F5E7; color: var(--green-dark); }
.badge-blue   { background: #E8EDF5; color: var(--blue); }
.badge-amber  { background: var(--amber-bg); color: var(--amber); }
.badge-red    { background: var(--red-bg); color: var(--red); }
.badge-grey   { background: var(--border-light); color: var(--text-muted); }
.badge-navy   { background: var(--navy); color: var(--white); }

/* ── Contrôle visibilité ── */
label.vis-ctrl {
  margin-left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #444;
}

label.vis-ctrl input[type='checkbox'] { transform: translateY(1px); }

/* ================================================================
   PAGE COURS — liste chapitres
   ================================================================ */

/* Masquage éléments inutiles sur page chapitres */
body.page-chapters #banner        { display: none !important; }
body.page-chapters .panel,
body.page-chapters .panel:has(#chaptersWrap) {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
}
body.page-chapters #h2            { display: none !important; }
body.page-chapters .panel > h3    { display: none !important; }
body.page-chapters .wrap {
  padding-top: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-top: 0 !important;
  max-width: 100% !important;
}
body.page-chapters #chaptersWrap  { max-width: 580px; margin: 0 auto; padding: 0 16px 48px; }

/* Liste chapitres */
body.page-chapters ul#chapters,
.chapters {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

body.page-chapters ul#chapters li,
.chapters li {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .25rem 0;
}

body.page-chapters ul#chapters li > a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  width: 100%;
  box-shadow: var(--shadow-sm);
}

body.page-chapters ul#chapters li > a:hover {
  border-color: var(--navy);
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
  text-decoration: none;
}

body.page-chapters ul#chapters li > a .chap-num {
  font-weight: 900;
  color: var(--navy);
  font-size: 13px;
  background: var(--border-light);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}

body.page-chapters ul#chapters li > a .chap-titlelabel {
  color: var(--text);
}

/* Boutons chapitres admin */
.chapters li > button,
#chapters li > button {
  padding: 0;
  margin-left: 4px;
  width: 1.2em;
  height: 1.2em;
  line-height: 1;
  font-size: 16px;
  background: transparent;
  border: none;
  vertical-align: middle;
  cursor: pointer;
}

.chapters li > button:hover,
#chapters li > button:hover { opacity: .75; }

.chapters li a { flex: 1 1 auto; text-decoration: none; }

/* Lock */
.locked-link { opacity: 0.5; pointer-events: auto; cursor: not-allowed; }
.chapters li .lock { margin-left: 6px; }

/* Add chapter button */
#add-chapter {
  display: block;
  margin-top: 16px;
  padding: 12px 24px;
  background: var(--navy);
  color: var(--white) !important;
  border: none;
  border-radius: var(--r-pill);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--t-fast);
}
#add-chapter:hover { background: var(--navy-mid); }

/* ================================================================
   PAGE CHAPITRE — EN-TÊTE
   ================================================================ */

.chap-header {
  display: flex;
  max-width: var(--content-w);
  margin: 0 auto 20px auto;
  gap: 16px;
  align-items: center;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.chap-title-area { flex: 4; }

.chap-title-area h1 {
  font-size: 32px !important;
  font-weight: 900 !important;
  color: var(--navy) !important;
  margin: 0;
}

.chap-image-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.chap-image-area img {
  width: 100%;
  max-width: 140px;
  height: auto;
  border-radius: var(--r-md);
  border: none !important;
}

/* Miniature chapitres */
.chap-thumb {
  display: block;
  margin: 12px auto;
  width: 180px;
  height: 120px;
  background: transparent !important;
}

.chap-thumb img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ================================================================
   SAVOIR-FAIRE
   ================================================================ */

.section-inner { width: 100%; max-width: var(--content-w); margin: 0 auto; }

#sf-container { display: flex; flex-direction: column; align-items: center; }

.sf-card {
  border-radius: var(--r-xl) !important;
  padding: 16px;
  margin: 12px 0;
  width: 100%;
  max-width: var(--content-w);
  border-width: 3px !important;
  border-style: solid !important;
  box-shadow: none !important;
}

/* Couleurs par position */
#sf-container .sf-card:nth-of-type(4n+1) { border-color: var(--p1) !important; background: #fff5f5 !important; }
#sf-container .sf-card:nth-of-type(4n+2) { border-color: var(--p2) !important; background: #fffbeb !important; }
#sf-container .sf-card:nth-of-type(4n+3) { border-color: var(--p3) !important; background: #f0faf2 !important; }
#sf-container .sf-card:nth-of-type(4n+4) { border-color: var(--p4) !important; background: #eff4ff !important; }

/* Titres SF */
.sf-head {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center !important;
  width: 100%;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.sf-head > div:first-child {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 4px !important;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--navy);
  text-align: center;
}

.sf-head h3 {
  font-size: 24px !important;
  font-weight: 900 !important;
  text-align: center;
  margin: 0 !important;
}

.sf-head h3::after { content: '' !important; }

.sf-head .muted {
  font-size: 13px !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mid) !important;
  text-align: center;
}

/* Couleur titre h3 selon position */
#sf-container .sf-card:nth-of-type(4n+1) .sf-head h3 { color: var(--p1) !important; }
#sf-container .sf-card:nth-of-type(4n+2) .sf-head h3 { color: #b8860b !important; }
#sf-container .sf-card:nth-of-type(4n+3) .sf-head h3 { color: var(--p3) !important; }
#sf-container .sf-card:nth-of-type(4n+4) .sf-head h3 { color: var(--p4) !important; }

/* Colonnes SF */
.sf-col {
  background: rgba(255,255,255,0.75) !important;
  border: 1.5px solid rgba(0,0,0,0.08) !important;
  border-radius: var(--r-xl) !important;
  padding: 14px 18px !important;
  margin-bottom: 10px !important;
  text-align: center;
}

.sf-col h4 {
  display: inline-block;
  padding: 4px 14px;
  border-radius: var(--r-pill);
  background: rgba(13,43,94,0.07) !important;
  border: none !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px 0 !important;
  color: var(--navy) !important;
}

/* Icônes SF */
.sf-card .sf-col:nth-of-type(1) h4::before { content: '🔎 '; }
.sf-card .sf-col:nth-of-type(2) h4::before { content: '🎲 '; }
.sf-card .sf-col:nth-of-type(3) h4::before { content: '💡 '; }

.sf-col ul, .bilan-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sf-col ul li, .bilan-col ul li {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px;
}

.sf-col ul li a.btn, .bilan-col ul li a.btn {
  flex: 0 0 auto !important;
}

.sf-col ul li .validate-row, .bilan-col ul li .validate-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  margin-left: 8px;
}

/* Ressource avec genially */
.sf-col ul li a.btn[href*='genially']::before,
.sf-col ul li a.btn[href*='genial.ly']::before,
.bilan-col ul li a.btn[href*='genially']::before,
.bilan-col ul li a.btn[href*='genial.ly']::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 5px;
  background: url('/assets/genially.png') no-repeat center/contain;
  vertical-align: middle;
}

/* ── Admin actions SF ── */
.sf-card .actions.compact,
.bilan-col .actions.compact {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.admin-actions.compact { display: flex; gap: .35rem; align-items: center; }
.admin-actions.compact .toggle { display: flex; align-items: center; gap: .25rem; font-size: .85rem; }
.admin-actions.compact button {
  font-size: .75rem;
  padding: .2rem .45rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  background: var(--white);
}
.admin-actions.compact button:hover { opacity: .75; }
.toggle input { transform: scale(.9); }

/* ================================================================
   BILAN
   ================================================================ */

#cours, #bilan { max-width: var(--content-w); margin-left: auto; margin-right: auto; }
#bilan h2 { text-align: left; }
#bilan .grid { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.bilan-col {
  width: 100%;
  max-width: var(--content-w);
  text-align: center;
}

.bilan-col .row { justify-content: center; }

.tag {
  display: inline-block;
  padding: 4px 14px;
  border-radius: var(--r-pill);
  background: rgba(13,43,94,0.07);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--navy);
}

#cours h2 { text-align: left; }

/* Bilan section colorée */
.bilan-col[data-id='surpasser'] .tag { background: #ffe8e8; color: var(--p1); }
.bilan-col[data-id='amuser']    .tag { background: #e8f8ea; color: #1e8a35; }
.bilan-col[data-id='reviser']   .tag { background: #fffbeb; color: #b8860b; }

/* ================================================================
   GENIALLY
   ================================================================ */

.genially-admin-box {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 14px;
  margin-top: 8px;
}

.genially-admin-box label { display: block; font-size: .9rem; margin: .35rem 0 .2rem; }
.genially-admin-box input,
.genially-admin-box textarea {
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: .45rem;
}
.genially-admin-box button { margin-top: .5rem; }

.genially-validate {
  margin-top: 8px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  background: var(--green-dark);
  color: var(--white);
  border: 0;
  border-radius: var(--r-pill);
  padding: 10px 20px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: background var(--t-fast);
}

.genially-validate:hover { background: var(--green-hover); }

.genially-validate.validated {
  background: var(--green-dark) !important;
  font-size: 0.85rem;
  padding: 6px 12px;
}

#geniallyDialog form button[value='cancel'] {
  background: var(--red);
  color: var(--white);
  border: 0;
  border-radius: var(--r-sm);
  padding: 6px 12px;
  cursor: pointer;
}

#geniallyDialog form button#geniallySubmit {
  background: var(--green-dark);
  color: var(--white);
  border: 0;
  border-radius: var(--r-sm);
  padding: 6px 12px;
  cursor: pointer;
}

/* Inline editor */
.genially-editor { border: 1px dashed var(--border); padding: 8px; border-radius: var(--r-sm); width: 100%; max-width: 600px; }
.genially-editor textarea { width: 100%; min-height: 60px; }
.genially-editor input[type='text'] { width: 100%; }
.genially-editor .row { justify-content: flex-end; }
.validate-row { display: flex; gap: 8px; align-items: center; }

/* ================================================================
   TOPBAR CHAPITRE
   ================================================================ */

.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar h1 { color: var(--navy); margin: 0; }
.topbar img { width: 120px; height: 120px; object-fit: cover; border-radius: 20px; border: 1.5px solid var(--border); }

/* ================================================================
   LOGIN PAGE
   ================================================================ */

.login-card {
  max-width: 420px;
  margin: 0 auto 48px;
  padding: 36px 32px;
  background: var(--white);
  border-radius: var(--r-2xl);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md);
}

.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-mid);
  margin: 16px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-card input[type='text'],
.login-card input[type='password'] {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  background: var(--white);
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.login-card input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46,204,113,0.12);
}

.login-pass-row { display: flex; align-items: center; gap: 8px; }
.login-pass-row input { flex: 1; }

#toggleEye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--navy);
  color: var(--white);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 16px;
  border: none;
  transition: background var(--t-fast);
}

#toggleEye:hover { background: var(--navy-mid); }

#btnLogin {
  width: 100%;
  margin-top: 24px;
  padding: 13px;
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
  font-size: 15px;
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--shadow-md);
}

#btnLogin:hover {
  background: var(--navy-mid);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

#loginError {
  min-height: 20px;
  font-size: 13px;
  color: var(--red);
  margin: 8px 0 0;
  font-weight: 500;
}

#banner { display: none !important; }

/* ================================================================
   PROFIL
   ================================================================ */

.wrap.profile-outer,
.wrap { padding-top: 0; }

.profile-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

.pcard {
  background: var(--white);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--border);
  padding: 24px 28px;
  margin-bottom: 20px;
}

/* Student note */
.student-note {
  font-size: 12px;
  color: var(--text);
  background: var(--bg) !important;
  border: 1px dashed var(--border) !important;
  color: var(--text) !important;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  max-width: 640px;
}

/* ── Médailles ── */
.medals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.medal { text-align: center; position: relative; }

.medal-disc {
  width: 72px;
  height: 72px;
  margin: 0 auto 6px;
  border: 2.5px solid var(--border);
  border-radius: 50%;
  background: var(--medal, var(--bg));
}

.medal.won .medal-disc { filter: none; border-color: var(--navy); }
.medal:not(.won) .medal-disc { filter: grayscale(0.85) contrast(0.8) brightness(0.95); }

.medal-check {
  position: absolute;
  top: 6px;
  right: calc(50% - 36px + 6px);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--green-dark);
  color: var(--white);
  border: 2px solid var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}

.medal:not(.won) .medal-check { display: none; }
.medal-label { font-size: 12px; line-height: 1.2; color: var(--text-mid); }

/* ── MathsCoins ── */
.coins-cell .plus-btn,
.coins-cell .minus-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  margin-left: 6px;
  cursor: pointer;
  transition: background var(--t-fast);
}

.coins-cell .plus-btn:hover  { background: #d6f5e7; border-color: var(--green); }
.coins-cell .minus-btn:hover { background: var(--red-bg); border-color: #f0b0b0; }

/* ================================================================
   ADMIN PAGE
   ================================================================ */

.admin-header {
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-mid) 100%);
  padding: 28px 36px 24px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-header h1 { color: var(--white); margin: 0; font-size: 22px; font-weight: 800; letter-spacing: .3px; }
.admin-header p  { color: rgba(255,255,255,.65); margin: 4px 0 0; font-size: 13px; }

.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 28px 24px 60px; }

.acard {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.acard-title { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 14px; }

.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin: 0 0 28px;
  overflow-x: auto;
  flex-shrink: 0;
}

.tab-btn {
  padding: 12px 22px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  border-radius: 0;
  transition: all var(--t-fast);
  width: auto !important;
}

.tab-btn:hover  { color: var(--navy); background: rgba(13,43,94,0.04); }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--navy); background: none; }

.tab-pane        { display: none; }
.tab-pane.active { display: block; }

/* ================================================================
   MODALS (badges)
   ================================================================ */

.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(13,43,94,0.55);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--white);
  padding: 36px 32px;
  border-radius: var(--r-2xl);
  text-align: center;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: popIn .3s ease;
  border: 1.5px solid var(--border);
}

.modal-content h2 {
  color: var(--navy);
  font-size: 20px;
  margin-top: 0;
  line-height: 1.4;
  font-weight: 800;
}

.modal-content img {
  width: 110px;
  height: 110px;
  margin: 20px 0;
  object-fit: contain;
}

.modal-content button {
  background: var(--navy);
  color: var(--white);
  border: none;
  padding: 12px 28px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t-fast);
  width: auto !important;
}

.modal-content button:hover {
  background: var(--navy-mid);
  transform: none;
}

@keyframes popIn {
  0%   { transform: scale(.85); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

/* ================================================================
   PDF ICONS (cours)
   ================================================================ */

.cours-pdf-row {
  display: flex;
  gap: 80px;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 0;
}

.cours-pdf-item { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.cours-pdf-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
  cursor: pointer;
  transition: transform var(--t-fast);
  filter: drop-shadow(0 3px 6px rgba(13,43,94,0.15));
}

.cours-pdf-icon:hover { transform: scale(1.08); }

.cours-pdf-label { font-size: 13px; font-weight: 600; color: var(--text); text-align: center; }

/* ================================================================
   FOOTER
   ================================================================ */

footer {
  opacity: .6;
  text-align: center;
  padding: 24px;
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
  color: var(--text-mid);
}

/* ================================================================
   UTILITAIRES
   ================================================================ */

.hidden  { display: none; }
.err     { color: var(--danger); }
.ok      { color: var(--ok); }
.eye { width: 20px; height: 20px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; margin-left: 8px; }

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 768px) {
  nav.top { padding: 0 16px !important; height: 52px; }
  .home-hero-wave { padding: 40px 0 80px; }
  .home-hero-inner { flex-direction: column; padding: 0 20px; gap: 24px; }
  .home-hero-img { justify-content: center; }
  .cours-pdf-row { gap: 40px; }
  .chap-header { flex-direction: column; }
  .login-card { margin: 0 16px 48px; padding: 28px 24px; }
}

@media (max-width: 480px) {
  nav.top { padding: 0 12px !important; }
  .modal-content { padding: 28px 20px; }
}

/* ================================================================
   MOTION RÉDUIT
   ================================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
