/* Mise en page : en haut l'élève du jour ; dessous la fiche de séance (deux blocs identiques) et, à côté sur grand écran, l'aperçu de ce que voient les parents. */
:root {
  --bg: #EDF0F6;
  --surface: #FBFCFE;
  --surface-2: #E1E7F2;
  --line: #D0D8E8;
  --fg: #17203A;
  --fg-muted: #566080;
  --accent: #2B4C9B;
  --accent-ink: #FFFFFF;
  --accent-tint: #DCE4F7;
  --ok-solid: #1F7D52; --ok-ink: #FFFFFF; --ok-tint: #DCF0E5; --ok-text: #14583A;
  --warn-solid: #EDB236; --warn-ink: #2B1E00; --warn-tint: #FBEBC4; --warn-text: #7A4E00;
  --bad-solid: #D24E68; --bad-ink: #FFFFFF; --bad-tint: #F9DEE3; --bad-text: #9A2A42;
  --shadow: rgba(23, 32, 58, 0.14);
  --qr-bg: #FFFFFF; /* blanc dans les deux thèmes : un QR code se scanne mieux sur fond clair */
  --font-display: 'Bricolage Grotesque', 'Hanken Grotesk', system-ui, sans-serif;
  --font-body: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ar: 'Amiri', 'Noto Naskh Arabic', 'Traditional Arabic', serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1420; --surface: #171E2E; --surface-2: #232C42; --line: #2C3652;
    --fg: #E6EAF4; --fg-muted: #9AA5C2;
    --accent: #8FAAF0; --accent-ink: #0B1430; --accent-tint: #1E2A4D;
    --ok-solid: #3DB07C; --ok-ink: #06261A; --ok-tint: #153326; --ok-text: #7FDDB0;
    --warn-solid: #E3A92F; --warn-ink: #261900; --warn-tint: #3A2D10; --warn-text: #F0CB78;
    --bad-solid: #E0718A; --bad-ink: #2E0A12; --bad-tint: #3C1A22; --bad-text: #F0A0B0;
    --shadow: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1420; --surface: #171E2E; --surface-2: #232C42; --line: #2C3652;
  --fg: #E6EAF4; --fg-muted: #9AA5C2;
  --accent: #8FAAF0; --accent-ink: #0B1430; --accent-tint: #1E2A4D;
  --ok-solid: #3DB07C; --ok-ink: #06261A; --ok-tint: #153326; --ok-text: #7FDDB0;
  --warn-solid: #E3A92F; --warn-ink: #261900; --warn-tint: #3A2D10; --warn-text: #F0CB78;
  --bad-solid: #E0718A; --bad-ink: #2E0A12; --bad-tint: #3C1A22; --bad-text: #F0A0B0;
  --shadow: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.55 var(--font-body);
  padding-block: 16px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }
.muted { color: var(--fg-muted); }

.wrap { max-width: 1120px; margin-inline: auto; display: flex; flex-direction: column; gap: 18px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .ar { font-family: var(--font-ar); font-size: 36px; line-height: 1; color: var(--accent); padding-bottom: 6px; }
h1 { font: 800 23px/1.1 var(--font-display); letter-spacing: -0.01em; }
h2 { font: 800 22px/1.2 var(--font-display); letter-spacing: -0.01em; text-wrap: balance; }
h3 { font: 700 17px/1.25 var(--font-display); }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--fg-muted); }
.proto { font-size: 12.5px; color: var(--fg-muted); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; }

/* Élève du jour */
.who { display: flex; flex-direction: column; gap: 8px; }
.students { display: flex; flex-wrap: wrap; gap: 8px; }
.stu { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; }
.stu[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-items: start; }
@media (min-width: 980px) { .layout { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } .preview { position: sticky; top: calc(16px + env(safe-area-inset-top, 0px)); } }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Blocs de saisie */
.block { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.block-head h3 { font-size: 19px; }
.sub { display: flex; flex-direction: column; gap: 10px; }
.sub + .sub { border-top: 1px solid var(--line); padding-top: 16px; }
.lbl { font-size: 13px; font-weight: 600; color: var(--fg-muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-sv { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 10px; }
.range-to { border-left: 3px solid var(--line); padding-left: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--fg-muted); }
input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 46px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); font-size: 16px;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
.hint { font-size: 12.5px; color: var(--fg-muted); }
.err { font-size: 13.5px; font-weight: 600; color: var(--bad-text); background: var(--bad-tint); border-radius: 8px; padding: 6px 10px; }

.units { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; align-self: flex-start; }
.units button { min-height: 36px; padding: 0 13px; border: 0; border-radius: 8px; background: transparent; color: var(--fg-muted); font-weight: 600; font-size: 13.5px; }
.units button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px var(--shadow); }

.grades { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grade { min-height: 54px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 6px; }
.grade i { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.grade[data-g="acquis"] i { background: var(--ok-solid); }
.grade[data-g="presque"] i { background: var(--warn-solid); }
.grade[data-g="revoir"] i { background: var(--bad-solid); }
.grade[data-g="acquis"][aria-pressed="true"] { background: var(--ok-solid); border-color: var(--ok-solid); color: var(--ok-ink); }
.grade[data-g="presque"][aria-pressed="true"] { background: var(--warn-solid); border-color: var(--warn-solid); color: var(--warn-ink); }
.grade[data-g="revoir"][aria-pressed="true"] { background: var(--bad-solid); border-color: var(--bad-solid); color: var(--bad-ink); }
.grade[aria-pressed="true"] i { background: currentColor; }

.next-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 6px 0; min-height: 36px; color: var(--accent); font-weight: 600; font-size: 14px; }
.link:disabled { color: var(--fg-muted); opacity: 0.6; cursor: default; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn { min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.notice { border-radius: 10px; padding: 10px 14px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.notice.ok { background: var(--ok-tint); color: var(--ok-text); }
.notice.info { background: var(--accent-tint); color: var(--accent); }
.notice .link { color: inherit; text-decoration: underline; }

/* Aperçu parents */
.preview { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.phone { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 6px 24px var(--shadow); }
.phone-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.phone-name { font: 800 24px/1.1 var(--font-display); }
.ro { font-size: 12px; font-weight: 600; color: var(--fg-muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.todo { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.todo-item { background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.todo-item.rev { background: var(--accent-tint); color: var(--fg); }
.todo-item .eyebrow { color: inherit; opacity: 0.85; }
.todo-part { font: 700 18px/1.3 var(--font-display); overflow-wrap: anywhere; }
.todo-due { font-size: 13.5px; opacity: 0.9; }
.sess { display: flex; flex-direction: column; gap: 10px; }
.sess-date { font-weight: 700; }
.line { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.line-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.line .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--fg-muted); }
.line .p { font-weight: 600; overflow-wrap: anywhere; }
.line .c { font-size: 14px; color: var(--fg-muted); font-style: italic; }
.chip { display: inline-flex; align-items: center; padding: 1px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.7; white-space: nowrap; }
.chip.acquis { background: var(--ok-tint); color: var(--ok-text); }
.chip.presque { background: var(--warn-tint); color: var(--warn-text); }
.chip.revoir { background: var(--bad-tint); color: var(--bad-text); }
details.older { border-top: 1px solid var(--line); padding-top: 10px; }
details.older summary { cursor: pointer; font-weight: 600; color: var(--accent); min-height: 36px; display: flex; align-items: center; }
details.older .sess { margin-top: 10px; }
details.older .sess + .sess { margin-top: 16px; }
.empty { color: var(--fg-muted); font-size: 14px; }
.foot { display: flex; justify-content: flex-end; }


/* Espace professeur */
.screen { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.back { align-self: flex-start; background: none; border: 0; padding: 6px 0; min-height: 40px; color: var(--accent); font-weight: 600; font-size: 15px; }
input[type="text"], input[type="search"], input[type="email"], input[type="password"] { width: 100%; min-height: 46px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 16px; }
.search { max-width: 420px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-name { font: 700 18px/1.2 var(--font-display); }
.row-line { font-size: 13.5px; color: var(--fg-muted); overflow-wrap: anywhere; }
.row-line b { color: var(--fg); font-weight: 600; }
.chev { font-size: 22px; color: var(--fg-muted); line-height: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card .row2 { max-width: 560px; }
.share-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
@media (min-width: 640px) { .share-grid { grid-template-columns: minmax(0, 1fr) auto; } }
.share-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 14px; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.qr { background: var(--qr-bg); padding: 12px; border-radius: 12px; width: 200px; height: 200px; max-width: 100%; display: flex; align-items: center; justify-content: center; }
.qr img, .qr canvas { display: block; max-width: 100%; }
.code { font: 800 26px/1.1 var(--font-display); letter-spacing: 0.08em; font-variant-numeric: tabular-nums; user-select: all; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn.danger { color: var(--bad-text); border-color: var(--bad-tint); }
.btn[aria-expanded="true"] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.sess-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.sess-actions { display: flex; gap: 14px; }
.sess-actions .link { min-height: 32px; padding: 2px 0; font-size: 13.5px; }
.sess-actions .link.del { color: var(--bad-text); }
.phone.flat { box-shadow: none; border-radius: 16px; }
.banner { background: var(--warn-tint); color: var(--warn-text); border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; }
.banner .link { color: inherit; text-decoration: underline; }
.parent-wrap { max-width: 560px; width: 100%; margin-inline: auto; display: flex; flex-direction: column; gap: 14px; }
details.archived summary { cursor: pointer; font-weight: 600; color: var(--fg-muted); min-height: 40px; display: flex; align-items: center; }
.arch-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
/* Progression, régularité, jalons */
.milestone { display: flex; gap: 12px; align-items: center; background: var(--ok-tint); color: var(--ok-text); border-radius: 14px; padding: 12px 14px; animation: pop 0.5s ease-out both; }
.milestone strong { display: block; font: 800 18px/1.2 var(--font-display); }
.milestone span { font-size: 13.5px; }
.ms-star { font-size: 28px; line-height: 1; color: var(--warn-solid); }
@keyframes pop { from { transform: scale(0.96); } to { transform: none; } }
.encourage { font: 700 16px/1.35 var(--font-display); color: var(--accent); margin: 2px 0 8px; }
.prog { display: flex; flex-direction: column; gap: 10px; }
.goal-head { display: flex; flex-direction: column; gap: 2px; }
.goal-name { font: 700 17px/1.3 var(--font-display); overflow-wrap: anywhere; }
.goal-due { font-size: 13.5px; color: var(--fg-muted); }
.pct { font: 800 30px/1 var(--font-display); color: var(--ok-text); font-variant-numeric: tabular-nums; }
.goal-ok { font-weight: 700; color: var(--ok-text); }
.blk { font-size: 13px; }
.hz-grid.auto { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.prog-count { font-size: 14px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.prog-count strong { font: 800 22px/1 var(--font-display); color: var(--fg); }
.bar { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; min-width: 4px; border-radius: 999px; background: linear-gradient(90deg, var(--ok-solid), var(--accent)); transition: width 0.6s ease; }
.hz-grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.hz { position: relative; aspect-ratio: 1; max-width: 100%; border-radius: 6px; background: var(--surface-2); border: 0; padding: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 10.5px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.hz b { position: relative; font-weight: 600; }
.hz i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--ok-solid); opacity: 0.45; }
.hz.part { box-shadow: inset 0 0 0 1.5px var(--ok-solid); }
.hz.done { background: var(--ok-solid); color: var(--ok-ink); }
.hz-grid.pick .hz { cursor: pointer; font-size: 12px; min-height: 30px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--fg-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 11px; height: 11px; border-radius: 3px; background: var(--surface-2); display: inline-block; }
.lg.done { background: var(--ok-solid); }
.lg.part { box-shadow: inset 0 0 0 1.5px var(--ok-solid); }
.regul { display: flex; flex-direction: column; gap: 8px; }
.dots-row { display: flex; align-items: center; gap: 10px; }
.dots-k { font-size: 12px; font-weight: 600; color: var(--fg-muted); width: 92px; flex-shrink: 0; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dot { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line); }
.dot.acquis { background: var(--ok-solid); box-shadow: none; }
.dot.presque { background: var(--warn-solid); box-shadow: none; }
.dot.revoir { background: var(--bad-solid); box-shadow: none; }
details.start summary { cursor: pointer; list-style: none; display: flex; flex-direction: column; gap: 2px; }
details.start summary::-webkit-details-marker { display: none; }
details.start summary h3::after { content: ' ▾'; color: var(--fg-muted); font-size: 14px; }
details.start[open] summary h3::after { content: ' ▴'; }
.danger-zone { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 16px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Ajouts de l'app ---------- */
html { -webkit-tap-highlight-color: transparent; }
.notice.err { background: var(--bad-tint); color: var(--bad-text); }
.top a.brand { color: inherit; text-decoration: none; }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.home { gap: 20px; }
.home-intro { display: flex; flex-direction: column; gap: 6px; max-width: 60ch; }
.home-intro h2 { font-size: 28px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 760px) { .home-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.narrow { max-width: 520px; width: 100%; }
.link.inline { padding: 0; min-height: 0; font-size: inherit; text-decoration: underline; }
.small { font-size: 13.5px; }
.center { text-align: center; }
.pad { padding: 48px 0; }
.select { user-select: all; font-weight: 600; }
.prose { gap: 12px; }
.prose p, .prose li { max-width: 65ch; line-height: 1.6; }
.prose ul { list-style: disc; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.prose h3 { margin-top: 8px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
a.btn.primary { color: var(--accent-ink); }
.site-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }
.site-foot .link { font-size: 13.5px; color: var(--fg-muted); }
button:disabled { opacity: 0.6; cursor: default; }
.mode-eleve #export, .mode-eleve #logout { display: none; }
