:root {
  --bg: #fbfaf7; --fg: #1f2328; --muted: #6b7280; --line: #e5e2da; --card: #fff;
  --accent: #2f6feb; --ok: #1a7f37; --ok-bg: #e6f4ea; --bad: #cf222e; --bad-bg: #fdecec;
  --part: #9a6700; --part-bg: #fff4d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --fg: #e6e6e6; --muted: #9aa0a6; --line: #2d3036; --card: #1d2024;
    --accent: #6ea8fe; --ok: #56d364; --ok-bg: #12301b; --bad: #ff7b72; --bad-bg: #3a1618;
    --part: #e3b341; --part-bg: #33290f;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg); line-height: 1.75; font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { position: sticky; top: 0; z-index: 1; padding: 10px 24px; background: var(--bg); border-bottom: 1px solid var(--line); font-weight: 600; }
.topbar #crumbs { font-weight: 400; color: var(--muted); }
main { max-width: 820px; margin: 0 auto; padding: 24px 24px 120px; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; margin-top: 2em; }
pre { background: var(--card); border: 1px solid var(--line); padding: 12px; overflow-x: auto; border-radius: 6px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .9em; }
pre code.hljs { background: transparent; padding: 0; }
table { border-collapse: collapse; } th, td { border: 1px solid var(--line); padding: 4px 10px; }
blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.card-title { font-weight: 700; line-height: 1.4; color: var(--fg); }
.seg { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--line); margin: 4px 0; }
.seg i { display: block; height: 100%; }
.seg .m { background: var(--ok); } .seg .t { background: var(--part); }
.continue { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cont { display: flex; flex-direction: column; gap: 6px; }
.cont .next { margin: 6px 0; padding: 10px 12px; border-radius: 8px; background: var(--bg); font-size: .9rem; }
.cont .next b { display: block; font-size: .72rem; color: var(--muted); }
.cont .alerts { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.cont .alerts .badge { margin: 0; }
.cont .primary { align-self: flex-start; margin-top: auto; text-decoration: none; }
.new-topic { border-style: dashed; color: var(--muted); align-items: center; justify-content: center; text-align: center; min-height: 160px; }
.shelf-row { display: grid; grid-template-columns: 1fr 160px 110px 80px; gap: 14px; align-items: center;
  padding: 10px 6px; border-bottom: 1px solid var(--line); color: var(--fg); }
.shelf-row:hover { background: var(--card); text-decoration: none; }
.shelf-row .name { font-weight: 600; }
.shelf-row .sub { font-size: .8rem; color: var(--muted); font-weight: 400; }
.shelf-row .r { text-align: right; font-size: .82rem; color: var(--muted); }
.shelf-row.stale .name { color: var(--muted); }
@media (max-width: 640px) {
  .shelf-row { grid-template-columns: 1fr 80px; } .shelf-row .hide-m { display: none; }
}
.mastery { display: flex; flex-wrap: wrap; gap: 12px; font-size: .85rem; color: var(--muted); }
.mastery b { color: var(--fg); font-weight: 600; }
.list { list-style: none; padding: 0; } .list li { padding: 4px 0; }
.badge { display: inline-block; font-size: .75rem; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); margin-right: 6px; }
.badge.ok, .badge.mastered { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.todo, .badge.taught { color: var(--part); background: var(--part-bg); border-color: transparent; }
.badge.review { color: var(--accent); }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.weak { font-size: .9rem; }
.question { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin: 16px 0; }
.qhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }
.qid { font-family: ui-monospace, Menlo, monospace; }
.dim { font-size: .72rem; font-weight: 500; padding: 0 6px; border-radius: 4px; background: var(--line); }
.dim.multi { background: var(--accent); color: #fff; }
.mark { margin-left: auto; font-size: .9rem; padding: 0 8px; border-radius: 6px; }
.mark-ok { color: var(--ok); background: var(--ok-bg); }
.mark-part { color: var(--part); background: var(--part-bg); }
.mark-bad { color: var(--bad); background: var(--bad-bg); }
.part { margin-top: 10px; }
.part-prompt p { display: inline; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; margin: 6px 0; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.option:hover { border-color: var(--accent); }
.option:not(.hit):not(.wrong):has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.option:has(input:disabled) { cursor: default; }
.option input { margin-top: .45em; }
.option .letter { font-weight: 600; min-width: 1.2em; }
.opt-body { flex: 1; } .opt-body > p:first-child { margin-top: 0; } .opt-body > p:last-child { margin-bottom: 0; }
.option.hit { border-color: var(--ok); background: var(--ok-bg); }
.option.missed { border: 1px dashed var(--ok); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.myq textarea { width: 100%; font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); }
.primary { font: inherit; font-weight: 600; padding: 8px 28px; border-radius: 8px; border: 0; background: var(--accent); color: #fff; cursor: pointer; }
.review { margin-top: 40px; border-top: 2px solid var(--line); }
.error { color: var(--bad); }

/* ---------- lesson: question + its own review side by side ---------- */
body.wide main { max-width: 1240px; }
body.wide .article, body.wide .myq, body.wide .review, body.wide main > p { max-width: 820px; }
.qa-head { display: flex; align-items: center; gap: 14px; }
.qa-head h2 { margin-right: auto; }
.qrow { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; margin: 16px 0; }
.qrow > .question { margin: 0; }
.qa.closed .qrow { grid-template-columns: minmax(0, 1fr); }
.qa.closed .rv { display: none; }
.rv-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: .9rem; }
.rv-card.placeholder { background: transparent; border-style: dashed; color: var(--muted); }
.rv-card h4 { margin: 12px 0 4px; font-size: .88rem; display: flex; gap: 8px; align-items: center; }
.rv-item { margin: 6px 0; } .rv-item p { margin: 0; display: inline; }
.rv-item b.ok { color: var(--ok); } .rv-item b.muted { color: var(--muted); }
.trap { color: var(--bad); font-weight: 600; font-size: .85rem; }
.dim.sa { background: var(--part-bg); color: var(--part); }
.qfoot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.ghost, button.quiet { font: inherit; font-size: .88rem; padding: 6px 16px; border-radius: 8px; cursor: pointer; background: transparent; }
button.ghost { color: var(--accent); border: 1px solid var(--accent); }
button.quiet { color: var(--muted); border: 1px solid var(--line); }
.qfoot button.primary { padding: 6px 18px; font-size: .9rem; }
.hint { font-size: .8rem; color: var(--muted); }
.hint.warn { color: var(--part); }
.sa-input { width: 100%; font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); margin-top: 6px; }
.cmd { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px dashed var(--accent); border-radius: 8px; font-size: .86rem; margin-top: 8px; }
.cmd code { flex: 1; color: var(--accent); overflow-wrap: anywhere; }
.cmd button { padding: 3px 12px; }
.mine { border-left: 3px solid var(--line); padding: 2px 10px; color: var(--muted); margin: 6px 0; }
.mine p { margin: 4px 0; }
@media (max-width: 900px) { .qrow { grid-template-columns: minmax(0, 1fr); } }

/* export: prev / next links at the bottom of a static lesson */
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); }
