/* GK — mobile first */
:root {
    --bg: #fff6f4;
    --bg-2: #fdecea;
    --surface: #ffffff;
    --surface-2: #fff0ef;
    --line: #f2dcdc;
    --line-strong: #e6c3c6;
    --ink: #2a1a2c;
    --ink-2: #5d4a5e;
    --muted: #8c7889;
    --accent: #d63f6e;
    --accent-2: #e8668c;
    --accent-soft: #fde3ea;
    --accent-ink: #ffffff;
    --violet: #7656d1;
    --violet-soft: #ece6fb;
    --ok: #23865f;
    --ok-soft: #e1f4ea;
    --ok-line: #9fd6b9;
    --bad: #c63b3b;
    --bad-soft: #fde7e5;
    --bad-line: #f0b0aa;
    --mid: #c27c13;
    --mid-soft: #fdf1dc;
    --mid-line: #efcd8f;
    --casus: #fff7e6;
    --casus-line: #f1d9a6;
    --casus-ink: #6d4a0d;
    --shadow: 0 1px 2px rgb(110 40 60 / .06), 0 8px 24px -12px rgb(110 40 60 / .18);
    --shadow-lg: 0 20px 50px -20px rgb(110 40 60 / .35);
    --radius: 20px;
    --radius-sm: 14px;
    --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --display: "Fraunces", Georgia, serif;
    --hand: "Caveat", "Segoe Script", cursive;
    --nav-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1220;
        --bg-2: #22172a;
        --surface: #261a2e;
        --surface-2: #2f2138;
        --line: #3a2b43;
        --line-strong: #4b3956;
        --ink: #f8ecf2;
        --ink-2: #dcc8d6;
        --muted: #ab95a8;
        --accent: #ff6f98;
        --accent-2: #ff8fb0;
        --accent-soft: #4a2235;
        --accent-ink: #2a0d18;
        --violet: #a991ff;
        --violet-soft: #312650;
        --ok: #5fd39f;
        --ok-soft: #173a2b;
        --ok-line: #2c6e50;
        --bad: #ff8a80;
        --bad-soft: #432023;
        --bad-line: #7a3a3a;
        --mid: #f3b65a;
        --mid-soft: #3d2f17;
        --mid-line: #6f5527;
        --casus: #33291a;
        --casus-line: #5c4a26;
        --casus-ink: #f3dca8;
        --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px -12px rgb(0 0 0 / .6);
        --shadow-lg: 0 20px 50px -20px rgb(0 0 0 / .7);
        color-scheme: dark;
    }
}

.c-rose { --c: var(--accent); --c-soft: var(--accent-soft); }
.c-violet { --c: var(--violet); --c-soft: var(--violet-soft); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100dvh;
    background:
        radial-gradient(120% 60% at 100% 0%, var(--bg-2) 0%, transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--ink);
    font: 400 16px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 10px; }
.ic { width: 20px; height: 20px; flex: none; }

.page {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 12px 16px calc(var(--nav-h) + var(--safe-b) + 28px);
}
.is-bare .page { padding-bottom: calc(24px + var(--safe-b)); }

/* ---------- Barre du haut ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(8px + var(--safe-t)) 12px 8px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.topbar-title { flex: 1; text-align: center; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-btn {
    display: grid; place-items: center;
    width: 44px; height: 44px;
    border: 0; border-radius: 14px;
    background: transparent; color: var(--ink);
}
.topbar-btn:active { background: var(--surface-2); }
.love-btn { color: var(--accent); }
.love-btn .ic { fill: currentColor; }
.logo { display: inline-flex; align-items: baseline; gap: 2px; width: 44px; padding-left: 4px; font: 700 22px/1 var(--display); letter-spacing: -.02em; }
.logo-heart { color: var(--accent); font-size: 15px; animation: beat 2.4s ease-in-out infinite; }

/* ---------- Barre d'onglets ---------- */
.tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: calc(var(--nav-h) + var(--safe-b));
    padding: 6px 8px var(--safe-b);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(16px);
    -webkit-backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--line);
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border-radius: 14px;
    color: var(--muted);
    font-size: 11.5px; font-weight: 600;
    transition: color .2s;
}
.tabbar a .ic, .tab-emoji { width: 24px; height: 24px; font-size: 20px; line-height: 24px; text-align: center; }
.tabbar a.is-active { color: var(--accent); }
.tabbar a.is-active .tab-emoji { transform: scale(1.12); }
.tabbar a:active { background: var(--surface-2); }

/* ---------- Typo ---------- */
.h1 { margin: 6px 0 4px; font: 600 clamp(26px, 7vw, 32px)/1.15 var(--display); letter-spacing: -.02em; text-wrap: balance; }
.h2 { margin: 8px 0 4px; font: 600 22px/1.2 var(--display); letter-spacing: -.01em; }
.muted { color: var(--muted); margin: 0 0 16px; }
.eyebrow { margin: 4px 0 0; color: var(--c, var(--accent)); font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.section-title { margin: 28px 4px 12px; font: 600 20px/1.2 var(--display); }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }
.center { text-align: center; }
.stack { display: grid; gap: 10px; margin-top: 16px; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 50px;
    padding: 12px 20px;
    border: 0; border-radius: 16px;
    font-weight: 600; font-size: 16px;
    text-align: center;
    transition: transform .12s ease, background .2s, opacity .2s;
    user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 17px; }
.btn-grow { flex: 1; }
.btn-primary {
    color: var(--accent-ink);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--accent) 80%, transparent);
}
.c-violet .btn-primary, .c-violet.btn-primary { background: linear-gradient(135deg, var(--violet) 0%, color-mix(in srgb, var(--violet) 70%, var(--accent)) 100%); box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--violet) 80%, transparent); }
@media (prefers-color-scheme: dark) { .c-violet .btn-primary { color: #170f2c; } }
.btn-soft { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.btn-good { background: var(--ok-soft); color: var(--ok); box-shadow: inset 0 0 0 1.5px var(--ok-line); }
.btn-bad { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad-line); }
.link-muted, .link-accent {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 44px; padding: 8px 4px;
    border: 0; background: none;
    color: var(--muted); font-size: 14.5px; font-weight: 500;
}
.link-accent { color: var(--accent); font-weight: 600; }
.link-muted .ic, .link-accent .ic { width: 18px; height: 18px; }
.badge {
    display: inline-grid; place-items: center;
    min-width: 22px; height: 22px; padding: 0 6px;
    border-radius: 99px;
    background: var(--accent); color: var(--accent-ink);
    font-size: 12px; font-weight: 700;
}

/* ---------- Accueil ---------- */
.hero { padding: 8px 4px 0; }
.hero-date { margin: 0; color: var(--muted); font-size: 14px; font-weight: 500; }
.hero-title { margin: 2px 0 16px; font: 600 clamp(28px, 8vw, 36px)/1.1 var(--display); letter-spacing: -.02em; text-wrap: balance; }
.note {
    position: relative;
    margin: 0;
    padding: 20px 22px 16px;
    border-radius: var(--radius);
    background:
        repeating-linear-gradient(transparent 0 31px, color-mix(in srgb, var(--accent) 12%, transparent) 31px 32px),
        linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
    box-shadow: var(--shadow);
    transform: rotate(-.6deg);
}
.note::before {
    content: "";
    position: absolute; top: -9px; left: 50%;
    width: 84px; height: 22px;
    translate: -50% 0;
    rotate: 2deg;
    background: color-mix(in srgb, var(--accent) 28%, transparent);
    border-radius: 3px;
    opacity: .8;
}
.note-text { margin: 0; padding-right: 30px; font: 600 25px/1.28 var(--hand); color: var(--ink); transition: opacity .25s; }
.note-sign { margin-top: 8px; text-align: right; font: 700 22px/1 var(--hand); color: var(--accent); }
.note-refresh {
    position: absolute; top: 10px; right: 10px;
    display: grid; place-items: center;
    width: 40px; height: 40px;
    border: 0; border-radius: 12px;
    background: transparent; color: var(--muted);
}
.note-refresh:active .ic { rotate: 180deg; transition: rotate .3s; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.stat {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
    min-width: 0;
}
.stat strong { font: 700 24px/1.1 var(--display); }
.stat span:last-child { color: var(--muted); font-size: 12px; line-height: 1.25; }
.stat-icon { color: var(--accent); }
.stat-icon.flame { color: #f0782d; }

.resume {
    display: flex; align-items: center; gap: 12px;
    margin-top: 14px; padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: var(--accent-ink);
    box-shadow: 0 14px 30px -16px var(--accent);
}
.resume-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: rgb(255 255 255 / .22); }
.resume-text { flex: 1; display: grid; min-width: 0; }
.resume-text span { opacity: .9; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.course-card {
    margin-bottom: 14px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
    border-top: 4px solid var(--c);
}
.course-head { display: flex; align-items: center; gap: 12px; padding: 16px; }
.course-emoji, .course-hero-emoji {
    display: grid; place-items: center; flex: none;
    width: 48px; height: 48px;
    border-radius: 15px;
    background: var(--c-soft);
    font-size: 24px;
}
.course-info { flex: 1; display: grid; min-width: 0; }
.course-title { font: 600 18px/1.2 var(--display); }
.course-meta { color: var(--muted); font-size: 13.5px; }
.ring {
    --size: 54px;
    display: grid; place-items: center; flex: none;
    width: var(--size); height: var(--size);
    border-radius: 50%;
    background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0);
    font-size: 13px; font-weight: 700;
}
.ring > span { display: grid; place-items: center; width: calc(var(--size) - 10px); height: calc(var(--size) - 10px); border-radius: 50%; background: var(--surface); }
.countdown {
    display: flex; align-items: center; gap: 8px;
    margin: -4px 16px 12px; padding: 8px 12px;
    border-radius: 12px;
    background: var(--c-soft);
    font-size: 14px;
}
.countdown .ic { color: var(--c); width: 18px; height: 18px; }
.course-actions { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.course-actions a {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 52px;
    font-size: 14.5px; font-weight: 600;
    color: var(--ink-2);
}
.course-actions a + a { border-left: 1px solid var(--line); }
.course-actions a.is-main { color: var(--c); }
.course-actions a:active { background: var(--surface-2); }
.course-actions .ic { width: 18px; height: 18px; }

.panel {
    margin-top: 18px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.panel > summary {
    display: flex; align-items: center; gap: 10px;
    min-height: 52px; padding: 0 16px;
    font-weight: 600;
    list-style: none;
    cursor: pointer;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: "›"; margin-left: auto; font-size: 22px; color: var(--muted); transition: rotate .2s; }
.panel[open] > summary::after { rotate: 90deg; }
.panel > :not(summary) { padding: 0 16px 14px; }
.exam-form { display: flex; align-items: flex-end; gap: 10px; }
.exam-form .field { flex: 1; }
.exam-form .btn { min-height: 48px; }
.logout { display: flex; justify-content: center; margin-top: 20px; }

/* ---------- Champs ---------- */
.field { display: grid; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field input, textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1.5px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface);
    font-size: 16px;
}
.field input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.form-error { margin: 0; color: var(--bad); font-weight: 600; font-size: 14.5px; }

/* ---------- Connexion ---------- */
.login { position: relative; display: grid; place-items: center; min-height: calc(100dvh - 40px); }
.login-card {
    position: relative; z-index: 1;
    width: 100%; max-width: 380px;
    padding: 32px 24px 24px;
    border-radius: 28px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-logo { font: 700 48px/1 var(--display); letter-spacing: -.03em; }
.login-logo span { color: var(--accent); font-size: 30px; display: inline-block; animation: beat 2.4s ease-in-out infinite; }
.login-title { margin: 14px 0 4px; font: 600 26px/1.2 var(--display); }
.login-sub { margin: 0 0 22px; color: var(--muted); }
.login-form { display: grid; gap: 14px; text-align: left; }
.login-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.login-hearts span {
    position: absolute;
    color: var(--accent);
    opacity: .16;
    font-size: 40px;
    animation: float 9s ease-in-out infinite;
}
.login-hearts span:nth-child(1) { left: 8%; top: 12%; }
.login-hearts span:nth-child(2) { right: 10%; top: 20%; font-size: 64px; animation-delay: -2s; }
.login-hearts span:nth-child(3) { left: 14%; bottom: 14%; font-size: 56px; animation-delay: -4s; }
.login-hearts span:nth-child(4) { right: 16%; bottom: 8%; animation-delay: -6s; }
.login-hearts span:nth-child(5) { left: 48%; top: 4%; font-size: 28px; animation-delay: -3s; }

/* ---------- Page cours ---------- */
.course-hero {
    margin: 4px 0 0;
    padding: 20px;
    border-radius: var(--radius);
    background: linear-gradient(160deg, var(--surface) 0%, var(--c-soft) 140%);
    box-shadow: var(--shadow);
}
.course-hero-meta { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.course-hero-sub { margin: 8px 0 16px; color: var(--ink-2); font-size: 13.5px; }
.hero-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.progress.is-good > span { background: var(--ok); }
.progress.is-mid > span { background: var(--mid); }
.progress.is-low > span { background: var(--bad); }
.flash {
    margin: 14px 0 0; padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--ok-soft); color: var(--ok);
    font-weight: 600; font-size: 14.5px;
}

.chapters { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.chapter { border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 80px; }
.chapter-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 10px; }
.chapter-head > .ic { color: var(--muted); }
.chapter-num {
    display: grid; place-items: center; flex: none;
    width: 34px; height: 34px;
    border-radius: 11px;
    background: var(--c-soft, var(--accent-soft)); color: var(--c, var(--accent));
    font: 700 16px/1 var(--display);
}
.chapter-info { flex: 1; display: grid; min-width: 0; }
.chapter-title { font-weight: 600; line-height: 1.3; }
.chapter-meta { color: var(--muted); font-size: 13px; }
.chapter-bar { height: 3px; margin: 0 14px; border-radius: 99px; background: var(--line); overflow: hidden; }
.chapter-bar > span { display: block; height: 100%; background: var(--ok); }
.chapter-actions { display: flex; gap: 8px; padding: 10px 14px 4px; overflow-x: auto; scrollbar-width: none; }
.pill {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    min-height: 40px; padding: 0 14px;
    border-radius: 99px;
    background: var(--surface-2);
    font-size: 14px; font-weight: 600; color: var(--ink-2);
}
.pill .ic { width: 17px; height: 17px; }
.pill em { font-style: normal; display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; }
.pill-main { background: var(--c-soft, var(--accent-soft)); color: var(--c, var(--accent)); }
.chapters .link-accent { color: var(--c, var(--accent)); }
.pill.is-off { opacity: .5; }
.more { padding: 0 10px 6px; }
.pdf-link { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; margin-top: 16px; color: var(--muted); font-weight: 600; font-size: 14.5px; }

.history { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.history a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.history-info { flex: 1; display: grid; min-width: 0; }
.history-info strong { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-info span { color: var(--muted); font-size: 13px; }
.score-chip { flex: none; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--muted); }
.score-chip.is-good { background: var(--ok-soft); color: var(--ok); }
.score-chip.is-mid { background: var(--mid-soft); color: var(--mid); }
.score-chip.is-low { background: var(--bad-soft); color: var(--bad); }

/* ---------- Fiche ---------- */
.fiche { padding-top: 4px; }
.prose { font-size: 16.5px; line-height: 1.65; color: var(--ink); }
.prose h2 {
    margin: 30px 0 10px;
    padding-top: 18px;
    border-top: 1px dashed var(--line-strong);
    font: 600 22px/1.25 var(--display);
    color: var(--c, var(--accent));
}
.prose h2:first-child { margin-top: 18px; padding-top: 0; border-top: 0; }
.prose h3 { margin: 22px 0 8px; font-size: 17.5px; font-weight: 700; }
.prose h4 { margin: 16px 0 6px; font-size: 16px; font-weight: 700; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--c, var(--accent)); }
.prose strong { font-weight: 700; color: var(--ink); background: linear-gradient(transparent 62%, color-mix(in srgb, var(--c, var(--accent)) 22%, transparent) 0); }
.prose blockquote {
    margin: 14px 0;
    padding: 12px 14px 12px 44px;
    position: relative;
    border-radius: 14px;
    background: var(--mid-soft);
    color: var(--ink);
    font-size: 15.5px;
}
.prose blockquote::before { content: "⚠️"; position: absolute; left: 14px; top: 11px; }
.prose code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); font-size: .9em; }
.prose hr { border: 0; border-top: 1px dashed var(--line-strong); margin: 20px 0; }
.fiche-cta {
    display: grid; gap: 10px; justify-items: center;
    margin-top: 28px; padding: 18px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.fiche-cta-title { margin: 0 0 4px; font: 600 19px/1.2 var(--display); }
.fiche-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.fiche-nav a {
    display: flex; align-items: center; gap: 6px;
    min-height: 56px; padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 13.5px; font-weight: 600; line-height: 1.25;
}
.fiche-nav a span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fiche-nav-next { grid-column: 2; text-align: right; justify-content: flex-end; }

/* ---------- Cartes mémoire ---------- */
.scope { display: grid; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex; align-items: center;
    min-height: 40px; padding: 0 14px;
    border-radius: 99px;
    background: var(--surface);
    box-shadow: inset 0 0 0 1.5px var(--line-strong);
    font-size: 14.5px; font-weight: 600; color: var(--ink-2);
}
.chip.is-on { background: var(--ink); color: var(--bg); box-shadow: none; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.segmented a { display: grid; place-items: center; min-height: 40px; border-radius: 11px; font-weight: 600; font-size: 14.5px; color: var(--muted); }
.segmented a.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.deck-label { margin: 14px 4px 10px; color: var(--muted); font-size: 14px; font-weight: 600; }
.deck-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 14px; font-weight: 700; color: var(--muted); }
.deck-top .progress { flex: 1; }
.flashcard {
    display: block; width: 100%;
    height: min(62dvh, 440px);
    min-height: 300px;
    perspective: 1400px;
    cursor: pointer;
    outline: none;
}
.flashcard-inner {
    position: relative; width: 100%; height: 100%;
    transform-style: preserve-3d;
    transition: transform .55s cubic-bezier(.3, .9, .3, 1.05);
}
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard.is-leaving .flashcard-inner { animation: leave .3s ease-in forwards; }
.flashcard.is-entering .flashcard-inner { animation: enter .35s ease-out; }
.flashcard-face {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 28px 22px;
    border-radius: 26px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    text-align: center;
    overflow-y: auto;
}
.flashcard-front { background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%); }
.flashcard-back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--surface) 0%, var(--accent-soft) 160%); }
.flashcard-chapter { position: absolute; top: 18px; left: 20px; right: 20px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flashcard-text { margin: 0; font: 600 clamp(20px, 5.6vw, 25px)/1.35 var(--display); text-wrap: balance; }
.flashcard-back .flashcard-text { font: 500 18.5px/1.5 var(--font); }
.flashcard-hint { position: absolute; bottom: 18px; color: var(--muted); font-size: 13px; }
.deck-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.deck-actions .btn { min-height: 58px; font-size: 16.5px; }
.deck-done { padding: 24px 8px; text-align: center; }
.deck-done-score { margin: 4px 0 12px; color: var(--muted); }
.love-line { margin: 8px auto 4px; max-width: 30ch; font: 600 24px/1.25 var(--hand); color: var(--accent); text-align: center; }

/* ---------- Formulaire QCM ---------- */
.quiz-form { display: grid; gap: 14px; margin-top: 8px; }
.group { margin: 0; padding: 16px; border: 0; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); min-width: 0; }
.group legend { float: left; width: 100%; margin-bottom: 12px; font-weight: 700; }
.group legend + * { clear: both; }
.panel .group { padding: 0; box-shadow: none; margin-bottom: 16px; }
.chip-radio { position: relative; }
.chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 58px; min-height: 44px; padding: 0 14px;
    border-radius: 13px;
    background: var(--surface-2);
    font-weight: 700; font-size: 15px; color: var(--ink-2);
    transition: background .15s, color .15s;
}
.chip-radio input:checked + span { background: var(--accent); color: var(--accent-ink); }
.chip-radio input:focus-visible + span { outline: 3px solid var(--accent-soft); }
.option { display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin-top: 8px; border-radius: 14px; box-shadow: inset 0 0 0 1.5px var(--line); cursor: pointer; }
.option:has(input:checked) { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.option input { margin-top: 4px; accent-color: var(--accent); width: 20px; height: 20px; flex: none; }
.option-body { display: grid; }
.option-body span { color: var(--muted); font-size: 14px; }
.check-all { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check-all input, .check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.checklist { display: grid; gap: 2px; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 0; border-top: 1px solid var(--line); cursor: pointer; }
.check-body { flex: 1; display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; line-height: 1.3; }
.check-body em { flex: none; font-style: normal; color: var(--muted); font-size: 13px; }
.sticky-cta {
    position: sticky;
    bottom: calc(var(--nav-h) + var(--safe-b) + 10px);
    z-index: 5;
    padding-top: 6px;
}

/* ---------- Jeu QCM ---------- */
.quiz { margin: -12px -16px 0; }
.quiz-top {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 10px;
    padding: calc(8px + var(--safe-t)) 12px 10px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.quiz-progress { flex: 1; display: grid; gap: 6px; }
.quiz-count { font-size: 13px; font-weight: 700; color: var(--muted); }
.quiz-mode { font-size: 12px; font-weight: 700; color: var(--c); padding: 4px 10px; border-radius: 99px; background: var(--c-soft); }
.timer { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.timer .ic { width: 16px; height: 16px; }
.timer.is-urgent { background: var(--bad-soft); color: var(--bad); animation: beat 1s ease-in-out infinite; }
.quiz-body { padding: 6px 16px 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag { padding: 4px 10px; border-radius: 99px; background: var(--c-soft); color: var(--c); font-size: 12.5px; font-weight: 700; }
.tag-soft { background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.casus {
    margin: 0 0 14px; padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--casus);
    box-shadow: inset 0 0 0 1px var(--casus-line);
    color: var(--casus-ink);
    font-size: 15.5px;
}
.casus p { margin: 0; }
.casus-label { margin-bottom: 6px !important; font-weight: 700; font-size: 13.5px; }
.statement { margin: 0 0 6px; font: 600 clamp(20px, 5.4vw, 23px)/1.35 var(--display); letter-spacing: -.005em; text-wrap: pretty; }
.choices { display: grid; gap: 10px; margin: 16px 0; }
.choice {
    position: relative;
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px;
    border-radius: 16px;
    background: var(--surface);
    box-shadow: inset 0 0 0 1.5px var(--line), var(--shadow);
    cursor: pointer;
    transition: box-shadow .15s, background .15s, transform .1s;
}
label.choice:active { transform: scale(.985); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-mark {
    display: grid; place-items: center; flex: none;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--surface-2);
    font-weight: 700; font-size: 14px; color: var(--muted);
    transition: background .15s, color .15s;
}
.choice-mark.is-box { border-radius: 9px; }
.choice-label { flex: 1; padding-top: 4px; font-size: 16px; line-height: 1.45; }
.choice:has(input:checked) { background: var(--c-soft); box-shadow: inset 0 0 0 2px var(--c), var(--shadow); }
.choice:has(input:checked) .choice-mark { background: var(--c); color: #fff; }
.choice:has(input:focus-visible) { outline: 3px solid var(--accent-soft); }
.choice.is-correct { background: var(--ok-soft); box-shadow: inset 0 0 0 2px var(--ok-line); cursor: default; }
.choice.is-correct .choice-mark { background: var(--ok); color: #fff; }
.choice.is-wrong { background: var(--bad-soft); box-shadow: inset 0 0 0 2px var(--bad-line); cursor: default; }
.choice.is-wrong .choice-mark { background: var(--bad); color: #fff; }
.choice.is-neutral { cursor: default; opacity: .85; }
.choice-feedback { display: block; margin-top: 6px; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.picked { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 99px; background: var(--surface); color: var(--muted); font-size: 11.5px; font-weight: 700; vertical-align: 2px; }
.quiz-bottom {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; gap: 10px;
    margin: 0 -16px; padding: 12px 16px calc(12px + var(--safe-b));
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.verdict {
    display: grid; gap: 2px;
    margin-top: 14px; padding: 14px 16px;
    border-radius: var(--radius-sm);
    animation: pop .35s cubic-bezier(.3, 1.4, .5, 1);
}
.verdict strong { font: 700 20px/1.2 var(--display); }
.verdict span { font: 600 21px/1.25 var(--hand); }
.verdict em { font-style: normal; font-weight: 700; font-size: 14px; }
.verdict.is-ok { background: var(--ok-soft); color: var(--ok); }
.verdict.is-partial { background: var(--mid-soft); color: var(--mid); }
.verdict.is-bad { background: var(--bad-soft); color: var(--bad); }
.explain { margin-top: 6px; padding: 16px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.explain-title { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 16px; font-weight: 700; color: var(--c); }
.explain .prose { font-size: 15.5px; }
.explain .prose p:last-child { margin-bottom: 0; }
.source { margin: 12px 0 0; padding-top: 10px; border-top: 1px dashed var(--line-strong); color: var(--muted); font-size: 13.5px; font-style: italic; }
.source a { color: var(--c); font-style: normal; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.tutor { display: grid; gap: 10px; margin-top: 14px; }
.tutor-thread { display: grid; gap: 10px; }
.bubble { padding: 14px 16px; border-radius: 18px; font-size: 15.5px; animation: pop .3s ease-out; }
.bubble .prose { font-size: 15.5px; }
.bubble .prose p:last-child { margin-bottom: 0; }
.bubble-ai { background: var(--c-soft); border-top-left-radius: 6px; }
.bubble-me { justify-self: end; max-width: 85%; background: var(--surface); box-shadow: var(--shadow); border-top-right-radius: 6px; }
.bubble-error { background: var(--bad-soft); color: var(--bad); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); animation: typing 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.tutor-follow { display: grid; gap: 8px; }
.report { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.report summary { display: flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; list-style: none; }
.report summary::-webkit-details-marker { display: none; }
.report summary .ic { width: 16px; height: 16px; }
.report form { display: grid; gap: 8px; justify-items: start; padding-bottom: 6px; }

/* ---------- Résultats ---------- */
.result { padding: 8px 0 4px; text-align: center; }
.result-ring {
    --size: 168px;
    display: grid; place-items: center;
    width: var(--size); height: var(--size);
    margin: 16px auto 10px;
    border-radius: 50%;
    background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0);
    animation: pop .6s cubic-bezier(.3, 1.4, .5, 1);
}
.result-ring > span { display: grid; place-items: center; width: calc(var(--size) - 22px); height: calc(var(--size) - 22px); border-radius: 50%; background: var(--bg); font: 700 42px/1 var(--display); }
.result-score { margin: 0; color: var(--muted); font-weight: 600; }
.card { padding: 16px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.notions { display: grid; gap: 14px; }
.notion-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 14.5px; }
.notion-head span:last-child { color: var(--muted); font-weight: 600; flex: none; }
.review { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.review-item a { display: block; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: inset 3px 0 0 var(--bad), var(--shadow); }
.review-q { margin: 0 0 6px; font-weight: 600; line-height: 1.4; }
.review-a { display: flex; gap: 6px; margin: 0; color: var(--ok); font-size: 14.5px; }
.review-a .ic { width: 18px; height: 18px; margin-top: 2px; }
.review-more { display: inline-flex; align-items: center; gap: 2px; margin-top: 8px; color: var(--c); font-size: 13.5px; font-weight: 700; }
.review-more .ic { width: 16px; height: 16px; }

/* ---------- Vide, chargement, toast ---------- */
.empty { display: grid; justify-items: center; gap: 6px; padding: 40px 12px; text-align: center; }
.empty-emoji { font-size: 52px; line-height: 1.1; animation: float 4s ease-in-out infinite; }
.loader {
    position: fixed; inset: 0; z-index: 100;
    display: grid; place-items: center;
    padding: 24px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.loader[hidden], .love-toast[hidden] { display: none; }
.loader-box { max-width: 320px; text-align: center; }
.loader-heart { color: var(--accent); font-size: 64px; line-height: 1; animation: beat 1s ease-in-out infinite; }
.loader-title { margin: 14px 0 6px; font-weight: 700; font-size: 17px; }
.loader-note { margin: 0; font: 600 23px/1.3 var(--hand); color: var(--accent); }
.love-toast {
    position: fixed; left: 50%; z-index: 90;
    bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
    width: min(92vw, 420px);
    translate: -50% 0;
    padding: 14px 18px;
    border-radius: 18px;
    background: var(--ink); color: var(--bg);
    box-shadow: var(--shadow-lg);
    font: 600 22px/1.3 var(--hand);
    text-align: center;
    animation: toast 3.6s ease forwards;
}
.burst { position: fixed; z-index: 95; pointer-events: none; color: var(--accent); font-size: 22px; animation: burst 1.4s ease-out forwards; }

/* ---------- Animations ---------- */
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(1); } 45% { transform: scale(1.1); } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-12px) rotate(6deg); } }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
@keyframes toast { 0% { opacity: 0; transform: translateY(16px); } 10%, 85% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(8px); } }
@keyframes burst { 0% { opacity: 0; transform: translate(0, 0) scale(.4); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(var(--r)); } }
@keyframes leave { to { transform: translateX(var(--leave, 120%)) rotate(var(--leave-r, 12deg)); opacity: 0; } }
@keyframes enter { from { transform: translateY(18px) scale(.96); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Plus grand écran ---------- */
@media (min-width: 560px) {
    .hero-actions { grid-template-columns: 1fr 1fr; }
    .page { padding-top: 20px; }
}
@media (min-width: 900px) {
    .tabbar { left: 50%; right: auto; bottom: 16px; width: 480px; translate: -50% 0; border: 1px solid var(--line); border-radius: 22px; height: var(--nav-h); padding-bottom: 6px; box-shadow: var(--shadow-lg); }
}
