:root {
  color-scheme: light;
  --ink: #1d2724;
  --green: #26684d;
  --green-dark: #1d523d;
  --paper: #f8f8f4;
  --line: #e7e9e2;
  --muted: #78817b;
  --sans: "DM Sans", sans-serif;
  --serif: "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, textarea { font: inherit; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid #8aaf91; outline-offset: 3px; }

.page-header { display: flex; width: min(1120px, calc(100% - 48px)); height: 82px; align-items: center; justify-content: space-between; margin: auto; border-bottom: 1px solid rgba(29, 39, 36, .08); }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 800 17px var(--serif); letter-spacing: -.8px; }
.brand-mark { display: grid; width: 33px; height: 33px; place-items: center; border-radius: 11px 11px 11px 4px; background: var(--green); color: #fff; font-size: 19px; letter-spacing: -1px; }
.brand-light { color: #78817b; font-weight: 500; }
.back-link { display: inline-flex; align-items: center; gap: 9px; color: #616b64; font-size: 12px; font-weight: 600; }
.back-link:hover { color: var(--green); }

.programme-main { width: min(1000px, calc(100% - 40px)); margin: 55px auto 80px; }
.workspace-tabs { display: flex; gap: 7px; margin: 0 0 20px; padding: 5px; border: 1px solid #e8ebe4; border-radius: 10px; background: #f0f2ed; }
.workspace-tab { min-height: 39px; flex: 1; border: 0; border-radius: 7px; background: transparent; color: #647068; cursor: pointer; font-size: 11px; font-weight: 700; }
.workspace-tab[aria-selected="true"] { background: #fff; color: var(--green); box-shadow: 0 2px 7px rgba(37, 58, 42, .08); }
.workspace-panel[hidden], .custom-panel[hidden] { display: none; }
.page-intro { margin-bottom: 29px; text-align: center; }
.eyebrow, .card-eyebrow { color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: 1.15px; text-transform: uppercase; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; }
.eyebrow span { color: #d3a25c; font-size: 14px; }
h1, h2, h3 { font-family: var(--serif); }
h1 { margin: 0; font-size: clamp(35px, 6vw, 51px); letter-spacing: -1.7px; line-height: 1.16; }
h1 span { color: var(--green); }
.intro-copy { max-width: 580px; margin: 14px auto 0; color: var(--muted); font-size: 13px; line-height: 1.8; }

.picker-card { padding: 22px 24px; border: 1px solid #ebede7; border-radius: 14px; background: #fff; box-shadow: 0 12px 35px rgba(37, 58, 42, .05); }
.picker-section h2 { margin: 0 0 12px; font: 700 13px var(--serif); letter-spacing: -.2px; }
.grade-section { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 21px; padding-top: 19px; border-top: 1px solid #eef0eb; }
.grade-section h2 { margin: 0; }
.subject-picker, .grade-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.subject-choice, .grade-choice { display: inline-flex; min-height: 38px; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid #e8ebe4; border-radius: 8px; background: white; color: #626c65; cursor: pointer; font-size: 11px; font-weight: 600; transition: background .18s ease, border-color .18s ease, color .18s ease; }
.subject-choice span { color: #7a9680; font-size: 14px; }
.subject-choice:hover, .grade-choice:hover { border-color: #b6c8b7; }
.subject-choice[aria-pressed="true"], .grade-choice[aria-pressed="true"] { border-color: #b1c9b3; background: #edf4ec; color: #285d3d; }
.grade-choice { min-width: 49px; justify-content: center; font-size: 12px; }

.chapter-section { margin-top: 36px; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.card-eyebrow { margin: 0 0 6px; color: #929a93; font-size: 9px; letter-spacing: 1px; }
.section-title-row h2 { margin: 0; font-size: 22px; letter-spacing: -.7px; }
.chapter-count { padding: 6px 10px; border-radius: 20px; background: #edf2eb; color: #55725a; font-size: 9px; font-weight: 700; }
.chapter-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.chapter-button { display: flex; min-height: 76px; align-items: center; gap: 13px; padding: 14px; border: 1px solid #e8ebe4; border-radius: 10px; background: white; color: var(--ink); cursor: pointer; text-align: left; transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.chapter-button:hover { transform: translateY(-2px); border-color: #b4c8b6; box-shadow: 0 8px 20px rgba(37, 58, 42, .06); }
.chapter-number { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 9px; background: #eef3eb; color: var(--green); font-size: 11px; font-weight: 700; }
body[data-subject="maths"] { --subject-accent: #a96814; --subject-soft: #fff3dd; --subject-border: #f0d9ae; }
body[data-subject="francais"] { --subject-accent: #a94d64; --subject-soft: #fff0f2; --subject-border: #f0d1d8; }
body[data-subject="svt"] { --subject-accent: #2d844f; --subject-soft: #ecf8ef; --subject-border: #c8e5cf; }
body[data-subject="technologie"] { --subject-accent: #3369a0; --subject-soft: #edf4fb; --subject-border: #caddec; }
body[data-subject="physique-chimie"] { --subject-accent: #9c4e97; --subject-soft: #f8eff7; --subject-border: #e8cfe4; }
body[data-subject="anglais"] { --subject-accent: #3f60a5; --subject-soft: #edf2fb; --subject-border: #cfdaf2; }
body[data-subject="espagnol"] { --subject-accent: #c68f22; --subject-soft: #fff6da; --subject-border: #eddba8; }
body[data-subject="allemand"] { --subject-accent: #464650; --subject-soft: #f0f0f3; --subject-border: #d6d6dc; }
body[data-subject="emc"] { --subject-accent: #4f704e; --subject-soft: #eff7ed; --subject-border: #d0e3ce; }
body[data-subject="histoire-geo"] { --subject-accent: #765491; --subject-soft: #f4effa; --subject-border: #e1d4ef; }
body[data-subject] .chapter-button:hover { border-color: var(--subject-border); }
body[data-subject] .chapter-number { background: var(--subject-soft); color: var(--subject-accent); }
body[data-subject] .chapter-arrow { color: var(--subject-accent); }
.chapter-button-copy { display: flex; flex: 1; flex-direction: column; gap: 5px; }
.chapter-button-copy strong { font: 700 12px var(--serif); }
.chapter-button-copy small { color: #89918b; font-size: 9px; }
.chapter-arrow { color: #7f9282; font-size: 16px; }

.lesson-card { --fiche-accent: #47764e; --fiche-soft: #f3f8f1; --fiche-border: #dce9d8; --fiche-example: #fff7e9; --fiche-method: #f1f0fa; margin-top: 30px; overflow: hidden; border: 1px solid #e7eae3; border-top: 5px solid var(--fiche-accent); border-radius: 14px; background: #fff; box-shadow: 0 16px 44px rgba(37, 58, 42, .08); scroll-margin-top: 20px; }
.lesson-card[data-subject="maths"] { --fiche-accent: #bd781b; --fiche-soft: #fff7e9; --fiche-border: #f1dfbf; --fiche-example: #fff1d9; --fiche-method: #f2effb; }
.lesson-card[data-subject="francais"] { --fiche-accent: #ad5369; --fiche-soft: #fff3f4; --fiche-border: #f0d8dd; --fiche-example: #fff0e9; --fiche-method: #f3eff9; }
.lesson-card[data-subject="svt"] { --fiche-accent: #2d844f; --fiche-soft: #edf8ef; --fiche-border: #cfe6d4; --fiche-example: #eff9f1; --fiche-method: #edf5fa; }
.lesson-card[data-subject="technologie"] { --fiche-accent: #3369a0; --fiche-soft: #edf4fb; --fiche-border: #cbddec; --fiche-example: #eff7fb; --fiche-method: #f1f1fa; }
.lesson-card[data-subject="physique-chimie"] { --fiche-accent: #9c4e97; --fiche-soft: #f8eff7; --fiche-border: #e7cfe3; --fiche-example: #fff1ed; --fiche-method: #f0eff9; }
.lesson-card[data-subject="anglais"] { --fiche-accent: #3f60a5; --fiche-soft: #edf2fb; --fiche-border: #cfdaf2; --fiche-example: #eff6ff; --fiche-method: #f1eff9; }
.lesson-card[data-subject="espagnol"] { --fiche-accent: #c68f22; --fiche-soft: #fff6da; --fiche-border: #eddba8; --fiche-example: #fff8e8; --fiche-method: #f7f1df; }
.lesson-card[data-subject="allemand"] { --fiche-accent: #464650; --fiche-soft: #f0f0f3; --fiche-border: #d6d6dc; --fiche-example: #f7f7f8; --fiche-method: #eceff5; }
.lesson-card[data-subject="emc"] { --fiche-accent: #4f704e; --fiche-soft: #eff7ed; --fiche-border: #d0e3ce; --fiche-example: #fff7e9; --fiche-method: #eef4ed; }
.lesson-card[data-subject="histoire-geo"] { --fiche-accent: #795797; --fiche-soft: #f7f2fb; --fiche-border: #e5d9ef; --fiche-example: #fff4e8; --fiche-method: #f0f3fb; }
.lesson-card[hidden] { display: none; }
.lesson-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 23px 26px; border-bottom: 1px solid var(--fiche-border); background: linear-gradient(110deg, var(--fiche-soft), #fff 82%); }
.lesson-heading .eyebrow { gap: 7px; margin-bottom: 7px; color: var(--fiche-accent); font-size: 9px; }
.lesson-heading .eyebrow span:first-child { font-size: 15px; }
.lesson-heading h2 { margin: 0; font-size: 24px; letter-spacing: -.8px; }
.brevet-badge { display: inline-flex; margin-top: 8px; padding: 5px 8px; border-radius: 20px; background: #fff4d8; color: #8a641f; font-size: 9px; font-weight: 700; }
.brevet-badge[hidden] { display: none; }
.download-button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 9px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--fiche-accent); color: white; cursor: pointer; font-size: 10px; font-weight: 700; transition: filter .18s ease, transform .18s ease; }
.download-button:hover { transform: translateY(-1px); filter: brightness(.92); }
.download-button span { font-size: 16px; }
.lesson-content { padding: 24px 26px 26px; }
.lesson-content h3, .exercise-heading h3 { margin: 0; font: 700 16px var(--serif); letter-spacing: -.35px; }
.lesson-content .subsection-title { margin: 21px 0 10px; font-size: 13px; }
.lesson-content > p { margin: 11px 0 14px; color: #59645d; font-size: 12px; line-height: 1.85; }
.lesson-content ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.lesson-content li { position: relative; padding-left: 19px; color: #657069; font-size: 11px; line-height: 1.7; }
.lesson-content li::before { position: absolute; top: 2px; left: 0; color: var(--fiche-accent); content: "✦"; font-size: 10px; }
.definition-list { display: grid; gap: 9px; margin: 0; }
.definition-item { padding: 11px 13px; border: 1px solid var(--fiche-border); border-left: 3px solid var(--fiche-accent); border-radius: 8px; background: var(--fiche-soft); }
.definition-item dt { margin-bottom: 4px; color: var(--fiche-accent); font-size: 11px; font-weight: 700; }
.definition-item dd { margin: 0; color: #657069; font-size: 11px; line-height: 1.7; }
.method-box { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--fiche-border); border-radius: 9px; background: var(--fiche-method); }
.method-box > strong { color: var(--fiche-accent); font-size: 10px; }
.method-box ul { margin-top: 8px; }
.method-box li { color: #5d6b79; }
.method-box li::before { color: var(--fiche-accent); }
.example-box { margin-top: 18px; padding: 14px 16px; border-left: 3px solid var(--fiche-accent); border-radius: 0 9px 9px 0; background: var(--fiche-example); }
.example-box strong { color: var(--fiche-accent); font-size: 10px; }
.example-box p { margin: 6px 0 0; color: #59645d; font-size: 11px; line-height: 1.7; }

.exercises-section { padding: 23px 26px 27px; border-top: 1px solid var(--fiche-border); background: var(--fiche-soft); }
.exercise-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.exercise-tools { display: flex; align-items: center; gap: 12px; }
.exercise-tools > span { color: #8a928c; font-size: 9px; }
.generate-button { min-height: 34px; padding: 0 11px; border: 1px solid var(--fiche-border); border-radius: 7px; background: #fff; color: var(--fiche-accent); cursor: pointer; font-size: 9px; font-weight: 700; }
.generate-button:hover { border-color: var(--fiche-accent); background: var(--fiche-soft); }
.generate-button span { margin-right: 4px; font-size: 13px; }
.exercise-list { display: grid; gap: 10px; }
.exercise-card { padding: 14px; border: 1px solid var(--fiche-border); border-radius: 9px; background: #fff; box-shadow: 0 3px 10px rgba(37, 58, 42, .025); }
.exercise-card h4 { margin: 0 0 10px; color: var(--fiche-accent); font-size: 10px; font-weight: 700; letter-spacing: .35px; }
.exercise-card > p { margin: 0 0 10px; color: #38443c; font-size: 11px; line-height: 1.7; }
.exercise-card textarea { display: block; width: 100%; min-height: 56px; resize: vertical; padding: 9px 10px; border: 1px solid #e7eae4; border-radius: 7px; color: var(--ink); font-size: 10px; line-height: 1.6; }
.exercise-card textarea::placeholder { color: #a3aaa4; }
.exercise-card textarea.is-correct { border-color: #9cbea2; background: #f3f8f2; }
.exercise-card textarea.is-incorrect { border-color: #e6aaa0; }
.exercise-answer-form { display: grid; gap: 8px; }
.exercise-actions { display: flex; align-items: center; gap: 12px; }
.exercise-check { min-height: 31px; padding: 0 11px; border: 0; border-radius: 6px; background: var(--fiche-soft); color: var(--fiche-accent); cursor: pointer; font-size: 9px; font-weight: 700; }
.exercise-check:hover { filter: brightness(.96); }
.exercise-feedback { min-height: 14px; margin: 0; color: #397148; font-size: 9px; line-height: 1.5; }
.exercise-feedback.is-incorrect { color: #9b5147; }
.solution-toggle { margin-top: 9px; padding: 0; border: 0; background: transparent; color: var(--fiche-accent); cursor: pointer; font-size: 10px; font-weight: 700; }
.solution-toggle:hover { text-decoration: underline; }
.solution { margin: 9px 0 0; padding: 10px 12px; border: 1px solid var(--fiche-border); border-radius: 7px; background: var(--fiche-soft); color: #49624d; font-size: 10px; line-height: 1.7; }
.solution[hidden] { display: none; }
.generated-status { min-height: 16px; margin: 14px 0 0; color: #718174; font-size: 9px; }
.generated-list:empty { display: none; }
.generated-exercise { border-color: var(--fiche-border); background: #fff; }
.generated-choices { display: grid; gap: 7px; margin-top: 10px; }
.generated-choice { min-height: 38px; padding: 8px 11px; border: 1px solid #e5eae2; border-radius: 7px; background: #fff; color: #566158; cursor: pointer; font-size: 10px; line-height: 1.5; text-align: left; }
.generated-choice:hover:not(:disabled) { border-color: var(--fiche-accent); }
.generated-choice:disabled { cursor: default; }
.generated-choice.is-correct { border-color: var(--fiche-accent); background: var(--fiche-soft); color: var(--fiche-accent); font-weight: 700; }
.generated-choice.is-incorrect { border-color: #e6aaa0; background: #fbefed; color: #9b5147; }
.curriculum-note { max-width: 730px; margin: 20px auto 0; color: #858e87; font-size: 10px; line-height: 1.75; text-align: center; }
.curriculum-note a { color: var(--green); font-weight: 700; text-decoration: underline; }
.brevet-card { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center; margin-top: 28px; padding: 24px; border: 1px solid #dfe7dd; border-radius: 14px; background: linear-gradient(120deg, #edf5ed, #fff8e9); }
.brevet-card h2 { margin: 0 0 8px; font-size: 21px; }
.brevet-card p:not(.card-eyebrow) { margin: 0; color: #657169; font-size: 11px; line-height: 1.7; }
.brevet-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.brevet-links a { min-height: 40px; display: grid; place-items: center; padding: 8px; border: 1px solid #dce5da; border-radius: 8px; background: #fff; color: #3e6547; font-size: 10px; font-weight: 700; text-align: center; }
.brevet-links a:hover { border-color: #93b397; background: #f6faf5; }

.custom-panel { margin-top: 7px; }
.custom-intro { margin-bottom: 18px; text-align: center; }
.custom-intro h2 { margin: 0; font-size: 25px; letter-spacing: -.8px; }
.custom-intro > p:last-child { max-width: 610px; margin: 9px auto 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.custom-form { display: grid; gap: 16px; padding: 22px; border: 1px solid #e8ebe4; border-radius: 13px; background: #fff; box-shadow: 0 12px 35px rgba(37, 58, 42, .05); }
.custom-form > label, .form-grid > label, .custom-row label { display: flex; flex-direction: column; gap: 7px; color: #505d54; font-size: 10px; font-weight: 700; }
.custom-form input, .custom-form select, .custom-form textarea { width: 100%; padding: 10px 11px; border: 1px solid #e1e6de; border-radius: 7px; background: #fff; color: var(--ink); font-size: 11px; font-weight: 400; }
.custom-form textarea { resize: vertical; line-height: 1.6; }
.custom-form input::placeholder, .custom-form textarea::placeholder { color: #a0a8a1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.label-hint { color: #949c95; font-size: 9px; font-weight: 400; }
.custom-fieldset { display: grid; gap: 12px; min-width: 0; margin: 0; padding: 15px; border: 1px solid #e9ede6; border-radius: 9px; }
.custom-fieldset legend { padding: 0 6px; color: #4b6250; font-size: 11px; font-weight: 700; }
.custom-rows { display: grid; gap: 10px; }
.custom-row { display: grid; grid-template-columns: 1fr 1.5fr; gap: 11px; padding: 11px; border-radius: 8px; background: #f8f9f6; }
.add-row-button, .clear-button { justify-self: start; padding: 7px 0; border: 0; background: transparent; color: var(--green); cursor: pointer; font-size: 10px; font-weight: 700; }
.add-row-button:hover, .clear-button:hover { text-decoration: underline; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.save-button { min-height: 42px; padding: 0 16px; border: 0; border-radius: 7px; background: var(--green); color: #fff; cursor: pointer; font-size: 10px; font-weight: 700; }
.save-button:hover { background: var(--green-dark); }
.custom-status { min-height: 16px; margin: -7px 0 0; color: #47704d; font-size: 10px; line-height: 1.5; }
.custom-status.is-error { color: #9b5147; }
.saved-section { margin-top: 30px; }
.saved-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.saved-heading h3 { margin: 0; font: 700 19px var(--serif); }
.saved-list { display: grid; gap: 10px; }
.saved-fiche { padding: 16px; border: 1px solid #e8ebe4; border-radius: 9px; background: #fff; }
.saved-fiche-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.saved-fiche h4 { margin: 0; font: 700 13px var(--serif); }
.saved-fiche-meta { margin: 5px 0 0; color: #89918b; font-size: 9px; }
.saved-fiche details { margin-top: 12px; color: #68736b; font-size: 10px; line-height: 1.65; }
.saved-fiche details > summary { color: var(--green); cursor: pointer; font-weight: 700; }
.saved-fiche details p { margin: 9px 0; }
.saved-fiche details ul, .saved-fiche details ol { display: grid; gap: 5px; padding-left: 20px; }
.saved-fiche-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.saved-fiche-actions button { min-height: 32px; padding: 0 10px; border: 1px solid #e3e9e1; border-radius: 6px; background: #fff; color: #4e6753; cursor: pointer; font-size: 9px; font-weight: 700; }
.saved-fiche-actions button:hover { border-color: #b7c9b8; background: #f4f8f2; }
.saved-fiche-actions .delete-fiche { color: #9b5147; }
.saved-empty { padding: 17px; border: 1px dashed #dfe5dc; border-radius: 9px; color: #879088; font-size: 10px; text-align: center; }

@media (max-width: 650px) {
  .page-header { width: calc(100% - 36px); height: 70px; }
  .brand { gap: 8px; font-size: 15px; }
  .brand-mark { width: 30px; height: 30px; font-size: 17px; }
  .back-link { gap: 5px; font-size: 10px; }
  .programme-main { width: calc(100% - 30px); margin-top: 40px; }
  .intro-copy { font-size: 12px; }
  .picker-card { padding: 18px 15px; }
  .subject-picker { gap: 6px; }
  .subject-choice { min-height: 36px; gap: 6px; padding: 0 9px; font-size: 10px; }
  .grade-section { align-items: flex-start; flex-direction: column; gap: 12px; }
  .chapter-list { grid-template-columns: 1fr; }
  .lesson-heading { align-items: flex-start; flex-direction: column; padding: 20px 18px; }
  .lesson-content { padding: 20px 18px; }
  .exercises-section { padding: 20px 18px 22px; }
  .exercise-heading { align-items: flex-start; flex-direction: column; }
  .exercise-tools { align-items: flex-start; flex-direction: column; gap: 8px; }
  .custom-form { padding: 16px; }
  .form-grid, .custom-row { grid-template-columns: 1fr; }
  .custom-fieldset { padding: 11px; }
  .saved-fiche-top { align-items: flex-start; flex-direction: column; }
  .brevet-card { grid-template-columns: 1fr; padding: 18px; }
}

@media print {
  body { background: white; }
  .page-header, .page-intro, .workspace-tabs, .picker-card, .chapter-section, .download-button, .curriculum-note, .custom-panel { display: none !important; }
  .programme-main { width: 100%; margin: 0; }
  .lesson-card, .lesson-card[hidden] { display: block !important; border: 0; box-shadow: none; }
  .lesson-heading { padding: 0 0 14px; }
  .lesson-content, .exercises-section { padding: 15px 0; background: white; }
  .exercise-card textarea, .solution-toggle { display: none; }
  .solution[hidden] { display: block !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
