:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --text: #161a2d;
  --muted: #646b85;
  --line: #e2e5ef;
  --primary: #2847d4;
  --primary-ink: #ffffff;
  --primary-soft: #e7ecff;
  --red: #e1000f;
  --ok: #16915a;
  --ok-soft: #e3f6ec;
  --ko: #d33a3a;
  --ko-soft: #fdeaea;
  --mid: #d98a00;
  --mid-soft: #fff4dc;
  --shadow: 0 1px 2px rgba(20, 25, 60, 0.05), 0 6px 20px rgba(20, 25, 60, 0.06);
  --radius: 18px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1220;
    --surface: #181c2e;
    --surface-2: #22273d;
    --text: #eef0f8;
    --muted: #9aa1bd;
    --line: #2b3049;
    --primary: #6f88ff;
    --primary-ink: #0f1220;
    --primary-soft: #232c55;
    --ok: #3ccf8e;
    --ok-soft: #133426;
    --ko: #ff6b6b;
    --ko-soft: #3a1c22;
    --mid: #ffb84d;
    --mid-soft: #3a2d14;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1220; --surface: #181c2e; --surface-2: #22273d; --text: #eef0f8; --muted: #9aa1bd; --line: #2b3049;
  --primary: #6f88ff; --primary-ink: #0f1220; --primary-soft: #232c55; --ok: #3ccf8e; --ok-soft: #133426;
  --ko: #ff6b6b; --ko-soft: #3a1c22; --mid: #ffb84d; --mid-soft: #3a2d14; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 20px; }
h3 { font-size: 16px; margin-bottom: 10px; }
p { margin: 0; }
kbd { font: 12px ui-monospace, monospace; opacity: 0.6; margin-left: 6px; }

.tricolore { position: fixed; inset: 0 0 auto 0; height: 4px; display: flex; z-index: 20; }
.tricolore span { flex: 1; }
.tricolore span:nth-child(1) { background: #2847d4; }
.tricolore span:nth-child(2) { background: #ffffff; }
.tricolore span:nth-child(3) { background: var(--red); }

.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ——— Navigation ——— */
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav[hidden] { display: none; }
.nav a {
  flex: 1; max-width: 150px; height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.nav a span { font-size: 21px; filter: grayscale(1); opacity: 0.65; transition: 0.2s; }
.nav a.active { color: var(--primary); }
.nav a.active span { filter: none; opacity: 1; transform: translateY(-1px); }

/* ——— Structure ——— */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 6px; }
.eyebrow { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.section-title { font-size: 17px; margin: 8px 2px -4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.foot { text-align: center; margin-top: 6px; }

.icon-btn {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px;
  background: var(--surface); border: 1px solid var(--line); cursor: pointer;
}

/* ——— Accueil ——— */
.hero { display: flex; align-items: center; gap: 16px; }
.hero-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hero-status { font-weight: 650; font-size: 16.5px; line-height: 1.3; }
.ring { width: 118px; height: 118px; flex: none; }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 11; }
.ring-fg { fill: none; stroke: var(--primary); stroke-width: 11; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 64px 64px; transition: stroke-dashoffset 0.8s ease; }
.ring.ok .ring-fg { stroke: var(--ok); }
.ring.mid .ring-fg { stroke: var(--mid); }
.ring-mark { stroke: var(--text); stroke-width: 2.5; opacity: 0.5; }
.ring-val { font-size: 34px; font-weight: 800; text-anchor: middle; fill: var(--text); }
.ring-max { font-size: 12px; text-anchor: middle; fill: var(--muted); }

.stat { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; }
.stat-val { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat-val span { font-size: 15px; font-weight: 600; color: var(--muted); }

.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.6s ease; }
.bar.ok span { background: var(--ok); }
.bar.mid span { background: var(--mid); }

.cta {
  display: flex; align-items: center; gap: 14px;
  background: var(--primary); color: var(--primary-ink);
  border-radius: var(--radius); padding: 18px; box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 35%, transparent);
  transition: transform 0.15s;
}
.cta:active, .tile:active, .theme-row:active, .btn:active, .opt:active { transform: scale(0.98); }
.cta b { font-size: 18px; display: block; }
.cta small { opacity: 0.85; font-size: 13.5px; }
.cta-ico { width: 46px; height: 46px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, 0.2); display: grid; place-items: center; font-size: 18px; }
.cta.alt { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.cta.alt .cta-ico { background: var(--primary-soft); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 3px; transition: transform 0.15s; }
.tile b { font-size: 15.5px; }
.tile small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.tile-ico { font-size: 24px; margin-bottom: 4px; }
.tile-ai { background: linear-gradient(135deg, var(--primary-soft), var(--surface)); }

.theme-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); transition: transform 0.15s; }
.theme-ico { font-size: 24px; width: 42px; height: 42px; display: grid; place-items: center; background: var(--surface-2); border-radius: 12px; flex: none; }
.theme-body { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.theme-body b { font-size: 15px; }
.theme-body small { color: var(--muted); font-size: 12.5px; }
.chev { color: var(--muted); font-size: 22px; }

/* ——— Entraînement ——— */
.train-top { display: flex; align-items: center; gap: 12px; }
.train-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.train-title b { font-size: 16px; }
.train-title small { color: var(--muted); font-size: 12.5px; }
.combo { font-weight: 750; font-size: 15px; padding: 6px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); filter: grayscale(1); opacity: 0.7; transition: 0.3s; }
.combo.hot { filter: none; opacity: 1; background: var(--mid-soft); border-color: transparent; }

.qcard { display: flex; flex-direction: column; gap: 12px; animation: rise 0.28s ease; }
.qcard.is-sit { border-left: 4px solid var(--mid); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.qmeta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.chip-new { background: var(--primary-soft); color: var(--primary); }
.chip-ai { background: linear-gradient(90deg, #f3e8ff, #e7ecff); color: #6a3fd1; }
.fmt { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary); }
.prompt { font-size: 21px; line-height: 1.32; font-weight: 700; }
.statement { font-size: 17px; font-weight: 600; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.speak { align-self: flex-start; border: 0; background: transparent; color: var(--muted); font-size: 13.5px; padding: 0; cursor: pointer; }

.options { display: flex; flex-direction: column; gap: 10px; }
.options.vf { flex-direction: row; }
.options.vf .opt { justify-content: center; font-weight: 700; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 16px; line-height: 1.3; transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
@media (hover: hover) { .opt:not(:disabled):hover { border-color: var(--primary); } }
.opt-l { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; font-weight: 750; font-size: 13px; background: var(--surface-2); color: var(--muted); }
.opt:disabled { cursor: default; }
.opt.good { border-color: var(--ok); background: var(--ok-soft); }
.opt.good .opt-l { background: var(--ok); color: #fff; }
.opt.bad { border-color: var(--ko); background: var(--ko-soft); animation: shake 0.35s; }
.opt.bad .opt-l { background: var(--ko); color: #fff; }
.opt.chosen { border-color: var(--primary); background: var(--primary-soft); }
.opt.chosen .opt-l { background: var(--primary); color: var(--primary-ink); }
.opt:disabled:not(.good):not(.bad) { opacity: 0.55; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.typed { display: flex; gap: 10px; }
.typed input, .search, .form input, .form select, .composer textarea {
  flex: 1; min-width: 0; padding: 13px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); font-size: 17px; outline: none;
}
.typed input:focus, .search:focus, .form input:focus, .composer textarea:focus { border-color: var(--primary); }
.typed input.good { border-color: var(--ok); background: var(--ok-soft); }
.typed input.bad { border-color: var(--ko); background: var(--ko-soft); }

.fb { border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; animation: rise 0.25s ease; }
.fb-ok { background: var(--ok-soft); }
.fb-ko { background: var(--ko-soft); }
.fb-neutral { background: var(--surface-2); }
.fb-title { font-weight: 800; font-size: 17px; }
.fb-ok .fb-title { color: var(--ok); }
.fb-ko .fb-title { color: var(--ko); }
.fb-expl { font-size: 14.5px; color: var(--text); opacity: 0.9; }
#feedback:not(:empty) { display: flex; flex-direction: column; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 650; font-size: 15.5px; cursor: pointer; transition: transform 0.1s;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.good { background: var(--ok); color: #fff; border-color: transparent; }
.btn.bad { color: var(--ko); border-color: color-mix(in srgb, var(--ko) 40%, transparent); }
.row2 .btn.bad { background: var(--ko-soft); }
.btn.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.btn.block { width: 100%; }
.btn.small { padding: 10px; font-size: 14px; }
.btn.file { cursor: pointer; }

.pause { display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 28px 18px; }
.pause .row2 { width: 100%; margin-top: 8px; }
.big-emoji { font-size: 48px; line-height: 1; }

/* ——— Examen ——— */
.facts { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.timer { font: 700 16px ui-monospace, SFMono-Regular, monospace; padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.timer.urgent { color: var(--ko); border-color: var(--ko); }
.dots { display: grid; grid-template-columns: repeat(20, 1fr); gap: 4px; }
.dot { height: 8px; border-radius: 99px; border: 0; padding: 0; background: var(--surface-2); cursor: pointer; }
.dot.done { background: color-mix(in srgb, var(--primary) 55%, var(--surface-2)); }
.dot.cur { background: var(--primary); transform: scaleY(1.4); }
.exam-row { display: flex; justify-content: space-between; align-items: center; background: var(--surface); padding: 12px 14px; border-radius: 14px; box-shadow: var(--shadow); font-size: 14.5px; }
.t-ok { color: var(--ok); }
.t-ko { color: var(--ko); }
.result { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 26px 18px; }
.result.passed { background: linear-gradient(180deg, var(--ok-soft), var(--surface)); }
.score { font-size: 64px; font-weight: 850; line-height: 1; letter-spacing: -0.03em; }
.score span { font-size: 24px; color: var(--muted); font-weight: 650; }
.trow { display: flex; justify-content: space-between; margin: 12px 0 6px; font-size: 14.5px; }
.trow.link:first-of-type { margin-top: 0; }

.review { background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.review summary { cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; line-height: 1.35; }
.review summary::-webkit-details-marker { display: none; }
.review[open] summary { margin-bottom: 8px; }
.review p { font-size: 14.5px; margin-top: 4px; }
.qnum { display: inline-block; min-width: 30px; font-size: 11.5px; font-weight: 750; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 1px 5px; margin-right: 4px; text-align: center; }
.dotm { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 4px; vertical-align: middle; }
.dotm.ok { background: var(--ok); }
.dotm.ko { background: var(--ko); }
.dotm.mid { background: var(--mid); }

/* ——— Progrès ——— */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 130px; position: relative; margin-bottom: 8px; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.chart small { font-size: 11px; color: var(--muted); }
.colbar { width: 100%; max-width: 26px; min-height: 3px; background: var(--primary-soft); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.colok { width: 100%; background: var(--primary); }
.colbar.pass { background: var(--ok); }
.colbar.fail { background: var(--ko); opacity: 0.8; }

/* ——— Réviser ——— */
.fiche summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.fiche summary::-webkit-details-marker { display: none; }
.fiche summary small { color: var(--muted); font-size: 13px; }
.fiche[open] summary { margin-bottom: 12px; }
.fiche dl { margin: 0 0 14px; display: grid; grid-template-columns: minmax(90px, 32%) 1fr; gap: 8px 12px; font-size: 14.5px; }
.fiche dt { font-weight: 700; }
.fiche dd { margin: 0; color: var(--text); opacity: 0.9; }
.chips-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin: 0 -16px; padding-inline: 16px; }
.chips-row::-webkit-scrollbar { display: none; }
.chip-btn { flex: none; border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 99px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip-btn.on { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.toggle { display: flex; gap: 10px; align-items: center; font-size: 14.5px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--primary); }

/* ——— Réglages ——— */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label:not(.toggle):not(.btn) { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14.5px; }
.form input, .form select { font-size: 16px; }

/* ——— Entretien IA ——— */
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 45dvh; }
.msg { max-width: 86%; padding: 12px 14px; border-radius: 18px; font-size: 15.5px; line-height: 1.45; position: relative; }
.msg.agent { align-self: flex-start; background: var(--surface); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: var(--primary); color: var(--primary-ink); border-bottom-right-radius: 6px; }
.mini-speak { float: right; margin: -4px -6px 0 8px; border: 0; background: none; cursor: pointer; font-size: 14px; opacity: 0.6; }
.typing { display: flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 50% { opacity: 0.25; } }
.composer { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); background: var(--bg); padding-top: 6px; }
.composer textarea { resize: none; max-height: 140px; font-size: 16px; }
.mic.rec { background: var(--ko); color: #fff; animation: blink 1s infinite; }

@media (max-width: 380px) {
  .prompt { font-size: 19px; }
  .ring { width: 100px; height: 100px; }
  .row3 .stat-val { font-size: 22px; }
}
@media (min-width: 700px) {
  .wrap { padding-top: 36px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
