:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d1f23; --muted: #6b6f76; --line: #e3e1da;
  --accent: #c8102e; --accent-ink: #fff; --ok: #1f7a4d; --ok-bg: #e5f3ec; --bad: #b42318; --bad-bg: #fbeae8;
  --warn-bg: #fff4d6; --code-bg: #1e2127; --code-ink: #e6e6e6; --soft: #f0eee8;
  --radius: 10px; --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15171a; --panel: #1d2024; --ink: #e8e8e6; --muted: #9a9ea6; --line: #2d3137;
    --ok-bg: #16301f; --bad-bg: #3a1a17; --warn-bg: #3a3116; --soft: #23272c; --code-bg: #0f1113; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; }
header.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
header.top .wrap { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { font-weight: 700; text-decoration: none; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.brand .hat { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }
nav { display: flex; gap: 4px; margin-left: auto; }
nav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 15px; }
nav a:hover, nav a.active { background: var(--soft); color: var(--ink); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; text-align: center; line-height: 20px; margin-left: 4px; }
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 28px; padding-bottom: 80px; }
h1 { font-size: 28px; line-height: 1.25; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 32px 0 12px; letter-spacing: -0.01em; }
h3 { font-size: 17px; margin: 22px 0 8px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat .n { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 14px; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 16px; border-radius: 8px; font: inherit; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.locked td { color: var(--muted); }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.ok > span { background: var(--ok); }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.exam { background: var(--accent); color: #fff; }
code, pre { font-family: var(--mono); font-size: 14px; }
:not(pre) > code { background: var(--soft); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--code-bg); color: var(--code-ink); padding: 14px 16px; border-radius: 8px; overflow-x: auto; line-height: 1.5; position: relative; }
pre code { background: none; padding: 0; }
.copy { position: absolute; top: 6px; right: 6px; font: 12px system-ui; background: #333; color: #ddd; border: 0; border-radius: 4px; padding: 2px 8px; cursor: pointer; opacity: .7; }
.copy:hover { opacity: 1; }
.notes table { margin: 12px 0; }
.notes blockquote { margin: 12px 0; padding: 8px 16px; border-left: 3px solid var(--accent); background: var(--soft); border-radius: 0 6px 6px 0; }
.cmds td:first-child { width: 42%; }
.cmds td:first-child code { white-space: pre-wrap; word-break: break-word; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.warn { background: var(--warn-bg); }
.q { padding: 18px 0; border-bottom: 1px solid var(--line); }
.q:last-of-type { border-bottom: 0; }
.q .num { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.q .text { margin: 4px 0 10px; font-weight: 500; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; cursor: pointer; }
.opt:hover { background: var(--soft); }
.opt input { margin-top: 5px; }
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
input[type=text], input[type=number], select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); width: 100%; }
input.cmd { font-family: var(--mono); }
.explain { margin-top: 10px; padding: 10px 14px; background: var(--soft); border-radius: 8px; font-size: 15px; }
.score { font-size: 48px; font-weight: 800; letter-spacing: -0.03em; }
.check { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check .icon { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; }
.check.pass .icon { background: var(--ok); }
.check.fail .icon { background: var(--bad); }
.check.skip .icon { background: var(--muted); }
.check .detail { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: pre-wrap; margin-top: 2px; }
details { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 8px 0; background: var(--panel); }
details summary { cursor: pointer; font-weight: 600; }
.timer { font-family: var(--mono); font-size: 22px; font-weight: 700; padding: 6px 14px; border-radius: 8px; background: var(--soft); }
.timer.low { background: var(--bad-bg); color: var(--bad); }
.sticky-bar { position: sticky; top: 56px; background: var(--bg); padding: 10px 0; z-index: 5; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.objectives li { margin: 2px 0; }
.chapter-nav { display: flex; justify-content: space-between; margin-top: 32px; gap: 12px; }
form.inline { display: inline; }
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
label.field small { color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } nav a { padding: 6px 8px; } .cmds td:first-child { width: auto; } }
.output { max-height: 320px; overflow: auto; }
.opt p, .q .text p, .explain p { margin: 0; }
.opt > span { flex: 1; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.step { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.step .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--soft); color: var(--muted); flex: none; }
.step.current { border-color: var(--accent); }
.step.current .dot { background: var(--accent); color: #fff; }
.step.done .dot { background: var(--ok); color: #fff; }
.learn.pdf-open { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.learn .pdf-col { display: none; }
.learn.pdf-open .pdf-col { display: block; position: sticky; top: 70px; height: calc(100vh - 90px); }
.pdf-col iframe { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
main.wrap.wide { max-width: 1600px; }
.manual-bar { padding: 10px 14px; border: 1px dashed var(--line); border-radius: var(--radius); margin: 14px 0; }
.lesson { font-size: 16.5px; line-height: 1.7; }
.lesson h3 { margin-top: 26px; }
.lesson h3:first-child { margin-top: 4px; }
.takeaways ul { margin: 6px 0 0; }
.takeaways { border-left: 4px solid var(--ok); }
.progress-dots { display: flex; gap: 6px; margin: 6px 0 4px; flex-wrap: wrap; }
.pd { width: 26px; height: 6px; border-radius: 3px; background: var(--line); display: block; }
.pd.done { background: var(--ok); }
.pd.here { outline: 2px solid var(--accent); outline-offset: 1px; }
.learn-nav { margin-top: 18px; }
.lesson .tip, .lesson blockquote { margin: 14px 0; }
@media (max-width: 900px) { .learn.pdf-open { display: block; } .learn.pdf-open .pdf-col { position: static; height: 80vh; margin-top: 16px; } .steps { grid-template-columns: 1fr; } }
