:root {
  --bg: #fbfaf7; --panel: #f3f1ea; --fg: #22252a; --muted: #646a73; --line: #dedbd0;
  --accent: #0b6e69; --accent-soft: #dff1ef;
  --warn: #a8500a; --warn-soft: #fdf1dc;
  --deep: #6b4fa3; --deep-soft: #f0ebf9;
  --good: #2f7d32; --good-soft: #e4f3e4;
  --code-bg: #f6f4ed; --term-bg: #1d2126; --term-fg: #e6e3da; --term-accent: #7fd1c7;
  --kw: #9b2393; --ty: #0b6e69; --st: #2f7d32; --cm: #7a7f87; --nu: #a8500a; --an: #6b4fa3;
  /* Not "Cascadia Code": it draws != as a single not-equal sign, and merges >=, <=, == and ->.
     A learner must see the characters they have to type. */
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181c; --panel: #1e2126; --fg: #e4e2dc; --muted: #9aa0a8; --line: #31353c;
    --accent: #4fc3b8; --accent-soft: #17332f;
    --warn: #e2a45c; --warn-soft: #33270f;
    --deep: #b9a2e8; --deep-soft: #2a2340;
    --good: #9ccc82; --good-soft: #1d2e1c;
    --code-bg: #1e2126; --term-bg: #0f1114; --term-fg: #dcd9d0;
    --kw: #d18be0; --ty: #6fd3c7; --st: #9ccc82; --cm: #7f8791; --nu: #e2a45c; --an: #b9a2e8;
  }
}
:root[data-theme="dark"] {
  --bg: #16181c; --panel: #1e2126; --fg: #e4e2dc; --muted: #9aa0a8; --line: #31353c;
  --accent: #4fc3b8; --accent-soft: #17332f;
  --warn: #e2a45c; --warn-soft: #33270f;
  --deep: #b9a2e8; --deep-soft: #2a2340;
  --good: #9ccc82; --good-soft: #1d2e1c;
  --code-bg: #1e2126; --term-bg: #0f1114; --term-fg: #dcd9d0;
  --kw: #d18be0; --ty: #6fd3c7; --st: #9ccc82; --cm: #7f8791; --nu: #e2a45c; --an: #b9a2e8;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.68 "Segoe UI", system-ui, -apple-system, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 290px; overflow-y: auto;
  padding: 1.4rem 1rem 2rem; background: var(--panel); border-right: 1px solid var(--line);
  font-size: .9rem; line-height: 1.4;
}
.sidebar .brand { display: block; font-weight: 700; font-size: 1.05rem; color: var(--fg); text-decoration: none; margin: 0 .5rem 1.2rem; }
.sidebar h4 { margin: 1.2rem .5rem .35rem; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sidebar ol { list-style: none; margin: 0; padding: 0; }
.sidebar li a, .sidebar li.upcoming { display: flex; gap: .5rem; padding: .28rem .5rem; border-radius: 6px; color: var(--fg); text-decoration: none; }
.sidebar li a:hover { background: var(--accent-soft); }
.sidebar li.current a { background: var(--accent-soft); font-weight: 600; }
.sidebar li.upcoming { color: var(--muted); opacity: .7; }
.sidebar .num { flex: 0 0 1.5rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar li.done a::after { content: "\2713"; margin-left: auto; color: var(--good); font-weight: 700; }
.theme, .menu, .copy {
  font: inherit; font-size: .8rem; color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 6px; padding: .25rem .6rem; cursor: pointer;
}
.theme:hover, .menu:hover, .copy:hover { color: var(--fg); border-color: var(--muted); }
.theme { margin: 1.6rem .5rem 0; }
.menu { display: none; position: fixed; top: .6rem; left: .6rem; z-index: 5; background: var(--panel); color: var(--fg); }

/* ---------- page layout ---------- */
main {
  margin-left: 290px; padding: 3rem 2rem 6rem;
  display: grid; grid-template-columns: minmax(0, 46rem) 13rem; gap: 3.5rem; justify-content: center;
}
article { min-width: 0; }
.toc { position: sticky; top: 2rem; align-self: start; font-size: .84rem; line-height: 1.4; }
.toc h4 { margin: 0 0 .5rem; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: .22rem .8rem; color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--accent); }
@media (max-width: 1250px) { main { grid-template-columns: minmax(0, 46rem); } .toc { display: none; } }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 4; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .sidebar.open { transform: none; }
  .menu { display: block; }
  main { margin-left: 0; padding: 4rem 16px 4rem; }
  td { min-width: 8.5rem; }
}

/* ---------- typography ---------- */
.eyebrow { margin: 0; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
h1 { font-size: 2.3rem; line-height: 1.15; margin: .3rem 0 1.5rem; letter-spacing: -.01em; }
h1 .num { color: var(--accent); margin-right: .9rem; font-variant-numeric: tabular-nums; }
h2 { font-size: 1.55rem; line-height: 1.25; margin: 3.4rem 0 .8rem; padding-top: 1.6rem; border-top: 1px solid var(--line); }
h3 { font-size: 1.15rem; margin: 2.2rem 0 .5rem; }
p, ul, ol { margin: 0 0 1.05rem; }
li { margin-bottom: .3rem; }
.lead { font-size: 1.15rem; color: var(--muted); }
/* pre-wrap: spaces inside inline code are significant (padding, alignment) and must not collapse */
/* Whatever font is used, never merge characters in code. */
code, kbd, pre, samp, figcaption, svg.diagram text { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
code { font-family: var(--mono); font-size: .88em; background: var(--panel); padding: .1em .35em; border-radius: 4px; white-space: pre-wrap; }
kbd { font-family: var(--mono); font-size: .82em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: .05em .4em; background: var(--panel); }
table { border-collapse: collapse; margin: 1.5rem 0; font-size: .93rem; display: block; overflow-x: auto; }
th, td { text-align: left; vertical-align: top; padding: .5rem .8rem; border-bottom: 1px solid var(--line); }
th { font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.goals { background: var(--panel); border-radius: 10px; padding: 1.1rem 1.4rem .4rem; margin: 1.5rem 0; }
.goals h3 { margin-top: 0; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- code and terminal ---------- */
figure { margin: 1.5rem 0; }
figure.code, figure.terminal { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
figure figcaption {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 2.1rem;
  padding: .3rem .5rem .3rem .9rem; font: .78rem var(--mono); color: var(--muted);
  background: var(--panel); border-bottom: 1px solid var(--line);
}
pre { margin: 0; padding: .9rem 1rem; overflow-x: auto; font: .88rem/1.6 var(--mono); background: var(--code-bg); tab-size: 4; }
pre code { background: none; padding: 0; font-size: inherit; }
.line { display: inline-block; min-width: 100%; }
.line.hl { background: var(--accent-soft); }
pre.numbered .line::before {
  counter-increment: line; content: counter(line);
  display: inline-block; width: 2ch; margin-right: 1.4ch; text-align: right; color: var(--muted); opacity: .7;
  user-select: none;
}
.kw { color: var(--kw); } .ty { color: var(--ty); } .st { color: var(--st); }
.cm { color: var(--cm); font-style: italic; } .nu { color: var(--nu); } .an { color: var(--an); }
figure.terminal { border-color: var(--term-bg); }
figure.terminal figcaption { background: #2a2f36; color: #aab0b8; border-bottom-color: #2a2f36; }
figure.terminal pre { background: var(--term-bg); color: var(--term-fg); tab-size: 8; }
.pl { color: #fff; font-weight: 600; }
.prompt { color: var(--term-accent); }
.typed { color: #ffd479; font-weight: 600; }  /* what the person at the keyboard typed */
/* The same marking used in a sentence ("text highlighted like this"): on the page's light
   background the colour alone is unreadable, so give it the terminal's dark background. */
:not(pre) > .typed { background: var(--term-bg); padding: .05em .4em; border-radius: 4px; }

/* ---------- callouts ---------- */
.callout { margin: 1.6rem 0; padding: .9rem 1.2rem .1rem; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.callout::before { content: attr(data-label); display: block; margin-bottom: .3rem; font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.warn::before { color: var(--warn); }
.callout.deeper { border-color: var(--deep); background: var(--deep-soft); }
.callout.deeper::before { color: var(--deep); }
.callout.bootcamp { border-color: var(--muted); background: var(--panel); }
.callout.bootcamp::before { color: var(--muted); }
.callout code { background: color-mix(in srgb, var(--bg) 60%, transparent); }

/* ---------- predict ---------- */
.predict { margin: 1.8rem 0; padding: 1rem 1.2rem; border: 1.5px dashed var(--accent); border-radius: 10px; }
.predict .tag { display: inline-block; margin-bottom: .5rem; padding: .05rem .6rem; border-radius: 99px; background: var(--accent); color: var(--bg); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.predict .q > :last-child { margin-bottom: .6rem; }
details > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details[open] > summary { margin-bottom: .6rem; }
.predict details > :last-child { margin-bottom: 0; }

/* ---------- exercises ---------- */
.exercise { margin: 2rem 0; padding: 1.2rem 1.4rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.exercise header { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.exercise h3 { margin: 0; flex: 1 1 auto; }
.exercise code { background: var(--bg); }
.exercise figure.code, .exercise figure.terminal { background: var(--bg); }
.badge { padding: .1rem .6rem; border-radius: 99px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.badge.warm-up { background: var(--good-soft); color: var(--good); }
.badge.core { background: var(--accent-soft); color: var(--accent); }
.badge.stretch { background: var(--deep-soft); color: var(--deep); }
.done { font-size: .85rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.done input { accent-color: var(--accent); width: 1rem; height: 1rem; vertical-align: -2px; }
.workdir { margin: .5rem 0 1rem; font-size: .88rem; color: var(--muted); }
.submit { margin: 1rem 0 0; font-size: .88rem; color: var(--muted); }
details.hint { margin: .5rem 0; padding: .5rem .8rem; border-radius: 6px; background: var(--bg); }
details.hint > :last-child { margin-bottom: 0; }
.lesson-done { display: block; margin: 3rem 0 1.5rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: 10px; font-size: 1rem; color: var(--fg); }

/* ---------- diagrams ---------- */
svg.diagram { display: block; width: 100%; height: auto; margin: 1.6rem auto; }
svg.diagram text { fill: var(--fg); font-family: "Segoe UI", system-ui, sans-serif; font-size: 14px; }
svg.diagram .small { font-size: 12px; fill: var(--muted); }
svg.diagram .mono { font-family: var(--mono); font-size: 13px; }
svg.diagram .box { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
svg.diagram .tool { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
svg.diagram .frame { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
svg.diagram .arrow { stroke: var(--muted); stroke-width: 1.8; fill: none; }
svg.diagram .head { fill: var(--muted); }
svg.diagram .hollow { fill: var(--bg); stroke: var(--muted); stroke-width: 1.5; }
svg.diagram .dashed { stroke-dasharray: 6 4; }
svg.diagram .strong { font-weight: 700; }

/* ---------- pager and index ---------- */
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.pager a { flex: 0 1 48%; padding: .8rem 1.1rem; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; font-weight: 600; }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; font-weight: 400; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pager .next { text-align: right; margin-left: auto; }
.hero h1 { font-size: 2.6rem; }
.button { display: inline-block; padding: .6rem 1.2rem; border-radius: 8px; background: var(--accent); color: var(--bg); font-weight: 600; text-decoration: none; }
.progress { margin: 2rem 0 1rem; }
.progress .bar { height: 8px; border-radius: 99px; background: var(--panel); overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress p { margin: .4rem 0 0; font-size: .85rem; color: var(--muted); }
.part-card h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: .8rem; }
.maps { font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: .1rem .6rem; }
.part-card ol { list-style: none; padding: 0; }
.part-card li { display: flex; gap: .9rem; padding: .55rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.part-card .num { flex: 0 0 1.8rem; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.part-card a { font-weight: 600; }
.part-card .sum { display: block; font-size: .88rem; color: var(--muted); }
.part-card li.upcoming { opacity: .62; }
.part-card li.done .num::after { content: " \2713"; color: var(--good); }

/* ---------- public edition: unreleased links, footer, release banner ---------- */
.later { color: var(--muted); border-bottom: 1px dotted var(--muted); cursor: help; }
.site-footer { margin-left: 290px; padding: 1.4rem 2rem 2.5rem; border-top: 1px solid var(--line); font-size: .84rem; line-height: 1.5; color: var(--muted); text-align: center; }
.site-footer p { margin: .25rem 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }
.release-banner { margin: 0 0 1.4rem; padding: .7rem 1rem; background: var(--accent-soft); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; font-size: .95rem; }
@media (max-width: 900px) { .site-footer { margin-left: 0; padding: 1.4rem 16px 2.5rem; } }
