/* Une feuille de calcul : fond quadrillé, barre de formule, progression en ligne de cellules. */
:root{
  --bg:#eef1f6; --grid:#dde3ec; --surface:#ffffff; --ink:#17203a; --muted:#566080;
  --accent:#2447d6; --on-accent:#ffffff; --hl:#ffe14d; --on-hl:#17203a;
  --ok:#17794a; --ko:#bd3327; --line:#c6cfdf;
  /* Polices du système : aucun appel à un serveur extérieur. */
  --f-display:"Trebuchet MS","Segoe UI",system-ui,sans-serif;
  --f-body:Verdana,"Segoe UI",system-ui,sans-serif;
  --f-mono:Consolas,"SF Mono","DejaVu Sans Mono",monospace;
}
@media (prefers-color-scheme:dark){
  :root{
    --bg:#10152a; --grid:#192039; --surface:#1a2140; --ink:#eef1fa; --muted:#9ba6c6;
    --accent:#93a8ff; --on-accent:#10152a; --ok:#62d39b; --ko:#ff8d80; --line:#303a63; color-scheme:dark;
  }
}
*{box-sizing:border-box}
html,body{margin:0}
body{
  background-color:var(--bg);
  background-image:linear-gradient(var(--grid) 1px,transparent 1px),linear-gradient(90deg,var(--grid) 1px,transparent 1px);
  background-size:72px 28px;
  color:var(--ink); font-family:var(--f-body); font-size:16px; line-height:1.5;
  min-height:100%; padding:20px 16px 48px;
}
.wrap{max-width:640px; margin:0 auto; display:flex; flex-direction:column; gap:14px}
.wrap.wide{max-width:900px}
.demo{font-family:var(--f-mono); font-size:12px; color:var(--muted); display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap}
.fx{display:flex; align-items:stretch; background:var(--surface); border:1px solid var(--line); font-family:var(--f-mono); font-size:14px}
.fx span{padding:8px 12px}
.fx .ref{border-right:1px solid var(--line); font-weight:700; min-width:52px; text-align:center}
.fx .sym{border-right:1px solid var(--line); color:var(--muted); font-style:italic}
.fx .txt{flex:1; overflow-wrap:anywhere}
.cells{display:grid; border:1px solid var(--line); border-right:0; background:var(--surface)}
.cells div{border-right:1px solid var(--line); text-align:center; font-family:var(--f-mono); font-size:12px; padding:5px 0; color:var(--muted)}
.cells .done{background:var(--accent); color:var(--on-accent)}
.cells .ok{background:var(--ok); color:var(--surface)}
.cells .ko{background:var(--ko); color:var(--surface)}
.cells .cur{background:var(--hl); color:var(--on-hl); font-weight:700}
.card{background:var(--surface); border:2px solid var(--accent); padding:26px 22px 22px; position:relative; display:flex; flex-direction:column; gap:18px}
.card::after{content:""; position:absolute; right:-6px; bottom:-6px; width:10px; height:10px; background:var(--accent); border:2px solid var(--surface)}
.tag{font-family:var(--f-mono); font-size:12px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted)}
.tag.riddle{display:inline-block; align-self:flex-start; background:var(--hl); color:var(--on-hl); padding:3px 8px}
h1,h2{font-family:var(--f-display); font-weight:700; margin:0; text-wrap:balance; line-height:1.15}
h1{font-size:clamp(32px,8vw,46px)}
h2{font-size:clamp(22px,5.4vw,28px)}
p{margin:0; max-width:60ch}
.hint{color:var(--muted); font-size:14px}
.formula{font-family:var(--f-mono); font-weight:700; font-size:22px; background:var(--bg); border:1px solid var(--line); padding:10px 14px; align-self:flex-start}
.opts{display:flex; flex-direction:column; gap:8px}
.opt{font:inherit; color:var(--ink); background:var(--surface); border:1px solid var(--line); padding:13px 14px; text-align:left; cursor:pointer; display:flex; gap:12px; align-items:flex-start}
.opt:hover:not(:disabled){border-color:var(--accent)}
.opt .box{flex:none; width:20px; height:20px; margin-top:2px; border:2px solid var(--muted); font-family:var(--f-mono); font-size:13px; line-height:16px; text-align:center; font-weight:700}
.opt.single .box{border-radius:50%}
.opt.on{border-color:var(--accent); box-shadow:inset 0 0 0 1px var(--accent)}
.opt.on .box{background:var(--accent); border-color:var(--accent); color:var(--on-accent)}
.opt.right{border-color:var(--ok); box-shadow:inset 0 0 0 1px var(--ok)}
.opt.right .box{background:var(--ok); border-color:var(--ok); color:var(--surface)}
.opt.wrong{border-color:var(--ko); box-shadow:inset 0 0 0 1px var(--ko)}
.opt.wrong .box{background:var(--ko); border-color:var(--ko); color:var(--surface)}
.opt:disabled{cursor:default; opacity:1}
.explain{border-left:4px solid var(--hl); padding:4px 0 4px 14px}
.explain strong{display:block; font-family:var(--f-display); font-size:19px}
label{display:flex; flex-direction:column; gap:6px; font-size:14px; color:var(--muted)}
input[type=text],input[type=email],input[type=password],textarea,select{font:inherit; color:var(--ink); background:var(--bg); border:1px solid var(--line); padding:11px 12px; width:100%}
textarea{min-height:70px; resize:vertical}
.hp{position:absolute; left:-9999px; width:1px; height:1px; overflow:hidden}
.nav{display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; align-items:center}
.btn{font-family:var(--f-display); font-weight:700; font-size:17px; padding:12px 22px; border:2px solid var(--accent); background:var(--accent); color:var(--on-accent); cursor:pointer; text-decoration:none; display:inline-block}
.btn.ghost{background:transparent; color:var(--accent)}
.btn.small{font-size:14px; padding:6px 12px}
.btn:disabled{opacity:.4; cursor:not-allowed}
:focus-visible{outline:3px solid var(--hl); outline-offset:2px}
.facts{display:flex; gap:8px; flex-wrap:wrap; font-family:var(--f-mono); font-size:13px}
.facts span{border:1px solid var(--line); padding:4px 9px; background:var(--bg)}
.score{font-family:var(--f-display); font-size:44px; font-weight:700; line-height:1}
.score small{font-size:18px; color:var(--muted); font-weight:400}
table{border-collapse:collapse; width:100%; font-size:14px}
th,td{border:1px solid var(--line); padding:7px 9px; text-align:left; vertical-align:top; overflow-wrap:anywhere}
th{background:var(--bg); font-weight:700}
.tablewrap{overflow-x:auto}
.sheet{font-size:15px}
.sheet .rh{background:var(--bg); color:var(--muted); font-family:var(--f-mono); font-size:12px; text-align:center; width:34px; padding:5px}
.sheet input{border:0; background:transparent; color:var(--ink); padding:0; font-family:var(--f-mono); font-size:15px; font-variant-numeric:tabular-nums; width:100%; min-width:70px}
.sheet .tot td{font-weight:700}
.sheet #total{background:var(--hl); color:var(--on-hl); font-family:var(--f-mono); font-variant-numeric:tabular-nums}
/* Administration */
.num{text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap}
.bar{height:8px; background:var(--accent); min-width:2px}
.bar.ok{background:var(--ok)}
.msg{border-left:4px solid var(--ok); padding:6px 12px; background:var(--surface)}
.msg.err{border-color:var(--ko)}
textarea.code{font-family:var(--f-mono); font-size:13px; min-height:420px; white-space:pre; overflow:auto}
a{color:var(--accent)}
@media (prefers-reduced-motion:no-preference){
  .card{animation:pop .18s ease-out}
  @keyframes pop{from{transform:translateY(6px)}to{transform:none}}
}

/* Affiche avec QR code */
.poster{align-items:center; text-align:center; padding:40px 24px}
.poster p{max-width:40ch}
#qr canvas{display:block; width:min(100%,340px); height:auto; image-rendering:pixelated; border:1px solid var(--line)}
.url{font-family:var(--f-mono); font-weight:700; font-size:20px; overflow-wrap:anywhere}
.poster .facts{justify-content:center}
@media print{
  :root{--bg:#fff; --surface:#fff; --ink:#000; --muted:#333; --line:#999}
  body{background:#fff; padding:0}
  .noprint{display:none !important}
  .poster{border-width:3px; margin-top:12mm; padding:18mm 12mm; gap:10mm; animation:none}
  .poster h1{font-size:44pt}
  .poster p{font-size:16pt}
  #qr canvas{width:95mm; border:0}
  .url{font-size:18pt}
}
