/* Révisions AIS — thème clair/sombre/contraste, accessible, mobile-first. */
:root {
  --fs: 1;                 /* échelle de police réglable */
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --bg: #f1f5f9;
  --bg2: #e2e8f0;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #cbd5e1;
  --accent-bg: #eff6ff;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.06);
  --radius: 14px;
}
[data-theme="dark"] {
  --primary: #60a5fa;
  --primary-d: #3b82f6;
  --success: #4ade80;
  --danger: #f87171;
  --warn: #fbbf24;
  --bg: #0b1120;
  --bg2: #131c2e;
  --card: #18233a;
  --text: #e8eef7;
  --muted: #93a4bd;
  --border: #2c3a55;
  --accent-bg: #16243d;
  --shadow: 0 2px 8px rgba(0,0,0,.4);
}
[data-contrast="high"] {
  --muted: var(--text);
  --border: var(--text);
  --bg2: var(--card);
}
[data-contrast="high"][data-theme="dark"] { --bg: #000; --card: #0a0f1a; }
[data-contrast="high"]:not([data-theme="dark"]) { --bg: #fff; --text: #000; --primary: #1747c2; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: calc(17px * var(--fs)); -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55;
  min-height: 100vh; -webkit-tap-highlight-color: transparent;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }

/* En-tête */
.appbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
}
.appbar .logo { width: 34px; height: 34px; flex: 0 0 auto; }
.appbar h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: .2px; }
.appbar .sub { font-size: .72rem; color: var(--muted); font-weight: 500; }
.appbar .spacer { flex: 1; }
.iconbtn {
  background: none; border: none; color: var(--text); cursor: pointer;
  width: 44px; height: 44px; border-radius: 10px; font-size: 1.2rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn:hover { background: var(--bg2); }

/* Cartes */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 1.15rem; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px; border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .08s, background .15s, border-color .15s; width: 100%;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: var(--bg2); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.lg { min-height: 64px; font-size: 1.12rem; }
.btnrow { display: grid; gap: 10px; margin-top: 14px; }
@media (min-width: 520px) { .btnrow.two { grid-template-columns: 1fr 1fr; } }

/* Accueil — gros CTA */
.hero { text-align: center; padding: 22px 16px; }
.hero .big { font-size: 2.4rem; font-weight: 800; color: var(--primary); }
.menu { display: grid; gap: 10px; }
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; cursor: pointer; color: var(--text); text-align: left; min-height: 60px;
}
.menu-item:hover { border-color: var(--primary); background: var(--accent-bg); }
.menu-item .ic { font-size: 1.5rem; width: 30px; text-align: center; }
.menu-item .t { font-weight: 600; }
.menu-item .d { font-size: .8rem; color: var(--muted); }
.menu-item .arrow { margin-left: auto; color: var(--muted); }

/* Pastilles */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--bg2); color: var(--muted); }
.chip.l1 { background: #dcfce7; color: #166534; }
.chip.l2 { background: #fef3c7; color: #92400e; }
.chip.l3 { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .chip.l1 { background: #14331f; color: #4ade80; }
[data-theme="dark"] .chip.l2 { background: #3a2c0c; color: #fbbf24; }
[data-theme="dark"] .chip.l3 { background: #3a1414; color: #f87171; }
.streak { font-weight: 700; }
.star { background: none; border: none; cursor: pointer; font-size: 1.05rem; padding: 2px 6px; line-height: 1; color: var(--warn); vertical-align: middle; }
.star:hover { transform: scale(1.15); }

/* Quiz */
.qmeta { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--muted); margin-bottom: 6px; }
.progress { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.progress > i { display: block; height: 100%; background: var(--primary); transition: width .3s; }
.qtext { font-size: 1.18rem; font-weight: 600; margin: 6px 0 16px; }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 2px solid var(--border); border-radius: 12px;
  padding: 14px 16px; min-height: 56px; cursor: pointer; color: var(--text); font-size: 1rem;
}
.opt:hover { border-color: var(--primary); }
.opt .key { flex: 0 0 26px; height: 26px; border-radius: 7px; background: var(--bg2); color: var(--muted);
  font-weight: 700; font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; }
.opt.sel { border-color: var(--primary); background: var(--accent-bg); }
.opt.good { border-color: var(--success); background: rgba(22,163,74,.12); }
.opt.bad { border-color: var(--danger); background: rgba(220,38,38,.12); }
.opt.good .key { background: var(--success); color: #fff; }
.opt.bad .key { background: var(--danger); color: #fff; }
.opt .wy { display: block; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.opt[disabled] { cursor: default; }
.expl { margin-top: 14px; padding: 14px; border-left: 4px solid var(--primary); background: var(--accent-bg); border-radius: 0 10px 10px 0; font-size: .92rem; }
.expl b { color: var(--primary); }
.fb { font-weight: 700; margin-top: 14px; }
.fb.ok { color: var(--success); }
.fb.no { color: var(--danger); }

/* Score */
.scorecircle { width: 130px; height: 130px; border-radius: 50%; margin: 0 auto 14px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 2.2rem; font-weight: 800; }
.s-hi { background: rgba(22,163,74,.15); color: var(--success); }
.s-mid { background: rgba(217,119,6,.15); color: var(--warn); }
.s-lo { background: rgba(220,38,38,.15); color: var(--danger); }
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 14px 0; }
.stat { background: var(--bg2); border-radius: 10px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.5rem; color: var(--primary); }
.stat span { font-size: .76rem; color: var(--muted); }

/* Barres CP */
.bar { height: 12px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin: 4px 0; }
.bar > i { display: block; height: 100%; }
.cprow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cprow:last-child { border: none; }
.cprow .name { flex: 1; }
.cprow .name b { font-weight: 600; }
.cprow .name .d { font-size: .76rem; color: var(--muted); }
.tag { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.tag.solide { background: rgba(22,163,74,.15); color: var(--success); }
.tag.conso { background: rgba(217,119,6,.15); color: var(--warn); }
.tag.fragile { background: rgba(220,38,38,.15); color: var(--danger); }

/* Réglages */
.field { margin: 14px 0; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: none; background: var(--card); color: var(--text); padding: 10px 16px; min-height: 44px; cursor: pointer; font-size: .95rem; }
.seg button.on { background: var(--primary); color: #fff; }
input[type=range] { width: 100%; height: 44px; }
input[type=date], textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-size: 1rem; font-family: inherit; }
textarea { min-height: 90px; resize: vertical; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 10px; font-size: .9rem; z-index: 50; box-shadow: var(--shadow); }

.fade { animation: f .25s ease; }
@keyframes f { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
@media print { .appbar, .btn, .menu, .iconbtn { display: none !important; } body { background: #fff; color: #000; } }
