/* =============================================================================================
   Git Course — design system (see DESIGN.md; change the spec first, then this file)
   Sections: 1 Tokens · 2 Reset/base · 3 Layout · 4 Components · 5 Diagrams · 6 Utilities ·
             7 Responsive · 8 Motion · 9 Print
   ============================================================================================= */

/* 1. Tokens ---------------------------------------------------------------------------------- */
:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-alt: #F1F3F7;
  --border: #DDE1E8;
  --border-strong: #B9C0CC;
  --text: #1B2230;
  --text-muted: #4B5563;
  --text-faint: #6B7280;

  --accent: #2B47B8;
  --accent-hover: #1F3590;
  --accent-soft: #E8EDFB;
  --accent-border: #C9D4F5;

  --tip-bg: #ECFDF3;     --tip-border: #86EFAC;     --tip-text: #14532D;
  --note-bg: #EFF4FF;    --note-border: #BFD3FF;    --note-text: #1E3A8A;
  --warn-bg: #FFF7E6;    --warn-border: #F2C266;    --warn-text: #663C00;
  --danger-bg: #FEF2F2;  --danger-border: #FCA5A5;  --danger-text: #7F1D1D;
  --define-bg: #F5F3FF;  --define-border: #C4B5FD;  --define-text: #3B2A7A;
  --analogy-bg: #ECFEFF; --analogy-border: #67E8F9; --analogy-text: #155E75;
  --example-bg: #F1F3F7; --example-border: #CBD2DE; --example-text: #1B2230;
  --hood-bg: #F3F4F6;    --hood-border: #9CA3AF;    --hood-text: #1B2230;

  --code-bg: #F5F7FA;
  --code-border: #DDE1E8;
  --code-text: #1B2230;
  --code-prompt: #6B7280;
  --code-output-bg: #FBFBFC;
  --code-inline-bg: #EEF1F6;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --r-sm: 6px; --r-md: 10px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .10);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .12);
  --topbar-h: 60px;
  --sidebar-w: 280px;
  --outline-w: 220px;
  --content-w: 760px;
  --ease: 150ms ease;
}

/* 2. Reset and base -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.25; color: var(--text); font-weight: 700; margin: 0 0 .6em; overflow-wrap: anywhere; }
h1 { font-size: 2rem; margin-top: .2em; }
h2 { font-size: 1.5rem; margin-top: 2.2em; padding-top: .7em; border-top: 1px solid var(--border); }
h3 { font-size: 1.2rem; font-weight: 600; margin-top: 1.6em; }
h4 { font-size: 1.05rem; font-weight: 600; margin-top: 1.4em; }
p, ul, ol, blockquote, figure { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.5em; }
li { margin-bottom: .35em; }
li > ul, li > ol { margin-top: .35em; margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover, a:focus-visible { text-decoration: underline; }
strong { font-weight: 600; }
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s6) 0; }
blockquote { margin: var(--s4) 0; padding: var(--s2) var(--s4); border-left: 4px solid var(--border-strong); color: var(--text-muted); background: var(--surface-alt); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
blockquote p:last-child { margin-bottom: 0; }
code, kbd, pre, samp, var { font-family: var(--mono); }
code { font-size: .92em; background: var(--code-inline-bg); border-radius: var(--r-sm); padding: .1em .35em; color: var(--code-text); }
pre { margin: 0; }
pre code { font-size: .92em; background: none; padding: 0; border-radius: 0; line-height: 1.55; }
kbd { font-size: .8em; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--text); white-space: nowrap; }
var { font-style: italic; color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
button { font-family: inherit; font-size: inherit; }
details > summary { cursor: pointer; }
.visually-hidden, .skip-link { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; top: 8px; left: 8px; width: auto; height: auto; clip: auto; clip-path: none; z-index: 1000; padding: 10px 14px; background: var(--surface); border: 2px solid var(--accent); border-radius: var(--r-sm); font-weight: 600; }

/* 3. Layout ---------------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 500;
  display: flex; align-items: center; gap: var(--s4);
  height: var(--topbar-h); padding: 0 var(--s5);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar__menu { display: none; width: 40px; height: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-sm); cursor: pointer; flex-direction: column; justify-content: center; align-items: center; gap: 4px; padding: 0; }
.topbar__menu span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }
.topbar__brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); white-space: nowrap; }
.topbar__brand:hover { text-decoration: none; color: var(--accent); }
.topbar__logo { width: 30px; height: 30px; }
.topbar__search { position: relative; flex: 1 1 auto; max-width: 520px; margin: 0 auto; }
.topbar__search-input {
  width: 100%; height: 40px; padding: 0 14px 0 38px; font: inherit; font-size: .95rem; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-pill); background: var(--surface-alt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234B5563' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center / 18px;
}
.topbar__search-input:focus { background-color: var(--surface); border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar__tool select { height: 40px; padding: 0 32px 0 12px; font: inherit; font-size: .9rem; font-weight: 500; color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231B2230' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; appearance: none; -webkit-appearance: none; cursor: pointer; }
.topbar__progress { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.topbar__progress:hover { text-decoration: none; color: var(--accent); }
.topbar__progress-bar { display: inline-block; width: 80px; height: 8px; border-radius: var(--r-pill); background: var(--surface-alt); border: 1px solid var(--border); overflow: hidden; }
.topbar__progress-bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--ease); }

.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--outline-w); max-width: 1440px; margin: 0 auto; }

.sidebar { border-right: 1px solid var(--border); background: var(--surface); }
.sidebar__inner { position: sticky; top: var(--topbar-h); max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: var(--s4) 0 var(--s6); }
.sidebar__home { display: block; padding: 8px 16px; font-weight: 600; font-size: .92rem; color: var(--text); border-left: 3px solid transparent; }
.sidebar__home:hover { background: var(--surface-alt); text-decoration: none; }
.sidebar__home--current { color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent); }
.sidebar__group-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 20px 16px 6px; padding: 0; border: 0; }
.sidebar__section { border: 0; }
.sidebar__summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 7px 16px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--text); user-select: none; }
.sidebar__summary::-webkit-details-marker { display: none; }
.sidebar__summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint); transform: rotate(-45deg); margin-left: 4px; transition: transform var(--ease); flex: none; }
.sidebar__section[open] > .sidebar__summary::after { transform: rotate(45deg); }
.sidebar__summary:hover { background: var(--surface-alt); }
.sidebar__num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-alt); color: var(--text-muted); font-size: .72rem; font-weight: 700; flex: none; }
.sidebar__section--current .sidebar__num { background: var(--accent-soft); color: var(--accent); }
.sidebar__section-title { flex: 1 1 auto; }
.sidebar__count { font-size: .72rem; font-weight: 500; color: var(--text-faint); }
.sidebar__list { list-style: none; margin: 0 0 6px; padding: 0; }
.sidebar__list li { margin: 0; }
.sidebar__link { display: flex; align-items: flex-start; gap: 8px; padding: 6px 16px 6px 30px; font-size: .88rem; line-height: 1.45; color: var(--text); border-left: 3px solid transparent; }
.sidebar__link:hover { background: var(--surface-alt); text-decoration: none; }
.sidebar__link[aria-current="page"] { background: var(--accent-soft); border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.sidebar__tick { position: relative; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; margin-top: 5px; background: var(--surface); }
.is-done > .sidebar__tick { background: #15803D; border-color: #15803D; }
.is-done > .sidebar__tick::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 7px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg); }

.content { width: 100%; max-width: calc(var(--content-w) + 2 * var(--s7)); margin: 0 auto; padding: var(--s6) var(--s7) var(--s7); min-width: 0; }
.content--home { max-width: 1160px; }
.lesson-body > :first-child { margin-top: 0; }
.lesson-body > h2:first-child { border-top: 0; padding-top: 0; }

.outline { padding: var(--s6) var(--s4) var(--s6) 0; }
.outline__inner { position: sticky; top: calc(var(--topbar-h) + var(--s5)); font-size: .85rem; max-height: calc(100vh - var(--topbar-h) - var(--s6)); overflow-y: auto; }
.outline__title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 0 0 8px; }
.outline ul { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.outline li { margin: 0; }
.outline a { display: block; padding: 4px 12px; color: var(--text-muted); border-left: 2px solid transparent; margin-left: -2px; line-height: 1.4; }
.outline a:hover { color: var(--accent); text-decoration: none; }
.outline a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.outline a[data-level="3"] { padding-left: 24px; font-size: .8rem; }
.outline:has(ul:empty) { visibility: hidden; }

.footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: var(--s6); }
.footer__inner { max-width: 1440px; margin: 0 auto; padding: var(--s5) var(--s6); font-size: .88rem; }
.footer__links { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 8px; font-weight: 500; }
.footer__note { margin: 0; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(27, 34, 48, .45); z-index: 600; }

/* 4. Components ------------------------------------------------------------------------------ */
.breadcrumb { font-size: .85rem; color: var(--text-muted); margin-bottom: var(--s4); overflow-wrap: anywhere; }
.breadcrumb__sep { color: var(--text-faint); }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 500; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; line-height: 1.5; padding: 2px 10px; border-radius: var(--r-pill); white-space: nowrap; vertical-align: middle; }
.badge--level-beginner { color: #166534; background: #DCFCE7; }
.badge--level-intermediate { color: #1E40AF; background: #DBEAFE; }
.badge--level-advanced { color: #92400E; background: #FEF3C7; }
.badge--level-expert { color: #5B21B6; background: #EDE9FE; }
.badge--stab-core, .badge--stab-cli { color: #1B2230; background: #E5E7EB; }
.badge--stab-gitlab { color: #9A3412; background: #FFEDD5; }
.badge--stab-github { color: #24292F; background: #E7E9EE; }
.badge--stab-vscode { color: #0F5EA8; background: #E1EFFB; }
.badge--stab-intellij { color: #9D174D; background: #FCE7F3; }
.badge--safe { color: var(--tip-text); background: var(--tip-bg); border: 1px solid var(--tip-border); }
.badge--careful { color: var(--warn-text); background: var(--warn-bg); border: 1px solid var(--warn-border); }
.badge--dangerous { color: var(--danger-text); background: var(--danger-bg); border: 1px solid var(--danger-border); }
.lesson-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 var(--s5); }
.meta-time { font-size: .85rem; color: var(--text-muted); }

.lesson-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); padding: var(--s4) var(--s5); background: var(--surface-alt); border-radius: var(--r-md); margin: 0 0 var(--s6); }
.lesson-meta__title { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 6px; padding: 0; border: 0; }
.lesson-meta ul { margin: 0; padding-left: 18px; font-size: .92rem; }
.lesson-meta li { margin-bottom: .25em; }

.callout { position: relative; border-left: 4px solid; border-radius: var(--r-md); padding: 14px 18px; margin: var(--s5) 0; }
.callout__title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 0 0 6px; }
.callout__title svg { width: 18px; height: 18px; flex: none; }
.callout > :last-child { margin-bottom: 0; }
.callout--tip { background: var(--tip-bg); border-color: var(--tip-border); color: var(--tip-text); }
.callout--note { background: var(--note-bg); border-color: var(--note-border); color: var(--note-text); }
.callout--warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.callout--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.callout--define { background: var(--define-bg); border-color: var(--define-border); color: var(--define-text); }
.callout--analogy { background: var(--analogy-bg); border-color: var(--analogy-border); color: var(--analogy-text); }
.callout--example { background: var(--example-bg); border-color: var(--example-border); color: var(--example-text); }
.callout--hood { background: var(--hood-bg); border-color: var(--hood-border); color: var(--hood-text); }
.callout--hood .callout__title { font-family: var(--mono); font-size: .9rem; }
.callout code { background: rgba(255, 255, 255, .7); }
.callout h3, .callout h4 { color: inherit; margin-top: .8em; }

.tabs { border: 1px solid var(--border); border-radius: var(--r-md); margin: var(--s5) 0; background: var(--surface); }
.tabs__list { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--border); background: var(--surface-alt); border-radius: var(--r-md) var(--r-md) 0 0; }
.tabs__tab { border: 1px solid transparent; border-bottom: 0; background: transparent; padding: 8px 14px; margin-bottom: -1px; border-radius: 8px 8px 0 0; font-weight: 500; font-size: .92rem; color: var(--text-muted); cursor: pointer; }
.tabs__tab:hover { color: var(--text); background: rgba(255, 255, 255, .6); }
.tabs__tab[aria-selected="true"] { background: var(--surface); color: var(--accent); border-color: var(--border); font-weight: 600; }
.tabs__panel { padding: var(--s4) var(--s5); }
.tabs__panel > :first-child { margin-top: 0; }
.tabs__panel > :last-child { margin-bottom: 0; }
.tabs__panel .code:first-child { margin-top: 0; }

.code { position: relative; margin: var(--s4) 0; border: 1px solid var(--code-border); border-radius: var(--r-md); background: var(--code-bg); overflow: hidden; }
.code__caption { font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); padding: 6px 12px; background: var(--surface-alt); border-bottom: 1px solid var(--code-border); }
.code pre { padding: 12px 14px; overflow-x: auto; }
.code pre code { color: var(--code-text); }
.code__prompt { color: var(--code-prompt); user-select: none; }
.code__copy { position: absolute; top: 3px; right: 6px; height: 24px; padding: 0 10px; font-size: .74rem; font-weight: 600; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; }
.code__copy:hover { color: var(--accent); border-color: var(--accent-border); }
.code__copy.is-copied { color: var(--tip-text); border-color: var(--tip-border); background: var(--tip-bg); }
.code__output { border-top: 1px dashed var(--border-strong); background: var(--code-output-bg); white-space: pre-wrap; overflow-wrap: anywhere; }
.code__output code { color: var(--text-muted); }
.code__output::before { content: "Output"; display: block; font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 4px; }
.code--output-only .code__output { border-top: 0; }
.code--output-only .code__output::before { display: none; }

ol.steps { list-style: none; counter-reset: step; padding: 0; margin: var(--s4) 0; }
ol.steps > li { position: relative; padding-left: 44px; margin-bottom: 12px; counter-increment: step; min-height: 28px; }
ol.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: center; }
ol.steps > li > :last-child { margin-bottom: 0; }
ol.steps .code { margin: 10px 0; }

.dodont { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin: var(--s5) 0; }
.dodont__do, .dodont__dont { border-radius: var(--r-md); padding: 14px 18px; border: 1px solid; }
.dodont__do { background: var(--tip-bg); border-color: var(--tip-border); }
.dodont__dont { background: var(--danger-bg); border-color: var(--danger-border); }
.dodont h3 { margin: 0 0 8px; font-size: 1rem; }
.dodont__do h3 { color: var(--tip-text); }
.dodont__dont h3 { color: var(--danger-text); }
.dodont ul { list-style: none; padding: 0; margin: 0; }
.dodont li { position: relative; padding-left: 24px; margin-bottom: 6px; }
.dodont li::before { position: absolute; left: 0; font-weight: 700; }
.dodont__do li::before { content: "✓"; color: var(--tip-text); }
.dodont__dont li::before { content: "✕"; color: var(--danger-text); }

.exercise { border: 1px solid var(--accent-border); background: var(--surface); border-radius: var(--r-md); padding: var(--s5); margin: var(--s6) 0; box-shadow: var(--shadow-sm); }
.exercise > h2 { margin-top: 0; padding-top: 0; border: 0; font-size: 1.3rem; }
.exercise > h2::before { content: "▶"; font-size: .7em; color: var(--accent); margin-right: 8px; vertical-align: 2px; }
.exercise > :last-child { margin-bottom: 0; }
.solution, .details { border: 1px dashed var(--border-strong); border-radius: var(--r-md); margin: var(--s4) 0; background: var(--surface); }
.solution > summary, .details > summary { padding: 10px 14px; font-weight: 600; color: var(--accent); list-style: none; display: flex; align-items: center; gap: 8px; }
.solution > summary::-webkit-details-marker, .details > summary::-webkit-details-marker { display: none; }
.solution > summary::before, .details > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform var(--ease); }
.solution[open] > summary::before, .details[open] > summary::before { transform: rotate(45deg); }
.solution__body, .details__body { padding: 0 14px 14px; }
.solution__body > :last-child, .details__body > :last-child { margin-bottom: 0; }

.quiz { background: var(--surface-alt); border-radius: var(--r-md); padding: var(--s5); margin: var(--s6) 0; }
.quiz > h2 { margin-top: 0; padding-top: 0; border: 0; font-size: 1.3rem; }
.quiz__q { border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; margin: 0 0 14px; min-width: 0; }
.quiz__q legend { font-weight: 600; padding: 0; margin-bottom: 8px; float: left; width: 100%; }
.quiz__q legend + * { clear: both; }
.quiz__option { display: flex; align-items: flex-start; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.quiz__option:hover { background: var(--surface-alt); }
.quiz__option input { margin: 5px 0 0; accent-color: var(--accent); flex: none; }
.quiz__q--right { border-color: var(--tip-border); background: var(--tip-bg); }
.quiz__q--wrong { border-color: var(--danger-border); background: var(--danger-bg); }
.quiz__q--right legend::after { content: " — correct"; color: var(--tip-text); font-weight: 600; }
.quiz__q--wrong legend::after { content: " — not quite"; color: var(--danger-text); font-weight: 600; }
.quiz__explain { clear: both; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-strong); font-size: .95rem; }
.quiz__explain > :last-child { margin-bottom: 0; }
.quiz__score { font-weight: 600; margin: 0; }

a.term { color: var(--text); text-decoration: underline dotted; text-decoration-color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a.term:hover { color: var(--accent); }
.tooltip { position: absolute; z-index: 700; max-width: 320px; padding: 10px 12px; font-size: .88rem; line-height: 1.5; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-md); }
.tooltip__term { display: block; font-weight: 700; margin-bottom: 2px; }
.tooltip__more { display: block; margin-top: 6px; font-size: .8rem; }

.keyterms { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin: var(--s6) 0 var(--s4); padding-top: var(--s5); border-top: 1px solid var(--border); }
.keyterms__title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 8px; padding: 0; border: 0; }
.keyterms__list { margin: 0; }
.keyterms__list a.term { display: inline-block; margin: 0 8px 8px 0; padding: 3px 10px; background: var(--accent-soft); color: var(--accent-hover); border-radius: var(--r-pill); font-size: .88rem; font-weight: 500; text-decoration: none; }
.keyterms__related { margin: 0; padding-left: 18px; font-size: .92rem; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: .95rem; line-height: 1.2; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--done { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--done::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong); }
.btn--done.is-done { background: var(--tip-bg); border-color: var(--tip-border); color: var(--tip-text); }
.btn--done.is-done::before { background: #15803D; border-color: #15803D; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E"); background-size: 12px; background-position: center; background-repeat: no-repeat; }
.btn--lg { padding: 14px 24px; font-size: 1.05rem; }
.done-row { margin: var(--s6) 0 0; }

.pager { display: flex; justify-content: space-between; gap: var(--s4); margin: var(--s7) 0 var(--s4); }
.pager__prev, .pager__next, .pager__spacer { flex: 1 1 0; min-width: 0; }
.pager__prev, .pager__next { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); }
.pager__prev:hover, .pager__next:hover { border-color: var(--accent-border); text-decoration: none; box-shadow: var(--shadow-sm); }
.pager__next { text-align: right; }
.pager__label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.pager__prev .pager__label::before { content: "← "; }
.pager__next .pager__label::after { content: " →"; }
.pager__title { font-weight: 600; color: var(--accent); }

.table-wrap { overflow-x: auto; margin: var(--s5) 0; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { background: var(--surface-alt); font-weight: 600; border-bottom: 2px solid var(--border-strong); }
tr:last-child td { border-bottom: 0; }
.table--zebra tbody tr:nth-child(even) td { background: var(--surface-alt); }

.section-list { list-style: none; padding: 0; margin: var(--s4) 0; }
.section-list li { margin: 0 0 8px; }
.section-list__link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); }
.section-list__link:hover { border-color: var(--accent-border); text-decoration: none; box-shadow: var(--shadow-sm); }
.section-list__link .sidebar__tick { margin-top: 0; }
.section-list__title { font-weight: 600; flex: 1 1 auto; }
.section-list__meta { display: flex; align-items: center; gap: 10px; font-size: .85rem; white-space: nowrap; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s4); margin: var(--s5) 0; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-sm); color: var(--text); }
.card:hover { border-color: var(--accent-border); text-decoration: none; box-shadow: var(--shadow-md); }
.card__num { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .9rem; }
.card__title { font-weight: 700; font-size: 1.02rem; line-height: 1.3; }
.card__meta { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: .82rem; }
.card__text { color: var(--text-muted); font-size: .92rem; margin: 0; }
.card__progress { display: block; height: 6px; border-radius: var(--r-pill); background: var(--surface-alt); overflow: hidden; margin-top: auto; }
.card__progress > span { display: block; height: 100%; background: #15803D; width: 0; }
.card--role .card__title { color: var(--accent-hover); }

.hero { padding: var(--s5) 0 var(--s6); }
.hero h1 { font-size: 2.6rem; line-height: 1.12; margin: 0 0 14px; letter-spacing: -.01em; }
.hero__lead { font-size: 1.2rem; color: var(--text-muted); max-width: 680px; margin: 0 0 20px; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.home h2 { border-top: 0; padding-top: 0; margin-top: 1.6em; }
.checklist { list-style: none; padding: 0; }
.checklist li { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.checklist input { margin-top: 6px; flex: none; accent-color: #15803D; }
.checklist__text { flex: 1 1 auto; min-width: 0; }
.checklist li.is-checked { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }

.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-md); max-height: 70vh; overflow-y: auto; padding: 6px; z-index: 800; }
.search-results__item { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.search-results__item:hover, .search-results__item[aria-selected="true"] { background: var(--accent-soft); text-decoration: none; }
.search-results__kind { display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; background: var(--surface-alt); color: var(--text-muted); margin-right: 6px; vertical-align: 1px; }
.search-results__title { font-weight: 600; }
.search-results__section { color: var(--text-faint); font-size: .8rem; margin-left: 6px; }
.search-results__snippet { display: block; font-size: .84rem; color: var(--text-muted); margin-top: 2px; }
.search-results__empty { padding: 10px; color: var(--text-muted); font-size: .9rem; }
.search-results mark { background: #FDE68A; color: inherit; padding: 0 1px; border-radius: 2px; }

.progress-panel__summary { font-size: 1.1rem; font-weight: 600; }
.progress-panel__sections { display: grid; gap: 10px; margin: var(--s4) 0 var(--s5); }
.progress-row { display: grid; grid-template-columns: 1fr 140px 60px; align-items: center; gap: 12px; font-size: .92rem; }
.progress-row__bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-alt); border: 1px solid var(--border); overflow: hidden; }
.progress-row__bar > span { display: block; height: 100%; background: #15803D; }
.progress-panel__data { width: 100%; font-family: var(--mono); font-size: .8rem; padding: 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin: var(--s4) 0; }
.columns__col > :first-child { margin-top: 0; }
.simulator { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); padding: var(--s4); margin: var(--s5) 0; }
.simulator__loading { margin: 0; color: var(--text-muted); }
.sim__bar { display: flex; align-items: center; gap: 8px; margin-bottom: var(--s3); flex-wrap: wrap; }
.sim__branch { font-family: var(--mono); font-size: .82rem; color: var(--accent); font-weight: 600; }
.sim__spacer { flex: 1 1 auto; }
.sim__btn { height: 30px; padding: 0 12px; font-size: .82rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm); cursor: pointer; }
.sim__btn:hover { border-color: var(--accent); color: var(--accent); }
.sim__btn--primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.sim__btn--primary:hover { color: #fff; background: var(--accent-dark, #22399A); }
.sim__areas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: var(--s3); }
.sim__area { border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-alt); padding: 8px 10px; min-width: 0; }
.sim__area h4 { margin: 0 0 6px; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.sim__area ul { margin: 0; padding-left: 16px; font-family: var(--mono); font-size: .76rem; overflow-wrap: anywhere; }
.sim__empty { margin: 0; font-size: .78rem; color: var(--text-muted); }
.sim__graph { overflow-x: auto; margin-bottom: var(--s3); }
.sim__svg { min-width: 320px; height: 92px; }
.sim__out { margin: 0 0 var(--s3); padding: 10px 12px; max-height: 240px; overflow: auto; font-family: var(--mono); font-size: .78rem; line-height: 1.5; white-space: pre-wrap; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--r-sm); color: var(--code-text); }
.sim__cmd { color: var(--accent); font-weight: 600; }
.sim__out div:empty { height: .8em; }
.sim__form { display: flex; gap: 8px; }
.sim__input { flex: 1 1 auto; min-width: 0; height: 34px; padding: 0 10px; font-family: var(--mono); font-size: .82rem; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm); }
.sim__input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sim__note { margin: var(--s3) 0 0; font-size: .85rem; color: var(--text-muted); }
.resolver__head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s3); }
.resolver__file { font-family: var(--mono); font-size: .82rem; font-weight: 600; color: var(--text); }
.resolver__state { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--danger-text, #7F1D1D); background: var(--danger-bg, #FEF2F2); border: 1px solid var(--danger-border, #FCA5A5); border-radius: var(--r-pill); padding: 2px 8px; }
.resolver__view { margin: 0 0 var(--s3); padding: 10px 12px; font-family: var(--mono); font-size: .78rem; line-height: 1.55; white-space: pre-wrap; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--r-sm); color: var(--code-text); overflow-x: auto; }
.resolver__line--marker { color: var(--text-muted); }
.resolver__line--ours { background: #FFF7E6; }
.resolver__line--base { background: var(--surface-alt); color: var(--text-muted); }
.resolver__line--theirs { background: #E8EDFB; }
.resolver__line--kept { background: #ECFDF3; }
.resolver__bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--s3); }
.resolver__btn { height: 30px; padding: 0 12px; font-size: .82rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm); cursor: pointer; }
.resolver__btn:hover { border-color: var(--accent); color: var(--accent); }
.resolver__btn--primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.resolver__btn--primary:hover { color: #fff; background: var(--accent-dark, #22399A); }
.resolver__textarea { width: 100%; font-family: var(--mono); font-size: .8rem; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); }
.resolver__hint, .resolver__verdict { margin: 0 0 var(--s2); font-size: .85rem; color: var(--text-muted); }
.resolver__verdict { color: var(--text); font-weight: 600; }
.staging__hint { margin: 0 0 var(--s3); font-size: .85rem; color: var(--text-muted); }
.staging__areas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: var(--s3); }
.staging__area { border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-alt); padding: 8px 10px; min-width: 0; }
.staging__area h4 { margin: 0 0 2px; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.staging__sub { margin: 0 0 8px; font-size: .75rem; color: var(--text-muted); }
.staging__empty { margin: 0; font-size: .78rem; color: var(--text-muted); }
.staging__file { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; margin-bottom: 6px; padding: 6px 8px; font-family: var(--mono); font-size: .76rem; text-align: left; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm); cursor: pointer; overflow-wrap: anywhere; }
.staging__file:hover { border-color: var(--accent); color: var(--accent); }
.staging__mark { flex: none; font-family: var(--sans); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.staging__out { margin: 0 0 var(--s3); padding: 10px 12px; font-family: var(--mono); font-size: .78rem; white-space: pre-wrap; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--r-sm); color: var(--code-text); }
.staging__bar { display: flex; gap: 8px; flex-wrap: wrap; }
.staging__btn { height: 30px; padding: 0 12px; font-size: .82rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm); cursor: pointer; }
.staging__btn:hover { border-color: var(--accent); color: var(--accent); }
.staging__btn--primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.staging__btn--primary:hover { color: #fff; background: var(--accent-dark, #22399A); }
@media (max-width: 599px) { .staging__areas { grid-template-columns: 1fr; } }
.resolver__cmds { margin: var(--s2) 0; padding: 10px 12px; font-family: var(--mono); font-size: .78rem; white-space: pre-wrap; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--r-sm); color: var(--code-text); }
@media (max-width: 959px) { .sim__areas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 599px) { .sim__areas { grid-template-columns: 1fr; } }
.directive-unknown { border: 1px dashed var(--danger-border); padding: 8px; }
.problem { padding-bottom: var(--s4); }
.glossary dt { font-weight: 700; font-size: 1.1rem; margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--border); scroll-margin-top: 80px; }
.glossary dd { margin: 6px 0 0; }
.glossary__short { font-weight: 500; }
.glossary__also { font-weight: 400; font-size: .9rem; }
.glossary__related { font-size: .9rem; color: var(--text-muted); }
.alpha-nav { display: flex; flex-wrap: wrap; gap: 4px; margin: var(--s4) 0; }
.alpha-nav a { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 6px; border: 1px solid var(--border); border-radius: var(--r-sm); font-weight: 600; font-size: .85rem; }
.alpha-nav a:hover { border-color: var(--accent); text-decoration: none; }

/* 5. Diagrams -------------------------------------------------------------------------------- */
.diagram { margin: var(--s5) 0; padding: var(--s4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); text-align: center; }
.diagram svg { display: block; width: 100%; height: auto; max-width: 760px; margin: 0 auto; font-family: var(--sans); }
.diagram figcaption { font-size: .88rem; color: var(--text-muted); margin-top: 10px; text-align: left; }
.diagram__missing { padding: var(--s5); border: 1px dashed var(--border-strong); border-radius: var(--r-sm); color: var(--text-muted); }

/* 6. Utilities ------------------------------------------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-small { font-size: .88rem; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.nowrap { white-space: nowrap; }

/* 7. Responsive ------------------------------------------------------------------------------ */
@media (max-width: 1279px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .outline { display: none; }
}
@media (max-width: 959px) {
  html { font-size: 16px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px var(--s4); row-gap: 10px; }
  .topbar__menu { display: flex; order: 0; }
  .topbar__brand { order: 1; flex: 1 1 auto; }
  .topbar__progress { order: 2; }
  .topbar__search { order: 3; flex: 1 1 100%; max-width: none; margin: 0; }
  .topbar__tool { order: 4; flex: 1 1 100%; }
  .topbar__tool select { width: 100%; }
  .layout { display: block; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); z-index: 700; transform: translateX(-100%); transition: transform 200ms ease; box-shadow: none; border-right: 1px solid var(--border); }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-md); }
  .sidebar__inner { position: static; max-height: 100vh; height: 100%; }
  .content { padding: var(--s5) var(--s4) var(--s6); }
  .content--home { padding: var(--s4); }
  .hero h1 { font-size: 2rem; }
  html { scroll-padding-top: 150px; }
}
@media (max-width: 599px) {
  .lesson-meta, .dodont, .keyterms, .columns { grid-template-columns: 1fr; }
  .pager { flex-direction: column; }
  .pager__next { text-align: left; }
  .progress-row { grid-template-columns: 1fr 50px; }
  .progress-row__bar { grid-column: 1 / -1; }
  .section-list__meta { white-space: normal; }
  .tabs__panel { padding: var(--s3) var(--s3); }
  .code pre { padding: 10px 12px; }
  .topbar__progress-bar { width: 50px; }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.3rem; }
}

/* 8. Motion ---------------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* 9. Print ----------------------------------------------------------------------------------- */
@media print {
  .topbar, .sidebar, .outline, .footer, .pager, .done-row, .code__copy, .skip-link, .drawer-backdrop, .breadcrumb, .search-results { display: none !important; }
  html { font-size: 11pt; }
  body { background: #fff; color: #000; }
  .layout { display: block; }
  .content { max-width: none; padding: 0; }
  .tabs__panel[hidden] { display: block !important; }
  .tabs__panel::before { content: attr(data-tool); display: block; font-size: .8rem; font-weight: 700; text-transform: uppercase; color: #555; margin-bottom: 6px; }
  .tabs__list { display: none; }
  details { display: block; }
  details::details-content { display: block !important; content-visibility: visible !important; }
  .solution > summary::before, .details > summary::before { display: none; }
  .quiz__explain { display: block !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; color: #555; }
  .code, .callout, .exercise, .quiz__q, .diagram { break-inside: avoid; }
  h2 { break-after: avoid; }
}
