/* ===================================================================
   Quiz de Préma — design épuré adulte (clair). Couleur d'accent par
   thème via --accent / --c.
   =================================================================== */
:root {
  --accent: #6d28d9;
  --bg: #f4f4f7;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e7e7ee;
  --radius: 18px;
  --shadow: 0 6px 22px rgba(20, 20, 50, 0.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 620px; margin: 0 auto; padding: 10px 14px 90px; }

/* ---- Navigation (bas) ---- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: 8px; justify-content: center;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.navtab {
  flex: 1; max-width: 240px; border: 0; border-radius: 14px; padding: 11px 10px;
  font-size: 15px; font-weight: 600; color: var(--muted);
  background: #eceaf6; cursor: pointer;
}
.navtab.on { color: #fff; background: var(--accent); }

/* ---- En-têtes ---- */
.title { font-size: 24px; font-weight: 800; margin: 12px 4px 4px; letter-spacing: -0.02em; }
.subtitle { margin: 0 4px 14px; color: var(--muted); font-size: 13.5px; }
.h2 { font-size: 15px; font-weight: 700; margin: 18px 4px 8px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 4px; }
.empty { color: var(--muted); text-align: center; padding: 36px 16px; }

/* ---- Grille de thèmes ---- */
.grid-head { margin-bottom: 6px; }
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px;
}
.tile {
  position: relative; border: 1px solid var(--line); background: var(--card);
  border-radius: var(--radius); padding: 16px 8px 13px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  box-shadow: var(--shadow); transition: transform 0.08s ease;
}
.tile:active { transform: scale(0.96); }
.tile-ic {
  font-size: 30px; line-height: 1;
  width: 52px; height: 52px; display: grid; place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 16%, white);
}
.tile-lb { font-size: 12.5px; font-weight: 600; text-align: center; color: var(--ink); line-height: 1.15; }
.tile-badge {
  position: absolute; top: 8px; right: 9px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 10px; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; color: var(--muted); background: #f0f0f5;
}
.tile.partial { border-color: color-mix(in srgb, var(--c) 45%, white); }
.tile.partial .tile-badge { color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); }
.tile.done { background: color-mix(in srgb, var(--c) 9%, white); border-color: color-mix(in srgb, var(--c) 40%, white); }
.tile.done .tile-ic { background: var(--c); filter: grayscale(0); }
.tile.done .tile-badge { color: #fff; background: var(--c); }

/* ---- Quiz ---- */
.quiz-head { display: flex; align-items: center; gap: 10px; margin: 8px 2px 14px; }
.back {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  width: 38px; height: 38px; font-size: 20px; cursor: pointer; color: var(--ink);
}
.quiz-ic { font-size: 24px; }
.quiz-title { font-size: 19px; font-weight: 800; }

.qprog { margin: 0 2px 14px; }
.qprog-tx { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.qprog-bar { height: 6px; background: #eceaf6; border-radius: 6px; overflow: hidden; }
.qprog-fill { height: 100%; background: var(--accent); transition: width 0.25s ease; }

.qcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; box-shadow: var(--shadow); }
.qtext { font-size: 17px; font-weight: 600; line-height: 1.35; margin-bottom: 16px; }
.qopts { display: flex; flex-direction: column; gap: 10px; }
.qopt {
  text-align: left; border: 1.5px solid var(--line); background: #fbfbfe;
  border-radius: 13px; padding: 13px 15px; font-size: 15px; color: var(--ink);
  cursor: pointer; transition: border-color 0.1s, background 0.1s;
}
.qopt:active { border-color: var(--accent); }
.qopt.locked { cursor: default; }
.qopt.good { border-color: #16a34a; background: #eafaf0; color: #14532d; font-weight: 600; }
.qopt.bad { border-color: #dc2626; background: #fdeced; color: #7f1d1d; }
.qres { margin-top: 14px; font-weight: 700; font-size: 15px; }
.qres.ok { color: #16a34a; }
.qres.ko { color: #dc2626; }
.qanec { margin-top: 8px; font-size: 13.5px; color: var(--muted); line-height: 1.4; background: #f7f7fb; border-radius: 10px; padding: 10px 12px; }
.qnext {
  margin-top: 16px; width: 100%; border: 0; border-radius: 13px; padding: 14px;
  font-size: 15px; font-weight: 700; color: #fff; background: var(--accent); cursor: pointer;
}

/* ---- Fin de thème ---- */
.donecard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 18px; text-align: center; box-shadow: var(--shadow); }
.done-ic { font-size: 46px; }
.done-tx { font-size: 17px; font-weight: 700; margin-top: 8px; }
.done-score { color: var(--muted); margin-top: 6px; font-size: 15px; }
.done-row { display: flex; gap: 10px; margin-top: 20px; }
.done-btn { flex: 1; border: 0; border-radius: 13px; padding: 13px; font-size: 14px; font-weight: 700; cursor: pointer; }
.done-btn.ghost { background: #eceaf6; color: var(--ink); }
.done-btn.primary { background: var(--accent); color: #fff; }

/* ---- Statistiques ---- */
.chips { display: flex; gap: 8px; margin: 4px 4px 14px; }
.chip { flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.metrics { display: flex; gap: 11px; margin: 0 4px 6px; }
.metric { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); }
.metric-v { font-size: 28px; font-weight: 800; color: var(--accent); }
.metric-l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 11px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 13px; cursor: pointer; text-align: left; }
.bar-ic { font-size: 19px; width: 24px; text-align: center; }
.bar-mid { flex: 1; min-width: 0; }
.bar-lb { font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.bar-track { height: 8px; background: #eef0f4; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width 0.3s ease; }
.bar-val { font-size: 14px; font-weight: 800; width: 42px; text-align: right; color: var(--ink); }

/* ---- Modale (courbe / à propos) ---- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(20, 20, 40, 0.45); display: grid; place-items: center; padding: 18px; }
.modal-box { width: 100%; max-width: 420px; background: var(--card); border-radius: 20px; padding: 18px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3); position: relative; }
.modal-box.small { max-width: 360px; }
.modal-head { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.modal-ic { font-size: 22px; }
.modal-title { font-size: 18px; font-weight: 800; }
.modal-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.modal-close { position: absolute; top: 12px; right: 12px; border: 0; background: #f0f0f5; border-radius: 50%; width: 30px; height: 30px; font-size: 14px; cursor: pointer; color: var(--muted); }
.chart { margin-top: 4px; }
.ap { font-size: 13.5px; color: var(--muted); line-height: 1.5; }

/* ---- À propos (ligne discrète) ---- */
.about { display: block; margin: 26px auto 4px; border: 0; background: none; color: #b6b6c4; font-size: 11.5px; cursor: pointer; }

/* ---- Bannière push ---- */
.push-banner { position: fixed; left: 12px; right: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 40; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 13px 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16); display: flex; align-items: center; gap: 12px; max-width: 600px; margin: 0 auto; }
.push-tx { flex: 1; font-size: 14px; font-weight: 600; }
.push-actions { display: flex; gap: 8px; }
.push-btn { border: 0; border-radius: 11px; padding: 9px 13px; font-size: 13px; font-weight: 700; cursor: pointer; }
.push-btn.ghost { background: #eceaf6; color: var(--muted); }
.push-btn.primary { background: var(--accent); color: #fff; }

.loader { text-align: center; color: var(--muted); padding: 50px 0; }
.loader.hidden { display: none; }

@media (prefers-color-scheme: dark) {
  :root { --bg: #15151c; --card: #1f1f29; --ink: #ececf2; --muted: #9a9aab; --line: #2c2c39; --shadow: 0 6px 22px rgba(0, 0, 0, 0.4); }
  .navtab, .chip, .done-btn.ghost { background: #2a2a36; }
  .qopt { background: #24242f; }
  .qanec { background: #24242f; }
  .tile-badge { background: #2a2a36; }
  .bar-track, .qprog-bar { background: #2c2c39; }
  .modal-close { background: #2a2a36; }
}
