:root {
  --bg: #eef7fb; --fg: #22333b; --muted: #5c6f78; --accent: #1d7fa8; --accent-soft: #54b9dc; --accent-2: #3f9e78;
  --card: #ffffff; --line: #d3e4ec; --soft: #e0f0f7; --panel: rgba(255, 255, 255, 0.98);
  --ok: #3f8a64; --todo: #b9cfd8; --note: #fff4e6; --focus: #2f6fb5;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif; }
body.live { overflow: hidden; height: 100%; }
a { color: var(--accent); }
button { font-weight: 700; font-size: 15px; font-family: inherit; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--fg); padding: 10px 18px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary.big { font-size: 19px; padding: 14px 30px; }
button.link { background: none; border: 0; padding: 4px 6px; color: var(--accent); text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 1040px; margin: 0 auto; padding: 14px 16px 0; }
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 18px; text-decoration: none; color: var(--fg); }
.topbar nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.topbar nav a, .topbar nav button { font-weight: 700; font-size: 14px; padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--fg); background: none; border: 0; }
.topbar nav a:hover, .topbar nav button:hover { background: var(--soft); }
.topbar .lang select { font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); color: var(--fg); }

/* ---------- home ---------- */
#home { max-width: 1040px; margin: 0 auto; padding: 18px 16px 40px; }
#home h1 { margin: 0; font-size: 34px; letter-spacing: -0.01em; }
.lede { color: var(--muted); max-width: 660px; line-height: 1.55; margin: 8px 0 0; }
.callout { background: var(--note); border: 1.5px solid #f1dcc0; border-radius: 16px; padding: 12px 14px; line-height: 1.5; margin: 16px 0 0; font-size: 15px; }
.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 20px 0 6px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.dash { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 16px 0 0; }
.dash h2, #home h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 6px; }
.dash h2:first-child { margin-top: 0; }
.dash h3 { font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 6px; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 700; }
.track { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.track .fill { height: 100%; background: var(--accent-2); border-radius: 999px; transition: width .4s; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 0; padding: 0; list-style: none; }
.badges li { background: var(--soft); border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; opacity: .55; }
.badges li.got { background: #f1faf4; border-color: #bfe0cd; opacity: 1; }
ol.steps { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 10px; }
ol.steps li { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px; }
ol.steps .e { font-size: 30px; line-height: 1.2; }
ol.steps b { font-size: 16px; }
ol.steps p { margin: 2px 0; color: var(--muted); line-height: 1.45; }
ol.steps small { color: var(--accent-2); font-weight: 800; }
footer.site { max-width: 1040px; margin: 0 auto; padding: 8px 16px 40px; color: var(--muted); font-size: 14px; line-height: 1.55; border-top: 1.5px solid var(--line); }
footer.site p { margin: 10px 0; }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 22px; padding: 0; max-width: min(620px, calc(100% - 32px)); width: 100%; color: var(--fg); background: var(--bg); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(34, 51, 59, .55); }
dialog .inner { padding: 22px 22px 18px; max-height: calc(100vh - 64px); overflow-y: auto; }
dialog h2 { margin: 0 0 8px; font-size: 24px; }
dialog h3 { font-size: 15px; color: var(--muted); margin: 14px 0 4px; }
dialog ul { padding-left: 20px; line-height: 1.55; margin: 8px 0; }
dialog li { margin: 6px 0; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1.5px solid var(--line); }
.setting small { display: block; color: var(--muted); }
/* Offline proof panel */
.proof-panel { position: fixed; inset: auto 12px 12px auto; width: min(480px, calc(100vw - 24px)); max-height: min(640px, calc(100vh - 24px)); overflow-y: auto; z-index: 60; background: #fff; border: 1px solid #d3e4ec; border-radius: 12px; padding: 14px; box-shadow: 0 8px 32px rgba(0,0,0,.25); color: #22333b; }
.proof-panel h2 { font-size: 14px; margin: 14px 0 6px; }
.proof-panel h2:first-child { margin-top: 0; }
.proof-panel .muted { color: #5c6f78; font-size: 13px; line-height: 1.5; }
.proof-panel .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.proof-panel .note { background: #fff4e3; border: 1px solid #f0d9b5; border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; margin: 8px 0; }
.proof-panel code { font: 12px ui-monospace, Menlo, monospace; background: #e0f0f7; padding: 1px 4px; border-radius: 4px; }
#proofLog { font: 11px ui-monospace, Menlo, monospace; max-height: 180px; overflow-y: auto; background: #f7f5f1; border-radius: 8px; padding: 6px 8px; margin: 6px 0; list-style: none; }
#proofLog li { padding: 3px 0; border-bottom: 1px solid #d3e4ec; overflow-wrap: anywhere; }
.proof-origin { font-weight: 700; color: #2f7d5b; }
.proof-origin.remote { color: #c0392b; }
#proofStore ul { font-size: 13px; padding-left: 18px; }

/* ---------- lesson view ---------- */
#lesson { display: none; }
body.live #lesson { display: block; }
body.live #home, body.live footer.site { display: none; }
#lesson { position: relative; max-width: 860px; margin: 0 auto; padding: 14px 16px 60px; }
#video { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
#coach { background: #22333b; color: #fff; border-radius: 16px; padding: 12px 16px; font-weight: 800; font-size: 18px; margin: 12px 0 8px; min-height: 52px; }
#panel .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grp { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.title { display: flex; gap: 10px; align-items: center; margin: 8px 0 0; }
.title .e { font-size: 36px; }
#stepName { font-size: 28px; margin: 0; }
#panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }
#howWrap p { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; line-height: 1.45; font-size: 15px; margin: 0; }
.timer { display: flex; gap: 10px; align-items: center; }
.timer .track { flex: 1; margin-top: 0; }
#timerTxt { font-weight: 800; white-space: nowrap; }
.dots { display: flex; gap: 8px; margin: 12px 0; font-size: 26px; }
.dots span { opacity: .35; }
.dots span.now { opacity: 1; transform: scale(1.15); }
.dots span.ok { opacity: 1; }
.checks { display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.check .dot { width: 26px; height: 26px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; color: #fff; font-weight: 900; flex: none; }
.check.ok .dot { background: var(--ok); }
.check .k { font-weight: 800; flex: none; }
.check .h { color: var(--muted); font-size: 14px; line-height: 1.45; }
.check.ok .h { color: var(--ok); font-weight: 700; }
.nav { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.quizbar { display: flex; justify-content: space-between; font-weight: 800; color: var(--muted); margin-top: 8px; }
#camchip { display: inline-flex; gap: 8px; align-items: center; background: #22333b; color: #fff; padding: 6px 8px 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; margin-top: 10px; }
#camchip .dot { width: 9px; height: 9px; border-radius: 50%; background: #5fd38d; }
#camchip button { padding: 4px 10px; font-size: 13px; }
#camchip[hidden] { display: none; }
#status { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 12px 0; }
#status[hidden] { display: none; }
#status .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
#celebrate { position: fixed; inset: 0; z-index: 41; display: none; align-items: center; justify-content: center; pointer-events: none; }
#celebrate div { background: rgba(255, 255, 255, 0.97); padding: 18px 28px; border-radius: 28px; font-size: 30px; font-weight: 900; box-shadow: 0 10px 40px rgba(0,0,0,.25); text-align: center; pointer-events: auto; cursor: pointer; }
#celebrate small { display: block; font-size: 15px; color: var(--muted); font-weight: 700; margin-top: 4px; }
#celebrate.show { display: flex; animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
dialog .actions .link { align-self: center; }
@media (max-width: 600px) {
  #home h1 { font-size: 27px; }
  #stepName { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
