/* MA(th)S — couche de design, indépendante de la maquette des manuels. */
:root {
  --ink: #182d42;
  --muted: #526579;
  --blue: #245a7e;
  --pink: #a34670;
  --purple: #69568e;
  --green: #256248;
  --line: #d6e0e8;
  --paper: #fff;
  --tint: #edf4f8;
  --canvas: #f5f7fa;
  --radius: 8px;
  --shadow: 0 2px 9px rgb(24 45 66 / 5%);
  --shell: 1240px;
  --gutter: clamp(18px, 4vw, 48px);
  --header-height: 77px;
}

body { background: var(--canvas); font-size: 16px; line-height: 1.6; }
main { max-width: var(--shell); padding: 34px var(--gutter) 64px; min-height: calc(100dvh - 160px); background: transparent; }
main > section { min-width: 0; }
h1 { font-size: clamp(2rem, 3.3vw, 2.65rem); font-weight: 800; line-height: 1.15; letter-spacing: -.045em; color: var(--ink); }
h1 > span { margin-left: 0; }
h2 { font-size: clamp(1.25rem, 2vw, 1.65rem); line-height: 1.32; letter-spacing: -.025em; font-weight: 750; }
.eyebrow { font-size: .75rem; letter-spacing: .1em; font-weight: 750; color: var(--blue); margin: 0 0 .65rem; }
.lead { color: var(--muted); font-size: 1rem; max-width: 55ch; margin: .65rem 0 0; }
.muted { font-size: .875rem; }
a, button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:where(a, button, input, select, textarea, summary):focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }
button, summary { cursor: pointer; }
button:disabled { cursor: not-allowed; }
.primary { border: 1px solid var(--blue); border-radius: 6px; padding: 10px 17px; min-height: 44px; font-size: .9rem; line-height: 1.4; font-weight: 700; background: var(--blue); display: inline-flex; align-items: center; justify-content: center; }
.primary:hover { background: #194663; }
.secondary { font-size: .9rem; font-weight: 650; color: var(--blue); text-underline-offset: .25em; border-bottom: 0; text-decoration: underline; }
button.secondary { min-height: 40px; border: 1px solid #b9cbd8; text-decoration: none; background: white; padding: 8px 12px; border-radius: 6px; }
button.secondary:hover { background: var(--tint); border-color: var(--blue); }
.text-link { font-size: .9rem; color: var(--green); font-weight: 700; text-decoration: underline; text-underline-offset: .25em; }
.back { min-height: 36px; display: inline-flex; align-items: center; margin: 0 0 1.1rem; font-size: .875rem; font-weight: 650; }
.empty-state { padding: 24px; border: 1px dashed #bacbd8; border-radius: var(--radius); color: var(--muted); text-align: center; }

/* Navigation stable et contexte scolaire. */
.site-header { position: sticky; top: 0; z-index: 20; max-width: none; padding: 0; display: block; background: #fff; border: 0; border-bottom: 1px solid var(--line); }
.header-inner { max-width: var(--shell); margin-inline: auto; padding: 15px var(--gutter); min-height: var(--header-height); display: flex; align-items: center; gap: clamp(18px, 3vw, 42px); }
.site-header .brand { flex-shrink: 0; }
.wordmark { font-size: 2.1rem; letter-spacing: -.07em; }
.main-nav { display: flex; align-items: center; gap: 5px; margin: 0; font-size: .9rem; flex: 1; }
.main-nav a { padding: 10px 14px; color: var(--muted); border-radius: 6px; min-height: 44px; white-space: nowrap; transition: background-color .15s; }
.main-nav a:hover { color: var(--blue); background: #f2f6f9; }
.main-nav a.active { color: var(--blue); box-shadow: none; background: #eaf2f7; }
.header-tools { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-shrink: 0; }
.level-switch { display: inline-flex; gap: 2px; border: 1px solid var(--line); background: #f4f7f9; padding: 3px; border-radius: 7px; }
.level-switch button { min-height: 36px; min-width: 37px; font-size: .95rem; line-height: 1; font-weight: 750; border: 0; border-radius: 4px; background: transparent; color: var(--muted); padding: 5px; }
.level-switch button[aria-pressed="true"] { color: var(--blue); background: #fff; box-shadow: 0 1px 4px #173b5521; }
.level-switch sup { font-size: .68em; }
.header-tools .dys-font-toggle, .header-tools .student-view-toggle { border-color: var(--line); border-radius: 6px; color: var(--blue); height: 44px; min-width: 44px; padding: 7px 10px; font-size: .8rem; margin: 0; }
.header-tools :is(.dys-font-toggle,.student-view-toggle)[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.header-tools .student-view-toggle { padding: 0; }
footer { max-width: var(--shell); background: transparent; padding: 20px var(--gutter); font-size: .8rem; border-top: 1px solid var(--line); }
footer a { text-decoration: underline; text-underline-offset: 3px; }

/* Accueil : deux choix immédiats, puis le contenu éditorial. */
.home-intro { margin: 0 0 27px; }
.home-intro h1 { margin: 0 0 .65rem; }
.home-intro h1 span { font-size: 1em; color: var(--pink); }
.home-intro > p:last-child { margin: 0; color: var(--muted); font-size: 1.03rem; }
.level-grid { gap: 20px; margin: 0 0 40px; }
.level-grid .level-card { display: flex; flex-direction: column; align-items: stretch; gap: 22px; padding: 25px; background: white; border: 1px solid var(--line); border-top: 3px solid var(--blue); border-radius: var(--radius); box-shadow: var(--shadow); }
.level-grid .level-four { border-top-color: var(--pink); }
.level-grid .level-card:hover { background: #fff; }
.level-card-heading { display: flex; align-items: center; gap: 20px; min-width: 0; }
.level-number { display: inline-flex; min-width: 80px; align-items: baseline; justify-content: center; font-size: 3.25rem; color: var(--blue); background: #eaf2f7; padding: 12px 9px; border-radius: 7px; }
.level-number sup { font-size: 1.2rem; }
.level-four .level-number { color: var(--pink); background: #f8edf2; }
.level-card h2 { font-size: 1.55rem; letter-spacing: -.035em; color: var(--ink); }
.level-card p:not(.eyebrow) { color: var(--muted); font-size: .875rem; margin: 4px 0 0; }
.level-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.level-actions a { flex: 1 1 135px; text-align: center; font-size: .9rem; font-weight: 700; padding: 10px 12px; min-height: 44px; border-radius: 5px; border: 1px solid var(--blue); display: grid; place-items: center; }
.level-actions .level-cta { background: var(--blue); color: white; }
.level-actions .level-cta:hover { background: #194663; }
.level-actions .level-secondary { border-color: #c5d5e0; color: var(--blue); }
.level-actions .level-secondary:hover { background: var(--tint); }
.culture-home { margin-top: 0; }
.culture-home-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.culture-home-heading .eyebrow { margin-bottom: .3rem; color: var(--green); }
.culture-home-heading h2 { font-size: 1.65rem; }
#culture-home { border-radius: var(--radius); box-shadow: var(--shadow); border: 0; border-top: 3px solid var(--green); }

/* Sommaire compact, lisible comme une table des matières. */
.intro { align-items: center; padding: 0 0 26px; border: 0; }
.intro h1 { font-size: clamp(2rem, 3vw, 2.5rem); margin: 0; }
.intro h1 span { color: var(--blue); display: inline-block; margin-left: .2em; }
.edition { border: 0; background: #fff; border-radius: var(--radius); padding: 13px 20px; color: var(--pink); font-size: 2.4rem; text-align: center; box-shadow: var(--shadow); }
.edition > span:last-child { font-size: .7rem; margin-top: 8px; }
.section-heading { align-items: baseline; padding: 0 0 14px; }
.section-heading h2:before { display: none; }
.section-heading > p { font-size: .875rem; }
.grid { gap: 10px 14px; }
#grid .card { background: white; border: 1px solid var(--line); border-radius: 6px; grid-template-columns: 48px minmax(0, 1fr); padding: 14px 16px 14px 10px; min-height: 76px; gap: 9px; align-items: center; }
#grid .card .number { color: var(--blue); background: #eaf1f6; font-size: 1.15rem; border-radius: 5px; padding: 9px 0; text-align: center; align-self: center; font-variant-numeric: tabular-nums; }
#grid .card h3 { font-size: 1rem; font-weight: 700; line-height: 1.4; color: var(--ink); padding-right: 16px; }
#grid .card.available h3::after { content: ''; position: absolute; inset-inline-end: 17px; top: calc(50% - 4px); width: 8px; height: 8px; border-right: 2px solid #597b92; border-top: 2px solid #597b92; transform: rotate(45deg); pointer-events: none; }
#grid .card.available:hover { background: #f0f6fa; border-color: #afc5d5; }
#grid .card.available:hover h3 { text-decoration: none; }
#grid .card.pending { background: #f0f3f5; }
#grid .card.pending .number { background: #e7ebee; color: #637587; }

/* Chapitres : ressources pratiques au premier plan, lecture intacte. */
#detail h1, #activities h1 { border-bottom: 0; padding-bottom: 0; color: var(--ink); margin-bottom: 1rem; }
#detail > .actions { align-items: center; gap: 8px 14px; margin: 16px 0; }
#detail > .actions > a, #detail > .actions > button { border: 1px solid #c5d3df; background: white; color: var(--blue); border-radius: 5px; text-decoration: none; font-size: .85rem; padding: 8px 12px; min-height: 40px; display: inline-flex; align-items: center; }
#detail > .actions > a:hover, #detail > .actions > button:hover { background: var(--tint); }
.chapter-resources { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; margin: 18px 0 22px; }
.resource-link { padding: 14px 16px; border: 1px solid #d7bdca; border-radius: 7px; background: #fcf5f8; color: #843a60; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.resource-link strong { font-size: .95rem; }
.resource-link span { color: #715365; font-size: .82rem; line-height: 1.4; }
.resource-link:hover { border-color: var(--pink); background: #f9edf3; }
.resource-explore { border-color: #dbd2e9; background: #f6f3fa; color: #614985; }
.resource-explore span { color: #665a79; }
.resource-explore:hover { border-color: var(--purple); background: #f0eaf7; }
.chapter-jumps { margin: 0 0 12px; position: sticky; top: var(--header-height); z-index: 10; padding: 10px 0; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; background: var(--canvas); border-bottom: 1px solid var(--line); }
.chapter-jumps button { min-height: 42px; border: 1px solid #c7d6e2; border-radius: 5px; background: white; color: var(--blue); padding: 9px 14px; font-size: .9rem; font-weight: 650; }
.chapter-jumps button[data-category="exercices"] { color: var(--pink); }
.chapter-jumps button[data-category="approfondissements"] { color: var(--purple); }
.chapter-jumps button[data-category="culture"] { color: var(--green); }
.chapter-jumps button:hover { box-shadow: inset 0 0 0 1px currentColor; }
.course-content .chapter-section { background: white; border-radius: 7px; margin: 12px 0; }
.course-content .chapter-section > summary { border-radius: 5px 5px 0 0; font-size: 1.2rem; padding: 16px 20px; scroll-margin-top: calc(var(--header-height) + 108px); }
.course-content .section-content { padding-inline: clamp(15px, 3vw, 30px); }
.course-content :is(h2,h3,[id]) { scroll-margin-top: calc(var(--header-height) + 108px); }
#detail .questions { background: white; border: 1px solid var(--line); border-top: 3px solid var(--blue); border-radius: var(--radius); padding: 24px; }
#detail .questions input, #detail .questions textarea { border-radius: 5px; }

/* Activités : les deux niveaux restent visibles, avec un filtre de type facultatif. */
.segmented { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 4px; background: #e9eff4; border: 1px solid #d9e3eb; border-radius: 7px; width: fit-content; max-width: 100%; }
.segmented button { border: 0; border-radius: 4px; color: var(--muted); background: transparent; padding: 9px 15px; font-size: .875rem; line-height: 1.45; min-height: 40px; font-weight: 650; }
.segmented button[aria-pressed="true"] { color: var(--blue); background: white; box-shadow: 0 1px 5px #143b5717; }
.segmented button:hover { color: var(--blue); }
.activity-kind-filter { margin: 22px 0 26px; }
.activity-level { margin: 0 0 32px; }
.activity-level-heading { padding-bottom: 9px; border-bottom: 1px solid var(--line); gap: 10px; }
.activity-level-digit { display: none; }
.activity-level .activity-group { margin: 22px 0 34px; }
.activity-level .activity-group h3 { font-size: 1.15rem; color: var(--ink); margin-bottom: 12px; }
.activity-grid { gap: 12px; }
.activity-card { background: white; border: 1px solid var(--line); border-top: 2px solid #bed1df; border-radius: var(--radius); box-shadow: none; padding: 18px; }
.activity-card h4 { font-size: 1.1rem; color: var(--ink); margin: 0 0 12px; }
.activity-card .actions { gap: 12px; align-items: center; }
.activity-card .activity-course, .activity-card .activity-type { font-size: .85rem; }
.activity-card .activity-chip { font-size: .75rem; font-weight: 650; }
.activity-quiz .primary { background: #8c3f62; border-color: #8c3f62; }
.activity-quiz .primary:hover { background: #71314e; }
.quiz-panel { max-width: 780px; margin-inline: auto; background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.quiz-option { min-height: 52px; border-radius: 6px; font-size: 1rem; }
.quiz-progress { font-size: .9rem; }
.quiz-length select { min-height: 44px; border-radius: 5px; }

/* Espace enseignant : navigation verticale et panneaux indépendants. */
.teacher-layout { display: grid; grid-template-columns: minmax(192px, 220px) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 26px; }
.teacher-menu { margin: 0; display: flex; flex-direction: column; gap: 4px; background: white; padding: 8px; border-radius: var(--radius); border: 1px solid var(--line); position: sticky; top: calc(var(--header-height) + 16px); }
.teacher-menu :is(button,a) { text-align: left; border: 0; border-radius: 5px; padding: 12px 13px; min-height: 45px; font-size: .9rem; color: var(--muted); background: transparent; font-weight: 650; line-height: 1.4; }
.teacher-menu [aria-pressed="true"] { background: #eaf2f7; color: var(--blue); font-weight: 750; }
.teacher-menu :is(button,a):hover { color: var(--blue); background: #f1f6fa; }
.teacher-panels { min-width: 0; }
.teacher-panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(17px, 2.4vw, 28px); min-width: 0; box-shadow: var(--shadow); }
.teacher-panel > :first-child { margin-top: 0; }
#teacher .teacher-panel h2 { color: var(--ink); font-size: 1.45rem; }
#quiz-stats-panel, #publication-panel { border: 0; padding: 0; }
#teacher .teacher-panel > p, #quiz-stats-panel > p, #publication-panel > p { font-size: .9rem; color: var(--muted); }
.stats-filters { padding: 16px; margin: 18px 0 20px; gap: 12px; align-items: end; border: 1px solid var(--line); border-radius: 7px; background: #f6f8fa; }
.stats-filters label { font-size: .875rem; flex: 1 1 145px; min-width: 0; }
.stats-filters select { min-height: 42px; width: 100%; border-radius: 5px; }
.stats-subnav { margin: 0 0 20px; width: 100%; }
.stats-subnav button { flex: 1 1 auto; white-space: normal; }
.stats-view { min-width: 0; }
.stats-summary { gap: 10px; margin: 0 0 16px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stats-summary article { background: #f7f9fb; border: 1px solid var(--line); border-radius: 7px; padding: 16px; }
.stats-summary article strong { font-size: clamp(1.45rem, 2.5vw, 2rem); color: var(--blue); font-variant-numeric: tabular-nums; }
.stats-summary article span { font-size: .875rem; line-height: 1.4; }
.stats-summary article small { font-size: .78rem; }
.stats-synthesis, .stats-section { border: 1px solid var(--line); border-radius: 6px; background: #fff; margin: 12px 0; }
.stats-synthesis > summary, .stats-section > summary { font-size: .95rem; padding: 13px 15px; border-radius: 5px; min-height: 46px; background: #f4f7fa; color: var(--blue); }
.stats-synthesis > summary { background: #edf4f8; }
.stats-table th, .stats-table td { font-size: .875rem; }
.stats-table-scroll { max-width: 100%; }
.publication-card { background: #f8fafb; border-radius: 6px; }
.publication-card > summary, .visibility-toggle { font-size: .875rem; min-height: 44px; }
.publication-badge { font-size: .75rem; }
.publication-controls { min-width: 0; }
.teacher-panel .publication-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.teacher-panel .question { border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 6px; }

/* Lexique et filtres : compléter les règles dont les sélecteurs étaient absents. */
.lexicon-word { border: 0; background: none; padding: 0; color: inherit; text-align: inherit; font: inherit; font-weight: inherit; text-decoration: underline; text-decoration-style: dotted; text-decoration-color: #748e9f; text-underline-offset: .25em; cursor: pointer; }
.lexicon-source { display: inline-block; margin-top: 1rem; font-size: .85rem; color: var(--blue); text-underline-offset: .2em; }
.bank-filters { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.bank-filters label { min-width: 155px; flex: 1; }
.bank-filters select { min-height: 44px; border-color: #bfced9; }
.bank-exercise { background: white; }

@media (max-width: 1000px) {
  .header-inner { gap: 16px; }
  .main-nav a { padding-inline: 10px; }
  .teacher-layout { grid-template-columns: 185px minmax(0, 1fr); gap: 14px; }
  .teacher-panel .publication-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  :root { --header-height: 0px; }
  .site-header { position: relative; }
  .header-inner { flex-wrap: wrap; gap: 8px 12px; padding-block: 12px 8px; }
  .header-tools { margin-left: auto; }
  .main-nav { order: 3; width: 100%; flex-basis: 100%; justify-content: space-between; margin: 0; gap: 2px; }
  .main-nav a { flex: 1; text-align: center; padding-inline: 4px; font-size: .875rem; }
  main { padding-top: 24px; }
  .teacher-layout { display: block; }
  .teacher-menu { position: static; flex-direction: row; flex-wrap: wrap; margin-bottom: 14px; padding: 5px; }
  .teacher-menu :is(button,a) { flex: 1 1 130px; text-align: center; padding: 9px; font-size: .85rem; }
  .chapter-jumps { top: 0; }
  .chapter-jumps button { font-size: .875rem; padding: 8px 11px; min-height: 44px; }
  .culture-home-heading h2 { font-size: 1.4rem; }
  .question-meta, .stats-filters { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .wordmark { font-size: 1.85rem; }
  .header-tools { gap: 5px; }
  .header-tools .dys-font-toggle { min-width: 42px; padding-inline: 6px; }
  .header-tools .student-view-toggle { width: 42px; min-width: 42px; flex-basis: 42px; }
  .level-switch { padding: 2px; }
  .level-switch button { min-width: 32px; min-height: 36px; }
  .level-grid { gap: 13px; margin-bottom: 30px; }
  .level-grid .level-card { padding: 17px; gap: 15px; }
  .level-number { min-width: 60px; font-size: 2.5rem; padding: 9px 7px; }
  .level-number sup { font-size: 1rem; }
  .level-card-heading { gap: 13px; }
  .level-card h2 { font-size: 1.35rem; }
  .intro { padding-bottom: 20px; }
  .intro .edition { display: none; }
  .intro h1 span { display: block; margin: .12em 0 0; }
  .culture-home-heading { align-items: flex-start; }
  .culture-home-heading .text-link { max-width: 95px; text-align: right; }
  .grid { grid-template-columns: 1fr; }
  #grid .card { min-height: 64px; padding-block: 10px; }
  .chapter-resources { grid-template-columns: 1fr; gap: 8px; }
  .resource-link { padding: 12px 14px; }
  .chapter-jumps { padding: 7px 0; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
  .chapter-jumps button { white-space: nowrap; flex: 0 0 auto; }
  .course-content .chapter-section > summary { font-size: 1.05rem; padding: 13px 14px; scroll-margin-top: 70px; }
  #detail .questions { padding: 17px; }
  .segmented { width: 100%; }
  .segmented button { flex: 1 1 auto; padding-inline: 9px; font-size: .85rem; }
  .activity-grid, .teacher-panel .publication-grid { grid-template-columns: 1fr; }
  .teacher-panel { padding: 14px; }
  .stats-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-summary article { padding: 12px; }
  .stats-filters { padding: 12px; }
  .stats-subnav button { flex: 1 1 40%; }
  .stats-synthesis > summary, .stats-section > summary { font-size: .875rem; }
  .quiz-panel { padding-inline: 14px; }
  footer { gap: 8px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .main-nav a { transition: none; }
}
@media print {
  .site-header, footer, .chapter-jumps, .chapter-resources, .teacher-menu, .stats-subnav, .activity-kind-filter { display: none !important; }
  main { max-width: none; background: white; padding: 0; }
  body { background: white; }
  .teacher-layout { display: block; }
  .teacher-panel { border: 0; box-shadow: none; padding: 0; }
}
