:root {
  --blue: #1e40af; --blue-2: #2563eb; --blue-soft: #eff4ff; --red: #b91c1c; --red-soft: #fef2f2;
  --ink: #1e293b; --muted: #64748b; --line: #e2e8f0; --bg: #f8fafc; --card: #fff;
  --good: #15803d; --good-soft: #dcfce7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --radius: 14px; --nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-padding-top: 76px; }
body { margin: 0; font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
main { max-width: 860px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
h1 { font-size: 26px; margin: 8px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 26px 0 10px; }
a { color: var(--blue-2); }
.muted { color: var(--muted); }
.err { color: var(--bad); background: var(--bad-soft); padding: 10px 14px; border-radius: 10px; }
button { font: inherit; cursor: pointer; }

/* ---------- Header & navigation ---------- */
header.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--blue); color: #fff; padding-top: calc(10px + env(safe-area-inset-top)); }
.brand { color: #fff; text-decoration: none; font-size: 19px; }
.gear { margin-left: auto; text-decoration: none; font-size: 20px; }
nav.tabs { display: none; gap: 4px; margin-left: 16px; }
nav.tabs a, nav.bottom a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 6px; border-radius: 10px; }
nav.tabs a { padding: 6px 12px; color: #dbe5ff; }
nav.tabs a.on { background: rgba(255, 255, 255, .18); color: #fff; }
nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--line); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
nav.bottom a { flex-direction: column; justify-content: center; gap: 0; flex: 1; font-size: 12px; color: var(--muted); }
nav.bottom a .ic { font-size: 22px; line-height: 1.2; }
nav.bottom a.on { color: var(--blue); font-weight: 600; }
@media (min-width: 900px) {
  nav.tabs { display: flex; }
  nav.bottom { display: none; }
  main { padding-bottom: 48px; }
}

/* ---------- Home ---------- */
.hello { margin-top: 4px; }
.big-cta { display: flex; gap: 16px; align-items: center; padding: 20px; border-radius: var(--radius); text-decoration: none;
  background: linear-gradient(135deg, var(--blue), #4f46e5); color: #fff; box-shadow: 0 8px 24px rgba(30, 64, 175, .25); }
.big-cta .ic { font-size: 40px; }
.big-cta b { font-size: 21px; display: block; }
.big-cta small { opacity: .85; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; gap: 2px; }
.tile .ic { font-size: 28px; }
.tile small { color: var(--muted); }
.row { display: flex; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: 8px 0;
  text-decoration: none; color: var(--ink); }
.row .d { color: var(--muted); min-width: 92px; }

/* ---------- Course (same look as the PDF) ---------- */
.toc { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; }
.toc summary { font-weight: 600; cursor: pointer; }
.toc ol { list-style: none; padding: 0; margin: 8px 0 0; }
.toc li { padding: 5px 0; }
.toc li.l2 { font-weight: 700; margin-top: 8px; }
.toc li.l3 { padding-left: 12px; }
.toc li.l4 { padding-left: 26px; font-size: 15px; }
.toc a { text-decoration: none; color: var(--ink); }
.course h1 { color: var(--ink); font-size: 24px; border-bottom: 3px solid var(--blue); padding-bottom: 8px; text-transform: uppercase; }
.course h2 { background: var(--blue); color: #fff; padding: 12px 16px; border-radius: 8px; font-size: 19px; text-transform: uppercase; margin-top: 32px; }
.course h3 { color: var(--blue); border-bottom: 2px solid #bfdbfe; padding-bottom: 6px; font-size: 19px; margin-top: 28px; }
.course h4, .course h5 { font-size: 17px; margin: 22px 0 8px; }
.course h5 { font-size: 16px; }
.course h4:has(+ h4), .course h4:has(+ h3), .course h4:has(+ h2), .course h5:has(+ h5), .course h5:has(+ h4) { color: var(--muted); font-weight: 600; }
.course p { margin: 8px 0; }
.course table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
.course th, .course td { border: 1px solid #cbd5e1; padding: 8px 10px; vertical-align: top; text-align: left; min-width: 130px; }
.course th { background: var(--blue-soft); color: var(--blue); }
.course img { max-width: 100%; height: auto; border-radius: 8px; }
.course .bilan, .course .mots, .course .question, .course .synthese, .course .correction, .course .figure, .course .info {
  margin: 14px 0; padding: 12px 16px; border-radius: 8px; }
.course .bilan { background: var(--red-soft); border-left: 5px solid var(--red); }
.course .block-title { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--red); margin-bottom: 4px; }
.course .mots { background: #fff; border: 1px solid var(--line); }
.course .mots .block-title { color: var(--ink); text-decoration: underline; letter-spacing: 0; text-transform: none; font-size: 16px; }
.course .mots strong { color: var(--blue-2); }
.course .mots ul { margin: 4px 0; padding-left: 20px; }
.course .mots li { margin: 6px 0; }
.course .question { border-left: 4px solid #94a3b8; background: transparent; font-style: italic; color: #334155; }
.course .question .block-title { display: none; }
.course .synthese, .course .correction { background: #f8fafc; border: 1px solid #cbd5e1; }
.course .info strong:first-child { color: var(--blue-2); }
.course .figure { border: 1px solid var(--line); background: #fff; text-align: center; }
.course .figure p:last-child { font-size: 14px; color: var(--muted); font-style: italic; }
.course .flash, .flash { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px #facc15; background-color: #fef9c3; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Bristol cards ---------- */
.fiche { background: var(--card); border: 1px solid #cbd5e1; border-top: 6px solid var(--c); border-radius: 10px; margin: 18px 0; overflow: hidden;
  background-image: repeating-linear-gradient(transparent 0 31px, #eef2f7 31px 32px); background-position: 0 10px; }
.fiche header { padding: 14px 16px 8px; display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); background: var(--card); }
.fiche h2 { margin: 0; font-size: 18px; }
.fref { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.points { margin: 0; padding: 10px 16px 10px 34px; }
.points li { margin: 6px 0; }
.points .lab { color: var(--c); }
.points ul { padding-left: 18px; }
.qr { border-top: 1px dashed #94a3b8; margin: 0 12px 12px; padding: 4px 8px 8px; background: #f8fafcee; border-radius: 0 0 8px 8px; }
.qr h3 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; margin: 10px 0 6px; }
.qr ol { padding-left: 22px; margin: 0 0 10px; }
.qr li { margin: 6px 0; }
.reveal { background: none; border: 0; padding: 2px 0; text-align: left; color: var(--ink); display: inline; font-size: inherit; line-height: inherit; }
.reveal::after { content: " 👀"; opacity: .6; }
.reveal.open::after { content: ""; }
.ans { background: var(--good-soft); border-radius: 8px; padding: 8px 12px; margin: 4px 0 8px; }
.ans p { margin: 0 0 6px; }
.ref { display: inline-block; margin: 3px 4px 3px 0; padding: 4px 10px; font-size: 13px; border-radius: 99px; border: 1px solid #bfdbfe;
  background: var(--blue-soft); color: var(--blue); text-align: left; }

/* ---------- Buttons & chips ---------- */
.btn { display: inline-block; background: var(--blue); color: #fff; border: 0; border-radius: 12px; padding: 12px 18px; text-decoration: none;
  font-weight: 600; min-height: 48px; }
.btn.big { display: block; width: 100%; font-size: 19px; padding: 16px; margin-top: 20px; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); margin-top: 24px; }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--blue-2); padding: 10px; display: block; margin: 8px auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.col { flex-direction: column; }
.chip { border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px; text-align: left; min-height: 48px; color: var(--ink); }
.chip b { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--c, var(--blue)); color: #fff; font-size: 14px; margin-right: 6px; }
.chip.on { border-color: var(--c, var(--blue)); background: var(--blue-soft); font-weight: 600; }
.chip:not(.on) b { background: #cbd5e1; }
.row-btns { display: flex; gap: 8px; }
.row-btns .link { margin: 0; }

/* ---------- Quiz ---------- */
.loading { text-align: center; padding: 60px 0; }
.spinner { width: 54px; height: 54px; margin: 0 auto 18px; border: 5px solid #dbeafe; border-top-color: var(--blue); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.qhead { display: flex; justify-content: space-between; color: var(--muted); font-weight: 600; }
.progress { height: 8px; background: #e2e8f0; border-radius: 99px; margin: 8px 0 16px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--blue-2); transition: width .3s; }
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 2px 10px rgba(15, 23, 42, .05); }
.qtype { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--blue-2); }
.qtext { font-size: 20px; font-weight: 600; margin: 6px 0 16px; }
.answers { display: grid; gap: 10px; }
.answers.two { grid-template-columns: 1fr 1fr; }
.ans-btn { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 14px 16px; text-align: left; min-height: 56px; color: var(--ink); font-size: 17px; }
.answers.two .ans-btn { text-align: center; font-weight: 600; }
.ans-btn:not(:disabled):active { background: var(--blue-soft); }
.ans-btn.good, .slot.good { border-color: var(--good); background: var(--good-soft); }
.ans-btn.bad, .slot.bad { border-color: var(--bad); background: var(--bad-soft); }
.ans-btn:disabled:not(.good):not(.bad) { opacity: .55; }
.trous { font-size: 19px; line-height: 2.3; }
.slot { min-width: 90px; border: 0; border-bottom: 3px solid var(--blue-2); background: var(--blue-soft); border-radius: 6px 6px 0 0; padding: 0 10px;
  font-size: 18px; color: var(--ink); vertical-align: baseline; }
.slot.filled { font-weight: 600; }
.slot s { color: var(--bad); }
.bank { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.word { border: 2px solid #c7d2fe; background: #eef2ff; border-radius: 99px; padding: 8px 16px; font-size: 17px; min-height: 44px; color: var(--ink); }
.word:disabled { opacity: .3; }
textarea { width: 100%; font: inherit; padding: 12px; border: 2px solid var(--line); border-radius: 12px; margin-bottom: 12px; resize: vertical; }
.fb { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: #f8fafc; border: 1px solid var(--line); }
.fb.ok { background: var(--good-soft); border-color: #86efac; }
.fb.ko { background: #fff7ed; border-color: #fdba74; }
.fb p { margin: 6px 0; }
.verdict { font-size: 20px; font-weight: 700; }
.fb blockquote { margin: 10px 0; padding: 8px 12px; border-left: 4px solid #94a3b8; background: rgba(255, 255, 255, .7); font-style: italic; border-radius: 0 8px 8px 0; }
.refs { margin-top: 6px; }
.self { font-weight: 600; margin-top: 14px; }
.result { text-align: center; padding: 30px 0 10px; }
.score { font-size: 64px; font-weight: 800; color: var(--blue); }
.msg { font-size: 22px; margin: 0; }
.miss { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--bad); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.miss p { margin: 4px 0; }

/* ---------- Course excerpt bottom sheet ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 78vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .2); transform: translateY(100%); transition: transform .2s ease-out;
  max-width: 860px; margin: 0 auto; padding-bottom: env(safe-area-inset-bottom); }
.sheet.up { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; color: var(--blue); }
.sheet-head button { margin-left: auto; border: 0; background: #f1f5f9; border-radius: 50%; width: 36px; height: 36px; flex: none; }
.sheet-body { overflow-y: auto; padding: 4px 16px 12px; }
.sheet-open { display: block; text-align: center; padding: 14px; border-top: 1px solid var(--line); font-weight: 600; text-decoration: none; }

/* ---------- Pronote ---------- */
.seance { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 12px 0; }
.seance header { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.seance .d { color: var(--muted); min-width: 140px; }
.tag { font-size: 12px; border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; color: var(--muted); }
.pc { overflow-wrap: anywhere; font-size: 15px; }
.pc * { font-family: inherit !important; max-width: 100%; }
.seance summary { color: var(--muted); cursor: pointer; padding: 6px 0; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 14px; background: #fff; }
.res { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; }
.res summary { font-weight: 600; cursor: pointer; }
.res ul { list-style: none; padding: 0; }
.res li { padding: 6px 0; border-top: 1px solid var(--line); }

/* ---------- Admin & login ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.jr { padding: 10px 0; border-bottom: 1px solid var(--line); }
.log { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 10px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; }
.p-login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--blue), #4f46e5); }
.login { background: #fff; padding: 32px 26px; border-radius: 20px; width: min(92vw, 360px); text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.login .logo { font-size: 54px; }
.login h1 { margin: 4px 0 18px; }
.login input { width: 100%; font: inherit; padding: 14px; border: 2px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.login button { width: 100%; background: var(--blue); color: #fff; border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 18px; }
