/* =====================================================================
   Nibras — système visuel « cahier du BAC »
   Papier Seyès, stylo bleu, stylo rouge de correction, surligneur fluo.
   Une seule famille (Readex Pro) pour le français et l'arabe.
   ===================================================================== */
:root {
  --paper: #F6F7FB;      /* fond : feuille légèrement bleutée */
  --sheet: #FFFFFF;      /* cartes : feuille blanche */
  --ink: #141B34;        /* texte */
  --ink-2: #3A4363;
  --muted: #6A7290;
  --line: #DCE2F0;       /* bordures */
  --grid: #E4E9F6;       /* lignes Seyès */
  --grid-strong: #CFD9F0;
  --blue: #1D3BA8;       /* stylo bleu : actions */
  --blue-600: #142C86;
  --blue-50: #ECF0FD;
  --red: #D7263D;        /* stylo rouge : direct, alertes, marge */
  --red-50: #FDEDEF;
  --hl: #FFE45C;         /* surligneur */
  --hl-soft: #FFF5BF;
  --green: #0E8F6E;      /* intercalaire école, succès */
  --green-50: #E2F5EE;
  --amber: #A65F00;
  --amber-50: #FFF2D9;

  --r-sheet: 16px;
  --r-ctl: 12px;
  --r-field: 10px;
  --shadow: 0 1px 0 #E3E8F4, 0 14px 30px -22px rgba(20, 27, 52, .45);
  --shadow-lift: 0 1px 0 #E3E8F4, 0 22px 40px -24px rgba(20, 27, 52, .55);

  --font: 'Readex Pro', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --fs-xs: .8125rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.1875rem; --fs-xl: 1.5rem; --fs-2xl: 2rem; --fs-3xl: 2.75rem;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 264px;
  --tabbar-h: 64px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs-md); line-height: 1.6; color: var(--ink); background: var(--paper); min-height: 100vh; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
a { color: var(--blue); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 600; letter-spacing: -.015em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 { letter-spacing: 0; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .9em; background: var(--blue-50); color: var(--blue-600); padding: 2px 8px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; }
::selection { background: var(--hl); color: var(--ink); }
:focus-visible { outline: 3px solid var(--hl); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.center { text-align: center; }
.end { text-align: end; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.hidden, [hidden] { display: none !important; }
.hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }
.ok-text { color: var(--green); font-weight: 600; }
.warn-text { color: var(--amber); font-weight: 600; }
.bad-text { color: var(--red); font-weight: 600; }
.hint { color: var(--muted); font-size: var(--fs-sm); }
.ic { width: 20px; height: 20px; flex: none; }

/* Fond « Seyès » discret pour les pages */
.paper-bg, .layout-app .main, .layout-public {
  background-color: var(--paper);
  background-image: linear-gradient(rgba(214, 222, 242, .7) 1px, transparent 1px);
  background-size: 100% 32px;
}

/* ---------- Coque application ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.navtoggle { position: absolute; opacity: 0; pointer-events: none; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sheet); border-inline-end: 1px solid var(--line); padding: 20px 14px; z-index: 40; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 18px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--blue); color: #fff; position: relative; overflow: hidden; flex: none; }
.brand-mark svg { width: 74%; height: 74%; }
.brand-mark .body { fill: currentColor; } .brand-mark .flame { fill: #FFE45C; transform-origin: 27.6px 12.5px; animation: nibras-flame 3.2s ease-in-out infinite; }
@keyframes nibras-flame { 0%, 100% { transform: scale(1) rotate(0); } 30% { transform: scale(1.06, .95) rotate(-3deg); } 60% { transform: scale(.96, 1.05) rotate(2deg); } }
.poster-mark { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; margin-inline-end: .35em; vertical-align: middle; border-radius: .4em; background: var(--blue); color: #fff; }
.poster-mark svg { width: 74%; height: 74%; } .poster-mark .body { fill: currentColor; } .poster-mark .flame { fill: #FFE45C; }
@media (prefers-reduced-motion: reduce) { .brand-mark .flame { animation: none; } }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 1.08rem; }
.brand-tag { font-size: var(--fs-xs); color: var(--muted); font-weight: 400; }
.sidebar .drawer-close { display: none; }
.sidenav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidenav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; font-size: .95rem; isolation: isolate; transition: background .2s var(--ease), color .2s; }
.sidenav a:hover { background: var(--blue-50); color: var(--blue); text-decoration: none; }
.sidenav a.active { color: var(--ink); font-weight: 600; }
.sidenav a.active .nav-label { position: relative; }
/* coup de surligneur sous la page active */
.sidenav a.active .nav-label::before { content: ''; position: absolute; inset-inline: -4px; bottom: 1px; height: .62em; background: var(--hl); border-radius: 3px 8px 4px 6px; z-index: -1; transform-origin: left center; animation: hl-swipe .5s var(--ease) .12s both; }
[dir="rtl"] .sidenav a.active .nav-label::before { transform-origin: right center; }
.sidenav a.active .ic { color: var(--blue); }
@keyframes hl-swipe { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.badge { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; display: inline-grid; place-items: center; background: var(--red); color: #fff; font-size: .75rem; font-weight: 700; }
.sidebar-foot { border-top: 1px dashed var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.me-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.me-text b { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); font-size: var(--fs-xs); }
.foot-actions { display: flex; flex-direction: column; gap: 2px; }
.ghost-link { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--ink-2); font: inherit; font-size: .9rem; background: none; border: 0; cursor: pointer; text-align: start; }
.ghost-link:hover { background: var(--blue-50); color: var(--blue); text-decoration: none; }
.ghost-link.danger:hover { background: var(--red-50); color: var(--red); }
.ghost-link .ic { width: 18px; height: 18px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.mobilebar { display: none; }
.tabbar { display: none; }
.scrim { display: none; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; color: var(--ink-2); background: transparent; border: 0; cursor: pointer; }
.icon-btn:hover { background: var(--blue-50); color: var(--blue); }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 28px 56px; }
.page { flex: 1; }
.narrow { max-width: 720px; margin-inline: auto; }
.narrow-sm { max-width: 460px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.gap-lg { gap: 20px; }
.grid-main { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.grid-side { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head .count, .count { display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 9px; border-radius: 99px; background: var(--hl-soft); color: var(--ink); font-size: var(--fs-sm); font-weight: 600; vertical-align: middle; }

/* ---------- Barre publique ---------- */
.public-shell { min-height: 100vh; display: flex; flex-direction: column; }
.publicbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1180px; width: 100%; margin: 0 auto; padding: 18px 28px; }
.publicnav { display: flex; align-items: center; gap: 6px; }
.footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; max-width: 1180px; width: 100%; margin: 0 auto; padding: 22px 28px 32px; color: var(--muted); font-size: var(--fs-sm); }

/* ---------- Cartes / « feuilles » ---------- */
.card { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-sheet); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 26px 8px; margin: 0; }
.empty-card { margin-bottom: 16px; }

/* ---------- Alertes en ligne / toasts ---------- */
.alert { position: relative; padding: 12px 16px 12px 18px; border-radius: var(--r-field); margin-bottom: 16px; border: 1px solid transparent; font-size: .95rem; }
.alert::before { content: ''; position: absolute; inset-inline-start: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: currentColor; opacity: .7; }
.alert ul { margin: 4px 0; padding-inline-start: 18px; }
.alert-success { background: var(--green-50); color: #0B6B53; }
.alert-error { background: var(--red-50); color: #A61B2E; }
.alert-info { background: var(--blue-50); color: var(--blue-600); }
.toasts { position: fixed; z-index: 100; inset-inline-end: 20px; top: 20px; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px 13px 16px; border-radius: 14px; background: var(--ink); color: #fff; box-shadow: 0 18px 40px -16px rgba(20, 27, 52, .6); font-size: .93rem; animation: toast-in .45s var(--ease) both; border-inline-start: 4px solid var(--hl); }
.toast-success { border-inline-start-color: #5CD6A9; }
.toast-error { border-inline-start-color: #FF7A8A; }
.toast-info { border-inline-start-color: #8FA8FF; }
.toast span { flex: 1; }
.toast-x { background: none; border: 0; color: rgba(255, 255, 255, .7); cursor: pointer; padding: 0; display: grid; }
.toast-x .ic { width: 18px; height: 18px; }
.toast.is-leaving { animation: toast-out .3s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px) scale(.97); } }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: var(--r-ctl); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2; cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: transform .12s var(--ease), background .2s, box-shadow .2s, border-color .2s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 6px 16px -10px rgba(29, 59, 168, .9); }
.btn-primary:hover { background: var(--blue-600); }
.btn-accent { background: var(--hl); color: var(--ink); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08); }
.btn-accent:hover { background: #FFDB2E; }
.btn-ghost { background: var(--sheet); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger-ghost { background: var(--sheet); color: var(--red); border-color: #F4C9CF; }
.btn-danger-ghost:hover { background: var(--red-50); }
.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: 10px; }
.btn-lg { padding: 14px 22px; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.actions.center { justify-content: center; }
.link-sm { display: inline-block; font-size: .9rem; font-weight: 500; margin-top: 6px; }

/* ---------- Formulaires ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); }
input, select, textarea { width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-field); padding: 11px 13px; transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: #9AA1BA; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-50); }
input:disabled { background: var(--paper); color: var(--muted); }
input[type=file] { padding: 9px; background: var(--paper); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--blue); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px; }
.filters > * { width: auto; flex: 1 1 170px; }
.filters .btn { flex: 0 0 auto; }
.inline-form { padding: 0; margin-bottom: 12px; border: 0; box-shadow: none; }
.code-form { display: flex; gap: 8px; max-width: 460px; }
.code-form input { text-transform: uppercase; letter-spacing: .14em; font-weight: 600; direction: ltr; text-align: center; }
.code-form-sm { max-width: 360px; }
.code-center { margin: 14px auto; justify-content: center; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--ink-2); cursor: pointer; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-inline-end: 84px; }
.pw-toggle { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); border: 0; background: var(--paper); color: var(--ink-2); font: inherit; font-size: var(--fs-xs); font-weight: 600; padding: 6px 10px; border-radius: 8px; cursor: pointer; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 12px 10px; text-align: start; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-size: var(--fs-xs); font-weight: 500; color: var(--muted); border-bottom-color: var(--line); }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #F8FAFF; }
tfoot th { color: var(--ink); font-size: .95rem; font-weight: 600; border: 0; }
th.end, td.end { text-align: end; }

/* ---------- Pastilles / listes ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; line-height: 1.6; }
a.chip:hover { text-decoration: none; filter: brightness(.97); }
.chip-ok { background: var(--green-50); color: #0B6B53; }
.chip-warn { background: var(--amber-50); color: var(--amber); }
.chip-expired { background: var(--red-50); color: #B21E33; }
.chip-none { background: #EEF0F6; color: var(--muted); }
.chip-info { background: var(--blue-50); color: var(--blue-600); }
.chip-live { background: var(--red-50); color: var(--red); }
.chip-live .live-dot { width: 8px; height: 8px; }
.kv { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 0; }
.kv li { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px dashed var(--grid-strong); font-size: .93rem; }
.kv li:last-child { border-bottom: 0; }
.kv li > span { color: var(--muted); }
.kv-compact li { padding: 6px 0; font-size: .88rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; flex-direction: column; padding: 11px 0; border-bottom: 1px solid var(--grid); }
.list li:last-child { border-bottom: 0; }
.list li.is-unread { font-weight: 600; }
.info-strip { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 0; color: var(--ink-2); font-size: .92rem; }

/* ---------- Statistiques ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-sheet); box-shadow: var(--shadow); color: var(--ink); overflow: hidden; }
.stat::before { content: ''; position: absolute; inset-inline-start: 14px; top: 0; bottom: 0; width: 1px; background: rgba(215, 38, 61, .35); }
.stat-label, .stat-value { padding-inline-start: 10px; }
.stat-link { transition: transform .2s var(--ease), box-shadow .2s; }
.stat-link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat-label { font-size: var(--fs-sm); color: var(--muted); }
.stat-value { font-size: 1.9rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-alert { background: linear-gradient(180deg, var(--hl-soft), var(--sheet) 70%); border-color: #F3DE7A; }

/* ---------- Onglets ---------- */
.tabs { display: inline-flex; padding: 4px; gap: 2px; background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; }
.tabs a { padding: 8px 14px; border-radius: 9px; color: var(--ink-2); font-weight: 500; font-size: .9rem; }
.tabs a:hover { text-decoration: none; background: var(--blue-50); }
.tabs a.active { background: var(--ink); color: #fff; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 8px 14px; border-radius: 9px; font-size: .88rem; font-weight: 500; color: var(--ink-2); transition: background .2s var(--ease), color .2s; }
.seg-present input:checked + span { background: var(--green); color: #fff; }
.seg-absent input:checked + span { background: var(--red); color: #fff; }
.seg-excused input:checked + span { background: var(--hl); color: var(--ink); }
.seg input:focus-visible + span { outline: 3px solid var(--hl); }
.seg-wide { display: flex; }
.seg-wide label { flex: 1; text-align: center; }

/* ---------- Page d'accueil ---------- */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; padding: 26px 0 40px; }
.hero-text { position: relative; }
.eyebrow { display: inline-block; font-size: var(--fs-sm); font-weight: 500; color: var(--red); margin-bottom: 10px; }
.hero h1 { font-size: clamp(2.1rem, 4.4vw, 3.4rem); line-height: 1.08; letter-spacing: -.03em; font-weight: 600; margin-bottom: 18px; }
[dir="rtl"] .hero h1 { letter-spacing: 0; line-height: 1.3; }
.lead { font-size: 1.12rem; color: var(--ink-2); max-width: 34em; margin-bottom: 24px; }
.hero-cards { display: grid; gap: 12px; }
.portal-card { position: relative; display: grid; grid-template-columns: 48px 1fr; gap: 4px 14px; padding: 18px 20px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-sheet); box-shadow: var(--shadow); }
.portal-card::after { content: ''; position: absolute; inset-inline-end: -1px; top: 18px; width: 6px; height: 34px; border-radius: 4px 0 0 4px; background: var(--blue); }
[dir="rtl"] .portal-card::after { border-radius: 0 4px 4px 0; }
.portal-student::after { background: var(--hl); }
.portal-school::after { background: var(--green); }
.portal-icon { grid-row: span 3; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue); }
.portal-student .portal-icon { background: var(--hl-soft); color: var(--ink); }
.portal-school .portal-icon { background: var(--green-50); color: var(--green); }
.portal-icon .ic { width: 24px; height: 24px; }
.portal-card h2 { margin: 0; font-size: var(--fs-md); }
.portal-card p { margin: 0 0 8px; color: var(--muted); font-size: .92rem; }
.portal-card .btn { justify-self: start; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 30px; }
.step { position: relative; padding: 20px 22px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-sheet); }
.step-n { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--blue); color: var(--blue); font-weight: 700; margin-bottom: 10px; }
.step p { margin: 0; color: var(--muted); font-size: .93rem; }

/* ---------- Connexion universelle ---------- */
.auth-main { display: block; }
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-paper { position: relative; overflow: hidden; background: #FBFCFF; border-inline-end: 1px solid var(--line); }
.paper-lines { position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(126, 152, 214, .42) 1px, transparent 1px),
    linear-gradient(rgba(176, 194, 236, .18) 1px, transparent 1px);
  background-size: 100% 32px, 100% 8px;
  background-position: 0 23px, 0 23px;
  animation: lines-in 1.1s var(--ease) both; }
.paper-margin { position: absolute; top: 0; bottom: 0; inset-inline-start: 88px; width: 2px; background: var(--red); transform-origin: top; animation: margin-draw .9s var(--ease) .25s both; }
.paper-content { position: relative; padding: 46px 48px 46px 120px; display: flex; flex-direction: column; min-height: 100%; }
[dir="rtl"] .paper-content { padding: 46px 120px 46px 48px; }
.brand-lg .brand-mark { width: 42px; height: 42px; font-size: 1.3rem; }
.brand-lg .brand-name { font-size: 1.25rem; }
.paper-title { margin: auto 0 26px; font-size: clamp(2rem, 3.6vw, 3.2rem); line-height: 64px; font-weight: 600; letter-spacing: -.03em; color: var(--ink); max-width: 11em; animation: rise .7s var(--ease) .45s both; }
[dir="rtl"] .paper-title { letter-spacing: 0; }
.paper-notes { list-style: none; margin: 0 0 auto; padding: 0; display: grid; gap: 0; max-width: 30em; }
.paper-notes li { position: relative; width: fit-content; line-height: 32px; font-size: 1.05rem; color: var(--blue-600); animation: rise .6s var(--ease) both; }
.paper-notes li:nth-child(1) { animation-delay: .6s; } .paper-notes li:nth-child(2) { animation-delay: .7s; } .paper-notes li:nth-child(3) { animation-delay: .8s; }
.paper-notes li::before { content: ''; position: absolute; inset-inline-start: -18px; top: 12px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--blue); }
.paper-notes li span, .paper-notes li { isolation: isolate; }
.auth[data-role="student"] .note-student, .auth[data-role="teacher"] .note-teacher, .auth[data-role="school"] .note-school { color: var(--ink); font-weight: 500; }
.auth[data-role="student"] .note-student::after, .auth[data-role="teacher"] .note-teacher::after, .auth[data-role="school"] .note-school::after {
  content: ''; position: absolute; inset-inline-start: -6px; inset-inline-end: 0; bottom: 6px; height: 14px; background: var(--hl); opacity: .85; z-index: -1; border-radius: 3px 10px 4px 8px; transform-origin: left; animation: hl-swipe .55s var(--ease) both; }
[dir="rtl"] .paper-notes li::after { transform-origin: right; }
@keyframes lines-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes margin-draw { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 40px clamp(22px, 6vw, 80px); max-width: 620px; width: 100%; margin-inline: auto; }
.auth-top { display: flex; justify-content: flex-end; align-items: center; margin-bottom: auto; padding-bottom: 28px; }
.auth-brand-mobile { display: none; }
.auth-title { font-size: var(--fs-xl); margin-bottom: 18px; }
.role-tabs { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-bottom: 22px; border-bottom: 2px solid var(--grid-strong); }
.role-tab { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 6px; color: var(--muted); font-weight: 500; font-size: .95rem; border-radius: 12px 12px 0 0; transition: color .2s, background .2s; }
.role-tab:hover { text-decoration: none; color: var(--ink); background: rgba(236, 240, 253, .7); }
.role-tab[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.role-ink { position: absolute; bottom: -2px; height: 4px; width: calc(100% / 3); inset-inline-start: 0; border-radius: 4px; background: var(--blue); transform: translateX(var(--ink-x, 0)); transition: transform .45s var(--ease), background .3s; }
.auth[data-role="student"] .role-ink { background: #F2C400; }
.auth[data-role="school"] .role-ink { background: var(--green); }
.auth[data-role="student"] .role-tab.role-student .ic { color: #C9A200; }
.auth[data-role="teacher"] .role-tab.role-teacher .ic { color: var(--blue); }
.auth[data-role="school"] .role-tab.role-school .ic { color: var(--green); }
.role-panels { position: relative; }
.role-panel.is-entering { animation: panel-in .42s var(--ease) both; }
@keyframes panel-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
[dir="rtl"] .role-panel.is-entering { animation-name: panel-in-rtl; }
@keyframes panel-in-rtl { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
.auth-extra p { margin: 4px 0 0; font-size: .93rem; color: var(--muted); }
.code-strip { margin-top: 26px; padding: 16px; border: 1px dashed var(--grid-strong); border-radius: var(--r-sheet); background: var(--sheet); display: grid; gap: 8px; }
.code-strip label { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 500; }
.code-strip .code-form { max-width: none; }
.auth[data-role="teacher"] .code-strip, .auth[data-role="school"] .code-strip { display: none; }
.auth-panel > .install-btn { margin-top: 14px; align-self: center; }
.auth.is-app-locked .role-tabs { display: none; }

/* ---------- Pages d'inscription / adhésion ---------- */
.auth-card { padding: 30px; }
.group-intro { position: relative; overflow: hidden; color: #fff; border: 0; background: var(--blue) center / cover no-repeat; }
.group-intro::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(20, 44, 134, .96), rgba(20, 44, 134, .72)); }
.group-intro::after { content: ''; position: absolute; top: 0; bottom: 0; inset-inline-start: 26px; width: 2px; background: rgba(255, 120, 140, .8); }
.group-intro > * { position: relative; padding-inline-start: 18px; }
.group-intro .eyebrow { color: var(--hl); }
.group-intro h1 { margin-bottom: 6px; }
.group-intro .info-strip { color: rgba(255, 255, 255, .92); }
.group-teacher { opacity: .95; margin: 0; display: flex; align-items: center; gap: 10px; }
.success-card { text-align: center; padding: 40px 26px; }
.success-card .info-strip { justify-content: center; }
.success-icon { width: 76px; height: 76px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 50%; background: var(--green-50); color: var(--green); font-size: 2rem; font-weight: 700; animation: pop .55s var(--ease) both; }
.success-icon.is-bad { background: var(--red-50); color: var(--red); }
.success-icon svg { width: 46px; height: 46px; }
.success-icon .draw { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .55s var(--ease) .25s forwards; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.full-card { border: 2px solid #F3DE7A; background: var(--hl-soft); }
.alt-list { display: grid; gap: 8px; }
.alt-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 14px; background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); transition: border-color .2s, transform .2s var(--ease); }
.alt-item:hover { text-decoration: none; border-color: var(--blue); transform: translateX(2px); }
.alt-item .chip { margin-inline-start: auto; }

/* ---------- Groupes / demandes ---------- */
.group-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.group-list .card { margin: 0; }
.group-card { position: relative; padding-inline-start: 30px; }
.group-card::before { content: ''; position: absolute; top: 18px; bottom: 18px; inset-inline-start: 14px; width: 2px; border-radius: 2px; background: var(--red); opacity: .55; }
.group-card.is-off { opacity: .6; }
.group-card.is-off::before { background: var(--muted); }
.group-card-top { display: flex; justify-content: space-between; gap: 8px; }
.group-card h3 { margin-bottom: 2px; font-size: 1.05rem; }
.code-line { font-size: var(--fs-sm); color: var(--muted); }
.req-list { display: grid; gap: 16px; }
.req-card { display: grid; grid-template-columns: 1fr 300px; gap: 22px; margin: 0; }
.req-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.req-name h3 { margin: 0; font-size: 1.05rem; }
.req-actions { display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--paper); border-radius: 14px; align-self: start; }
.pay-form { gap: 8px; }
.cred-panel { border: 2px solid #9ED9C2; background: linear-gradient(180deg, var(--green-50), var(--sheet) 65%); animation: rise .5s var(--ease) both; }
.cred-panel h2 { color: #0B6B53; }
.cred-box { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 26px; padding: 14px 16px; margin: 10px 0; background: var(--sheet); border: 1px dashed #9ED9C2; border-radius: 12px; }
.cred-box > div { display: flex; flex-direction: column; gap: 4px; }
.cred-box span { font-size: var(--fs-xs); color: var(--muted); }
.cred-box code { font-size: 1.12rem; padding: 5px 11px; }
.sticky-bar { position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; box-shadow: 0 18px 40px -16px rgba(20, 27, 52, .6); }
.wl-check { width: 20px; height: 20px; }

/* ---------- Abonnement / progression ---------- */
.sub-meter { margin: 6px 0 16px; }
.sub-meter-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.progress { height: 8px; margin: 10px 0; border-radius: 99px; background: var(--grid); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 99px; background: var(--green); transform-origin: left; animation: grow .9s var(--ease) .15s both; }
[dir="rtl"] .progress span { transform-origin: right; }
.progress-warn span { background: #E7A400; }
.progress-expired span, .progress-none span { background: var(--red); }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- Cours (élève) ---------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-bottom: 20px; }
.course-grid .card { margin: 0; }
.course-card { position: relative; display: flex; flex-direction: column; padding-top: 26px; overflow: hidden; }
.course-card::before { content: ''; position: absolute; top: 0; inset-inline: 0; height: 6px; background: var(--green); }
.course-warn::before { background: #E7A400; }
.course-expired::before, .course-none::before, .course-banned::before { background: var(--red); }
.course-confirmed::before { background: var(--blue); }
.course-banned { opacity: .9; }
.course-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.course-subject { font-size: var(--fs-sm); font-weight: 600; color: var(--blue); }
.course-card h3 { margin: 0; font-size: 1.1rem; }
.course-card .link-sm { margin-top: auto; padding-top: 8px; }

/* ---------- Avatars / images ---------- */
.avatar { width: 40px; height: 40px; display: inline-grid; place-items: center; flex: none; overflow: hidden; border-radius: 50%; background: var(--blue-50); color: var(--blue); font-weight: 600; font-size: 1rem; border: 2px solid var(--sheet); box-shadow: 0 0 0 1px var(--line); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 32px; height: 32px; font-size: .85rem; }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.3rem; }
.avatar-xl { width: 88px; height: 88px; font-size: 2rem; }
.with-avatar { display: inline-flex; align-items: center; gap: 12px; }
h1.with-avatar { display: flex; }
.grid-images { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.img-preview { margin: 4px 0 6px; }
.img-preview-wide { height: 130px; display: grid; place-items: center; border-radius: 12px; border: 1px dashed var(--grid-strong); background: var(--paper) center / cover no-repeat; color: var(--muted); font-size: var(--fs-sm); }

/* ---------- École ---------- */
.school-hero { position: relative; overflow: hidden; color: #fff; border: 0; padding: 30px; background: var(--ink) center / cover no-repeat; }
.school-hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20, 27, 52, .25), rgba(20, 27, 52, .9)); }
.school-hero.has-banner { min-height: 240px; display: flex; align-items: flex-end; }
.school-hero-inner { position: relative; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.school-hero h1 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); margin: 0; }
.school-hero .muted { color: rgba(255, 255, 255, .82); }
.school-hero .eyebrow { color: var(--hl); }
.teacher-block { overflow: hidden; padding-top: 0; }
.teacher-cover { height: 14px; margin: 0 -22px 14px; background: var(--blue); }
.teacher-cover.has-cover { height: 150px; background-size: cover; background-position: center; }
.teacher-cover.has-cover + .teacher-block-head { margin-top: -40px; }
.teacher-cover.has-cover + .teacher-block-head h2 { margin-top: 32px !important; }
.teacher-block-head { position: relative; display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pub-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pub-group { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--sheet); transition: border-color .2s, transform .2s var(--ease); }
.pub-group:hover { border-color: var(--blue); transform: translateY(-2px); }
.pub-group .btn { margin-top: auto; }
.search-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.search-bar > * { flex: 1 1 200px; }
.dash-banner { height: 170px; margin-bottom: -48px; border-radius: var(--r-sheet); background: var(--ink) center / cover no-repeat; box-shadow: var(--shadow); }
.dash-banner + .page-head { position: relative; padding: 0 20px; }
.school-li { flex-direction: row !important; justify-content: space-between; align-items: center; gap: 10px; }

/* ---------- Présences / direct ---------- */
.att-tools { display: flex; justify-content: flex-end; }
.att-list { display: flex; flex-direction: column; }
.att-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--grid); }
.att-name { display: flex; flex-direction: column; gap: 2px; }
.att-name .chip { align-self: flex-start; }
.live-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 rgba(215, 38, 61, .5); animation: pulse 1.6s infinite; display: inline-block; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(215, 38, 61, .5); } 70% { box-shadow: 0 0 0 10px rgba(215, 38, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(215, 38, 61, 0); } }
.chrono { display: inline-block; padding: 4px 12px; border-radius: 99px; background: var(--ink); color: #fff; font-weight: 600; font-size: .95rem; font-variant-numeric: tabular-nums; letter-spacing: .04em; direction: ltr; }
.chrono-sm { font-size: .9rem; }
.live-start { text-align: center; padding: 46px 24px; }
.live-start-icon { width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; font-size: 1.8rem; box-shadow: 0 0 0 10px var(--red-50); }
.live-start-form { max-width: 460px; margin: 0 auto; align-items: center; }
.live-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; align-items: start; }
.live-board { text-align: center; }
.live-board:fullscreen { display: flex; flex-direction: column; justify-content: center; align-items: center; background: var(--sheet); }
.live-board:fullscreen .live-qr img, .live-board:fullscreen .live-qr canvas { width: 46vh !important; height: 46vh !important; }
.live-board:fullscreen .live-code { font-size: 5.5rem; }
.live-head { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--red); font-weight: 600; margin-bottom: 14px; }
.live-qr { display: inline-block; padding: 14px; background: #fff; border: 2px solid var(--ink); border-radius: 18px; }
.live-qr img, .live-qr canvas { display: block; }
.live-code-label { margin-top: 14px; color: var(--muted); font-size: var(--fs-sm); }
.live-code { font-size: 3.2rem; font-weight: 700; letter-spacing: .1em; color: var(--blue); font-variant-numeric: tabular-nums; direction: ltr; }
.live-refresh { max-width: 280px; height: 5px; margin: 6px auto; border-radius: 99px; background: var(--grid); overflow: hidden; }
.live-refresh span { display: block; height: 100%; background: var(--hl); transition: width 1s linear; }
.live-count { font-size: 1.2rem; }
.live-list { list-style: none; margin: 0; padding: 0; max-height: 540px; overflow: auto; }
.live-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--grid); }
.live-list li.is-in { animation: rise .35s var(--ease) both; }
.live-list li.is-in .with-avatar > span:last-child { font-weight: 600; }
.live-banner-wrap { display: grid; gap: 10px; margin-bottom: 18px; }
.live-banner-wrap:empty { display: none; }
.live-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: var(--sheet); border: 2px solid #F3B5BE; border-radius: var(--r-sheet); box-shadow: var(--shadow); animation: rise .45s var(--ease) both; }
.live-banner.is-checked { border-color: #9ED9C2; }
.live-banner.is-checked .live-dot { background: var(--green); animation: none; }
.live-banner-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-weight: 600; }
.live-banner .code-form input { max-width: 170px; }
.live-panel .card-head h2 { display: flex; align-items: center; gap: 10px; }
.live-rows { display: flex; flex-direction: column; }
.live-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--grid); }
.live-row:last-child { border-bottom: 0; }

/* ---------- Affiche QR ---------- */
.poster { position: relative; max-width: 520px; margin: 0 auto 22px; padding: 34px 30px 28px 56px; text-align: center; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lift);
  background-image: linear-gradient(rgba(176, 194, 236, .35) 1px, transparent 1px); background-size: 100% 32px; }
.poster::before { content: ''; position: absolute; top: 0; bottom: 0; inset-inline-start: 34px; width: 2px; background: var(--red); }
[dir="rtl"] .poster { padding: 34px 56px 28px 30px; }
.poster-brand { font-weight: 700; color: var(--blue); }
.poster-logo { margin-top: 10px; }
.poster-kicker { margin: 10px 0 4px; color: var(--red); font-weight: 600; }
.poster-title { font-size: 1.8rem; margin-bottom: 4px; }
.poster-teacher { color: var(--ink-2); font-weight: 500; }
.poster-qr { display: inline-block; margin: 12px 0; padding: 14px; background: #fff; border: 2px solid var(--ink); border-radius: 16px; }
.poster-qr img, .poster-qr canvas { display: block; }
.poster-code { margin: 6px 0; font-size: 1.05rem; }
.poster-code b { letter-spacing: .16em; color: var(--blue); }
.poster-info { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin: 10px 0; color: var(--ink-2); font-size: .92rem; }
.poster-url { margin: 0; font-size: .75rem; color: var(--muted); word-break: break-all; }

/* ---------- Reçu ---------- */
.receipt-page { padding: 26px 16px; background: var(--paper); }
.receipt { max-width: 640px; margin: 0 auto; padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sheet); box-shadow: var(--shadow); }
.receipt-head { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 2px solid var(--ink); }
.receipt-head h1 { margin: 0; }
.receipt-table th { width: 40%; font-size: .9rem; }
.receipt-total th, .receipt-total td { border: 0; font-size: 1.2rem; font-weight: 700; color: var(--ink); }
.receipt-sign { display: flex; justify-content: flex-end; margin-top: 48px; }
.receipt-sign span { min-width: 210px; padding-top: 6px; border-top: 1px solid var(--ink-2); text-align: center; color: var(--muted); font-size: .9rem; }

/* ---------- Transitions de page (navigateurs compatibles) ---------- */
@view-transition { navigation: auto; }
.page { view-transition-name: page; }
::view-transition-old(page) { animation: vt-out .18s var(--ease) both; }
::view-transition-new(page) { animation: vt-in .32s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .grid-main, .grid-side, .live-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero { grid-template-columns: 1fr; gap: 26px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); height: 100%; transform: translateX(-104%); transition: transform .35s var(--ease); box-shadow: 0 0 60px rgba(20, 27, 52, .25); }
  [dir="rtl"] .sidebar { transform: translateX(104%); }
  .navtoggle:checked ~ .sidebar { transform: none; }
  .sidebar .drawer-close { display: inline-grid; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(20, 27, 52, .5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .navtoggle:checked ~ .scrim { opacity: 1; pointer-events: auto; }
  .mobilebar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .mobilebar .brand { margin-inline-end: auto; }
  .me-mini { display: grid; }
  .tabbar { position: fixed; z-index: 25; inset-inline: 0; bottom: 0; display: flex; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
  .tabbar a, .tab-more { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .7rem; font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tabbar a:hover { text-decoration: none; }
  .tab-ic { position: relative; display: grid; place-items: center; width: 52px; height: 30px; border-radius: 99px; transition: background .25s var(--ease); }
  .tab-ic .badge { position: absolute; top: -4px; inset-inline-end: 4px; min-width: 18px; height: 18px; font-size: .65rem; padding: 0 5px; }
  .tabbar a.active { color: var(--ink); font-weight: 600; }
  .tabbar a.active .tab-ic { background: var(--hl); animation: tab-pop .4s var(--ease); }
  @keyframes tab-pop { 0% { transform: scale(.7); } 100% { transform: scale(1); } }
  .tab-label { max-width: 76px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .layout-app .container { padding: 20px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .toasts { inset-inline: 16px; top: 72px; max-width: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-paper { display: none; }
  .auth-panel { justify-content: flex-start; padding-top: 22px; background-image: linear-gradient(var(--grid) 1px, transparent 1px); background-size: 100% 32px; }
  .auth-top { justify-content: space-between; margin-bottom: 20px; }
  .auth-brand-mobile { display: inline-flex; }
  .sticky-bar { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  h1 { font-size: 1.6rem; }
  .container { padding-inline: 16px; }
  .publicbar, .footer { padding-inline: 16px; }
  .grid-2, .steps, .grid-images { grid-template-columns: 1fr; }
  .stats { gap: 10px; }
  .stat { padding: 14px 14px; }
  .stat-value { font-size: 1.4rem; }
  .req-card { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .code-form { flex-direction: column; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head > .btn, .page-head > form, .page-head > .actions { align-self: stretch; }
  .live-row { grid-template-columns: 1fr auto; }
  .live-code { font-size: 2.5rem; }
  .role-tab span { font-size: .85rem; }
  .dash-banner { height: 110px; }
}

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
  @view-transition { navigation: none; }
}

/* ---------- Impression ---------- */
@media print {
  body, .layout-app .main, .layout-public { background: #fff !important; }
  .no-print, .sidebar, .tabbar, .mobilebar, .toasts, .footer, .publicbar { display: none !important; }
  .shell { display: block; }
  .container { padding: 0; max-width: none; }
  .card, .poster, .receipt { box-shadow: none; }
  a { color: inherit; }
}
.portal-card > :not(.portal-icon) { grid-column: 2; }
.portal-card .link-sm { justify-self: start; }

/* Accueil : la page de cahier */
.hero-sheet { padding: 40px 40px 34px 76px; background: #FBFCFF; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lift);
  background-image: linear-gradient(rgba(126, 152, 214, .38) 1px, transparent 1px); background-size: 100% 32px; background-position: 0 31px; overflow: hidden; }
.hero-sheet::before { content: ''; position: absolute; top: 0; bottom: 0; inset-inline-start: 46px; width: 2px; background: var(--red); transform-origin: top; animation: margin-draw .9s var(--ease) .1s both; }
[dir="rtl"] .hero-sheet { padding: 40px 76px 34px 40px; }
.hero-sheet h1 { animation: rise .7s var(--ease) .3s both; }
.hero-sheet .lead { animation: rise .7s var(--ease) .42s both; }
.hero-code { display: grid; gap: 8px; animation: rise .7s var(--ease) .54s both; }
.hero-code label { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); }
@media (max-width: 640px) { .hero-sheet { padding: 26px 20px 24px 46px; } [dir="rtl"] .hero-sheet { padding: 26px 46px 24px 20px; } .hero-sheet::before { inset-inline-start: 26px; } }

/* Corrections après relecture visuelle */
.code-form input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 400; }
.live-banner-head { flex: 1 1 260px; }
.live-banner-head .chrono { margin-inline-start: auto; }
.live-banner .code-form { flex-direction: row; flex: 1 1 260px; max-width: 360px; }
.live-banner .code-form input { max-width: none; letter-spacing: .2em; }
@media (max-width: 640px) {
  .table-wrap table { min-width: 560px; }
  .live-banner .code-form { max-width: none; }
}
.auth-panel { position: relative; }
.auth-top { position: absolute; top: 28px; inset-inline: clamp(22px, 6vw, 80px); margin: 0; padding: 0; }
@media (max-width: 900px) { .auth-top { position: static; margin-bottom: 20px; } }

/* =====================================================================
   Avis de séance
   ===================================================================== */
.fb-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--grid); margin: 10px 0 8px; gap: 2px; }
.fb-bar span { width: var(--w); transform-origin: left; animation: grow .8s var(--ease) both; }
[dir="rtl"] .fb-bar span { transform-origin: right; }
.fb-bar span:nth-child(2) { animation-delay: .1s; } .fb-bar span:nth-child(3) { animation-delay: .2s; }
.fb-got { background: var(--green); } .fb-partly { background: #F2C400; } .fb-lost { background: var(--red); }
.fb-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-sm); color: var(--ink-2); }
.fb-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 6px; vertical-align: -1px; }
.fb-card .card-head { margin-bottom: 4px; }
.sess-li { display: grid !important; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.sess-li .fb-bar { grid-column: 1 / -1; height: 6px; margin: 2px 0 0; }
.sess-fb { justify-self: end; }
.fb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.fb-tile { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); transition: border-color .2s, transform .2s var(--ease); }
.fb-tile:hover { text-decoration: none; border-color: var(--blue); transform: translateY(-2px); }
.fb-tile .fb-bar { height: 8px; margin: 6px 0; }
.fb-tile-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.verdict-card { position: relative; overflow: hidden; border-width: 2px; }
.verdict-card::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 8px; background: var(--muted); }
.verdict-move_on { border-color: #9ED9C2; } .verdict-move_on::before { background: var(--green); }
.verdict-recap { border-color: #F3DE7A; } .verdict-recap::before { background: #F2C400; }
.verdict-reexplain { border-color: #F3B5BE; } .verdict-reexplain::before { background: var(--red); }
.verdict-kicker { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.verdict-title { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 2px 0 6px; letter-spacing: -.02em; }
.verdict-move_on .verdict-title { color: #0B6B53; } .verdict-reexplain .verdict-title { color: #B21E33; } .verdict-recap .verdict-title { color: var(--amber); }
.verdict-text { color: var(--ink-2); max-width: 46ch; }
.fb-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0 10px; }
.fb-counts div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--paper); }
.fb-counts b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.fb-counts span { font-size: var(--fs-xs); color: var(--muted); }
.fb-comments li { gap: 4px; }
.fb-quote { position: relative; padding-inline-start: 14px; color: var(--ink); }
.fb-quote::before { content: ''; position: absolute; inset-inline-start: 0; top: 4px; bottom: 4px; width: 3px; border-radius: 3px; background: var(--muted); }
.fb-q1::before { background: var(--red); } .fb-q2::before { background: #F2C400; } .fb-q3::before { background: var(--green); }
@media (max-width: 640px) { .fb-counts { grid-template-columns: repeat(2, 1fr); } }

/* =====================================================================
   Discussion de groupe
   ===================================================================== */
.flip-rtl { } [dir="rtl"] .flip-rtl { transform: scaleX(-1); }
.back-ic { transform: scaleX(-1); } [dir="rtl"] .back-ic { transform: none; }
.is-chat .container.page { padding-top: 0; padding-bottom: 0; max-width: 980px; display: flex; flex-direction: column; }
.chat { position: relative; display: flex; flex-direction: column; height: calc(100vh - 0px); min-height: 0; background: var(--sheet); border-inline: 1px solid var(--line); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--sheet); position: sticky; top: 0; z-index: 3; }
.chat-title { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.chat-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-pins { display: flex; gap: 8px; overflow-x: auto; padding: 8px 14px; background: var(--hl-soft); border-bottom: 1px solid #F3DE7A; }
.pin-item { display: inline-flex; align-items: center; gap: 8px; max-width: 320px; padding: 6px 12px; border: 0; border-radius: 99px; background: #fff; font: inherit; font-size: var(--fs-sm); cursor: pointer; color: var(--ink); flex: none; }
.pin-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-mark { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; margin-inline-end: 4px; vertical-align: 1px; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 8px; overscroll-behavior: contain;
  background-color: var(--paper); background-image: linear-gradient(rgba(214, 222, 242, .55) 1px, transparent 1px); background-size: 100% 32px; }
.chat-older { display: block; margin: 0 auto 12px; }
.chat-list { display: flex; flex-direction: column; gap: 2px; }
.chat-empty { padding: 60px 10px; }
.day { display: flex; justify-content: center; margin: 14px 0 8px; }
.day span { padding: 3px 12px; border-radius: 99px; background: var(--sheet); border: 1px solid var(--line); font-size: var(--fs-xs); color: var(--muted); }
.msg { position: relative; display: flex; align-items: flex-end; gap: 8px; max-width: 82%; margin-top: 8px; animation: msg-in .3s var(--ease) both; }
.msg.cont { margin-top: 2px; }
.msg.cont > .avatar { visibility: hidden; }
.msg.cont .who { display: none; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bubble { position: relative; min-width: 64px; padding: 8px 12px 6px; border-radius: 16px; border-end-start-radius: 6px; background: var(--sheet); border: 1px solid var(--line); box-shadow: 0 1px 0 #E3E8F4; }
.mine .bubble { background: var(--blue); color: #fff; border-color: var(--blue); border-end-start-radius: 16px; border-end-end-radius: 6px; }
.mine .bubble a { color: #fff; text-decoration: underline; }
.from-teacher:not(.mine) .bubble { border-color: #BFCBF5; background: #F3F6FF; }
.who { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--blue-600); margin-bottom: 2px; }
.who-tag { padding: 0 6px; border-radius: 99px; background: var(--hl); color: var(--ink); font-size: .68rem; font-weight: 600; }
.msg-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; margin-top: 2px; font-size: .68rem; opacity: .65; font-variant-numeric: tabular-nums; }
.is-deleted .bubble { background: transparent; border-style: dashed; box-shadow: none; color: var(--muted); font-style: italic; }
.mine.is-deleted .bubble { color: var(--muted); }
.media { display: block; position: relative; width: min(300px, 64vw); max-height: 360px; margin: 2px -6px 6px; padding: 0; overflow: hidden; border: 0; border-radius: 12px; background: var(--grid); cursor: pointer; }
.media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bubble video { display: block; width: min(320px, 70vw); max-height: 420px; margin: 2px -6px 6px; border-radius: 12px; background: #000; }
.play { position: absolute; inset: 0; margin: auto; width: 56px; height: 56px; border-radius: 50%; background: rgba(20, 27, 52, .7); }
.play::after { content: ''; position: absolute; top: 50%; left: 54%; transform: translate(-50%, -50%); border-style: solid; border-width: 10px 0 10px 16px; border-color: transparent transparent transparent #fff; }
.media-size { position: absolute; inset-inline-end: 8px; bottom: 8px; padding: 2px 8px; border-radius: 99px; background: rgba(20, 27, 52, .7); color: #fff; font-size: .7rem; }
.media-video:not(:has(img)) { aspect-ratio: 16 / 9; }
.media-expired { display: block; padding: 8px 10px; margin-bottom: 4px; border-radius: 10px; background: var(--paper); color: var(--muted); font-size: var(--fs-sm); font-style: italic; }
.mine .media-expired { background: rgba(255, 255, 255, .15); color: #E6EBFF; }
.file-card { display: flex; align-items: center; gap: 10px; min-width: 220px; margin: 2px -4px 6px; padding: 10px; border-radius: 12px; background: var(--paper); color: var(--ink) !important; text-decoration: none !important; }
.mine .file-card { background: rgba(255, 255, 255, .14); color: #fff !important; }
.mine .file-card .muted { color: #DCE3FF; }
.file-ext { display: grid; place-items: center; width: 42px; height: 48px; border-radius: 8px; background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; flex: none; }
.file-info { display: flex; flex-direction: column; min-width: 0; }
.file-info b { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.msg-more { align-self: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-more, .msg:focus-within .msg-more { opacity: 1; }
@media (hover: none) { .msg-more { opacity: .7; } }
.msg-menu { position: absolute; z-index: 5; bottom: 100%; inset-inline-end: 0; display: flex; flex-direction: column; min-width: 150px; padding: 6px; background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lift); animation: rise .2s var(--ease) both; }
.mine .msg-menu { inset-inline-end: auto; inset-inline-start: 0; }
.msg-menu button { padding: 8px 12px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: var(--fs-sm); text-align: start; cursor: pointer; color: var(--ink); }
.msg-menu button:hover { background: var(--blue-50); }
.msg-menu .danger { color: var(--red); }
.msg.flash .bubble { animation: flash 1.4s var(--ease); }
@keyframes flash { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 30% { box-shadow: 0 0 0 4px var(--hl); } }
.chat-jump { position: absolute; z-index: 4; inset-inline-end: 18px; bottom: 96px; padding: 8px 14px; border: 0; border-radius: 99px; background: var(--ink); color: #fff; font: inherit; font-size: var(--fs-sm); cursor: pointer; box-shadow: var(--shadow-lift); animation: rise .25s var(--ease) both; }
.chat-compose { border-top: 1px solid var(--line); background: var(--sheet); padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.chat-compose-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-compose textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; padding: 11px 14px; border-radius: 22px; line-height: 1.4; }
.send-btn { width: 46px; height: 46px; padding: 0; border-radius: 50%; flex: none; }
.attach-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--paper); cursor: pointer; }
.chat-attach-preview { position: relative; display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); overflow: hidden; }
.chat-attach-preview img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--grid); }
.pv-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pv-text b { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-progress { position: absolute; inset-inline: 0; bottom: 0; height: 3px; }
.pv-progress span { display: block; height: 100%; width: 0; background: var(--blue); transition: width .2s; }
.chat-locked { padding: 6px 4px 0; text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.chat-compose.is-locked .chat-compose-row { opacity: .45; }
.chat-storage { position: absolute; inset-inline-start: 14px; bottom: 74px; margin: 0; pointer-events: none; }
.lightbox { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(10, 14, 30, .92); animation: lines-in .2s both; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lb-close { position: absolute; top: 16px; inset-inline-end: 16px; color: #fff; }
.chat-index { padding: 6px; }
.chat-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; color: var(--ink); }
.chat-row + .chat-row { border-top: 1px solid var(--grid); }
.chat-row:hover { background: #F8FAFF; text-decoration: none; }
.chat-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-row-last { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-last .who { display: inline; font-size: inherit; color: var(--ink-2); }
.has-unread .chat-row-last { color: var(--ink); font-weight: 500; }
.chat-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chat-row-meta .badge { margin: 0; }
@media (max-width: 900px) {
  .is-chat .mobilebar { display: none; }
  .is-chat .container.page { padding: 0; }
  .chat { height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-bottom)); border: 0; }
  .msg { max-width: 88%; }
  .chat-storage { display: none; }
}
@media (min-width: 901px) { .chat { height: 100vh; } }

/* =====================================================================
   Tableau de bord élève
   ===================================================================== */
.now { margin-bottom: 20px; }
.now-card { position: relative; overflow: hidden; padding: 24px 26px; border-radius: 22px; background: var(--sheet); border: 1px solid var(--line); box-shadow: var(--shadow-lift); animation: rise .5s var(--ease) both; }
.now-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.now-top .chrono { margin-inline-start: auto; }
.now-kicker { font-size: var(--fs-sm); color: var(--muted); }
.now-title { font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 0 0 4px; letter-spacing: -.02em; }
.now-sub { color: var(--ink-2); margin: 0 0 14px; }
.now-hint { color: var(--muted); font-size: var(--fs-sm); margin: 10px 0 0; }
.now-live { background: linear-gradient(135deg, #1D3BA8 0%, #142C86 100%); color: #fff; border: 0; }
.now-live::after { content: ''; position: absolute; top: 0; bottom: 0; inset-inline-start: 18px; width: 2px; background: rgba(255, 120, 140, .9); }
.now-live > * { position: relative; padding-inline-start: 10px; }
.now-live .now-kicker, .now-live .now-sub, .now-live .now-hint { color: rgba(255, 255, 255, .85); }
.now-live .chrono { background: #fff; color: var(--ink); }
.now-live.is-checked { background: linear-gradient(135deg, #0E8F6E 0%, #0B6B53 100%); }
.now-live.is-checked .live-dot { background: #fff; animation: none; }
.now-code { display: flex; gap: 10px; max-width: 440px; }
.now-code input { flex: 1; font-size: 1.4rem; font-weight: 600; letter-spacing: .3em; text-align: center; direction: ltr; border: 0; }
.now-code input::placeholder { font-size: 1rem; letter-spacing: 0; font-weight: 400; }
.now-rate { background: linear-gradient(180deg, var(--hl-soft) 0%, var(--sheet) 55%); border-color: #F3DE7A; }
.rate-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rate-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px; border: 2px solid var(--line); border-radius: 16px; background: var(--sheet); font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; transition: transform .15s var(--ease), border-color .2s, background .2s; }
.rate-btn:hover:not(:disabled) { transform: translateY(-2px); }
.rate-btn:active:not(:disabled) { transform: scale(.96); }
.rate-btn:disabled:not(.is-chosen) { opacity: .4; }
.rate-got:hover, .rate-got.is-chosen { border-color: var(--green); background: var(--green-50); }
.rate-partly:hover, .rate-partly.is-chosen { border-color: #F2C400; background: var(--hl-soft); }
.rate-lost:hover, .rate-lost.is-chosen { border-color: var(--red); background: var(--red-50); }
/* visages dessinés en CSS */
.rate-face { position: relative; width: 46px; height: 46px; border-radius: 50%; border: 3px solid currentColor; }
.rate-face::before { content: ''; position: absolute; top: 13px; left: 11px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 13px 0 0 currentColor; }
.rate-face::after { content: ''; position: absolute; left: 11px; width: 18px; height: 9px; border: 3px solid currentColor; }
.rate-face-got { color: var(--green); } .rate-face-got::after { top: 20px; border-top: 0; border-radius: 0 0 14px 14px; }
.rate-face-partly { color: #C9A200; } .rate-face-partly::after { top: 26px; height: 0; border-width: 3px 0 0; border-radius: 0; }
.rate-face-lost { color: var(--red); } .rate-face-lost::after { top: 25px; border-bottom: 0; border-radius: 14px 14px 0 0; }
.rate-btn.is-chosen .rate-face { animation: pop .45s var(--ease); }
.rate-why { margin-top: 14px; animation: rise .3s var(--ease) both; }
.rate-why textarea { resize: vertical; }
.rate-done { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 24px 0; font-size: 1.1rem; }
.rate-check { position: relative; width: 44px; height: 44px; border-radius: 50%; background: var(--green); animation: pop .45s var(--ease) both; }
.rate-check::after { content: ''; position: absolute; left: 15px; top: 10px; width: 10px; height: 18px; border: solid #fff; border-width: 0 4px 4px 0; transform: rotate(45deg); }
.now-idle { background: linear-gradient(120deg, var(--sheet) 0%, var(--blue-50) 100%); }
.now-idle .now-sub { margin-bottom: 0; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-sheet); box-shadow: var(--shadow); color: var(--ink); }
.kpi > div:last-child { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.kpi b { font-weight: 600; font-size: .95rem; }
.kpi-link:hover { text-decoration: none; border-color: var(--blue); }
.kpi-ring { position: relative; width: 60px; height: 60px; flex: none; display: grid; place-items: center; }
.kpi-icon { border-radius: 50%; background: var(--blue-50); color: var(--blue); }
.kpi-icon .ic { width: 26px; height: 26px; }
.kpi-icon .badge { position: absolute; top: -2px; inset-inline-end: -4px; margin: 0; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
[dir="rtl"] .ring { transform: rotate(-90deg) scaleY(-1); }
.ring circle { fill: none; stroke-width: 6; }
.ring-bg { stroke: var(--grid); }
.ring-fg { stroke: var(--green); stroke-linecap: round; stroke-dasharray: var(--c); stroke-dashoffset: var(--c); animation: ring-fill 1.1s var(--ease) .2s forwards; }
.ring-warn .ring-fg { stroke: #E7A400; } .ring-bad .ring-fg { stroke: var(--red); } .ring-blue .ring-fg { stroke: var(--blue); }
@keyframes ring-fill { to { stroke-dashoffset: var(--o); } }
.ring-label { position: relative; font-weight: 600; font-size: .95rem; font-variant-numeric: tabular-nums; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.course-rail { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.course { position: relative; margin: 0; padding-top: 18px; overflow: hidden; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 70ms); }
.course::before { content: ''; position: absolute; top: 0; inset-inline: 0; height: 5px; background: var(--green); }
.course-warn::before { background: #E7A400; } .course-expired::before, .course-none::before, .course-banned::before { background: var(--red); } .course-confirmed::before { background: var(--blue); }
.course-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.course-body { display: flex; justify-content: space-between; gap: 12px; }
.course-body h3 { margin: 0 0 4px; font-size: 1.1rem; }
.course-when { color: var(--ink-2); margin: 6px 0 0; }
.course-ring { position: relative; width: 64px; height: 64px; flex: none; display: grid; place-items: center; }
.ring-cap { position: absolute; bottom: -16px; left: 0; right: 0; text-align: center; font-size: .68rem; color: var(--muted); }
.att-dots { display: flex; align-items: center; gap: 5px; margin: 16px 0 4px; flex-wrap: wrap; }
.att-dots .muted { margin-inline-start: 6px; }
.adot { width: 12px; height: 12px; border-radius: 4px; background: var(--grid); }
.adot-present { background: var(--green); } .adot-absent { background: var(--red); } .adot-excused { background: #F2C400; }
.course-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--grid-strong); }
.course-actions .btn .ic { width: 16px; height: 16px; }
.course-actions .badge { margin-inline-start: 4px; min-width: 18px; height: 18px; font-size: .65rem; }
.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.todo a, .todo li > span { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--paper); color: var(--ink); font-size: .92rem; }
.todo a:hover { text-decoration: none; background: var(--blue-50); }
.todo-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--sheet); color: var(--blue); flex: none; }
.todo-ic .ic { width: 17px; height: 17px; }
.todo-rate .todo-ic { color: #C9A200; } .todo-pay .todo-ic { color: var(--red); } .todo-warn .todo-ic { color: var(--amber); } .todo-chat .todo-ic { color: var(--green); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; top: 6px; bottom: 6px; inset-inline-start: 6px; width: 2px; background: var(--grid); }
.tl { position: relative; display: flex; gap: 12px; padding: 7px 0; }
.tl > div { display: flex; flex-direction: column; min-width: 0; }
.tl b { font-weight: 500; font-size: .92rem; }
.tl-dot { position: relative; z-index: 1; width: 14px; height: 14px; margin-top: 4px; border-radius: 50%; border: 3px solid var(--sheet); background: var(--muted); flex: none; box-shadow: 0 0 0 1px var(--line); }
.tl-att-present .tl-dot { background: var(--green); } .tl-att-absent .tl-dot { background: var(--red); } .tl-att-excused .tl-dot { background: #F2C400; } .tl-pay .tl-dot { background: var(--blue); }
.pay-details { margin-top: 12px; border-top: 1px dashed var(--grid-strong); padding-top: 10px; }
.pay-details summary { cursor: pointer; font-weight: 500; color: var(--blue); }
@media (max-width: 1080px) { .dash-grid { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .now-card { padding: 20px 18px; border-radius: 18px; }
  .now-code { flex-direction: column; }
  .rate-btn { padding: 12px 4px; font-size: .85rem; }
  .kpis { gap: 10px; }
  .kpi { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .course-rail { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; margin-inline: -16px; padding: 4px 16px 10px; }
  .course-rail .course { flex: 0 0 86%; scroll-snap-align: center; }
}

/* ---- Tableau de bord élève : mise en page téléphone ---- */
.dash-grid > *, .dash-main, .dash-side { min-width: 0; }
.course-head { min-width: 0; }
.course-head .chip { min-width: 0; max-width: 100%; white-space: normal; text-align: start; line-height: 1.25; }
.course-subject { flex: none; }
.course-body > div:first-child { min-width: 0; }
.kpi-ring .ring-label { font-size: .9rem; letter-spacing: -.02em; }
.ring-label small { font-size: .62em; font-weight: 600; margin-inline-start: 1px; }
@media (max-width: 640px) {
  body { overflow-x: clip; }
  .now { margin-bottom: 14px; }
  .now-title { font-size: 1.45rem; }
  .now-sub { font-size: .95rem; }
  /* chiffres : 2 × 2, compacts, anneau à gauche du texte */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
  .kpi { flex-direction: row; align-items: center; gap: 10px; padding: 12px 10px; border-radius: 16px; }
  .kpi-ring { width: 46px; height: 46px; }
  .kpi-ring .ring-label { font-size: .78rem; }
  .kpi-icon .ic { width: 22px; height: 22px; }
  .kpi b { font-size: .86rem; line-height: 1.2; overflow-wrap: anywhere; hyphens: auto; }
  .kpi > div:last-child { flex: 1; }
  .kpi .small { font-size: .74rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .ring circle { stroke-width: 7; }
  /* « Mes cours » + champ code sur toute la largeur */
  .section-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .section-head .code-form { display: flex; flex-direction: row; gap: 8px; width: 100%; max-width: none; margin: 0; }
  .section-head .code-form input { flex: 1; min-width: 0; text-align: start; }
  .section-head .code-form .btn { flex: none; width: auto; }
  /* cartes de cours */
  .course-rail .course { flex-basis: 88%; padding: 16px 16px 14px; }
  .course-rail .course:only-child { flex-basis: 100%; }
  .course-head { flex-wrap: wrap; }
  .course-body h3 { font-size: 1.05rem; }
  .course-ring { width: 54px; height: 54px; }
  .course .alert { margin: 10px 0 0; padding: 10px 12px; font-size: .86rem; }
  .course-actions { flex-wrap: wrap; }
  .course-actions .btn { flex: 1 1 auto; justify-content: center; }
  .dash-side .card { padding: 16px; }
  .dash-side h2 { font-size: 1.1rem; }
  .todo a, .todo li > span { font-size: .88rem; padding: 9px 10px; }
}

/* =====================================================================
   Liste des discussions — façon messagerie Instagram
   ===================================================================== */
.is-inbox .container.page { max-width: 640px; }
.ig { --ig-grad: conic-gradient(from 210deg, #FEDA75, #FA7E1E, #D62976, #962FBF, #4F5BD5, #FEDA75); background: var(--sheet); border: 1px solid var(--line); border-radius: 22px; padding: 18px 0 8px; box-shadow: var(--shadow); }
.ig-head { display: flex; align-items: center; justify-content: space-between; padding: 0 20px 12px; }
.ig-head h1 { font-size: 1.35rem; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.ig-search { display: flex; align-items: center; gap: 10px; margin: 0 16px 14px; padding: 0 14px; height: 40px; border-radius: 12px; background: #EFEFF3; color: #8E8E93; }
.ig-search .ic { width: 18px; height: 18px; }
.ig-search input { border: 0; background: transparent; padding: 0; height: 100%; font-size: .95rem; box-shadow: none !important; }
.ig-search input:focus { outline: none; }

.ig-stories { display: flex; gap: 14px; overflow-x: auto; padding: 4px 16px 14px; scrollbar-width: none; }
.ig-stories::-webkit-scrollbar { display: none; }
.ig-story { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 74px; flex: none; color: var(--ink); }
.ig-story:hover { text-decoration: none; }
.ig-ring { display: grid; place-items: center; width: 70px; height: 70px; border-radius: 50%; padding: 3px; background: #DBDBDB; transition: transform .2s var(--ease); }
.ig-story:active .ig-ring { transform: scale(.94); }
.ig-story.is-new .ig-ring { background: var(--ig-grad); animation: ig-spin 6s linear infinite; }
.ig-story.is-live .ig-ring { background: conic-gradient(var(--red), #FF6A3D, var(--red)); }
.ig-ring .avatar { width: 100%; height: 100%; border: 3px solid var(--sheet); box-shadow: none; font-size: 1.5rem; }
.ig-story.is-new .ig-ring .avatar { animation: ig-spin 6s linear infinite reverse; }
@keyframes ig-spin { to { transform: rotate(360deg); } }
.ig-live-pill { position: absolute; top: 56px; padding: 1px 7px; border-radius: 6px; border: 2px solid var(--sheet); background: linear-gradient(90deg, #D62976, var(--red)); color: #fff; font-size: .62rem; font-weight: 700; letter-spacing: .04em; }
.ig-story-name { width: 100%; text-align: center; font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.ig-story.is-new .ig-story-name { color: var(--ink); font-weight: 600; }

.ig-tabs { display: flex; gap: 22px; padding: 4px 20px 0; border-bottom: 1px solid var(--grid); }
.ig-tab { position: relative; padding: 10px 0 12px; border: 0; background: none; font: inherit; font-weight: 600; font-size: .95rem; color: #8E8E93; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.ig-tab.is-active { color: var(--ink); }
.ig-tab.is-active::after { content: ''; position: absolute; inset-inline: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.ig-tab-n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #3797F0; color: #fff; font-size: .68rem; display: inline-grid; place-items: center; }

.ig-list { list-style: none; margin: 0; padding: 6px 0; }
.ig-row a { display: flex; align-items: center; gap: 14px; padding: 8px 20px; color: var(--ink); transition: background .15s; }
.ig-row a:hover { text-decoration: none; background: #F7F7F9; }
.ig-row a:active { background: #EFEFF3; }
.ig-ava { position: relative; flex: none; }
.ig-ava .avatar { width: 56px; height: 56px; border: 0; box-shadow: none; font-size: 1.35rem; }
.ig-ava.is-live { padding: 2px; border-radius: 50%; background: conic-gradient(var(--red), #FF6A3D, var(--red)); }
.ig-ava.is-live .avatar { border: 2px solid var(--sheet); width: 54px; height: 54px; }
.ig-ava-dot { position: absolute; bottom: 2px; inset-inline-end: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--red); border: 3px solid var(--sheet); animation: pulse 1.6s infinite; }
.ig-initial { background: linear-gradient(140deg, hsl(var(--h) 75% 62%), hsl(calc(var(--h) + 40) 70% 48%)); color: #fff; font-weight: 700; }
.ig-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ig-name { display: flex; align-items: center; gap: 6px; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ig-lock { width: 13px; height: 13px; color: #8E8E93; flex: none; }
.ig-last { display: flex; min-width: 0; font-size: .875rem; color: #8E8E93; }
.ig-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ig-time { flex: none; white-space: nowrap; margin-inline-start: .35em; }
.ig-row.is-unread .ig-name { font-weight: 700; }
.ig-row.is-unread .ig-preview { color: var(--ink); font-weight: 600; }
.ig-dot { width: 9px; height: 9px; border-radius: 50%; background: #3797F0; flex: none; }
.ig-none { text-align: center; padding: 20px; }
.ig-empty { text-align: center; padding: 40px 24px 50px; }
.ig-empty-ic { display: grid; place-items: center; width: 92px; height: 92px; margin: 0 auto 16px; border-radius: 50%; border: 2px solid var(--ink); }
.ig-empty-ic .ic { width: 40px; height: 40px; }
@media (max-width: 900px) {
  .is-inbox .container.page { padding: 0 0 calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); }
  .ig { border: 0; border-radius: 0; box-shadow: none; min-height: calc(100dvh - 60px - var(--tabbar-h)); padding-top: 14px; }
}
@media (prefers-reduced-motion: reduce) { .ig-story.is-new .ig-ring, .ig-story.is-new .ig-ring .avatar { animation: none; } }
