/* Grade trainer — dark, single column, no framework. */
:root {
  color-scheme: dark;
  --bg: #14161a;
  --panel: #1d2026;
  --panel-2: #24282f;
  --border: #30353d;
  --text: #e6e8ec;
  --muted: #8b919c;
  --accent: #5aa9ff;
  --accent-ink: #0b1320;
  --good: #3ec27c;
  --mid: #e0b23a;
  --bad: #e5605b;
  --code-bg: #0f1114;
  --mark: #6a5300;
  --radius: 10px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
/* Light palette: dark-first design, so light is the second theme. Tokens only. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f2f3f6; --panel: #ffffff; --panel-2: #e9ebf0; --border: #d3d7de;
    --text: #1b1f26; --muted: #5d6673; --accent: #1f6fd1; --accent-ink: #ffffff;
    --good: #1f9a5a; --mid: #b07d00; --bad: #c8403b; --code-bg: #eef0f4; --mark: #ffe58a;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f3f6; --panel: #ffffff; --panel-2: #e9ebf0; --border: #d3d7de;
  --text: #1b1f26; --muted: #5d6673; --accent: #1f6fd1; --accent-ink: #ffffff;
  --good: #1f9a5a; --mid: #b07d00; --bad: #c8403b; --code-bg: #eef0f4; --mark: #ffe58a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); }
a { color: var(--accent); }
button { font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
.muted { color: var(--muted); font-weight: 400; }

.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 18px; }
.brand .muted { font-size: 13px; margin-left: 8px; }
.tabs { display: flex; gap: 6px; }
.tabs button { background: transparent; border-color: transparent; }
.tabs button.active { background: var(--panel-2); border-color: var(--border); }

main { max-width: 960px; margin: 0 auto; padding: 20px; }
/* the course page carries blocks of real command output: give it the extra width when the screen has it */
@media (min-width: 1100px) { main:has(#tab-course.active) { max-width: 1180px; } }
.tab { display: none; }
.tab.active { display: block; }

.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.filter-group { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.filter-group .label { width: 70px; color: var(--muted); padding-top: 6px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 11px; font-size: 13px; border-radius: 999px; background: transparent; color: var(--muted); }
.chip.active { background: var(--panel-2); color: var(--text); border-color: var(--accent); }

.stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.stats b { color: var(--text); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card-head { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.badge.grade { color: var(--accent); }
.badge.topic { color: var(--text); }
.badge.box { margin-left: auto; }
.question { font-size: 18px; font-weight: 600; margin-bottom: 14px; white-space: pre-wrap; }
textarea { width: 100%; min-height: 90px; resize: vertical; background: var(--code-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: inherit; margin-bottom: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.answer { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.rate { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.rate .label { color: var(--muted); font-size: 13px; margin-right: 6px; }
.rate-btn.bad { border-color: var(--bad); color: var(--bad); }
.rate-btn.mid { border-color: var(--mid); color: var(--mid); }
.rate-btn.good { border-color: var(--good); color: var(--good); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* rendered answers */
.md p { margin: 0 0 10px; }
.md ul { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md h4 { margin: 14px 0 6px; font-size: 14px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.md code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; font-family: var(--mono); }
.md pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  overflow-x: auto; font-size: 13px; font-family: var(--mono); line-height: 1.45; margin: 0 0 10px; }
.md pre code { background: none; padding: 0; }
/* a wide block scrolls inside itself; show that it does: thin scrollbar and a fade at the right edge */
.md pre { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.md pre::-webkit-scrollbar { height: 8px; }
.md pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.md pre::-webkit-scrollbar-track { background: transparent; }
.code-wrap { position: relative; }
.code-wrap::after { content: ''; position: absolute; top: 1px; right: 1px; bottom: 10px; width: 26px; pointer-events: none;
  border-radius: 0 8px 8px 0; background: linear-gradient(to right, transparent, var(--code-bg)); opacity: 0; transition: opacity .15s; }
.code-wrap.more::after { opacity: 1; }
.code-hint { position: absolute; right: 8px; bottom: 10px; font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 7px; pointer-events: none; opacity: 0; transition: opacity .15s; }
.code-wrap.more .code-hint { opacity: 1; }
.code-copy { position: absolute; top: 6px; right: 8px; z-index: 2; font-size: 11px; line-height: 1.3; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); cursor: pointer; opacity: .75; }
.code-wrap:hover .code-copy, .code-copy:focus { opacity: 1; color: var(--text); border-color: var(--accent); }
.code-copy.ok { color: var(--accent); border-color: var(--accent); opacity: 1; }
.md .code-wrap pre { padding-right: 100px; }
@media (max-width: 640px) { .code-copy { opacity: 1; } }
/* a block of output must scroll inside itself, not wrap: columns of show vlan / porterrshow stay aligned */
.md pre code { white-space: pre; overflow-wrap: normal; word-break: normal; }
.md .note { border-left: 3px solid var(--mid); padding: 6px 10px; background: var(--panel-2); border-radius: 4px; margin: 0 0 10px; color: var(--muted); }

/* reference */
.search-row { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
input[type=search] { flex: 1; background: var(--code-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font: inherit; }
.ref-group h3 { margin: 22px 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; }
details.q { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
details.q > summary { cursor: pointer; padding: 10px 14px; display: flex; gap: 8px; align-items: baseline; }
details.q > summary .badge { flex-shrink: 0; }
details.q .md { padding: 4px 14px 12px; border-top: 1px solid var(--border); }
mark { background: var(--mark); color: var(--text); padding: 0 2px; border-radius: 2px; }

/* matrix */
.table-wrap { overflow-x: auto; }
table#matrix { border-collapse: collapse; width: 100%; font-size: 13px; }
#matrix th, #matrix td { border: 1px solid var(--border); padding: 8px 10px; vertical-align: top; text-align: left; }
#matrix th { background: var(--panel); position: sticky; top: 0; }
#matrix td.area { font-weight: 600; white-space: nowrap; background: var(--panel); }
#matrix td.cell { cursor: pointer; min-width: 220px; }
#matrix td.cell:hover { background: var(--panel-2); }
#matrix td.cell.none { cursor: default; color: var(--muted); }
#matrix ul { margin: 0 0 6px; padding-left: 16px; }
#matrix li { margin: 1px 0; }
/* topics the examiner asks beyond the exported document */
#matrix li.extra { color: var(--muted); font-style: italic; list-style-type: '+ '; }
.bar { height: 6px; background: var(--code-bg); border-radius: 3px; overflow: hidden; margin-top: 6px; display: flex; }
.bar i { display: block; height: 100%; }
.bar .g { background: var(--good); } .bar .m { background: var(--mid); } .bar .b { background: var(--bad); }
.cell-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

@media (max-width: 640px) {
  .filter-group .label { width: 100%; padding-top: 0; }
  .question { font-size: 16px; }
}

/* lesson mode */
.lesson-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 14px; margin-bottom: 12px; font-size: 14px; }
.done-title { font-size: 20px; font-weight: 600; color: var(--text); }
.actions.center { justify-content: center; }
.badge.good { color: var(--good); }

/* course */
.course { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
#course-nav { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; font-size: 15px; }
.course-progress { color: var(--muted); margin-bottom: 12px; }
.course-module h3 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.course-module ol { list-style: none; margin: 0; padding: 0; }
.course-module li { padding: 7px 8px 7px 28px; border-radius: 6px; cursor: pointer; position: relative; line-height: 1.35; }
.course-module li:hover { background: var(--panel-2); }
.course-module li.current { background: var(--panel-2); border-left: 3px solid var(--accent); }
.course-module li.done { color: var(--muted); }
.course-module li .mark { position: absolute; left: 8px; color: var(--good); }
.course-module li .small { font-size: 12.5px; }
.course-module li a { color: inherit; text-decoration: none; display: block; }
.course-module h3 { font-size: 14px; }
.course-progress { font-size: 14px; }
#course-body h2 { margin: 6px 0 14px; font-size: 24px; }
.lesson-head { display: flex; gap: 6px; flex-wrap: wrap; }
.module-intro { border-left: 3px solid var(--accent); padding: 4px 12px; color: var(--muted); margin-bottom: 8px; }
details.lesson-q summary span:last-child { font-weight: 600; }
@media (max-width: 800px) {
  .course { grid-template-columns: 1fr; }
  #course-nav { position: static; max-height: none; order: 2; }
}

/* narrow screens: keep everything inside the viewport */
.tabs { flex-wrap: wrap; }
.course > * { min-width: 0; }
.md, .question { overflow-wrap: anywhere; }
/* inline commands wrap only between words, never in the middle of a token; a token longer than the
   line still breaks so nothing overflows the page */
.md code { white-space: pre-wrap; overflow-wrap: break-word; }
.md code.nb { white-space: nowrap; }   /* short commands stay whole on one line */
/* a command too long for a line gets its own line and scrolls inside itself, never cut in half */
.md code.long { display: block; white-space: pre; overflow-x: auto; margin: 4px 0; padding: 5px 8px; }
@media (max-width: 640px) {
  .top { padding: 10px 12px; }
  .tabs button { padding: 6px 10px; font-size: 14px; }
  main { padding: 12px; }
}
details.q > summary { overflow: hidden; }
details.q > summary > span:last-child { min-width: 0; flex: 1; }
details.q > summary pre { max-width: 100%; }
/* a question can carry its own block of output: it is markdown too, so it must scroll like any other block
   and not be clipped by the summary */
details.q > summary .qtext { font-weight: 600; min-width: 0; flex: 1; }   /* without min-width a block of output refuses to shrink and gets clipped */
details.q > summary .qtext p { margin: 0 0 6px; }
details.q > summary .qtext p:last-child { margin-bottom: 0; }
details.q > summary .qtext pre { font-weight: 400; margin: 6px 0 0; }
@media (max-width: 640px) {
  /* on a phone the badge and the fold arrow keep the first line, the question and its output get the full width */
  details.q > summary { flex-wrap: wrap; }
  details.q > summary .qtext { flex: 1 1 100%; }
}

button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
.transfer { margin-top: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.transfer textarea { min-height: 120px; font-family: var(--mono); font-size: 12px; }

/* lab */
.lab { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.lab > * { min-width: 0; }
.lab-side h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lab-list { list-style: none; margin: 0 0 16px; padding: 0; font-size: 13px; }
.lab-list li { padding: 6px 8px 6px 26px; border-radius: 6px; cursor: pointer; position: relative; line-height: 1.3; }
.lab-list li:hover { background: var(--panel-2); }
.lab-list li.current { background: var(--panel-2); border-left: 3px solid var(--accent); }
.lab-list li.done { color: var(--muted); }
.lab-list li .mark { position: absolute; left: 8px; color: var(--good); }
.lab-checks { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.lab-checks h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lab-checks ul { list-style: none; margin: 0; padding: 0; }
.lab-checks li { padding: 3px 0; }
.lab-checks li.ok { color: var(--good); }
.lab-checks li.todo { color: var(--text); }
.lab-main h2 { margin: 6px 0 10px; font-size: 22px; }
.terminal { margin-top: 10px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; font-family: var(--mono); font-size: 13px; }
.term-out { height: 420px; overflow: auto; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.term-out .tl.cmd { color: var(--accent); }
.term-out .tl.sys { color: var(--muted); font-style: italic; }
.term-in { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--border); }
.term-prompt { color: var(--accent); white-space: pre; }
.term-in input { flex: 1; background: transparent; border: 0; color: var(--text); font: inherit; outline: none; }
.editor { margin-top: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.editor-head { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.editor textarea { min-height: 240px; font-family: var(--mono); font-size: 13px; margin-bottom: 8px; }
@media (max-width: 900px) { .lab { grid-template-columns: 1fr; } .term-out { height: 300px; } }
.sol-step { border: 1px solid var(--border); border-radius: 6px; margin: 4px 0; background: var(--panel); }
.sol-step summary { cursor: pointer; padding: 6px 10px; font-size: 13px; }
.sol-step pre { margin: 0; border: 0; border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; }
.sol-step ul { list-style: none; margin: 0; padding: 6px 12px; font-size: 13px; }
.sol-step li.ok { color: var(--good); }
.course-inline { margin-top: 18px; }
.course-inline .card { border-color: var(--accent); }
.course-lab { margin: 10px 0 16px; }
.course-lab .lab-main h2 { font-size: 18px; }
.lab-pick { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; max-width: 100%; }

/* lesson steps */
.step-dots { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.step-dots .dot { padding: 4px 10px; font-size: 12px; border-radius: 999px; background: transparent; color: var(--muted); border: 1px solid var(--border); }
.step-dots .dot.seen { color: var(--text); border-color: var(--good); }
.step-dots .dot.active { background: var(--panel-2); color: var(--text); border-color: var(--accent); font-weight: 600; }
.lesson-step { min-height: 120px; }
.lesson-nav { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); align-items: center; }
.lesson-nav .quiet { background: transparent; border-color: transparent; color: var(--muted); font-size: 13px; }
.lesson-nav .quiet:hover { color: var(--text); border-color: var(--border); }
.view-toggle { margin-left: auto; }

/* split lab (course practice step): text left, console right */
.lab.split { display: block; }
.lab.split .lab-main { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.3fr); gap: 16px; align-items: start; }
.lab.split .lab-main > * { min-width: 0; }
.lab.split .lab-text h2 { font-size: 17px; margin: 4px 0 8px; }
.lab.split .lab-text .md { font-size: 14px; }
.lab.split .lab-checks { margin-top: 10px; }
.lab.split .terminal { margin-top: 8px; }
.lab.split .term-out { height: 460px; }
@media (max-width: 960px) { .lab.split .lab-main { grid-template-columns: 1fr; } .lab.split .term-out { height: 320px; } }

/* sync block */
.sync { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 16px 0; }
.sync h4 { margin: 0 0 6px; font-size: 14px; }
.sync-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.sync-row input { flex: 1; min-width: 220px; background: var(--code-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font: inherit; }
#sync-status[data-state="on"] { color: var(--good); }
#sync-status[data-state="error"] { color: var(--bad); }
#sync-status[data-state="busy"] { color: var(--muted); }

/* centred lesson header */
.lesson-head { justify-content: center; position: relative; padding-right: 0; }
.lesson-head .view-toggle { margin-left: 0; position: absolute; right: 0; top: 0; }
#course-body h2 { text-align: center; }
.step-dots { justify-content: center; }
@media (max-width: 640px) { .lesson-head { padding-top: 34px; } .lesson-head .view-toggle { top: 0; right: 0; } }

/* reading cards inside a theory step */
.card-body { min-height: 80px; }

.outline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 12px; font-size: 13px; }
.outline .label { color: var(--muted); }
.badge.kind-basics { color: var(--good); border-color: var(--good); }
.badge.kind-output { color: var(--mid); border-color: var(--mid); }
.badge.kind-practice { color: var(--accent); }
.ref-filters { margin: 4px 0 8px; }

.help-tip { width: 28px; height: 28px; padding: 0; border-radius: 50%; font-weight: 700; color: var(--muted); }
.help-box { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; font-size: 13px; }
.help-box ul { margin: 6px 0 0; padding-left: 18px; }
.help-box li { margin: 2px 0; }

/* daily badge */
.daily-badge { margin-left: 12px; font-size: 12px; font-weight: 500; color: var(--muted); }
.daily-badge.met { color: var(--good); }
/* notes */
.notes { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.notes .label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.notes textarea { min-height: 60px; margin-bottom: 0; }
.prev-note { border-left: 3px solid var(--good); padding: 6px 10px; margin: 0 0 10px; background: var(--panel-2); border-radius: 4px; font-size: 14px; }
/* cloze */
.cloze-wrap { display: flex; gap: 8px; margin: 4px 0 12px; }
.cloze-wrap input { flex: 1; background: var(--code-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font: inherit; font-family: var(--mono); }
.cloze-result { border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; background: var(--panel-2); border: 1px solid var(--border); }
.cloze-result.ok { border-color: var(--good); } .cloze-result.bad { border-color: var(--bad); }
.cloze-result .verdict { font-weight: 600; margin-bottom: 4px; }
.cloze-result.ok .verdict { color: var(--good); } .cloze-result.bad .verdict { color: var(--bad); }
.question .blank { display: inline-block; min-width: 70px; border-bottom: 2px solid var(--accent); text-align: center; color: var(--accent); }
/* exam */
.exam-bar { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.exam-bar #exam-timer { font-family: var(--mono); color: var(--muted); }
.exam-bar button { margin-left: auto; }
.exam-summary .score { font-size: 28px; font-weight: 700; margin: 6px 0; }
.exam-summary .score.good { color: var(--good); } .exam-summary .score.mid { color: var(--mid); } .exam-summary .score.bad { color: var(--bad); }
.exam-summary ul { padding-left: 20px; }
/* progress tab */
.progress-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pbox { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; }
.pbox h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pbox .big { font-size: 26px; font-weight: 700; }
.pbox input[type=number] { width: 70px; background: var(--code-bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font: inherit; }
.section-title { margin: 20px 0 6px; font-size: 16px; }
.diary-list { list-style: none; margin: 0; padding: 0; }
.diary-list li { padding: 8px 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr; gap: 4px; }
.diary-list li:first-child { border-top: 0; }
.diary-list .dq { font-weight: 600; }
.diary-list .meta { font-size: 12px; color: var(--muted); }
.diary-list input { width: 100%; background: var(--code-bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font: inherit; font-size: 13px; }
.weak-list { margin: 0; padding-left: 18px; }
.exam-hist { width: 100%; border-collapse: collapse; font-size: 13px; }
.exam-hist td, .exam-hist th { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); }
/* diagrams */
.diagram { margin: 12px 0 16px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.diagram svg { width: 100%; height: auto; max-width: 640px; display: block; margin: 0 auto; font-family: var(--font); }
.diagram figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; }
.d-box { fill: var(--panel-2); stroke: var(--border); stroke-width: 1.5; }
.d-box.d-switch { stroke: var(--accent); }
.d-pill { fill: var(--panel); }
.d-text { fill: var(--text); font-size: 15px; font-weight: 600; }
.d-tag { fill: var(--text); font-size: 13px; }
.d-tag.d-muted { fill: var(--muted); font-size: 12px; }
.d-tag.d-accent { fill: var(--accent); font-weight: 600; }
.d-line { stroke: var(--text); stroke-width: 2; opacity: .8; }
.d-line.d-trunk { stroke: var(--accent); stroke-width: 3; }
@media (max-width: 700px) { .progress-grid { grid-template-columns: 1fr; } }
.track-link { align-self: center; margin-left: 10px; font-size: 13px; color: var(--muted); text-decoration: none; border: 1px dashed var(--border); border-radius: 8px; padding: 5px 10px; }
.track-link:hover { color: var(--text); border-color: var(--accent); }

/* focus mode */
.train-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.train-top .quiet { background: transparent; border-color: var(--border); color: var(--muted); font-size: 13px; padding: 5px 12px; }
.train-status { font-size: 13px; color: var(--muted); }
.filters { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stats-foot { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }
.stats-foot b { color: var(--text); font-weight: 600; }
.card-head .meta { align-self: center; }
.card-head .badge.box { margin-left: auto; cursor: help; }
.outline { margin: 0 0 12px; }
/* lesson title row */
.lesson-title { display: flex; align-items: center; justify-content: center; gap: 8px; }
.lesson-title h2 { margin: 6px 0 10px; }
.lesson-title .info { background: transparent; border: 0; color: var(--muted); font-size: 16px; padding: 2px 6px; }
.lesson-title .info:hover { color: var(--accent); }
.lesson-title .copy-link { background: transparent; border: 1px solid var(--border); color: var(--muted); font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.lesson-title .copy-link:hover { color: var(--accent); }
.lesson-title .copy-link.ok { color: var(--good); }
#lesson-meta { margin-bottom: 10px; }
.badge { white-space: normal; display: inline-block; margin: 2px 0; max-width: 100%; }   /* long DevOps topics wrap instead of pushing the page */
.outline .badge { white-space: normal; text-align: left; }   /* answer-plan badges carry whole headings */

/* exam onboarding */
.exam-how { margin: 12px 0 16px; padding-left: 22px; }
.exam-how li { margin: 6px 0; }
.exam-progressbar { height: 6px; background: var(--code-bg); border-radius: 3px; overflow: hidden; margin: 0 0 10px; }
.exam-progressbar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.exam-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.exam-steps .step { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.exam-steps .step.active { border-color: var(--accent); color: var(--text); background: var(--panel-2); font-weight: 600; }
.exam-hint { margin: -4px 0 10px; }
#exam-qtimer.late { color: var(--mid); border-color: var(--mid); }

/* sources spoiler */
details.sources { margin: 10px 14px 12px; font-size: 13px; }
details.sources summary { color: var(--muted); cursor: pointer; }
details.sources ul { margin: 6px 0 0; padding-left: 18px; }
details.sources li { margin: 3px 0; }
.card details.sources, #exam-ref + details.sources { margin-left: 0; margin-right: 0; }

/* diagnostic chains */
.chain-list ul { list-style: none; margin: 0; padding: 0; }
.chain-list li { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin: 6px 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.chain-list li:hover { border-color: var(--accent); background: var(--panel-2); }
.chain-intro { margin-bottom: 12px; }
.chain-step { border-top: 1px solid var(--border); padding: 12px 0; }
.chain-step.current { border-top: 2px solid var(--accent); }
.chain-step.missed .chain-ask { color: var(--mid); }
.chain-ask { font-weight: 600; margin-bottom: 8px; }
.chain-out { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 13px; font-family: var(--mono); line-height: 1.45; margin: 0 0 8px; white-space: pre; }
.chain-note { color: var(--muted); font-size: 14px; }
.chain-msg { min-height: 18px; margin: -4px 0 8px; }
.chain-end { padding-top: 12px; border-top: 1px solid var(--border); }

/* one path: hero, nav home, milestones, achievements */
.hero { border-color: var(--accent); }
.hero-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.hero-name { font-size: 26px; font-weight: 700; cursor: pointer; }
.hero-name:hover { color: var(--accent); }
.hero-title { color: var(--accent); font-weight: 600; }
.hero-xp { min-width: 220px; flex: 1; max-width: 320px; }
.hero-xp .bar { height: 8px; margin: 6px 0; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 4px; font-size: 13px; color: var(--muted); }
.hero-stats b { color: var(--text); }
.hero-go { align-items: center; margin-top: 12px; }
button.big { font-size: 16px; padding: 12px 20px; }
.pbox-title { margin: 0 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
#course-body > .card, #course-body > details.card { margin-bottom: 14px; }
details.card summary { cursor: pointer; font-weight: 600; }
details.card > div { margin-top: 12px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ach { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; opacity: .45; font-size: 13px; }
.ach span { color: var(--muted); font-size: 12px; }
.ach.on { opacity: 1; border-color: var(--good); }
.ach.on b::before { content: '✓ '; color: var(--good); }
.nav-home { font-weight: 600; cursor: pointer; padding: 6px 8px; border-radius: 6px; margin: 0 0 8px -8px; color: var(--text); }
.nav-home:hover { background: var(--panel-2); }
.nav-home.current { background: var(--panel-2); border-left: 3px solid var(--accent); }
.course-module li.milestone { color: var(--accent); }
.course-module li.milestone.done { color: var(--muted); }
.course-module li.milestone .mark { color: var(--accent); }
.course-module li.done .mark { color: var(--good); }
.step-desc { margin: 12px 0; }
#home-lab .lab { margin-top: 8px; }

/* live lab */
.live-box { margin: 12px 0; }
.live-term { width: 100%; height: min(440px, 60vh); min-height: 300px; border: 1px solid var(--border); border-radius: 8px; background: #0f1114; margin-top: 10px; }
.live-checks { margin-top: 12px; }
.quiet-link { align-self: center; font-size: 13px; color: var(--muted); }
.course-module li.milestone.live { color: var(--good); }
@media (max-width: 640px) {
  .live-term { height: 55vh; }
  .hero-name { font-size: 22px; }
  .hero-stats { gap: 4px 12px; }
  .lesson-head .badge { font-size: 11px; }
}
.path-pin { margin-left: 14px; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; white-space: nowrap; }
.path-pin:hover { border-color: var(--accent); }
.path-pin.done { color: var(--good); }
@media (max-width: 640px) { .brand .muted { display: none; } .path-pin { margin-left: 8px; font-size: 12px; padding: 3px 9px; } }
.live-error { color: var(--bad); font-size: 14px; }

/* answer checklist and follow-ups */
.rubric { margin: 14px 0 6px; padding: 12px 14px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; background: var(--panel-2); }
.rubric h4 { margin: 0 0 8px; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.rubric ul + h4 { margin-top: 12px; }
.rubric ul { list-style: none; margin: 0; padding: 0; }
.rubric li { margin: 4px 0; }
.rubric label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.rubric input { margin-top: 4px; }
.rubric-score { margin: 6px 0 0; }
.followup { border: 1px solid var(--border); border-radius: 6px; margin: 4px 0; background: var(--panel); }
.followup summary { cursor: pointer; padding: 6px 10px; font-weight: 600; font-size: 14px; }
.followup .md { padding: 0 12px 8px; font-size: 14px; }
.rate-btn.suggest, #btn-exam-ok.suggest, #btn-exam-bad.suggest { box-shadow: 0 0 0 2px var(--accent); }

/* annotated output lines inside code blocks */
.md pre .hl { display: inline-block; min-width: 100%; background: color-mix(in srgb, var(--accent) 14%, transparent); border-left: 3px solid var(--accent); margin-left: -12px; padding-left: 9px; box-sizing: border-box; }
.md pre .ann { color: var(--accent); font-weight: 600; }

/* design pass: hero, path map, cards, step list */
.hero { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--panel)), var(--panel) 60%); }
.hero-name { letter-spacing: -.01em; }
.path-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.pm-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--panel-2); display: flex; flex-direction: column; gap: 6px; }
.pm-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pm-card.done { border-color: var(--good); }
.pm-title { font-weight: 700; font-size: 15px; }
.pm-card .bar { height: 6px; }
.pm-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.pm-go { padding: 4px 10px; font-size: 13px; }
.card { box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.course-module h3 { letter-spacing: .06em; }
.course-module li { border-left: 3px solid transparent; }
.course-module li.current { border-left-color: var(--accent); }
.course-module li.milestone .mark { font-size: 12px; }
#course-body h2 { letter-spacing: -.01em; }
.lesson-step .md p, .lesson-step .md li { line-height: 1.6; }
button.primary { box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.step-dots .dot.active { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
@media (max-width: 640px) {
  .path-map { grid-template-columns: 1fr; }
  #course-nav .course-module ol { display: none; }
  #course-nav .course-module.open ol, #course-nav .course-module:has(li.current) ol { display: block; }
  #course-nav .course-module h3 { cursor: pointer; padding: 8px 0; border-bottom: 1px solid var(--border); }
  #course-nav .course-module h3::after { content: ' ▾'; color: var(--muted); }
}

/* edit proposals */
.pencil { margin: 8px 14px 12px; font-size: 12px; padding: 3px 9px; color: var(--muted); background: transparent; border-color: transparent; }
.pencil:hover { color: var(--accent); border-color: var(--border); }
.editor-box { margin: 10px 0; }
.ed-label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.ed-fmt { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 6px; }
.ed-fmt .chip { font-family: var(--mono); font-size: 12px; padding: 3px 9px; border-color: var(--border); }
.ed-fmt .chip:hover { border-color: var(--accent); color: var(--accent); }
.ed-fmt .muted { font-size: 12px; }
.ed-fmt code { background: var(--code-bg); padding: 0 4px; border-radius: 3px; font-family: var(--mono); }
.ed-field, .ed-note, .ed-term { width: 100%; box-sizing: border-box; background: var(--code-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: 13px/1.45 var(--mono); }
.ed-note, .ed-term { font-family: var(--font); font-size: 14px; }
.ed-term { margin-bottom: 8px; }
.proposal { border: 1px solid var(--border); border-radius: 8px; margin: 6px 0; background: var(--panel-2); }
.proposal summary { cursor: pointer; padding: 8px 12px; font-size: 14px; }
.proposal > div, .proposal > pre, .proposal > p { margin-left: 12px; margin-right: 12px; }
pre.diff { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.d-del { color: var(--bad); } .d-add { color: var(--good); }
.edit-hist { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.edit-hist li { padding: 4px 0; border-top: 1px solid var(--border); }
.track-link.logout { border-style: solid; }

/* question cards: the text is selectable, the arrow folds the card */
details.q > summary { cursor: text; list-style: none; }   /* the text is selectable; the arrow button opens the card. Nested spoilers keep the pointer */
details.q > summary::-webkit-details-marker { display: none; }
details.q > summary > span:last-of-type { user-select: text; }
.dtoggle { margin-left: auto; flex-shrink: 0; align-self: flex-start; background: transparent; border-color: transparent; color: var(--muted); padding: 0 8px; font-size: 16px; line-height: 1.2; cursor: pointer; }
.dtoggle:hover { color: var(--accent); border-color: var(--border); }
details.q[open] > summary .dtoggle { color: var(--accent); }

/* glossary: abbreviations with a tap-card */
abbr.gl { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: var(--accent); cursor: help; }
.gl-pop { position: absolute; z-index: 60; max-width: min(420px, calc(100vw - 24px)); background: var(--panel); color: var(--text); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.45; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.gl-pop b { color: var(--accent); }
.gl-pop .gl-full { display: block; font-weight: 600; margin-bottom: 4px; }
.gl-list { columns: 2; column-gap: 24px; }
.gl-list li { break-inside: avoid; margin: 0 0 8px; font-size: 14px; }
.gl-list b { color: var(--accent); }
.gl-list li .pencil { margin: 0 0 0 4px; padding: 0 6px; }
.gl-pop .gl-edit { display: block; margin: 8px 0 0; font-size: 12px; padding: 3px 9px; color: var(--muted); background: transparent; border-color: var(--border); }
.gl-add { position: absolute; z-index: 61; font-size: 13px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--accent); background: var(--panel); color: var(--accent); cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.3); max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .gl-list { columns: 1; } }
.edits-pin { margin-left: 8px; font-size: 12px; font-weight: 600; color: #fff; background: var(--accent); text-decoration: none; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }

/* the test after a lesson */
.qz-q { font-size: 17px; font-weight: 600; }
.qz-opts { display: grid; gap: 8px; margin: 8px 0 12px; }
.qz-opt { text-align: left; padding: 10px 14px; font-size: 15px; line-height: 1.4; white-space: normal; }
.qz-opt.ok { border-color: var(--good); color: var(--good); font-weight: 600; }
.qz-opt.bad { border-color: var(--bad); color: var(--bad); }
.qz-opt.off { opacity: .55; }
.qz-opt:disabled { cursor: default; }
.qz-why { border-left: 3px solid var(--border); padding: 8px 12px; margin: 0 0 10px; background: var(--panel-2); border-radius: 6px; }
.qz-why.ok { border-left-color: var(--good); }
.qz-why.bad { border-left-color: var(--bad); }
.qz-miss { border-top: 1px solid var(--border); padding: 8px 0; }
.qz-miss p { margin: 0 0 4px; }
.qz-delta { font-weight: 600; }
.qz-delta.good { color: var(--good); }
.qz-delta.bad { color: var(--bad); }
.qz-trend { margin: 12px 0 4px; }
/* up to 30 attempts are kept, so the row scrolls inside itself instead of pushing the page */
.qz-bars { display: flex; align-items: flex-end; gap: 5px; height: 76px; padding-top: 18px; overflow-x: auto; }
.qz-bar { position: relative; flex: 0 0 auto; width: 26px; background: var(--bad); border-radius: 3px 3px 0 0; opacity: .85; }
.qz-bar.ok { background: var(--good); }
.qz-bar i { position: absolute; top: -17px; left: 0; right: 0; text-align: center; font-size: 12px; font-style: normal; color: var(--muted); }

/* numbered steps in answers */
.md ol { margin: 0 0 10px; padding-left: 24px; }
.md .tbl { overflow-x: auto; margin: 0 0 10px; }
.md table { border-collapse: collapse; font-size: 0.93em; min-width: 60%; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--code-bg); font-weight: 600; }
.md ol li { margin: 3px 0; }
/* the "Зачем" takeaway of an answer: a box at the top, so the reader knows what the theory is for before the details */
.md .why { border-left: 3px solid var(--accent); background: var(--panel-2); border-radius: 0 8px 8px 0; padding: 8px 12px 2px; margin: 0 0 14px; }
.md .why h4 { margin-top: 0; }
.md .why p { margin: 0 0 8px; }
/* the self-check step of a lesson is read-only on the working gear */
.badge.ro { color: var(--good); border-color: var(--good); text-transform: none; letter-spacing: 0; font-weight: 400; vertical-align: middle; }
/* the deep part of a theory ("Подробнее…") stays folded until the reader wants it */
.md details.deep { border: 1px dashed var(--border); border-radius: 8px; padding: 4px 12px; margin: 0 0 12px; }
.md details.deep > summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; padding: 4px 0; list-style: none; }
.md details.deep > summary::before { content: '▸ '; }
.md details.deep[open] > summary::before { content: '▾ '; }
.md details.deep[open] > summary { margin-bottom: 6px; }
