/* Shared visual layer. Legacy exercise selectors and interactions stay intact. */
:root{--ink:#203d36;--muted:#64736d;--paper:#f8f7f2;--surface:#fff;--line:#e2e7df;--green:#27644f;--soft:#eaf0e5;--accent:#e7b775;--font-family-arabic:'Noto Naskh Arabic','Amiri',serif}
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;color:var(--ink);background:var(--paper);font-family:Inter,system-ui,-apple-system,'Segoe UI',sans-serif;line-height:1.6;font-size:16px}a{color:inherit}button,input,select{font:inherit}button,a,input,select,summary{-webkit-tap-highlight-color:transparent}button,a.btn{cursor:pointer}button:disabled{cursor:default;opacity:.55}a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible{outline:3px solid #bd791f;outline-offset:4px}button,input,select{min-height:44px}h1,h2,h3,p{margin-top:0}h1,h2,h3{line-height:1.2;letter-spacing:-.035em}a{text-underline-offset:4px}.site-nav{max-width:1280px;margin:auto;display:flex;align-items:center;justify-content:space-between;gap:24px;padding:24px 40px;background:var(--paper);position:relative;z-index:15;border-bottom:1px solid var(--line)}.brand{display:flex;align-items:center;gap:10px;text-decoration:none;font-size:21px;font-weight:750;white-space:nowrap;letter-spacing:-.6px}.brand-mark{display:grid;place-items:center;width:39px;height:39px;background:var(--green);color:white;border-radius:13px 13px 13px 3px;font:30px/1.2 var(--font-family-arabic)}.brand-light{font-weight:400}.nav-links{display:flex;gap:28px}.nav-links a{font-size:14px;text-decoration:none;color:var(--muted);padding:10px 0}.nav-links a:hover,.nav-links a[aria-current]{color:var(--green)}.nav-links a[aria-current]{box-shadow:0 2px var(--green)}.account-link{display:flex;align-items:center;gap:8px;text-decoration:none;font-size:13px;background:var(--surface);padding:10px 16px;border:1px solid var(--line);border-radius:50px;max-width:190px}.account-link span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.account-dot{background:var(--green);width:7px;height:7px;border-radius:50%;flex:none}.shell{max-width:1200px;margin:0 auto;padding:0 40px}.eyebrow{font-size:11px;font-weight:750;letter-spacing:2px;text-transform:uppercase;color:var(--green);margin-bottom:20px}.hero{display:grid;grid-template-columns:1.3fr 1fr;gap:64px;align-items:center;padding:64px 0 48px}.hero h1{font-weight:550;font-size:clamp(36px,4.5vw,59px);margin:18px 0 23px;max-width:650px}.hero h1 em{font-family:Georgia,serif;font-weight:400;color:var(--green)}.hero p{color:var(--muted);max-width:470px;font-size:16px}.hero-actions{display:flex;gap:12px;flex-wrap:wrap;margin-top:28px}.btn{display:inline-flex;align-items:center;justify-content:center;gap:10px;min-height:46px;padding:11px 20px;border:1px solid var(--green);border-radius:9px;background:var(--green);color:#fff;text-decoration:none;font-weight:600;font-size:14px;transition:transform .15s,background .15s}.btn:hover{background:#1e503f;transform:translateY(-1px)}.btn.secondary{background:transparent;color:var(--ink);border-color:var(--line)}.btn.secondary:hover{background:var(--soft)}.btn.small{padding:8px 14px;font-size:13px}.hero-art{position:relative;min-height:300px;display:grid;place-items:center;border-radius:180px 180px 20px 20px;background:#e9eee2;overflow:hidden}.hero-art:before,.hero-art:after{content:'';position:absolute;border:1px solid #cbd7c0;border-radius:50%;width:330px;height:330px;inset:25px auto auto;transform:rotate(20deg)}.hero-art:after{width:245px;height:245px;top:65px}.hero-arabic{font:130px/1.6 var(--font-family-arabic);color:var(--green);z-index:1;margin:0 0 12px}.art-caption{position:absolute;bottom:32px;letter-spacing:3px;font-size:11px;color:var(--green);text-transform:uppercase}.art-tag{position:absolute;right:18px;top:27px;background:#fffdf7;border:1px solid #e1d9c7;padding:8px 12px;border-radius:8px;font-size:11px;z-index:2}.stats-strip{display:grid;grid-template-columns:repeat(3,1fr);padding:23px 0;border-top:1px solid var(--line);border-bottom:1px solid var(--line);margin-bottom:48px}.strip-item{display:flex;align-items:center;gap:12px;padding:0 25px;border-right:1px solid var(--line)}.strip-item:first-child{padding-left:0}.strip-item:last-child{border:0}.strip-item strong{font-size:28px;font-weight:500}.strip-item span{font-size:12px;line-height:1.6;color:var(--muted)}.section-heading{display:flex;justify-content:space-between;align-items:end;gap:20px;margin-bottom:22px}.section-heading h2{font-size:29px;font-weight:550;margin:0 0 7px}.section-heading p{font-size:14px;color:var(--muted);margin:0}.section-heading .eyebrow{margin-bottom:10px}.subtle-link{font-size:13px;color:var(--green);white-space:nowrap}.course-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:17px;margin-bottom:44px}.course-card{position:relative;display:flex;flex-direction:column;align-items:start;background:var(--surface);border:1px solid var(--line);border-radius:13px;padding:25px;text-decoration:none;transition:transform .2s,border .2s;min-width:0}.course-card:hover{transform:translateY(-3px);border-color:#a1b49b}.course-card.featured{background:#edf2e7}.card-top{display:flex;justify-content:space-between;align-items:center;width:100%;margin-bottom:26px}.course-icon{font:31px/1.4 var(--font-family-arabic);width:48px;height:48px;display:grid;place-items:center;background:var(--soft);border-radius:12px}.course-card:nth-child(2) .course-icon{background:#f7eedf}.course-card:nth-child(3) .course-icon{background:#e9edf2}.badge{font-size:10px;letter-spacing:.7px;text-transform:uppercase;padding:5px 9px;border-radius:5px;background:var(--soft);color:var(--green);font-weight:700}.course-card h3{font-size:20px;margin-bottom:10px}.course-card p{font-size:13px;color:var(--muted);margin-bottom:23px}.card-bottom{margin-top:auto;font-size:12px;display:flex;justify-content:space-between;width:100%;padding-top:16px;border-top:1px solid var(--line)}.practice-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:45px}.practice-card{background:var(--surface);border:1px solid var(--line);border-radius:11px;padding:22px;text-decoration:none;display:flex;flex-direction:column;gap:7px}.practice-card strong{font-size:15px}.practice-card small{color:var(--muted);font-size:12px}.practice-card:hover{border-color:var(--green)}.callout{display:flex;justify-content:space-between;gap:30px;align-items:center;background:#e9eee2;border:1px solid #dce4d4;border-radius:13px;padding:28px;margin:40px 0}.callout h3{font-size:21px;margin-bottom:8px}.callout p{color:var(--muted);font-size:14px;margin:0}.site-footer{display:flex;justify-content:space-between;gap:16px;border-top:1px solid var(--line);padding:24px 0;color:var(--muted);font-size:12px;background:none;text-align:left;margin-top:45px}.page-heading{padding:46px 0 28px}.page-heading h1{font-size:42px;font-weight:550;margin-bottom:12px}.page-heading p{color:var(--muted);max-width:690px}.toolbar{display:flex;gap:12px;align-items:end;flex-wrap:wrap;margin-bottom:23px}.field{display:flex;flex-direction:column;gap:6px;flex:1;min-width:170px}.field label{font-size:12px;font-weight:650;color:var(--muted)}input,select{background:var(--surface);color:var(--ink);border:1px solid var(--line);padding:11px 13px;border-radius:8px;max-width:100%;width:100%}.mode-switch{display:flex;gap:5px;padding:4px;background:#e9ede4;border-radius:9px;width:max-content;margin-bottom:26px;max-width:100%;flex-wrap:wrap}.mode-switch button{border:0;background:transparent;color:var(--muted);padding:8px 18px;border-radius:6px;font-size:13px}.mode-switch button[aria-pressed=true]{background:var(--surface);color:var(--green);box-shadow:0 1px 4px #203d3610}.vocab-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.word-card{background:var(--surface);border:1px solid var(--line);border-radius:13px;padding:22px;display:flex;flex-direction:column;gap:10px}.word-card .arabic{font:38px/1.9 var(--font-family-arabic);text-align:center;margin:8px 0;color:var(--ink);letter-spacing:0}.word-card h3{font-size:16px;margin:0;letter-spacing:0}.word-card .translit{font-size:15px;color:var(--green)}.word-card .word-actions{display:flex;gap:8px;margin-top:auto;padding-top:8px;flex-wrap:wrap}.word-card small{font-size:10px;color:var(--muted)}.word-card .category{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:1px}.word-status{float:right;color:var(--green);font-size:12px}.result-count,.helper{font-size:13px;color:var(--muted)}.notice{padding:13px 17px;border:1px solid var(--line);background:var(--soft);border-radius:8px;font-size:13px;margin:16px 0}.notice:empty{display:none}.error-text{color:#9a3b27}.success-text{color:var(--green)}.learning-panel{max-width:700px;margin:0 auto 25px;padding:32px;background:var(--surface);border:1px solid var(--line);border-radius:16px;text-align:center}.learning-panel .arabic{font:72px/1.9 var(--font-family-arabic);margin:20px 0}.learning-panel .answer{font-size:23px;margin:10px 0 24px}.learning-panel form{text-align:left}.learning-panel .actions{display:flex;justify-content:center;gap:12px;flex-wrap:wrap}.progress-track{height:6px;background:var(--soft);border-radius:10px;overflow:hidden;margin:16px 0}.progress-track span{display:block;background:var(--green);height:100%}.auth-layout{display:grid;grid-template-columns:1fr 1fr;gap:80px;padding:70px 0;align-items:center}.auth-intro h1{font-size:46px;font-weight:550}.auth-intro p{color:var(--muted)}.auth-card{background:var(--surface);border:1px solid var(--line);padding:32px;border-radius:16px}.auth-card .field{margin-bottom:18px}.auth-card .btn{width:100%}.auth-card h2{font-size:25px;margin:0 0 25px}.auth-card form p{font-size:12px;color:var(--muted)}.auth-tabs{display:flex;gap:20px;margin-bottom:27px;border-bottom:1px solid var(--line)}.auth-tabs button{background:none;border:0;border-bottom:2px solid transparent;border-radius:0;padding:10px 0;font-size:14px;color:var(--muted)}.auth-tabs button[aria-pressed=true]{color:var(--green);border-bottom-color:var(--green)}.metric-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px;margin-bottom:30px}.metric{border:1px solid var(--line);padding:25px;border-radius:13px;background:var(--surface)}.metric strong{display:block;font-size:36px;line-height:1.3;font-weight:550}.metric span{font-size:13px;color:var(--muted)}.progress-list{display:grid;grid-template-columns:1fr 1fr;gap:16px}.progress-row{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:23px;text-decoration:none}.progress-row h3{font-size:17px;margin-bottom:8px}.progress-row p{font-size:13px;color:var(--muted);margin:0}.sync-chip{display:inline-flex;align-items:center;gap:8px;border:1px solid var(--line);padding:6px 10px;font-size:11px;border-radius:30px;background:var(--surface)}.sync-chip:before{content:'';width:6px;height:6px;border-radius:50%;background:var(--green)}details{font-size:13px;padding:16px 0}summary{cursor:pointer;font-weight:600}details p{margin:12px 0}.danger{color:#9a3b27!important;border-color:#d6aea5!important} [hidden]{display:none!important}.empty-state{text-align:center;padding:55px 15px;background:var(--surface);border:1px dashed var(--line);border-radius:12px;grid-column:1/-1}.skip-link{position:absolute;top:-80px;left:20px;z-index:100;background:var(--ink);color:white;padding:10px}.skip-link:focus{top:10px}
/* Old lessons receive the same frame, without replacing their specialized components. */
.legacy-page>header{background:var(--green);padding:24px max(20px,calc((100vw - 1120px)/2));border-radius:0;box-shadow:none}.legacy-page>header h1{font-size:clamp(22px,4vw,32px);margin:10px 0}.legacy-page>main{max-width:1200px;margin:24px auto;padding:0 22px}.legacy-page .back-button{border-radius:8px;min-height:44px}.legacy-page .site-nav a{color:var(--ink)}.legacy-page button{max-width:100%}.legacy-page input:not([type=checkbox]):not([type=radio]){min-width:0}.legacy-page .translit-selector,.legacy-page .quran-selector{max-width:850px}.legacy-page footer{background:transparent;color:var(--muted)}.legacy-page canvas{max-width:100%;touch-action:none}
[data-theme=dark]{--ink:#e5eee7;--muted:#b1bfb6;--paper:#18221e;--surface:#212f28;--line:#394a40;--green:#85bf9f;--soft:#2d4034}[data-theme=dark] .site-nav,[data-theme=dark] .word-card,[data-theme=dark] .course-card{color:var(--ink)}[data-theme=dark] .btn:not(.secondary){background:#32644b;color:white}[data-theme=dark] .hero-art,[data-theme=dark] .callout,[data-theme=dark] .mode-switch,[data-theme=dark] .course-card.featured{background:#283a2e}[data-theme=dark] .art-tag{background:#2c382c;border-color:#546a52}[data-theme=dark] .course-icon{background:#2d4034!important}
@media(max-width:900px){.site-nav{padding:18px 24px;gap:18px}.nav-links{gap:16px}.shell{padding:0 24px}.hero{gap:30px;padding-top:42px}.hero-art{min-height:280px}.course-grid,.vocab-grid{grid-template-columns:repeat(2,1fr)}.practice-grid{grid-template-columns:repeat(2,1fr)}.auth-layout{gap:35px}.hero h1{font-size:43px}.brand{font-size:18px}}
@media(max-width:650px){.site-nav{flex-wrap:wrap;gap:14px;padding:16px 20px}.brand{font-size:19px}.brand-mark{width:34px;height:34px}.nav-links{order:3;width:100%;justify-content:space-between;gap:10px;border-top:1px solid var(--line);padding-top:4px}.nav-links a{font-size:12px}.account-link{margin-left:auto;padding:7px 11px;font-size:11px;max-width:155px}.shell{padding:0 20px}.hero{grid-template-columns:1fr;gap:28px;padding:32px 0}.hero h1{font-size:42px;max-width:500px}.hero-art{min-height:210px;border-radius:120px 120px 15px 15px;max-width:100%;width:100%}.hero-arabic{font-size:96px}.hero-art:before{top:-30px}.hero-art:after{top:6px}.art-caption{bottom:21px}.hero p{font-size:15px}.hero-actions{margin-top:23px}.hero-actions .btn{flex:1}.stats-strip{margin-bottom:32px;padding:19px 0}.strip-item{padding:0 12px;flex-direction:column;gap:1px;align-items:start}.strip-item strong{font-size:24px}.strip-item span{font-size:10px}.section-heading{align-items:start}.section-heading h2{font-size:26px}.section-heading .subtle-link{font-size:11px}.course-grid{gap:12px;margin-bottom:33px}.course-card{padding:19px}.course-card h3{font-size:17px}.course-card p{font-size:12px}.card-top{margin-bottom:17px}.course-icon{width:38px;height:38px;font-size:27px}.badge{font-size:8px;padding:4px 6px}.course-grid .featured{grid-column:1/-1}.course-grid .featured .card-top{margin-bottom:12px}.practice-grid{gap:10px}.practice-card{padding:17px}.practice-card strong{font-size:14px}.callout{flex-direction:column;align-items:start;padding:22px;gap:18px}.site-footer{flex-direction:column;gap:4px;margin-top:32px}.page-heading{padding:30px 0 18px}.page-heading h1{font-size:34px}.vocab-grid{grid-template-columns:1fr}.word-card{padding:21px}.word-card .arabic{font-size:44px}.toolbar .field{min-width:calc(50% - 12px)}.toolbar .field:first-child{flex-basis:100%}.learning-panel{padding:24px 18px}.learning-panel .arabic{font-size:58px}.auth-layout{grid-template-columns:1fr;padding:32px 0;gap:20px}.auth-intro h1{font-size:36px}.auth-card{padding:23px}.metric-grid{gap:9px}.metric{padding:16px 10px}.metric strong{font-size:27px}.metric span{font-size:10px}.progress-list{grid-template-columns:1fr}.legacy-page>main{padding:0 12px}.legacy-page .answer-row{flex-wrap:wrap}.legacy-page .input-row{flex-wrap:wrap}.legacy-page .final-stats{flex-wrap:wrap}.legacy-page .stats-bar{flex-wrap:wrap}.legacy-page .letter-selector-grid{grid-template-columns:repeat(auto-fit,minmax(55px,1fr))}.legacy-page .action-row{flex-wrap:wrap}.legacy-page .learning-header{flex-wrap:wrap}}
.profile-list{display:grid;gap:10px;margin:20px 0 28px}.profile-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px;background:var(--soft);border-radius:9px;font-size:14px}.profile-row span{overflow-wrap:anywhere;min-width:0}.profile-row .btn{width:auto;flex:none}.import-panel{border:1px solid var(--line);border-radius:12px;padding:23px;margin-top:20px;background:var(--surface)}.import-panel h3{font-size:19px}.import-panel input{margin:10px 0}.import-panel label{font-size:13px}.profile-row button{white-space:nowrap}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;animation:none!important;transition:none!important}}

/* ======================================================================
   Atelier arabe · Thème commun des anciennes pages · 2026-09-17 / v3
   CSS uniquement : les contenus, scripts et sauvegardes restent inchangés.
   Les !important ciblent les couleurs injectées par les exercices existants.
   Aucun sélecteur de thème ne force l'affichage des écrans masqués.
   ====================================================================== */
html { font-size: 16px; }
body.legacy-page {
  --primary-color: var(--green);
  --primary-hover: #20533f;
  --primary-light: var(--soft);
  --secondary-color: var(--green);
  --secondary-hover: #20533f;
  --success-color: #27644f;
  --error-color: #a43f32;
  --warning-color: #8a5b1e;
  --info-color: var(--green);
  --color-primary: var(--green);
  --color-accent: var(--accent);
  --color-correct: var(--success-color);
  --color-wrong: var(--error-color);
  --color-hint: var(--warning-color);
  --white: var(--surface);
  --gray-50: var(--paper);
  --gray-100: var(--paper);
  --gray-200: var(--soft);
  --gray-300: var(--line);
  --gray-400: #87968c;
  --gray-500: var(--muted);
  --gray-600: var(--muted);
  --gray-700: var(--ink);
  --gray-800: var(--ink);
  --gray-900: var(--ink);
  --text-muted: var(--muted);
  --bg-secondary: var(--soft);
  --font-family-primary: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-size-base: 1rem;
  --font-size-sm: .875rem;
  --font-size-xs: .75rem;
  --font-size-lg: 1.125rem;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 13px;
  --radius-2xl: 16px;
  --shadow-sm: 0 1px 3px #203d3606;
  --shadow-md: 0 3px 12px #203d3608;
  --shadow-lg: 0 8px 28px #203d3610;
  --shadow-xl: 0 12px 36px #203d3614;
  --state-success-bg: #eaf2e8;
  --state-error-bg: #fbede9;
  --state-warning-bg: #faf0df;
  --success-light: var(--state-success-bg);
  --error-light: var(--state-error-bg);
  --warning-light: var(--state-warning-bg);
  height: auto;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-family-primary);
  font-size: 1rem;
  line-height: 1.65;
}
body.legacy-page :is(h1,h2,h3,h4) { color: var(--ink); text-shadow: none; }
body.legacy-page h2 { font-size: clamp(22px, 2.5vw, 29px); font-weight: 550; margin: 0 0 18px; line-height: 1.3; }
body.legacy-page h2::after { content: none; }
body.legacy-page h3 { font-size: 20px; font-weight: 600; }
body.legacy-page p { font-size: 1rem; line-height: 1.7; }

/* En-tête : le même fond et les mêmes espaces que l'accueil. */
body.legacy-page > header {
  position: relative; top: auto; z-index: 1;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start;
  gap: 12px; width: 100%; max-width: 1200px; margin: 0 auto;
  padding: 42px 40px 24px; background: transparent; color: var(--ink);
  text-align: left; border: 0; box-shadow: none;
}
body.legacy-page > header h1 { flex: 1 1 100%; margin: 0 0 8px; font-size: clamp(28px, 3.8vw, 42px); font-weight: 550; line-height: 1.25; }
body.legacy-page > header nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
body.legacy-page > header nav a {
  display: inline-flex; align-items: center; min-height: 44px; margin: 0;
  padding: 8px 13px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); background: var(--surface); font-size: 13px; text-decoration: none;
}
body.legacy-page > header nav a:hover { color: var(--green); background: var(--soft); border-color: var(--green); transform: none; }
body.legacy-page .home-btn::before { content: none; }
body.legacy-page > header :is(.progress-manager-btn,.theme-toggle) {
  position: static; inset: auto; transform: none;
  width: 44px; height: 44px; min-height: 44px; flex: 0 0 44px; margin: 0;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 19px; box-shadow: none;
}
body.legacy-page > header :is(.progress-manager-btn,.theme-toggle):hover { background: var(--soft); border-color: var(--green); transform: none; }
body.legacy-page > main,
body.legacy-page > :is(#listening-section,#selection-section,#quiz-section) {
  width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px 40px 40px;
}
body.legacy-page > footer {
  width: calc(100% - 80px); max-width: 1120px; margin: 42px auto 0; padding: 24px 0;
  border-top: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 12px; text-align: left;
}
body.legacy-page #font-picker-container { max-width: 1200px; padding: 0 40px; margin: 0 auto; }
body.legacy-page .fm-bar { justify-content: flex-start; gap: 8px; padding: 14px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
body.legacy-page .fm-title { color: var(--muted); font-size: 12px; }

/* Surfaces : cartes de cours, exercices, bilans et fiches de lecture. */
body.legacy-page :is(.lesson-card,.vowel-lesson-card,.view-card,.letter-group,
  .letter-forms-card,.letter-card-intro,.letter-card-learning,.vowel-card,.harakat-item,
  .quiz-container,.word-card,.verse-card,.final-score-screen,.custom-quiz-section,
  .custom-quiz-selector,.custom-quiz-results,.retry-screen,.completion-screen,
  .current-letter-section,.mobile-controls,.mobile-selector-content,.drawing-container,
  .stat-panel,.stat-box,.lesson-checkbox,.count-card,#exercise-container) {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 13px; box-shadow: none; min-width: 0;
}
body.legacy-page :is(.lesson-card,.vowel-lesson-card) { padding: 24px; border-left: 1px solid var(--line) !important; }
body.legacy-page :is(.lesson-card,.vowel-lesson-card).unlocked:hover { transform: translateY(-3px); border-color: var(--green) !important; box-shadow: var(--shadow-md); }
body.legacy-page :is(.lesson-card,.vowel-lesson-card).locked { opacity: .6; filter: none; cursor: not-allowed; }
body.legacy-page :is(.view-card,.quiz-container,.word-card,.verse-card,.final-score-screen,#exercise-container) { padding: 28px; }
body.legacy-page :is(.letter-card-intro,.letter-card-learning,.letter-forms-card,.vowel-card) { padding: 20px; }
body.legacy-page :is(.progressive-header,.vowels-hero) {
  padding: 28px; margin-bottom: 26px; background: var(--soft); color: var(--ink);
  border: 1px solid var(--line); border-radius: 13px; box-shadow: none; text-align: left;
}
body.legacy-page :is(.progressive-header,.vowels-hero) h2 { text-align: left; margin-bottom: 10px; }
body.legacy-page :is(.progressive-subtitle,.vowels-hero p) { color: var(--muted); font-size: 14px; margin: 0; max-width: 760px; }
body.legacy-page .prerequisite-notice { background: var(--surface) !important; color: var(--muted); border: 1px solid var(--line); }
body.legacy-page :is(.progress-overview,.vowels-stats,.results-stats,.stats-grid) { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(145px,100%),1fr)); gap: 12px; margin-top: 22px; }
body.legacy-page :is(.progress-stat,.vowels-stat,.stat-box,.stat-panel) { padding: 18px; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: none; }
body.legacy-page :is(.stat-number,.stat-value,.vowels-stat strong) { color: var(--green); font-size: 29px; font-weight: 550; }
body.legacy-page :is(.stat-label,.vowels-stat span,.lesson-description,.word-meaning,.form-label,.form-note,.letter-pronunciation,.word-hint,.score-display,.progress-label,.position-label,.input-hint) { color: var(--muted); font-size: 13px; }
body.legacy-page :is(.vowel-lesson-card,.view-card) :is(h2,h3,p,strong) { color: var(--ink); }
body.legacy-page .lesson-number { display: inline-block; margin-bottom: 5px; color: var(--green); background: none; font-size: 11px; font-weight: 700; letter-spacing: 1.4px; }
body.legacy-page .lesson-title { font-size: 21px; }
body.legacy-page :is(.lessons-grid,.vowels-lessons-grid) { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; margin-bottom: 28px; }
body.legacy-page :is(.lesson-letters,.arabic-row,.harakat-intro,.intro-instructions,.instructions,.form-item,.letter-details,.word-item,.count-card,.learning-phase .intro-content) {
  background: var(--soft); color: var(--ink); border-color: var(--line); border-radius: 10px; box-shadow: none;
}
body.legacy-page :is(.lesson-letters,.arabic-row) { padding: 16px; margin: 18px 0; }
body.legacy-page :is(.preview-letter,.vowel-symbol,.question-arabic,.letter-symbol-big,.letter-symbol-learning,.form-shape,.arabic-cell,.table-audio-btn strong) { color: var(--ink); }
body.legacy-page :is(.vowel-card,.harakat-intro,.harakat-item) p { color: var(--muted); }
body.legacy-page :is(.intro-header,.harakat-item) { border-color: var(--line) !important; }

/* Boutons : mêmes dimensions, contrastes et états sur toutes les activités. */
body.legacy-page button {
  min-height: 44px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); box-shadow: none;
  padding: 10px 16px; font-family: var(--font-family-primary);
  font-size: 14px; font-weight: 600; line-height: 1.45;
}
body.legacy-page button:not(:disabled):not(.disabled):hover { background: var(--soft); border-color: var(--green); box-shadow: none; transform: translateY(-1px); }
body.legacy-page :is(.start-btn,.start-lesson-btn,.start-custom-quiz-btn,.next-lesson-btn,
  .quiz-btn,.retry-btn,.retry-custom-quiz-btn,.validate-btn,.next-word-btn,.primary-btn,
  .submit-answer-btn,.custom-quiz-btn,.review-all-btn,.mode-button,
  .selection-button button,.final-actions button:first-child,.nav-buttons button:first-child) {
  background: var(--green) !important; color: #fff; border: 1px solid var(--green);
  font-size: 14px; font-weight: 600; border-radius: 9px; padding: 12px 20px;
}
body.legacy-page :is(.start-btn,.start-lesson-btn,.start-custom-quiz-btn,.next-lesson-btn,
  .quiz-btn,.retry-btn,.retry-custom-quiz-btn,.validate-btn,.next-word-btn,.primary-btn,
  .submit-answer-btn,.custom-quiz-btn,.review-all-btn,.mode-button,
  .selection-button button,.final-actions button:first-child,.nav-buttons button:first-child):not(:disabled):not(.disabled):hover { background: var(--primary-hover) !important; color: #fff; }
body.legacy-page :is(.start-btn,.start-custom-quiz-btn) { max-width: 360px; margin-top: 18px; }
body.legacy-page :is(.back-btn,.menu-btn,.secondary-btn,.preset-btn,.skip-btn,.hint-btn,
  .audio-btn,.play-audio-btn,.audio-button,.control-button,.mobile-control-btn,.mobile-nav-btn,.fm-btn,.select-all-btn) {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 9px; box-shadow: none;
}
body.legacy-page :is(.audio-btn,.play-audio-btn,.play-btn,.hint-btn) { background: var(--soft); color: var(--green); }
body.legacy-page .play-btn { width: 44px; height: 44px; padding: 8px; border: 1px solid var(--line); }
body.legacy-page .secondary-btn.arabic-btn span { color: var(--muted); }
body.legacy-page :is(button:disabled,button.disabled,.start-btn.disabled) { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
body.legacy-page .fm-btn.active { background: var(--green); border-color: var(--green); color: #fff; }
body.legacy-page :is(button,a,input,select,textarea,[tabindex]):focus-visible { outline: 3px solid #bd791f; outline-offset: 3px; }
body.legacy-page :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),select,textarea) {
  min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); box-shadow: none; font-family: var(--font-family-primary);
}
body.legacy-page :is(.translit-input,.verse-textarea,.letter-name-input,#answer-input) { width: 100%; padding: 13px 15px; font-size: 17px; text-align: left; }
body.legacy-page .verse-textarea { min-height: 120px; resize: vertical; }
body.legacy-page input:is([type=checkbox],[type=radio]) { width: 19px; height: 19px; min-height: 19px; flex: 0 0 19px; padding: 0; accent-color: var(--green); }
body.legacy-page input[type=range] { padding: 0; min-height: 32px; accent-color: var(--green); }
body.legacy-page :is(.input-area,.quiz-input-container,.controls-row,.learning-actions,.final-actions,.nav-buttons,.action-row,.completion-actions,.retry-actions,.results-actions) { gap: 12px; flex-wrap: wrap; }
body.legacy-page .input-area .translit-input { flex: 1 1 200px; }

/* Sélecteurs : les styles en ligne des catégories sont unifiés ici. */
body.legacy-page :is(.translit-selector,.quran-selector,.verse-selector) { max-width: 980px; padding: 0; margin: 0 auto; }
body.legacy-page :is(.translit-exercise,.quran-exercise,.verse-exercise) { max-width: 820px; padding: 0; margin: 0 auto; }
body.legacy-page .selector-intro { color: var(--muted); font-size: 14px; max-width: 650px; margin: 0 auto 24px; }
body.legacy-page :is(.cat-grid,.surah-grid) { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
body.legacy-page :is(.cat-card,.surah-card,.letter-toggle,.letter-option,.mobile-letter-option,
  .letter-item,.option,.option-btn,.quiz-option,.quiz-option-letter,.quiz-option-form,
  .recognition-option,.mobile-recognition-option) {
  background: var(--surface) !important; color: var(--ink) !important;
  border: 1px solid var(--line) !important; border-radius: 11px; box-shadow: none; min-width: 0;
}
body.legacy-page :is(.cat-card,.surah-card) { padding: 22px 16px; gap: 8px; }
body.legacy-page :is(.cat-card,.surah-card,.letter-toggle,.letter-option,.mobile-letter-option,
  .letter-item,.option,.option-btn,.quiz-option,.quiz-option-letter,.quiz-option-form):not(.selected):not(:disabled):hover {
  background: var(--soft) !important; border-color: var(--green) !important; transform: translateY(-2px);
}
body.legacy-page :is(.cat-card,.surah-card,.letter-toggle,.letter-option,.mobile-letter-option,.letter-item,.option).selected {
  background: var(--soft) !important; border-color: var(--green) !important; color: var(--green) !important;
  box-shadow: inset 0 0 0 1px var(--green);
}
body.legacy-page :is(.cat-count,.surah-desc,.letter-toggle .letter-translit) { color: var(--muted) !important; font-size: 12px; }
body.legacy-page :is(.cat-card.selected,.surah-card.selected,.letter-toggle.selected,.letter-item.selected) :is(.cat-count,.surah-desc,.letter-translit,.letter-name,.letter-pronunciation,.letter-symbol) { color: var(--green) !important; }
body.legacy-page .letter-group-label { border-color: var(--line) !important; color: var(--muted) !important; font-size: 12px; letter-spacing: .5px; }
body.legacy-page :is(.cat-badge,.verse-badge,.surah-badge) { background: var(--soft) !important; color: var(--green) !important; border: 1px solid var(--line) !important; border-radius: 6px; }
body.legacy-page :is(.letter-chip,.vowel-lesson-meta .pill,.vowel-badges span) { background: var(--soft); color: var(--green); border: 1px solid var(--line); border-radius: 6px; }
body.legacy-page .completion-badge { background: var(--state-success-bg); color: var(--success-color); border: 1px solid var(--line); font-size: 11px; }
body.legacy-page :is(.review-badge,.vowel-lesson-meta .pill.review,.streak-fire) { background: var(--state-warning-bg); color: var(--warning-color); border: 1px solid var(--line); animation: none; }
body.legacy-page :is(.letter-item,.option)::before { background: none; }
body.legacy-page :is(.letter-list,.letter-grid-intro,.letter-grid-learning) { gap: 14px; padding: 12px 0; }
body.legacy-page :is(.letter-item,.option) { padding: 18px 12px; }
body.legacy-page .letter-symbol { color: var(--ink); font-size: 36px; line-height: 1.65; }
body.legacy-page :is(.quiz-option-letter,.quiz-option-form,.letter-option,.mobile-letter-option) { font-family: var(--font-family-arabic); font-size: 32px; line-height: 1.6; }
body.legacy-page .quiz-option-letter { font-size: 42px; }
body.legacy-page .quiz-option-form :is(strong,.position-label) { color: inherit; }
body.legacy-page .option-btn { font-size: 17px; }
body.legacy-page .option { font-family: var(--font-family-arabic); font-size: 36px; }

/* Lecture : taille suffisante pour les signes, y compris sur petits écrans. */
body.legacy-page :is(.arabic-display,.quiz-letter-display,.quiz-letter,.question-arabic,.arabic-word) {
  color: var(--ink); line-height: 1.8; letter-spacing: 0;
  font-family: var(--font-family-arabic); text-align: center;
  overflow-wrap: anywhere; word-break: normal;
}
body.legacy-page .arabic-display { font-size: clamp(44px,6vw,76px); padding: 14px 0; }
body.legacy-page .verse-card .arabic-display { font-size: clamp(34px,4vw,54px); }
body.legacy-page :is(.quiz-letter-display,.quiz-letter) { font-size: clamp(64px,10vw,120px) !important; }
body.legacy-page .arabic-word { font-size: clamp(38px,6vw,64px); }
body.legacy-page :is(.translit-reminder,.elongation-reminder,.full-translit,.harakat-intro) { background: var(--soft); color: var(--muted); border: 1px solid var(--line); border-radius: 9px; padding: 14px; }
body.legacy-page .translation-hint { background: var(--state-warning-bg); color: var(--warning-color); border-radius: 9px; }
body.legacy-page .translation-block { color: var(--muted); }
body.legacy-page :is(.harakat-info,.harakat-tooltip) { background: var(--green); color: #fff; }
body.legacy-page .harakat-tooltip::after { border-top-color: var(--green); }

/* Progression : conserve les largeurs calculées par les scripts. */
body.legacy-page :is(.progress-bar-mini,.progress-bar-wrap,.progress-bar-custom,.mini-progress) { background: var(--line); height: 6px; border-radius: 20px; }
body.legacy-page :is(.progress-fill,.progress-bar-fill,.progress-fill-custom,.mini-progress span) { background: var(--green) !important; border-radius: 20px; }
body.legacy-page :is(.quiz-score,.score,.score-display,.progress-text) { color: var(--muted); font-size: 14px; font-weight: 500; }
body.legacy-page :is(.score-circle,.achievement-badge) { background: var(--soft); color: var(--green); border-color: var(--line); box-shadow: none; }
body.legacy-page .count-option input[type=radio]:checked + .count-card { background: var(--soft); border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
body.legacy-page .count-option input[type=radio]:checked + .count-card :is(.count-number,.count-label,.count-time) { color: var(--green); }
body.legacy-page :is(.timer-display,.timer) { background: var(--soft); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: none; }
body.legacy-page :is(.timer-display.timer-warning,.timer.warning) { background: var(--state-warning-bg); color: var(--warning-color); }
body.legacy-page :is(.timer-display.timer-critical,.timer.critical) { background: var(--state-error-bg); color: var(--error-color); }

/* Feedback : un code couleur explicite, distinct de la sélection. */
body.legacy-page :is(.feedback,.translit-feedback,.verse-feedback,.feedback-box,.recognition-feedback,.mobile-feedback) { border-radius: 10px; box-shadow: none; font-size: 15px; }
body.legacy-page :is(.translit-feedback,.verse-feedback,.feedback,.feedback-box,.recognition-feedback,.mobile-feedback,.word-count-bar).correct,
body.legacy-page :is(.recognition-feedback,.mobile-feedback).success,
body.legacy-page .word-count-bar.has-words { background: var(--state-success-bg); color: var(--success-color); border: 1px solid var(--success-color); }
body.legacy-page :is(.translit-feedback,.verse-feedback,.feedback,.feedback-box).wrong,
body.legacy-page :is(.feedback,.feedback-box).incorrect,
body.legacy-page :is(.recognition-feedback,.mobile-feedback).error { background: var(--state-error-bg); color: var(--error-color); border: 1px solid var(--error-color); }
body.legacy-page :is(.translit-feedback.hint,.verse-feedback.partial,.word-count-bar.no-words) { background: var(--state-warning-bg); color: var(--warning-color); border: 1px solid var(--warning-color); }
body.legacy-page :is(.option-btn,.quiz-option,.quiz-option-letter,.option,.recognition-option,.mobile-recognition-option,.word-slot,.answer-item).correct {
  background: var(--state-success-bg) !important; color: var(--success-color) !important; border-color: var(--success-color) !important;
}
body.legacy-page :is(.option-btn,.quiz-option,.quiz-option-letter,.option,.word-slot,.answer-item):is(.wrong,.incorrect) {
  background: var(--state-error-bg) !important; color: var(--error-color) !important; border-color: var(--error-color) !important;
}
body.legacy-page .word-slot.missing { background: var(--paper); color: var(--muted); border: 1px dashed var(--line); }
body.legacy-page .verse-feedback.correct .feedback-header { color: var(--success-color); }
body.legacy-page .verse-feedback.partial .feedback-header { color: var(--warning-color); }
body.legacy-page .verse-feedback.wrong .feedback-header { color: var(--error-color); }
body.legacy-page .slot-student { color: inherit; }
body.legacy-page .slot-correct { color: var(--success-color); }
body.legacy-page :is(.custom-quiz-description,.score-number,.score-fraction,.badge-name) { color: var(--ink); }
body.legacy-page :is(.timer-display h3,.timer-display .time) { color: inherit; }
body.legacy-page :is(.cumulative-badge,.word-display,.quiz-letter-display,.quiz-score,.answer-recap,.retry-message,.review-section) {
  background: var(--soft); color: var(--ink); border: 1px solid var(--line); border-radius: 11px; box-shadow: none;
}
body.legacy-page :is(.custom-quiz-container,.lesson-selector,.question-count-selector,.errors-review) {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 13px; box-shadow: none; padding: 22px;
}
body.legacy-page :is(.feedback-box,.reference-details) { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
body.legacy-page .reference-details summary { color: var(--ink); }
body.legacy-page .correct-answers-section summary { background: var(--state-success-bg); color: var(--success-color); border: 1px solid var(--line); border-radius: 9px; }
body.legacy-page .word-item .ar { color: var(--ink); }
body.legacy-page .arabic-cell span { color: var(--muted); }
body.legacy-page .quiz-option-fast { font-family: var(--font-family-arabic); font-size: 38px; line-height: 1.7; min-width: 64px; }
/* L'alphabet signale aussi ses réponses par des styles en ligne. */
body.legacy-page :is(.quiz-option,.quiz-option-letter,.quiz-option-fast)[style*="--success-color"] {
  background: var(--state-success-bg) !important; color: var(--success-color) !important; border-color: var(--success-color) !important;
}
body.legacy-page :is(.quiz-option,.quiz-option-letter,.quiz-option-fast)[style*="--error-color"] {
  background: var(--state-error-bg) !important; color: var(--error-color) !important; border-color: var(--error-color) !important;
}

/* Tableaux des deux cours : lisibles, avec défilement horizontal local. */
body.legacy-page .letter-group { padding: 26px; margin-bottom: 24px; overflow-x: auto; }
body.legacy-page :is(.centered-table,.alphabet-table-wrap) { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; box-shadow: none; }
body.legacy-page :is(.letter-table,.alphabet-vowels-table) { min-width: 560px; width: 100%; margin: 0; border-collapse: collapse; box-shadow: none; background: var(--surface); }
body.legacy-page :is(.letter-table,.alphabet-vowels-table) th { background: var(--soft); color: var(--ink); padding: 15px 12px; font-size: 13px; font-weight: 650; box-shadow: none; border-bottom: 1px solid var(--line); }
body.legacy-page :is(.letter-table,.alphabet-vowels-table) td { color: var(--ink); background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px 12px; font-size: 30px; }
body.legacy-page .letter-table tbody tr:nth-child(even) td { background: var(--paper); }
body.legacy-page .letter-table tbody tr:nth-child(odd) td { background: var(--surface); }
body.legacy-page .letter-table tbody tr:hover td { background: var(--soft) !important; transform: none; }
body.legacy-page .letter-table .letter-name { font-size: 14px; color: var(--muted); }
body.legacy-page .table-audio-btn { background: var(--surface); color: var(--ink); border-color: var(--line); }
body.legacy-page .table-audio-btn span { color: var(--muted); }

/* Dessin : surface blanche conservée pour l'encre et la reconnaissance. */
body.legacy-page .drawing-container { padding: 26px; }
body.legacy-page :is(.canvas-container,.mobile-canvas-container) { background: #fff; border: 1px solid #becabe; border-radius: 13px; box-shadow: none; }
body.legacy-page :is(#drawing-canvas,#mobile-drawing-canvas) { background: #fff; border-radius: 12px; }
body.legacy-page .mobile-container {
  height: auto; min-height: 0; width: 100%; max-width: 960px;
  margin: 0 auto; padding: 16px 24px 36px; gap: 14px; flex-direction: column;
}
body.legacy-page .mobile-canvas-container { flex: 0 0 auto; height: clamp(280px,45vh,430px); min-height: 280px; margin: 0; }
body.legacy-page .current-letter-section { padding: 18px; }
body.legacy-page .current-letter-display { font-size: 52px; color: var(--ink); line-height: 1.6; }
body.legacy-page :is(.mobile-reference-overlay,.reference-overlay) { color: #687968; }
body.legacy-page .mobile-controls { padding: 16px; gap: 10px; }
body.legacy-page .mobile-feedback { color: var(--muted); background: var(--surface); border: 1px solid var(--line); margin: 0; }
body.legacy-page .mobile-feedback.success { color: var(--success-color); background: var(--state-success-bg); border-color: var(--success-color); }
body.legacy-page .mobile-feedback.error { color: var(--error-color); background: var(--state-error-bg); border-color: var(--error-color); }
body.legacy-page .mobile-letter-selector { background: #142b22b8; padding: 20px; }
body.legacy-page .mobile-selector-content { max-width: 650px; margin: 25px auto; max-height: calc(100dvh - 90px); }
body.legacy-page .mobile-close-btn { background: var(--surface); color: var(--ink); border: 1px solid var(--line); width: 44px; height: 44px; padding: 8px; }

/* Le mode sombre utilise la même famille de verts et garde ses contrastes. */
[data-theme=dark] body.legacy-page {
  --primary-hover: #31604a;
  --success-color: #a0d6b1;
  --error-color: #ffb6aa;
  --warning-color: #edcc95;
  --state-success-bg: #273e2f;
  --state-error-bg: #482e2a;
  --state-warning-bg: #413a2a;
}
[data-theme=dark] body.legacy-page :is(.start-btn,.start-lesson-btn,.start-custom-quiz-btn,
  .next-lesson-btn,.quiz-btn,.retry-btn,.retry-custom-quiz-btn,.validate-btn,.next-word-btn,
  .primary-btn,.submit-answer-btn,.custom-quiz-btn,.review-all-btn,.mode-button,
  .selection-button button,.final-actions button:first-child,.nav-buttons button:first-child,.fm-btn.active) { background: #32644b !important; color: #fff; border-color: #658d73; }
[data-theme=dark] body.legacy-page :is(.harakat-info,.harakat-tooltip) { background: #32644b; }

@media (max-width: 1000px) {
  body.legacy-page :is(.lessons-grid,.vowels-lessons-grid) { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 768px) {
  body.legacy-page > header { padding: 30px 24px 18px; }
  body.legacy-page > main,
  body.legacy-page > :is(#listening-section,#selection-section,#quiz-section) { padding: 12px 24px 28px; }
  body.legacy-page #font-picker-container { padding: 0 24px; }
  body.legacy-page > footer { width: calc(100% - 48px); }
  body.legacy-page :is(.cat-grid,.surah-grid,.forms-grid) { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body.legacy-page :is(.progressive-header,.vowels-hero,.view-card,.word-card,.verse-card,.quiz-container,.final-score-screen) { padding: 22px; }
  body.legacy-page :is(.letter-grid-intro,.letter-grid-learning) { grid-template-columns: repeat(auto-fit,minmax(min(140px,100%),1fr)); }
  body.legacy-page .letter-group { padding: 18px; }
  body.legacy-page .centered-table { overflow-x: auto; }
  body.legacy-page .nav-buttons { flex-direction: row; align-items: stretch; }
  body.legacy-page .nav-buttons button { flex: 1 1 150px; width: auto; max-width: none; }
  body.legacy-page :is(.final-stats,.exercise-topbar,.quiz-header-row) { flex-wrap: wrap; gap: 14px; }
}
@media (max-width: 520px) {
  body.legacy-page > header { padding: 26px 20px 16px; gap: 8px; }
  body.legacy-page > header h1 { font-size: 28px; overflow-wrap: anywhere; }
  body.legacy-page > header nav { flex: 1 1 auto; }
  body.legacy-page > main,
  body.legacy-page > :is(#listening-section,#selection-section,#quiz-section) { padding: 12px 20px 28px; }
  body.legacy-page #font-picker-container { padding: 0 20px; }
  body.legacy-page > footer { width: calc(100% - 40px); margin-top: 24px; }
  body.legacy-page :is(.lessons-grid,.vowels-lessons-grid,.forms-grid) { grid-template-columns: minmax(0,1fr); gap: 14px; }
  body.legacy-page :is(.lesson-card,.vowel-lesson-card) { padding: 20px; }
  body.legacy-page :is(.progressive-header,.vowels-hero,.view-card,.word-card,.verse-card,.quiz-container,.final-score-screen,#exercise-container) { padding: 20px 16px; }
  body.legacy-page :is(.progress-overview,.vowels-stats) { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  body.legacy-page :is(.progress-stat,.vowels-stat) { padding: 14px 10px; }
  body.legacy-page :is(.stat-number,.stat-value,.vowels-stat strong) { font-size: 24px; }
  body.legacy-page :is(.cat-card,.surah-card) { padding: 16px 10px; }
  body.legacy-page :is(.cat-grid,.surah-grid) { gap: 10px; }
  body.legacy-page .input-area { align-items: stretch; }
  body.legacy-page .input-area .translit-input { flex-basis: 100%; }
  body.legacy-page .input-area .validate-btn { width: 100%; }
  body.legacy-page :is(.action-row,.final-actions,.learning-actions) > button { flex: 1 1 120px; }
  body.legacy-page :is(.count-options,.quiz-options-grid) { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body.legacy-page :is(.quiz-options,.quiz-options-letters,.option-grid) { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body.legacy-page .letter-list { grid-template-columns: repeat(auto-fit,minmax(72px,1fr)); gap: 9px; }
  body.legacy-page .letter-item { padding: 12px 6px; }
  body.legacy-page .letter-symbol { font-size: 33px; }
  body.legacy-page .letter-name { font-size: 12px; }
  body.legacy-page .fm-bar { padding: 10px; gap: 6px; }
  body.legacy-page .fm-btn { padding: 8px 11px; font-size: 12px; }
  body.legacy-page .harakat-tooltip { max-width: min(280px,80vw); }
  body.legacy-page .mobile-container { padding: 12px 20px 28px; }
  body.legacy-page .mobile-controls { padding: 12px; }
  body.legacy-page .mobile-letter-grid { gap: 8px; }
  body.legacy-page .mobile-selector-content { padding: 16px; }
  body.legacy-page .drawing-container { padding: 16px; }
  body.legacy-page .brush-size { flex-wrap: wrap; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.legacy-page .mobile-container { flex-direction: column; height: auto; }
  body.legacy-page .current-letter-section { flex: none; }
  body.legacy-page .mobile-controls { flex: none; grid-template-columns: repeat(4,minmax(0,1fr)); }
  body.legacy-page .mobile-canvas-container { flex: none; height: 280px; margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  body.legacy-page *,body.legacy-page *::before,body.legacy-page *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Finitions communes et séance A1 par catégories · 2026-09-17 / v4 */
.site-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.site-nav .site-theme-toggle {
  position: static; display: inline-flex; align-items: center; justify-content: center;
  flex: none; gap: 7px; min-width: 44px; height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 50px; background: var(--surface);
  color: var(--ink); font-size: 12px; font-weight: 600; box-shadow: none;
}
.site-theme-toggle > span:first-child { font-size: 23px; line-height: 1; }
.site-nav .site-theme-toggle:hover { border-color: var(--green); background: var(--soft); transform: none; }
.site-nav .site-actions .account-link { margin-left: 0; }
.site-actions .account-link { max-width: 155px; }
body.legacy-page .stats-button {
  position: fixed; right: 20px; bottom: 20px; z-index: 30;
  display: grid; place-items: center; width: 46px; height: 46px;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--ink); box-shadow: 0 4px 20px #0001;
}
body.legacy-page .stats-button:hover { background: var(--soft); border-color: var(--green); }
.mode-switch { background: var(--soft); }
.word-card, .course-card, .practice-card, .learning-panel { min-width: 0; overflow-wrap: break-word; }
.learning-panel .arabic { letter-spacing: 0; }
.skip-link { color: var(--paper); }
[data-theme=dark] { color-scheme: dark; }
[data-theme=light] { color-scheme: light; }
[data-theme=dark] .brand-mark { color: var(--paper); }
[data-theme=dark] .error-text, [data-theme=dark] .danger { color: #ffb6a5 !important; }
[data-theme=dark] .hero-art::before, [data-theme=dark] .hero-art::after { border-color: var(--line); }
[data-theme=dark] .callout { border-color: var(--line); }
.a1-selection { padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.a1-selection h2 { font-size: 28px; font-weight: 550; margin-bottom: 12px; }
.a1-selection .eyebrow { margin-bottom: 12px; }
.a1-themes { margin: 24px 0; padding: 0; border: 0; min-width: 0; }
.a1-themes legend { padding: 0; font-size: 14px; font-weight: 650; margin-bottom: 12px; }
.a1-selection-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.a1-theme-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.a1-theme-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 18px; min-width: 0; border: 1px solid var(--line); border-radius: 11px;
  background: var(--paper); color: var(--ink);
}
.a1-theme-card:hover { border-color: var(--green); }
.a1-theme-card[aria-pressed=true] { background: var(--soft); border-color: var(--green); }
.a1-theme-number { font-size: 12px; color: var(--muted); flex: none; }
.a1-theme-copy { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.a1-theme-copy strong { font-size: 14px; line-height: 1.4; font-weight: 650; }
.a1-theme-copy small { font-size: 12px; color: var(--muted); }
.a1-theme-check { width: 24px; height: 24px; display: grid; place-items: center; flex: none; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); }
.a1-theme-card[aria-pressed=true] .a1-theme-check { background: var(--green); color: var(--surface); border-color: var(--green); }
.a1-start-row { display: flex; gap: 18px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.a1-start-row .field { max-width: 320px; }
.a1-start-row > .btn { flex: 1; }
.a1-selection > .helper:last-child { margin: 0; }
.a1-session-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.a1-session-top .eyebrow { margin: 0; }
.a1-session-stats { color: var(--green); background: var(--soft); border-radius: 8px; font-size: 12px; padding: 10px 12px; margin-bottom: 18px; }
.a1-session form { margin-top: 24px; }
.a1-session form label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 650; }
.a1-session form input { font-size: 16px; }
.a1-session form .helper { margin: 10px 0 18px; }
.a1-saved-note { margin: 24px 0 0; font-size: 12px; }
.a1-summary h2 { font-size: 32px; }
.a1-score { font-size: 64px; line-height: 1.2; color: var(--green); font-weight: 550; margin: 20px 0 12px; }
.a1-score span { font-size: 28px; }
.a1-summary details { text-align: left; margin-bottom: 20px; }
.a1-review-list { list-style: none; padding: 0; margin: 12px 0 0; }
.a1-review-list li { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.a1-review-list li > span[lang=ar] { font: 30px/1.8 var(--font-family-arabic); flex: 1; }
.a1-review-list li > span:nth-child(2) { flex: 2; min-width: 0; }
.a1-review-list strong { display: block; font-size: 14px; color: var(--green); }
.a1-review-list small { display: block; color: var(--muted); font-size: 12px; }
@media (max-width: 950px) {
  .site-nav { flex-wrap: wrap; }
  .site-nav .nav-links { order: 3; width: 100%; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 4px; }
  .site-actions { margin-left: auto; }
}
@media (max-width: 650px) {
  .site-nav { gap: 10px; }
  .site-actions { gap: 6px; }
  .site-theme-toggle .theme-label { display: none; }
  .site-actions .account-link { max-width: 110px; }
  .site-nav .site-theme-toggle { padding: 8px; }
  .a1-selection { padding: 22px 16px; }
  .a1-theme-grid { grid-template-columns: minmax(0,1fr); gap: 10px; }
  .a1-theme-card { padding: 16px 14px; }
  .a1-start-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .a1-start-row .field { max-width: none; }
  .a1-selection-tools .btn { flex: 1 1 auto; }
  .a1-session .actions > .btn { flex: 1 1 100px; }
  .a1-review-list li { gap: 10px; flex-wrap: wrap; }
  .a1-review-list li > span[lang=ar] { min-width: 70px; }
  .a1-review-list li > span:nth-child(2) { min-width: 100px; }
  .mode-switch { width: 100%; }
  .mode-switch button { flex: 1 1 calc(50% - 5px); padding: 10px; }
}
@media (max-width: 380px) {
  .site-nav .brand-light { display: none; }
  .site-nav .nav-links { gap: 8px; }
  .site-nav .nav-links a { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .course-card { transition: none; }
}
