/* Partiels L2 - aplats pastel par matière, grosses tuiles, cartes qu'on retourne. */

:root {
  color-scheme: light;
  --bg: oklch(0.975 0.006 285);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.955 0.009 285);
  --ink: oklch(0.21 0.025 285);
  --ink-2: oklch(0.43 0.022 285);
  --line: oklch(0.905 0.011 285);
  --grid: oklch(0.93 0.012 285);
  --accent: oklch(0.55 0.2 290);
  --accent-soft: oklch(0.93 0.05 290);
  --ok: oklch(0.52 0.14 155);
  --ok-soft: oklch(0.94 0.06 155);
  --bad: oklch(0.55 0.19 25);
  --bad-soft: oklch(0.94 0.045 25);
  --btn: oklch(0.21 0.025 285);
  --btn-ink: oklch(0.99 0 0);
  --shadow: 0 1px 2px oklch(0.2 0.03 285 / 0.06), 0 8px 24px -12px oklch(0.2 0.03 285 / 0.18);

  /* une couleur par matière : aplat, encre, trait fort */
  --compta: oklch(0.885 0.07 235);    --compta-ink: oklch(0.33 0.08 240);    --compta-strong: oklch(0.6 0.13 240);
  --finance: oklch(0.875 0.075 300);  --finance-ink: oklch(0.34 0.1 300);    --finance-strong: oklch(0.58 0.16 300);
  --maths: oklch(0.925 0.085 95);     --maths-ink: oklch(0.36 0.07 80);      --maths-strong: oklch(0.66 0.13 80);
  --management: oklch(0.895 0.075 162); --management-ink: oklch(0.34 0.07 165); --management-strong: oklch(0.58 0.12 165);
  --marketing: oklch(0.89 0.07 355);  --marketing-ink: oklch(0.36 0.1 355);  --marketing-strong: oklch(0.6 0.16 355);
  --droit: oklch(0.895 0.075 55);     --droit-ink: oklch(0.37 0.09 45);      --droit-strong: oklch(0.63 0.14 45);

  --r-s: 12px; --r-m: 18px; --r-l: 26px;
  --f-display: "Bricolage Grotesque", "Geist", system-ui, sans-serif;
  --f-ui: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z-sticky: 10; --z-bar: 20; --z-toast: 40;
  --wrap: 1080px;
  --bottom-h: 0px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: oklch(0.17 0.012 285);
    --surface: oklch(0.215 0.014 285);
    --surface-2: oklch(0.25 0.016 285);
    --ink: oklch(0.95 0.008 285);
    --ink-2: oklch(0.77 0.015 285);
    --line: oklch(0.31 0.016 285);
    --grid: oklch(0.255 0.016 285);
    --accent: oklch(0.74 0.15 290);
    --accent-soft: oklch(0.3 0.07 290);
    --ok: oklch(0.76 0.14 155);
    --ok-soft: oklch(0.3 0.06 155);
    --bad: oklch(0.74 0.15 25);
    --bad-soft: oklch(0.31 0.07 25);
    --btn: oklch(0.95 0.008 285);
    --btn-ink: oklch(0.17 0.012 285);
    --shadow: 0 1px 2px oklch(0 0 0 / 0.3), 0 10px 28px -14px oklch(0 0 0 / 0.6);
    --compta: oklch(0.36 0.07 240);    --compta-ink: oklch(0.93 0.035 235);    --compta-strong: oklch(0.74 0.12 235);
    --finance: oklch(0.36 0.08 300);   --finance-ink: oklch(0.93 0.035 300);   --finance-strong: oklch(0.74 0.14 300);
    --maths: oklch(0.38 0.065 85);     --maths-ink: oklch(0.94 0.05 95);       --maths-strong: oklch(0.8 0.13 90);
    --management: oklch(0.36 0.065 165); --management-ink: oklch(0.93 0.04 162); --management-strong: oklch(0.76 0.12 162);
    --marketing: oklch(0.37 0.08 355); --marketing-ink: oklch(0.93 0.035 355); --marketing-strong: oklch(0.75 0.14 355);
    --droit: oklch(0.38 0.075 50);     --droit-ink: oklch(0.94 0.04 55);       --droit-strong: oklch(0.77 0.13 50);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.17 0.012 285);
  --surface: oklch(0.215 0.014 285);
  --surface-2: oklch(0.25 0.016 285);
  --ink: oklch(0.95 0.008 285);
  --ink-2: oklch(0.77 0.015 285);
  --line: oklch(0.31 0.016 285);
  --grid: oklch(0.255 0.016 285);
  --accent: oklch(0.74 0.15 290);
  --accent-soft: oklch(0.3 0.07 290);
  --ok: oklch(0.76 0.14 155);
  --ok-soft: oklch(0.3 0.06 155);
  --bad: oklch(0.74 0.15 25);
  --bad-soft: oklch(0.31 0.07 25);
  --btn: oklch(0.95 0.008 285);
  --btn-ink: oklch(0.17 0.012 285);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.3), 0 10px 28px -14px oklch(0 0 0 / 0.6);
  --compta: oklch(0.36 0.07 240);    --compta-ink: oklch(0.93 0.035 235);    --compta-strong: oklch(0.74 0.12 235);
  --finance: oklch(0.36 0.08 300);   --finance-ink: oklch(0.93 0.035 300);   --finance-strong: oklch(0.74 0.14 300);
  --maths: oklch(0.38 0.065 85);     --maths-ink: oklch(0.94 0.05 95);       --maths-strong: oklch(0.8 0.13 90);
  --management: oklch(0.36 0.065 165); --management-ink: oklch(0.93 0.04 162); --management-strong: oklch(0.76 0.12 162);
  --marketing: oklch(0.37 0.08 355); --marketing-ink: oklch(0.93 0.035 355); --marketing-strong: oklch(0.75 0.14 355);
  --droit: oklch(0.38 0.075 50);     --droit-ink: oklch(0.94 0.04 55);       --droit-strong: oklch(0.77 0.13 50);
}

/* la matière courante : [data-m] pose --m, --m-ink, --m-strong */
[data-m="compta"] { --m: var(--compta); --m-ink: var(--compta-ink); --m-strong: var(--compta-strong); }
[data-m="finance"] { --m: var(--finance); --m-ink: var(--finance-ink); --m-strong: var(--finance-strong); }
[data-m="maths"] { --m: var(--maths); --m-ink: var(--maths-ink); --m-strong: var(--maths-strong); }
[data-m="management"] { --m: var(--management); --m-ink: var(--management-ink); --m-strong: var(--management-strong); }
[data-m="marketing"] { --m: var(--marketing); --m-ink: var(--marketing-ink); --m-strong: var(--marketing-strong); }
[data-m="droit"] { --m: var(--droit); --m-ink: var(--droit-ink); --m-strong: var(--droit-strong); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--f-ui);
  font-feature-settings: "ss01", "tnum" 0;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom));
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 800; line-height: 1.08; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.12rem; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: 12px; top: -60px; z-index: var(--z-toast); background: var(--btn); color: var(--btn-ink); padding: 10px 14px; border-radius: var(--r-s); text-decoration: none; }
.skip:focus { top: 12px; }

/* barre du haut (ordi) */
.topbar { position: sticky; top: 0; z-index: var(--z-bar); background: color-mix(in oklch, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid color-mix(in oklch, var(--line) 70%, transparent); }
.topbar-in { max-width: var(--wrap); margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 800 1.08rem/1 var(--f-display); letter-spacing: -0.02em; }
.logo svg { width: 30px; height: 30px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a { text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 500; font-size: 0.95rem; color: var(--ink-2); transition: background 0.18s var(--ease), color 0.18s var(--ease); }
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--btn); color: var(--btn-ink); }
.sync { font-size: 0.8rem; color: var(--ink-2); min-width: 1px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); opacity: 0; transition: opacity 0.2s; }
.sync[data-s]::before { opacity: 1; }
.sync[data-s="wait"]::before { background: var(--maths-strong); }
.sync[data-s="off"]::before { background: var(--bad); }

/* barre du bas (téléphone) */
.bottombar { position: fixed; inset: auto 0 0 0; z-index: var(--z-bar); display: none; background: color-mix(in oklch, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.bottombar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center; text-decoration: none; font-size: 0.72rem; font-weight: 600; color: var(--ink-2); border-radius: 14px; }
.bottombar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.bottombar a[aria-current="page"] { color: var(--ink); }
.bottombar a[aria-current="page"] svg { stroke-width: 2.3; }
.nav-av { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; overflow: hidden; font: 800 0.75rem/1 var(--f-display); font-style: normal; background: var(--finance); color: var(--finance-ink); box-shadow: 0 0 0 2px var(--surface); }
.nav-av.has-img { background: var(--surface-2); }
.nav-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tabs a[data-tab="compte"] { display: inline-flex; align-items: center; gap: 8px; padding-left: 6px; }
.tabs a[data-tab="compte"] .nav-av { width: 24px; height: 24px; box-shadow: none; }
.bottombar a[aria-current="page"] .nav-av { box-shadow: 0 0 0 2px var(--ink); }
.bottombar a[aria-current="page"] span { background: var(--accent-soft); padding: 0 8px; border-radius: 999px; }

@media (max-width: 859px) {
  .topbar { display: none; }
  .bottombar:not([hidden]) { display: flex; }
  body.has-nav { --bottom-h: 66px; }
}

/* mise en page */
main { outline: none; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 20px 16px 48px; }
@media (min-width: 860px) { .wrap { padding: 32px 24px 64px; } }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.78rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 34px 0 14px; }
.section-title h2 { font-size: 1.3rem; }
.section-title a { font-size: 0.9rem; font-weight: 600; color: var(--accent); text-decoration: none; }

/* surlignage pilule, façon marqueur */
.hl { background: var(--m, var(--accent-soft)); color: var(--m-ink, var(--ink)); padding: 0.02em 0.32em; border-radius: 0.4em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 999px; border: 0; background: var(--btn); color: var(--btn-ink); font-weight: 600; font-size: 0.97rem; text-decoration: none; cursor: pointer; transition: transform 0.15s var(--ease), background 0.18s var(--ease), opacity 0.18s; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: color-mix(in oklch, var(--btn) 86%, var(--accent)); }
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.ghost:hover { background: color-mix(in oklch, var(--surface-2) 80%, var(--ink) 8%); }
.btn.line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.line:hover { box-shadow: inset 0 0 0 1.5px var(--ink-2); }
.btn.subject { background: var(--m-ink); color: var(--m); }
.btn.big { min-height: 54px; padding: 0 26px; font-size: 1.02rem; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 0.88rem; }
.btn.is-loading { pointer-events: none; opacity: 0.7; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.kbd { display: inline-block; min-width: 1.5em; padding: 0 0.35em; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; font: 600 0.72rem/1.5 var(--f-ui); text-align: center; color: var(--ink-2); background: var(--surface); }
@media (hover: none) { .kbd { display: none; } }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px 0 8px; margin-left: -8px; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 0.92rem; color: var(--ink-2); }
.back:hover { background: var(--surface-2); color: var(--ink); }
.back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.m { background: var(--m); color: var(--m-ink); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }

/* formulaires */
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.9rem; }
.input { width: 100%; min-height: 50px; padding: 0 16px; border-radius: var(--r-m); border: 1.5px solid var(--line); background: var(--surface); font-size: 1rem; transition: border-color 0.18s, box-shadow 0.18s; }
.input:hover { border-color: color-mix(in oklch, var(--line) 50%, var(--ink-2)); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input::placeholder { color: var(--ink-2); opacity: 0.8; }
.form-error { color: var(--bad); font-weight: 600; font-size: 0.9rem; min-height: 1.4em; }
.seg { display: inline-flex; padding: 4px; background: var(--surface-2); border-radius: 999px; gap: 2px; }
.seg button { border: 0; background: transparent; min-height: 40px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: 0.92rem; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* écran de connexion */
.auth { min-height: 100dvh; display: grid; align-items: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.auth-in { width: 100%; max-width: 980px; margin: 0 auto; display: grid; gap: 36px; align-items: center; }
@media (min-width: 860px) { .auth-in { grid-template-columns: 1.1fr 1fr; gap: 64px; } }
.auth-hero h1 { font-size: clamp(2.3rem, 6vw, 3.6rem); letter-spacing: -0.035em; margin-top: 20px; }
.auth-hero p { font-size: 1.08rem; color: var(--ink-2); margin-top: 16px; max-width: 34ch; }
.auth-school { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.auth-school img { width: 132px; height: auto; display: block; }
.auth-school span { font: 600 0.82rem/1 var(--f-ui); color: var(--ink-2); padding-left: 14px; border-left: 1px solid var(--line); height: 26px; display: flex; align-items: center; }
.auth-school .logo-sombre { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth-school .logo-clair { display: none; } :root:not([data-theme="light"]) .auth-school .logo-sombre { display: block; } }
:root[data-theme="dark"] .auth-school .logo-clair { display: none; }
:root[data-theme="dark"] .auth-school .logo-sombre { display: block; }
.auth-mosaic { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 360px; }
.auth-mosaic span { aspect-ratio: 1.25; border-radius: 18px; background: var(--m); color: var(--m-ink); font: 800 0.85rem/1 var(--f-display); padding: 10px; display: flex; align-items: flex-end; }
.auth-mosaic span:nth-child(2) { border-radius: 18px 18px 18px 40px; }
.auth-mosaic span:nth-child(4) { border-radius: 40px 18px 18px 18px; }
.auth-card { background: var(--surface); border-radius: var(--r-l); padding: 26px 22px; box-shadow: var(--shadow); border: 1px solid var(--line); }
@media (min-width: 860px) { .auth-card { padding: 34px; } }
.auth-card h2 { font-size: 1.5rem; }
.auth-foot { margin-top: 18px; text-align: center; }
.linkish { background: none; border: 0; padding: 6px 4px; color: var(--ink-2); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkish:hover { color: var(--ink); }

/* logo de l'école, discret */
.school { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 0.78rem; line-height: 1.4; }
.school img { width: 84px; height: auto; filter: grayscale(1); opacity: 0.55; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .school img { filter: grayscale(1) invert(1); opacity: 0.5; } }
:root[data-theme="dark"] .school img { filter: grayscale(1) invert(1); opacity: 0.5; }

/* accueil */
.hello { display: grid; gap: 18px; }
@media (min-width: 860px) { .hello { grid-template-columns: 1.35fr 1fr; align-items: stretch; } }
.countdown { position: relative; overflow: hidden; border-radius: var(--r-l); padding: 24px 22px 22px; background: var(--m); color: var(--m-ink); min-height: 190px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; }
.countdown .big { font: 800 clamp(3.4rem, 12vw, 5.2rem)/0.9 var(--f-display); letter-spacing: -0.04em; }
.countdown .big small { font-size: 0.38em; letter-spacing: -0.01em; margin-left: 6px; }
.countdown .what { font-weight: 600; font-size: 1.02rem; }
.countdown .next-list { display: flex; gap: 6px; flex-wrap: wrap; }
.countdown .next-list span { font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: color-mix(in oklch, var(--m-ink) 12%, transparent); }
.countdown::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: color-mix(in oklch, var(--m-ink) 8%, transparent); }
.streak { border-radius: var(--r-l); padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 14px; align-content: space-between; }
.streak .n { font: 800 2.4rem/1 var(--f-display); letter-spacing: -0.03em; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week div { display: grid; justify-items: center; gap: 5px; font-size: 0.72rem; color: var(--ink-2); font-weight: 600; }
.week i { width: 100%; max-width: 34px; aspect-ratio: 1; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-style: normal; }
.week i.on { background: var(--accent); color: var(--btn-ink); }
.week i.on::before { content: "✓"; font-size: 0.85rem; color: var(--surface); }
.week i.today { box-shadow: inset 0 0 0 2px var(--accent); }

.today-list { display: grid; gap: 10px; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); transition: border-color 0.18s, background 0.18s; }
.task:hover { border-color: color-mix(in oklch, var(--line) 40%, var(--m-strong)); }
.task .dot { width: 44px; height: 44px; border-radius: 14px; background: var(--m); color: var(--m-ink); display: grid; place-items: center; font: 800 0.8rem/1 var(--f-display); }
.task h3 { font-size: 1.02rem; font-family: var(--f-ui); font-weight: 600; letter-spacing: 0; }
.task p { font-size: 0.88rem; color: var(--ink-2); margin-top: 2px; }
.task a.cover { text-decoration: none; }
.task.done h3 { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--ink-2); }
.check { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.check svg { width: 28px; height: 28px; }
.check circle { fill: none; stroke: currentColor; stroke-width: 1.8; }
.check path { fill: none; stroke: var(--btn-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check[aria-pressed="true"] circle { fill: var(--ok); stroke: var(--ok); }
.check[aria-pressed="true"] path { opacity: 1; stroke: var(--surface); }
.check:hover { color: var(--ink); }
.exam-banner { padding: 14px 16px; border-radius: var(--r-m); background: var(--accent-soft); font-weight: 600; display: flex; gap: 10px; align-items: center; }

.review-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-radius: var(--r-l); background: var(--btn); color: var(--btn-ink); text-decoration: none; transition: transform 0.15s var(--ease); }
.review-cta:active { transform: scale(0.985); }
.review-cta .n { font: 800 2rem/1 var(--f-display); }
.review-cta .stack-icon { width: 58px; height: 46px; position: relative; flex: none; }
.review-cta .stack-icon i { position: absolute; inset: 0; border-radius: 10px; }
.review-cta .stack-icon i:nth-child(1) { background: var(--finance); transform: rotate(-10deg) translate(-6px, 2px); }
.review-cta .stack-icon i:nth-child(2) { background: var(--maths); transform: rotate(6deg) translate(4px, -1px); }
.review-cta .stack-icon i:nth-child(3) { background: var(--management); }

/* matières groupées par jour de partiel */
.exam-days { display: grid; gap: 18px; }
@media (min-width: 860px) { .exam-days { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
.exam-day-label { font-weight: 700; font-size: 0.85rem; color: var(--ink-2); margin: 0 0 8px 4px; }
.exam-day-label::first-letter, .day-head h3::first-letter { text-transform: uppercase; }
.exam-day-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 860px) { .exam-day-tiles { grid-template-columns: 1fr; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 22px; min-height: 150px; padding: 18px; border-radius: var(--r-l); background: var(--m); color: var(--m-ink); text-decoration: none; transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease); overflow: hidden; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile:active { transform: scale(0.98); }
.tile h3 { font: 800 1.32rem/1.05 var(--f-display); letter-spacing: -0.025em; }
.tile .when { font-size: 0.8rem; font-weight: 600; opacity: 0.85; margin-top: 4px; }
.tile .foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.tile .pct { font: 800 1.6rem/1 var(--f-display); letter-spacing: -0.03em; }
.tile .pct small { font-size: 0.55em; }
.tile .soon { font-size: 0.78rem; font-weight: 600; opacity: 0.8; }
.ring { width: 46px; height: 46px; flex: none; }
.ring circle { fill: none; stroke-width: 5; }
.ring .bg { stroke: color-mix(in oklch, var(--m-ink) 14%, transparent); }
.ring .fg { stroke: var(--m-ink); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset 0.6s var(--ease); }
.tile.empty { background: var(--surface-2); color: var(--ink-2); }
.tile.empty::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 2px var(--m); pointer-events: none; }

/* matière */
.subject-head { border-radius: var(--r-l); padding: 22px 22px 24px; background: var(--m); color: var(--m-ink); display: grid; gap: 18px; position: relative; overflow: hidden; }
.subject-head h1 { font-size: clamp(2rem, 6vw, 2.8rem); letter-spacing: -0.035em; }
.subject-head .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 0.85rem; font-weight: 600; }
.subject-head .meta span { padding: 4px 10px; border-radius: 999px; background: color-mix(in oklch, var(--m-ink) 11%, transparent); }
.bar { height: 10px; border-radius: 999px; background: color-mix(in oklch, var(--m-ink) 14%, transparent); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--m-ink); width: 0; transition: width 0.6s var(--ease); }
.bar.neutral { background: var(--surface-2); }
.bar.neutral i { background: var(--m-strong); }
.modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
@media (min-width: 680px) { .modes { grid-template-columns: repeat(5, 1fr); } }
.mode { display: flex; flex-direction: column; gap: 10px; padding: 16px; min-height: 112px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); text-decoration: none; transition: border-color 0.18s, transform 0.15s var(--ease); }
.mode:hover { border-color: var(--m-strong); }
.mode:active { transform: scale(0.98); }
.mode svg { width: 26px; height: 26px; fill: none; stroke: var(--m-strong); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mode b { font-weight: 700; font-size: 1rem; }
.mode span { font-size: 0.82rem; color: var(--ink-2); margin-top: auto; }
.mode[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.chapters { display: grid; gap: 8px; }
.chap { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: center; padding: 14px 16px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); }
.chap h3 { font: 600 0.98rem/1.35 var(--f-ui); letter-spacing: 0; }
.chap .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.chap .bar { grid-column: 1 / -1; height: 6px; }
.chap .pct { font-weight: 700; font-size: 0.9rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tag-link { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); text-decoration: none; font-size: 0.82rem; font-weight: 600; color: var(--ink); }
.tag-link:hover { background: var(--m); color: var(--m-ink); }

/* fiche : papier quadrillé discret */
.paper { background-color: var(--surface); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; background-position: -1px -1px; border-radius: var(--r-l); border: 1px solid var(--line); padding: 22px 18px; }
@media (min-width: 860px) { .paper { padding: 34px 40px; } }
.fiche-layout { display: grid; gap: 18px; }
@media (min-width: 1000px) { .fiche-layout { grid-template-columns: 240px 1fr; gap: 28px; align-items: start; } }
.toc { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; position: sticky; top: 0; z-index: var(--z-sticky); background: var(--bg); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.toc::-webkit-scrollbar { display: none; }
.toc a { flex: none; text-decoration: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.toc a.on { background: var(--m); color: var(--m-ink); border-color: transparent; }
@media (min-width: 1000px) {
  .toc { flex-direction: column; overflow: visible; top: 80px; margin: 0; padding: 0; background: none; }
  .toc a { border: 0; background: none; border-radius: var(--r-s); padding: 9px 12px; white-space: normal; }
  .toc a:hover { background: var(--surface-2); color: var(--ink); }
}
.fiche-chap + .fiche-chap { margin-top: 44px; }
.fiche-chap > h2 { display: inline; font-size: 1.5rem; background: var(--m); color: var(--m-ink); padding: 0.05em 0.35em; border-radius: 0.35em; -webkit-box-decoration-break: clone; box-decoration-break: clone; line-height: 1.4; }
.fiche-block { margin-top: 22px; }
.fiche-block > h3 { font-size: 1.18rem; margin-bottom: 8px; }
.fiche-chap .chap-acts { margin-top: 18px; }

/* prose markdown */
.md { max-width: 72ch; font-size: 1rem; line-height: 1.65; text-wrap: pretty; }
.md > * + * { margin-top: 0.75em; }
.md h1, .md h2, .md h3, .md h4 { margin-top: 1.4em; }
.md h2 { font-size: 1.25rem; }
.md h3 { font-size: 1.08rem; }
.md h4 { font: 700 1rem/1.3 var(--f-ui); }
.md ul, .md ol { padding-left: 1.3em; }
.md li + li { margin-top: 0.3em; }
.md li::marker { color: var(--m-strong, var(--ink-2)); font-weight: 700; }
.md strong { font-weight: 700; background: linear-gradient(transparent 58%, color-mix(in oklch, var(--m, var(--accent-soft)) 85%, transparent) 58%); padding: 0 0.08em; }
.md em { font-style: italic; }
.md blockquote { margin: 1em 0; padding: 12px 16px; background: var(--surface-2); border-radius: var(--r-s); }
.md code { font: 500 0.9em/1.4 ui-monospace, "SF Mono", Menlo, monospace; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 6px; }
.md hr { border: 0; height: 1px; background: var(--line); margin: 1.6em 0; }
.md .tbl { overflow-x: auto; margin: 1em 0; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface); }
.md table { border-collapse: collapse; width: 100%; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.md th, .md td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.md tr:last-child td { border-bottom: 0; }
.md th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; }
.md .katex { font-size: 1.06em; }

/* cartes mémo */
.session-top { display: flex; align-items: center; gap: 12px; }
.session-top .bar { flex: 1; height: 8px; }
.session-top .count { font-weight: 700; font-size: 0.9rem; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.flip-zone { perspective: 1400px; margin: 22px auto 0; max-width: 620px; }
.flip { position: relative; width: 100%; min-height: min(56vh, 420px); border: 0; padding: 0; background: none; cursor: pointer; text-align: left; transform-style: preserve-3d; transition: transform 0.5s var(--ease); display: grid; }
.flip.on { transform: rotateY(180deg); }
.face { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 30px; padding: 26px 24px; display: flex; flex-direction: column; gap: 16px; min-height: inherit; }
.face.front { background: var(--m); color: var(--m-ink); }
.face.back { background: var(--surface); border: 2px solid var(--m); transform: rotateY(180deg); color: var(--ink); overflow-y: auto; }
.face .lbl { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; font-weight: 600; opacity: 0.85; }
.face.front .q { font: 800 clamp(1.4rem, 4.6vw, 2rem)/1.15 var(--f-display); letter-spacing: -0.02em; margin: auto 0; text-wrap: balance; }
.face.front .q .katex { font-size: 1em; }
.face.front .hint { font-size: 0.85rem; font-weight: 600; opacity: 0.75; }
.face.back .md { font-size: 1.05rem; font-weight: 400; }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 620px; margin: 18px auto 0; }
.rate button { min-height: 64px; border-radius: var(--r-m); border: 0; cursor: pointer; font-weight: 700; font-size: 0.95rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: transform 0.12s var(--ease), filter 0.15s; }
.rate button:active { transform: scale(0.96); }
.rate button small { font-weight: 500; font-size: 0.75rem; opacity: 0.85; }
.rate .r1 { background: var(--bad-soft); color: var(--bad); }
.rate .r2 { background: var(--surface-2); color: var(--ink); }
.rate .r3 { background: var(--ok-soft); color: var(--ok); }
.rate button:hover { filter: brightness(0.97); }
.reveal-btn { max-width: 620px; margin: 18px auto 0; display: flex; }

/* QCM */
.qcm-q { margin-top: 22px; }
.qcm-q .qtext { font: 600 1.18rem/1.45 var(--f-ui); letter-spacing: -0.005em; max-width: 60ch; }
.qcm-q .qtext p + p { margin-top: 0.5em; }
.choices { display: grid; gap: 10px; margin-top: 18px; max-width: 720px; }
.choice { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; width: 100%; text-align: left; min-height: 58px; padding: 12px 14px; border-radius: var(--r-m); border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.12s var(--ease); font-size: 0.98rem; line-height: 1.4; }
.choice:hover:not(:disabled) { border-color: var(--m-strong); }
.choice:active:not(:disabled) { transform: scale(0.99); }
.choice .letter { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: 0.9rem; }
.choice[aria-pressed="true"] { border-color: var(--ink); background: var(--surface-2); }
.choice[aria-pressed="true"] .letter { background: var(--btn); color: var(--btn-ink); }
.choice:disabled { cursor: default; }
.choice.is-right { border-color: var(--ok); background: var(--ok-soft); }
.choice.is-right .letter { background: var(--ok); color: var(--surface); }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.is-wrong .letter { background: var(--bad); color: var(--surface); }
.choice .verdict { font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.choice.is-right .verdict { color: var(--ok); }
.choice.is-wrong .verdict { color: var(--bad); }
.explain { margin-top: 18px; max-width: 720px; padding: 18px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); animation: rise 0.25s var(--ease); }
.explain .head { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 8px; }
.explain .src { margin-top: 10px; font-size: 0.82rem; color: var(--ink-2); }
.next-row { display: flex; justify-content: flex-end; gap: 10px; max-width: 720px; margin-top: 16px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.setup { display: grid; gap: 22px; max-width: 720px; }
.setup fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.setup legend { font-weight: 700; margin-bottom: 10px; padding: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pill span { display: inline-flex; align-items: center; min-height: 42px; padding: 0 16px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line); font-weight: 600; font-size: 0.9rem; transition: background 0.15s, border-color 0.15s; }
.pill input:checked + span { background: var(--m); color: var(--m-ink); border-color: transparent; }
.pill input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.result { border-radius: var(--r-l); padding: 26px 22px; background: var(--m); color: var(--m-ink); display: grid; gap: 10px; }
.result .score { font: 800 clamp(3.2rem, 11vw, 4.6rem)/0.95 var(--f-display); letter-spacing: -0.04em; }
.result .score small { font-size: 0.4em; }
.miss { display: grid; gap: 10px; margin-top: 12px; }
.miss-item { padding: 16px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); }
.miss-item .q { font-weight: 600; }
.miss-item .a { margin-top: 8px; display: flex; gap: 8px; align-items: baseline; font-size: 0.92rem; }

/* exos et sujets */
.list { display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center; padding: 16px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); text-decoration: none; transition: border-color 0.18s; }
.item:hover { border-color: var(--m-strong); }
.item h3 { font: 600 1rem/1.35 var(--f-ui); letter-spacing: 0; }
.item p { font-size: 0.84rem; color: var(--ink-2); }
.steps { display: grid; gap: 12px; margin-top: 22px; }
.step { border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.step .sq { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; font-weight: 600; }
.step .sq .num { flex: none; width: 28px; height: 28px; border-radius: 9px; background: var(--m); color: var(--m-ink); display: grid; place-items: center; font-size: 0.85rem; font-weight: 800; }
.step .sa { padding: 4px 16px 18px 56px; animation: rise 0.25s var(--ease); }
.step .sa-btn { margin: 0 16px 14px 56px; }
@media (max-width: 599px) { .step .sa { padding-left: 16px; } .step .sa-btn { margin-left: 16px; } }
.pieges { margin-top: 18px; padding: 18px; border-radius: var(--r-m); background: var(--bad-soft); }
.pieges h3 { color: var(--bad); margin-bottom: 8px; font-family: var(--f-ui); font-weight: 700; font-size: 1rem; letter-spacing: 0; }
.verdict-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.timer { font: 800 2.2rem/1 var(--f-display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.timer-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); margin-top: 18px; }
.timer-box.run .timer { color: var(--m-ink); }
.timer-box.run { background: var(--m); color: var(--m-ink); border-color: transparent; }

/* planning */
.days { display: grid; gap: 12px; }
.day { border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); padding: 16px; display: grid; gap: 10px; }
.day.today { border: 2px solid var(--accent); }
.day.past { opacity: 0.72; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.day-head h3 { font-size: 1.1rem; }
.day .task { border: 0; background: var(--surface-2); padding: 10px 12px; }
.day .task .dot { width: 38px; height: 38px; border-radius: 12px; }
@media (min-width: 860px) { .days { grid-template-columns: repeat(2, 1fr); } }

/* compte */
.panel { border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); padding: 20px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 680px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 14px 16px; border-radius: var(--r-m); background: var(--surface-2); }
.stat b { display: block; font: 800 1.6rem/1.1 var(--f-display); letter-spacing: -0.02em; }
.stat span { font-size: 0.82rem; color: var(--ink-2); }
.avatar.has-img, .mini-av.has-img { padding: 0; overflow: hidden; background: var(--surface-2); }
.avatar img, .mini-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-av { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; margin-left: -7px; font: 800 0.72rem/1 var(--f-display); background: var(--finance); color: var(--finance-ink); flex: none; }
.me-chip { text-decoration: none; padding-left: 9px; min-height: 32px; }
.me-chip:hover { color: var(--ink); }
.av-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px; }
.av-opt { aspect-ratio: 1; border-radius: 22px; padding: 0; border: 0; overflow: hidden; cursor: pointer; background: var(--surface-2); outline: 3px solid transparent; outline-offset: 3px; transition: outline-color .2s cubic-bezier(.25,1,.5,1), transform .2s cubic-bezier(.25,1,.5,1); }
.av-opt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-opt:hover { transform: translateY(-2px); }
.av-opt[aria-checked="true"] { outline-color: var(--accent, var(--ink)); }
.av-opt:focus-visible { outline-color: var(--ink-2); }
.av-none span { display: grid; place-items: center; width: 100%; height: 100%; font: 800 1.6rem/1 var(--f-display); background: var(--finance); color: var(--finance-ink); }
@media (prefers-reduced-motion: reduce) { .av-opt { transition: none; } .av-opt:hover { transform: none; } }
.avatar { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font: 800 1.4rem/1 var(--f-display); background: var(--finance); color: var(--finance-ink); }

/* vide, chargement */
.empty-state { text-align: center; padding: 40px 20px; border-radius: var(--r-l); background: var(--surface); border: 1.5px dashed var(--line); display: grid; gap: 12px; justify-items: center; }
.empty-state .art { width: 84px; height: 64px; position: relative; margin-bottom: 4px; }
.empty-state .art i { position: absolute; inset: 0; border-radius: 14px; background: var(--m, var(--accent-soft)); }
.empty-state .art i:first-child { transform: rotate(-8deg) translate(-8px, 2px); opacity: 0.6; }
.skel { border-radius: var(--r-m); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--bottom-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: var(--z-toast); background: var(--btn); color: var(--btn-ink); padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: 0.92rem; box-shadow: var(--shadow); animation: rise 0.22s var(--ease); max-width: calc(100vw - 32px); text-align: center; }

.foot-note { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

.view { animation: view-in 0.22s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .flip { transition: none; }
  .flip.on { transform: none; }
  .flip.on .front { visibility: hidden; }
  .flip:not(.on) .back { visibility: hidden; }
  .face.back { transform: none; }
}

/* ---------- Tuteur IA ---------- */
.ask-row { margin-top: 14px; display: flex; }
.ask-row.center { justify-content: center; margin-top: 16px; }
.ask-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 14px 0 11px; border-radius: 999px; border: 0; background: var(--accent-soft); color: var(--ink); font-weight: 600; font-size: 0.88rem; cursor: pointer; transition: background 0.15s var(--ease), transform 0.15s var(--ease); }
.ask-btn:hover { background: color-mix(in oklch, var(--accent-soft) 78%, var(--accent)); }
.ask-btn:active { transform: scale(0.97); }
.ask-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.step .sa .ask-btn { margin-top: 12px; min-height: 34px; font-size: 0.84rem; }

body:has(dialog[open]) { overflow: hidden; }
.sheet { position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; height: min(88dvh, 760px); max-height: none; padding: 0; border: 0; border-radius: var(--r-l) var(--r-l) 0 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-up 0.26s var(--ease); }
.sheet::backdrop { background: oklch(0.16 0.02 285 / 0.45); animation: fade-in 0.2s var(--ease); }
@media (min-width: 860px) {
  .sheet { inset: 0 0 0 auto; width: 440px; height: 100dvh; border-radius: var(--r-l) 0 0 var(--r-l); }
  .sheet[open] { animation-name: sheet-in; }
}
@keyframes sheet-up { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheet-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } }

.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--surface); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.chat-head h2 { font-size: 1.2rem; }
.chat-reset { margin-left: auto; font-size: 0.84rem; }
.chat-x { margin-left: auto; flex: none; width: 40px; height: 40px; border-radius: 999px; border: 0; background: var(--surface-2); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.chat-reset:not([hidden]) + .chat-x { margin-left: 0; }
.chat-x:hover { background: color-mix(in oklch, var(--surface-2) 80%, var(--ink) 10%); }
.chat-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.chat-ctx { margin: 12px 14px 0; padding: 10px 14px; border-radius: var(--r-m); background: var(--m); color: var(--m-ink); font-size: 0.88rem; line-height: 1.4; }
.chat-ctx b { display: block; font-weight: 700; font-size: 0.78rem; margin-bottom: 2px; }
.chat-ctx p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px; display: flex; flex-direction: column; gap: 16px; }
.msg-me { align-self: flex-end; max-width: 85%; padding: 10px 14px; border-radius: 18px 18px 6px 18px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; animation: rise 0.2s var(--ease); }
.msg-ia .md { font-size: 0.98rem; line-height: 1.6; }
.msg-ia .md > * + * { margin-top: 0.6em; }
.msg-note { margin-top: 6px; font-size: 0.8rem; color: var(--ink-2); }
.msg-err { padding: 10px 14px; border-radius: var(--r-m); background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: 0.9rem; }
.thinking { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); font-size: 0.9rem; min-height: 26px; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--m-strong, var(--accent)); animation: blink 1.1s ease-in-out infinite; }
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
.thinking span { margin-left: 6px; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: none; } 40% { opacity: 1; transform: translateY(-2px); } }
.chat-empty { margin: auto 0 0; display: grid; gap: 12px; }
.chat-empty > p { color: var(--ink-2); max-width: 40ch; }
.chat-sugg { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.chat-sugg button { text-align: left; min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 0.92rem; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.chat-sugg button:hover { border-color: var(--m-strong, var(--accent)); background: color-mix(in oklch, var(--m, var(--accent-soft)) 30%, var(--surface)); }
.chat-guest { margin: auto 0; display: grid; gap: 10px; justify-items: start; padding: 4px 2px; }
.chat-form { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.chat-box { display: flex; gap: 8px; align-items: flex-end; }
.chat-box textarea { flex: 1; min-width: 0; resize: none; min-height: 46px; max-height: 160px; padding: 12px 16px; border-radius: 23px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 1rem; line-height: 1.35; }
.chat-box textarea::placeholder { color: var(--ink-2); opacity: 0.85; }
.chat-box textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.chat-send { flex: none; width: 46px; height: 46px; border-radius: 999px; border: 0; background: var(--btn); color: var(--btn-ink); display: grid; place-items: center; cursor: pointer; transition: transform 0.15s var(--ease), opacity 0.15s; }
.chat-send:active { transform: scale(0.94); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.chat-send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chat-foot { margin-top: 7px; font-size: 0.76rem; color: var(--ink-2); text-align: center; }

.tutor-mats { margin: 18px 0 16px; }
.pill[aria-current] span { background: var(--m); color: var(--m-ink); border-color: transparent; }
a.pill { text-decoration: none; color: inherit; }
a.pill:focus-visible { outline: none; }
a.pill:focus-visible span { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.tutor-box { display: flex; height: max(440px, calc(100dvh - var(--bottom-h) - 290px)); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; background: var(--surface); }
@media (min-width: 860px) { .tutor-box { height: max(480px, calc(100dvh - 300px)); } }

.done-before { margin-top: 18px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); padding: 4px 16px; }
.done-before summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; gap: 10px; font-weight: 700; list-style: none; }
.done-before summary::-webkit-details-marker { display: none; }
.done-before summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg) translateY(-3px); transition: transform 0.2s var(--ease); }
.done-before[open] summary::after { transform: rotate(225deg) translateY(-1px); }
.done-before .today-list { padding: 4px 0 16px; }
.done-before .task { border: 0; background: var(--surface-2); }

@media (prefers-reduced-motion: reduce) {
  .sheet[open], .sheet::backdrop { animation: fade-in 0.15s linear !important; }
  .thinking i { animation: none; opacity: 0.6; }
}
