/* ===== Foundry exam trainer — minimalist, muted palette, responsive ===== */
:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --border: #e2e0da;
  --border-strong: #cfccc4;
  --text: #2b2a27;
  --text-soft: #6b6862;
  --text-faint: #94918a;
  --accent: #4f6d7a;          /* muted slate-teal */
  --accent-soft: #e6eef1;
  --accent-strong: #3d5661;
  --good: #5a7a5a;            /* muted green */
  --good-soft: #e7efe6;
  --bad: #a1615a;             /* muted terracotta */
  --bad-soft: #f2e6e4;
  --warn: #9a8248;           /* muted ochre */
  --warn-soft: #f2ecdd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --maxw: 860px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b1a;
    --surface: #242322;
    --surface-2: #2b2a28;
    --border: #38363300;
    --border: #383633;
    --border-strong: #4a4744;
    --text: #e8e6e1;
    --text-soft: #a8a49d;
    --text-faint: #7c7871;
    --accent: #7fa3b0;
    --accent-soft: #2c3a40;
    --accent-strong: #9dbcc7;
    --good: #86ac86;
    --good-soft: #2a352a;
    --bad: #cc8f88;
    --bad-soft: #3a2b29;
    --warn: #c6ac72;
    --warn-soft: #3a3324;
    --shadow: 0 1px 2px rgba(0,0,0,.2), 0 4px 16px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

/* ---- Header / footer ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 600; }
.brand-mark { font-size: 20px; color: var(--accent); }
.brand-text { font-size: 15px; letter-spacing: .01em; }
@media (max-width: 520px){ .brand-text{ font-size: 13px; } }
.top-nav { display: flex; gap: 4px; }
.nav-btn {
  border: 1px solid transparent; background: transparent; color: var(--text-soft);
  font: inherit; font-size: 14px; padding: 7px 12px; border-radius: var(--radius-sm); cursor: pointer;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent-strong); }

.site-footer { color: var(--text-faint); font-size: 13px; padding: 32px 0; margin-top: 40px; border-top: 1px solid var(--border); }

main.wrap { padding-top: 26px; padding-bottom: 20px; min-height: 60vh; }
.loading { color: var(--text-faint); text-align: center; padding: 60px 0; }

/* ---- Generic bits ---- */
h1 { font-size: 26px; margin: 0 0 6px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
.subtitle { color: var(--text-soft); margin: 0 0 22px; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 550;
  padding: 11px 20px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  transition: filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--accent-strong); border-color: transparent; }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; }

.link { color: var(--accent-strong); background: none; border: none; font: inherit; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }

/* ---- Cards / program picker ---- */
.card-list { display: grid; gap: 16px; }
.program-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%;
  font: inherit; color: inherit; display: block; transition: border-color .12s ease, transform .06s ease;
}
.program-card:hover { border-color: var(--accent); }
.program-card:active { transform: translateY(1px); }
.program-card .pc-badge { display: inline-block; font-size: 12px; color: var(--accent-strong); background: var(--accent-soft); padding: 3px 9px; border-radius: 20px; margin-bottom: 10px; }
.program-card h2 { font-size: 18px; }
.program-card .pc-desc { color: var(--text-soft); font-size: 14px; margin: 8px 0 12px; }
.program-card .pc-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-faint); align-items: center; }
.program-card .pc-progress { margin-top: 12px; }

/* ---- Progress bar ---- */
.pbar { height: 8px; background: var(--border); border-radius: 20px; overflow: hidden; }
.pbar > span { display: block; height: 100%; background: var(--accent); border-radius: 20px; transition: width .4s ease; }
.pbar.goal { position: relative; }
.pbar.goal::after { content: ""; position: absolute; top: -3px; bottom: -3px; left: 70%; width: 2px; background: var(--border-strong); }
.pbar > span.is-good { background: var(--good); }
.pbar > span.is-bad { background: var(--bad); }

/* ---- Chunk map ---- */
.map-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.chunk-list { display: grid; gap: 10px; margin: 18px 0 24px; }
.chunk-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; font: inherit; color: inherit; cursor: pointer; transition: border-color .12s ease;
}
.chunk-row:hover { border-color: var(--accent); }
.chunk-row:disabled { cursor: not-allowed; opacity: .55; }
.chunk-row.review { background: var(--warn-soft); border-color: transparent; }
.chunk-row.review .cr-index { background: var(--warn); color: #fff; }
.cr-index {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft);
  color: var(--accent-strong); font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.cr-body { flex: 1 1 auto; min-width: 0; }
.cr-title { font-weight: 550; font-size: 15px; }
.cr-sub { font-size: 12.5px; color: var(--text-faint); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.cr-status { flex: 0 0 auto; font-size: 13px; font-weight: 600; }
.cr-status .pill { display: inline-block; padding: 3px 10px; border-radius: 20px; }
.pill.done { background: var(--good-soft); color: var(--good); }
.pill.low { background: var(--bad-soft); color: var(--bad); }
.pill.todo { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border); }
.level-tag { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); }

/* ---- Quiz (question block) ---- */
.quiz-head { margin-bottom: 20px; }
.quiz-head .kicker { font-size: 13px; color: var(--accent-strong); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.review-banner { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 18px; font-size: 14px; }

.q-block {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.q-num { font-size: 13px; color: var(--text-faint); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.q-text { font-weight: 550; margin-bottom: 14px; }
.opts { display: grid; gap: 8px; }
.opt {
  display: flex; gap: 11px; align-items: flex-start; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); cursor: pointer; transition: border-color .12s, background .12s;
}
.opt:hover { border-color: var(--border-strong); background: var(--surface-2); }
.opt input { margin: 3px 0 0; accent-color: var(--accent); flex: 0 0 auto; }
.opt .opt-letter { font-weight: 600; color: var(--text-soft); flex: 0 0 auto; }
.opt.checked { border-color: var(--accent); background: var(--accent-soft); }

/* results state */
.opt.reveal { cursor: default; }
.opt.reveal:hover { background: transparent; }
.opt.reveal.correct { border-color: var(--good); background: var(--good-soft); }
.opt.reveal.wrong-pick { border-color: var(--bad); background: var(--bad-soft); }
.opt.reveal.dim { opacity: .8; }
.opt-main { flex: 1 1 auto; min-width: 0; }
.opt-mark { flex: 0 0 auto; font-size: 15px; }
.expl { font-size: 13.5px; color: var(--text-soft); margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }
.opt.reveal.correct .expl { color: var(--text); }
.badge-pick { font-size: 11px; background: var(--accent); color:#fff; padding: 1px 7px; border-radius: 20px; margin-left: 6px; vertical-align: middle; }
.confused-note { margin-top: 10px; font-size: 13px; background: var(--accent-soft); color: var(--accent-strong); padding: 9px 12px; border-radius: var(--radius-sm); }
.confused-note b { font-weight: 600; }
.needs-review-note { margin-top: 10px; font-size: 12.5px; background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: var(--radius-sm); }

.q-result-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.q-result-head .rmark { font-size: 18px; }
.q-block.res-correct { border-left: 3px solid var(--good); }
.q-block.res-wrong { border-left: 3px solid var(--bad); }

/* sticky action bar */
.action-bar {
  position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 16px 0 10px; margin-top: 8px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.action-bar .spacer { flex: 1 1 auto; }
.answered-count { font-size: 13px; color: var(--text-faint); }

/* ---- Results summary ---- */
.summary-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.score-big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.score-big small { font-size: 16px; font-weight: 500; color: var(--text-soft); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; margin-top: 16px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat .s-label { font-size: 12px; color: var(--text-faint); }
.stat .s-value { font-size: 20px; font-weight: 650; }
.goal-wrap { margin-top: 18px; }
.goal-wrap .goal-labels { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-soft); margin-bottom: 6px; }

/* ---- Progress overview ---- */
.ov-chunk { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.ov-chunk:last-child { border-bottom: none; }
.ov-body { flex: 1 1 auto; min-width: 0; }
.ov-title { font-size: 14.5px; font-weight: 500; }
.ov-bar { margin-top: 6px; }
.ov-pct { flex: 0 0 auto; width: 52px; text-align: right; font-weight: 650; font-size: 15px; }
.ov-pct.low { color: var(--bad); }
.ov-pct.good { color: var(--good); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin: 24px 0 6px; }

/* toast / dialog */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.dialog { background: var(--surface); border-radius: var(--radius); padding: 22px; max-width: 400px; width: 100%; box-shadow: var(--shadow); }
.dialog h3 { margin: 0 0 8px; }
.dialog p { margin: 0 0 18px; color: var(--text-soft); font-size: 14px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.flag-review { color: var(--warn); font-size: 12px; }

.empty { text-align: center; color: var(--text-faint); padding: 50px 0; }
