/* =========================================================================
   Projet de gestion — feuille de style unique, sans dépendance externe.
   Mobile d'abord ; barre latérale à partir de 900 px ; mode sombre.
   ========================================================================= */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #171a23;
  --muted: #5b6273;
  --faint: #8a90a0;
  --border: #e2e5ee;
  --border-strong: #cfd4e0;
  --primary: #2748c9;
  --primary-ink: #ffffff;
  --primary-soft: #e8edfd;
  --success: #17804a;
  --success-soft: #e3f4ea;
  --warn: #a45f00;
  --warn-soft: #fdf1dd;
  --danger: #c0322b;
  --danger-soft: #fce7e6;
  --violet: #6a45cf;
  --violet-soft: #efe9fc;
  --info: #2459c2;
  --info-soft: #e5eefc;
  --neutral-soft: #eef0f4;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 2px 8px rgba(20, 24, 40, .05);
  --shadow-lg: 0 8px 28px rgba(20, 24, 40, .14);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1c2e;
    --surface: #152640;
    --surface-2: #1b3050;
    --text: #e8eef7;
    --muted: #aebdd1;
    --faint: #8397b2;
    --border: #25405f;
    --border-strong: #33537a;
    --primary: #7d97ff;
    --primary-ink: #0d1330;
    --primary-soft: #1f3563;
    --success: #5fd08f;
    --success-soft: #15372f;
    --warn: #f0b456;
    --warn-soft: #3b3020;
    --danger: #ff8078;
    --danger-soft: #3d2130;
    --violet: #b39cff;
    --violet-soft: #2b2c5c;
    --info: #86aefc;
    --info-soft: #1c3458;
    --neutral-soft: #213a5c;
    --shadow: 0 1px 2px rgba(3, 10, 25, .35);
    --shadow-lg: 0 8px 28px rgba(3, 10, 25, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1c2e; --surface: #152640; --surface-2: #1b3050; --text: #e8eef7; --muted: #aebdd1; --faint: #8397b2;
  --border: #25405f; --border-strong: #33537a; --primary: #7d97ff; --primary-ink: #0d1330; --primary-soft: #1f3563;
  --success: #5fd08f; --success-soft: #15372f; --warn: #f0b456; --warn-soft: #3b3020; --danger: #ff8078; --danger-soft: #3d2130;
  --violet: #b39cff; --violet-soft: #2b2c5c; --info: #86aefc; --info-soft: #1c3458; --neutral-soft: #213a5c;
  --shadow: 0 1px 2px rgba(3, 10, 25, .35); --shadow-lg: 0 8px 28px rgba(3, 10, 25, .45); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.ic { flex: none; vertical-align: middle; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: 8px; }
.skip:focus { left: 8px; }

/* ---------------------------------------------------------------- structure */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-size: .8rem; font-weight: 800; letter-spacing: .02em; flex: none; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  color: var(--text); background: transparent; border: 0; cursor: pointer; }
.icon-btn:hover { background: var(--neutral-soft); text-decoration: none; }
.dot { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; }

.layout { display: block; }
.sidebar { display: none; }
main { padding: 16px; max-width: 1120px; margin: 0 auto; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottomnav a, .bottomnav button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem; font-weight: 600; min-height: 44px; background: none; border: 0; font-family: inherit; cursor: pointer;
}
.bottomnav a:hover { text-decoration: none; color: var(--text); }
.bottomnav a[aria-current="page"] { color: var(--primary); }
.bottomnav a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }
.bottomnav .dot { top: 4px; right: calc(50% - 22px); }

.moremenu { position: fixed; inset: 0; z-index: 40; background: rgba(10, 12, 20, .45); display: none; }
.moremenu.open { display: block; }
.moremenu .sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 10px 12px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); max-height: 80vh; overflow: auto; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 2px auto 10px; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottomnav, .topbar .only-mobile { display: none; }
  .layout { display: grid; grid-template-columns: 248px 1fr; min-height: calc(100vh - 61px); }
  .sidebar { display: block; position: sticky; top: 61px; height: calc(100vh - 61px); overflow: auto;
    padding: 14px 10px; border-right: 1px solid var(--border); background: var(--surface); }
  main { padding: 24px 28px 48px; width: 100%; }
}
.side-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 550; }
.side-link:hover { background: var(--neutral-soft); text-decoration: none; }
.side-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.side-link .count { margin-left: auto; font-size: .75rem; font-weight: 700; background: var(--danger); color: #fff; border-radius: 10px; padding: 1px 7px; }
.side-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 12px 6px; font-weight: 700; }

/* ---------------------------------------------------------------- blocs */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { color: var(--muted); margin: 2px 0 0; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; margin-bottom: 8px; min-height: 36px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .stack > * + * { margin-top: 12px; }
.card-title { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-bottom: 10px; }
.card-title h2, .card-title h3 { margin: 0; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .875rem; }
.xs { font-size: .78rem; }
.grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } .grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }
@media (min-width: 640px) and (max-width: 899px) { .grid-4 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hr { height: 1px; background: var(--border); margin: 14px 0; border: 0; }

/* ---------------------------------------------------------------- héros élève */
.hero { background: linear-gradient(135deg, #2748c9 0%, #5237cf 100%);
  color: #fff; border-radius: 18px; padding: 18px; box-shadow: var(--shadow-lg); }
.hero a { color: #fff; }
.hero .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; opacity: .85; font-weight: 700; }
.hero h2 { font-size: 1.25rem; margin: 4px 0 6px; color: #fff; }
.hero .meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: .9rem; opacity: .95; }
.hero .btn { background: #fff; color: #1d2f8f; border-color: #fff; }
.hero .btn:hover { background: #eef2ff; }
:root[data-theme="dark"] .hero .btn, .hero .btn { color: #1d2f8f; }

/* ---------------------------------------------------------------- avancement */
.progress { display: flex; flex-direction: column; gap: 6px; }
.progress .top { display: flex; justify-content: space-between; align-items: baseline; font-weight: 650; }
.progress .pct { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
progress { appearance: none; -webkit-appearance: none; width: 100%; height: 10px; border: 0; border-radius: 99px; overflow: hidden; background: var(--neutral-soft); }
progress::-webkit-progress-bar { background: var(--neutral-soft); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--primary); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 99px; }
progress.on-hero { background: rgba(255, 255, 255, .25); }
progress.on-hero::-webkit-progress-bar { background: rgba(255, 255, 255, .25); }
progress.on-hero::-webkit-progress-value { background: #fff; }
progress.on-hero::-moz-progress-bar { background: #fff; }
progress.success::-webkit-progress-value { background: var(--success); }
progress.success::-moz-progress-bar { background: var(--success); }
progress.thin { height: 6px; }

.ring { --size: 76px; width: var(--size); height: var(--size); position: relative; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- statuts */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; line-height: 1.4; }
.chip-neutral { background: var(--neutral-soft); color: var(--muted); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-violet { background: var(--violet-soft); color: var(--violet); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-success { background: var(--success-soft); color: var(--success); }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--neutral-soft); color: var(--muted); letter-spacing: .02em; }
.tag-code { background: var(--primary-soft); color: var(--primary); }

/* ---------------------------------------------------------------- listes de tâches */
.tasklist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tasklist li + li { border-top: 1px solid var(--border); }
.taskrow { display: flex; align-items: center; gap: 12px; padding: 14px 14px; color: var(--text); min-height: 64px; }
.taskrow:hover { background: var(--surface-2); text-decoration: none; }
.taskrow .code { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: .85rem; flex: none; background: var(--neutral-soft); color: var(--muted); }
.taskrow .code.s-ouverte, .taskrow .code.s-prolongee { background: var(--info-soft); color: var(--info); }
.taskrow .code.s-a_reprendre { background: var(--warn-soft); color: var(--warn); }
.taskrow .code.s-rendue { background: var(--violet-soft); color: var(--violet); }
.taskrow .code.s-validee { background: var(--success-soft); color: var(--success); }
.taskrow .code.s-verrouillee { background: var(--danger-soft); color: var(--danger); }
.taskrow .title { font-weight: 650; line-height: 1.3; }
.taskrow .sub { font-size: .82rem; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.taskrow .end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.taskrow .chev { color: var(--faint); }

/* ---------------------------------------------------------------- boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: color-mix(in srgb, var(--success) 88%, #000); }
.btn-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--neutral-soft); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- formulaires */
label, .label { display: block; font-weight: 650; margin-bottom: 6px; font-size: .92rem; }
.help { font-size: .82rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=datetime-local], input[type=url],
select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
input[type=number] { font-variant-numeric: tabular-nums; }
.field { margin-bottom: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 550; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--danger); font-size: .88rem; font-weight: 600; }
.otp-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- alertes */
.flash { list-style: none; padding: 0; margin: 0 0 14px; }
.flash li { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-weight: 600; margin-bottom: 8px; }
.flash .success { background: var(--success-soft); color: var(--success); }
.flash .error { background: var(--danger-soft); color: var(--danger); }
.flash .info, .flash .warning { background: var(--info-soft); color: var(--info); }
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.callout.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.callout.success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.callout p { margin: 0; }
.callout strong { display: block; }

/* ---------------------------------------------------------------- page tâche */
.task-head { display: flex; flex-direction: column; gap: 10px; }
.task-head .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.countdown { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 4px 10px; border-radius: 99px; background: var(--neutral-soft); color: var(--text); font-size: .85rem; }
.countdown.soon { background: var(--warn-soft); color: var(--warn); }
.countdown.late { background: var(--danger-soft); color: var(--danger); }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); margin: 6px 0 14px; background: var(--bg); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 12px 12px; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 650; cursor: pointer; border-bottom: 3px solid transparent; min-height: 44px; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .badge { background: var(--danger); color: #fff; font-size: .7rem; border-radius: 9px; padding: 0 6px; }
[role="tabpanel"][hidden] { display: none; }

.help-block h3 { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.help-block h3:first-child { margin-top: 0; }
.help-block ul { padding-left: 1.2rem; margin: 0 0 .5rem; }
.help-block li { margin-bottom: 4px; }
.sites { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.sites a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 600; min-height: 48px; }
.sites a:hover { border-color: var(--primary); text-decoration: none; }
.sites .url { color: var(--faint); font-weight: 500; font-size: .8rem; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }

/* éditeur */
.editor-wrap { border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); }
.editor-wrap .toolbar { border-radius: 14px 14px 0 0; }
.toolbar { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 65px; z-index: 5; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar button { flex: none; }
.toolbar button { min-width: 40px; height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; display: grid; place-items: center; }
.toolbar button:hover { background: var(--neutral-soft); }
.toolbar .sep { width: 1px; background: var(--border); margin: 6px 4px; }
.editor, .rendered { padding: 16px; min-height: 280px; outline: none; overflow-wrap: anywhere; }
.editor:focus { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }
.editor table, .rendered table, .prose table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: .95rem; display: block; overflow-x: auto; }
.editor td, .editor th, .rendered td, .rendered th, .prose td, .prose th { border: 1px solid var(--border-strong); padding: 8px; min-width: 130px; vertical-align: top; text-align: left; }
.editor th, .rendered th, .prose th { background: var(--surface-2); }
.editor h3, .rendered h3 { margin-top: 14px; }
.savebar { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
.savestate { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; }
.savestate.ok { color: var(--success); }
.savestate.pending { color: var(--muted); }
.savestate.err { color: var(--danger); }
.actionbar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 15; display: flex; gap: 8px; padding: 10px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
@media (min-width: 900px) { .actionbar { bottom: 0; } }

.comment { display: flex; gap: 10px; padding: 12px 0; }
.comment + .comment { border-top: 1px solid var(--border); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: none; background: var(--primary-soft); color: var(--primary); }
.avatar.teacher { background: var(--violet-soft); color: var(--violet); }
.avatar.sm { width: 30px; height: 30px; font-size: .68rem; letter-spacing: -.02em; }
.quote { border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 0 8px 8px 0; font-size: .88rem; margin: 4px 0 6px; color: var(--text); }
mark.annot { background: color-mix(in srgb, var(--warn) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; cursor: pointer; }
mark.annot.flash { outline: 2px solid var(--warn); }
.avatars { display: flex; }
.avatars .avatar { border: 2px solid var(--surface); margin-left: -5px; }
.avatars .avatar:first-child { margin-left: 0; }

/* ---------------------------------------------------------------- tableau de bord enseignant */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); }
.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi .n { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: .85rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi.alert .n { color: var(--danger); }
.kpi.todo .n { color: var(--violet); }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.filters a { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border-strong); color: var(--text); font-weight: 600; font-size: .88rem; background: var(--surface); min-height: 40px; display: inline-flex; align-items: center; }
.filters a[aria-current="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters a:hover { text-decoration: none; }
.gcards { display: grid; gap: 12px; }
@media (min-width: 640px) { .gcards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .gcards { grid-template-columns: repeat(3, 1fr); } }
.gcard { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); }
.gcard:hover { border-color: var(--primary); text-decoration: none; }
.gcard .gname { font-weight: 800; font-size: 1.05rem; }
.gcard .org { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gcard .step { font-size: .88rem; display: flex; gap: 8px; align-items: center; }
.gcard .flags { display: flex; gap: 6px; flex-wrap: wrap; }
.gcard .foot { display: flex; justify-content: space-between; align-items: center; color: var(--faint); font-size: .8rem; }

/* tableaux */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.data { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.data th.sticky { background: var(--surface-2); z-index: 2; }
.unpub { color: var(--faint); font-style: italic; }

/* ---------------------------------------------------------------- messagerie */
.threads { list-style: none; padding: 0; margin: 0; }
.thread { display: flex; gap: 12px; align-items: center; padding: 14px; color: var(--text); border-bottom: 1px solid var(--border); background: var(--surface); min-height: 68px; }
.threads li:first-child .thread { border-radius: var(--radius) var(--radius) 0 0; }
.threads li:last-child .thread { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
.thread:hover { background: var(--surface-2); text-decoration: none; }
.thread .name { font-weight: 700; }
.thread.unread .name::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-left: 8px; vertical-align: middle; }
.thread .preview { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }
.bubble-row { display: flex; gap: 8px; align-items: flex-end; }
.bubble-row.me { flex-direction: row-reverse; }
.bubble { max-width: 82%; padding: 10px 12px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--border); overflow-wrap: anywhere; }
.bubble .body { white-space: pre-wrap; }
.bubble-row.me .bubble { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); border-radius: 16px 16px 4px 16px; }
.bubble-row.teacher .bubble { background: var(--violet-soft); border-color: transparent; }
.bubble .who { font-size: .75rem; font-weight: 700; opacity: .8; margin-bottom: 2px; }
.bubble .when { font-size: .7rem; opacity: .7; margin-top: 4px; }
.bubble.deleted { font-style: italic; opacity: .6; }
.composer { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 10px 0; background: var(--bg); }
@media (min-width: 900px) { .composer { bottom: 0; } }
.composer textarea { min-height: 48px; height: 48px; border-radius: 24px; padding: 12px 16px; }
.composer .btn { border-radius: 24px; }

/* ---------------------------------------------------------------- divers */
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .ic { color: var(--faint); margin-bottom: 6px; }
.notif { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.notif.unread { background: var(--primary-soft); }
.notif:hover { text-decoration: none; background: var(--surface-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.score-big { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.score-big small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.criteria { display: grid; gap: 10px; }
.crit { display: grid; grid-template-columns: 1fr 96px; gap: 10px; align-items: center; }
.crit .max { color: var(--muted); font-size: .85rem; }
.bank { display: flex; gap: 6px; flex-wrap: wrap; }
.bank button { border: 1px dashed var(--border-strong); background: var(--surface); color: var(--text); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; text-align: left; }
.bank button:hover { border-color: var(--primary); color: var(--primary); }
.selection-pop { position: absolute; z-index: 50; display: none; }
.selection-pop.show { display: block; }
.creds { border-collapse: collapse; width: 100%; }
.creds td, .creds th { border: 1px solid var(--border-strong); padding: 10px; text-align: left; }
.creds .pw { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 1.05rem; font-weight: 700; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand-mark { width: 48px; height: 48px; border-radius: 14px; font-size: 1.1rem; margin-bottom: 14px; }
.tour { position: fixed; inset: 0; z-index: 60; background: rgba(10, 12, 20, .55); display: grid; place-items: end center; padding: 16px; }
@media (min-width: 640px) { .tour { place-items: center; } }
.tour[hidden] { display: none; }
.tour .card { max-width: 420px; width: 100%; }
.tour .steps { display: flex; gap: 6px; justify-content: center; margin: 10px 0; }
.tour .steps span { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.tour .steps span.on { background: var(--primary); width: 22px; border-radius: 4px; }
.tour-slide[hidden] { display: none; }
.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.4rem; }
.prose ul { padding-left: 1.2rem; }
details.fold { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
details.fold + details.fold { margin-top: 8px; }
details.fold summary { cursor: pointer; padding: 12px 14px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 48px; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::after { content: "+"; font-size: 1.3rem; color: var(--muted); }
details.fold[open] summary::after { content: "–"; }
details.fold > div { padding: 0 14px 14px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; font-size: .88rem; }
.timeline li + li { border-top: 1px dashed var(--border); }
.plus { color: var(--success); font-weight: 700; }
.minus { color: var(--danger); font-weight: 700; }

/* ---------------------------------------------------------------- projection */
body.projection { padding: 0; background: var(--surface); font-size: 22px; }
.proj { max-width: 1200px; margin: 0 auto; padding: 32px 48px; }
.proj h1 { font-size: 2rem; }
.proj .rendered { font-size: 1.1em; padding: 0; }
.proj-bar { position: fixed; top: 12px; right: 12px; display: flex; gap: 8px; font-size: 14px; }

@media print {
  .topbar, .sidebar, .bottomnav, .no-print, .actionbar { display: none !important; }
  body { background: #fff; padding: 0; }
  main { padding: 0; }
  .card { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.mt { margin-top: 12px; }
.mt-lg { margin-top: 22px; }
.mb { margin-bottom: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.ring .track { stroke: var(--neutral-soft); }
.ring .bar { stroke: var(--primary); }
.nopad { padding: 0; }
.taskrow .m-chip { display: none; }
@media (max-width: 639px) {
  .taskrow .m-chip { display: inline-flex; }
  .taskrow .d-chip { display: none; }
  .taskrow { padding: 12px; gap: 12px; }
}
@media (max-width: 639px) {
  .tabs button { padding: 12px 10px; }
  .tabs button .ic { display: none; }
}
@media (min-width: 900px) {
  .layout { background: linear-gradient(to right, var(--surface) 248px, transparent 248px); }
}
main, .gcards > *, .grid > *, .gcard, .card { min-width: 0; }
.gcard .step .grow { min-width: 0; }
.thread .name, .thread .preview { display: block; }
.thread .grow > .row { min-width: 0; }
.thread .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap, .tabs, .filters, .toolbar { position: relative; } .toolbar { position: sticky; }

@media (max-width: 639px) {
  .tabs { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
  .tabs button:last-child { margin-right: 28px; }
}
.notions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.notion { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 10px; padding: 6px 12px; font: inherit; font-size: .86rem; line-height: 1.35; cursor: pointer; text-align: left; min-height: 36px; }
.notion:hover { border-color: var(--primary); color: var(--primary); }
.notion mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; }
.prog-q + .prog-q { border-top: 1px dashed var(--border); }
.toast { position: fixed; left: 16px; right: 16px; margin: 0 auto; width: fit-content; font-size: .9rem; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 70; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow-lg); max-width: 560px; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.classe-switch select { min-height: 38px; padding: 6px 10px; width: auto; max-width: 170px; font-weight: 650; font-size: .9rem; }
@media (max-width: 639px) { .topbar .brand-text { display: none; } }
.hr-top { border-top: 1px solid var(--border); padding-top: 12px; }
