/* ==========================================================================
   ROS 2 From Zero — interactive guide
   Shared stylesheet. No build step, no framework.
   ========================================================================== */

:root {
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-sunk: #eef0f4;
  --fg: #1b1f27;
  --fg-muted: #5a6272;
  --border: #dde1e8;
  --accent: #2563eb;
  --accent-soft: #e0e9ff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --node: #2563eb;
  --topic: #0d9488;
  --service: #9333ea;
  --action: #db2777;
  --param: #ca8a04;
  --term-bg: #0f141c;
  --term-fg: #d6dde8;
  --term-dim: #7c8798;
  --term-green: #4ade80;
  --term-blue: #60a5fa;
  --term-yellow: #facc15;
  --term-red: #f87171;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --mono: ui-monospace, "JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 280px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117; --bg-elev: #161b23; --bg-sunk: #1d232d; --fg: #e4e8ef; --fg-muted: #9aa4b5;
    --border: #2a313d; --accent: #6b9bff; --accent-soft: #1d2b4a; --ok: #4ade80; --ok-soft: #12301f;
    --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #f87171; --bad-soft: #3b1414;
    --node: #6b9bff; --topic: #2dd4bf; --service: #c084fc; --action: #f472b6; --param: #facc15;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1117; --bg-elev: #161b23; --bg-sunk: #1d232d; --fg: #e4e8ef; --fg-muted: #9aa4b5;
  --border: #2a313d; --accent: #6b9bff; --accent-soft: #1d2b4a; --ok: #4ade80; --ok-soft: #12301f;
  --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #f87171; --bad-soft: #3b1414;
  --node: #6b9bff; --topic: #2dd4bf; --service: #c084fc; --action: #f472b6; --param: #facc15;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans);
  font-size: 17px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
img, svg { max-width: 100%; }
code, kbd, pre { font-family: var(--mono); font-size: .9em; }
:not(pre) > code { background: var(--bg-sunk); padding: .1em .35em; border-radius: 4px; border: 1px solid var(--border); white-space: nowrap; }
kbd { background: var(--bg-elev); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--fg); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.topbar .brand .logo { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, #22314f, #2563eb); display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 800; }
.topbar .spacer { flex: 1; }
.topbar .progress-pill { font-size: 13px; color: var(--fg-muted); white-space: nowrap; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--fg); border-radius: 8px; height: 34px; min-width: 34px; cursor: pointer; font-size: 15px; padding: 0 8px; }
.icon-btn:hover { background: var(--bg-sunk); }
#menu-btn { display: none; }

.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar {
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; border-right: 1px solid var(--border);
  background: var(--bg-elev); padding: 16px 10px 40px;
}
.sidebar h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); margin: 18px 10px 6px; }
.sidebar a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px; text-decoration: none; color: var(--fg); font-size: 14.5px; line-height: 1.35; }
.sidebar a:hover { background: var(--bg-sunk); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .num { font-family: var(--mono); font-size: 12px; color: var(--fg-muted); width: 20px; flex: none; }
.sidebar .check { margin-left: auto; color: var(--ok); font-size: 13px; }

main { padding: 32px 48px 80px; max-width: 980px; width: 100%; }
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 56px; width: 290px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  #menu-btn { display: inline-block; }
  main { padding: 24px 16px 80px; }
  .topbar .progress-pill { display: none; }
}

/* ---------- typography ---------- */
h1 { font-size: 2.2rem; line-height: 1.2; margin: .2em 0 .4em; letter-spacing: -.02em; }
h2 { font-size: 1.55rem; margin: 2.6rem 0 .8rem; padding-top: .4rem; letter-spacing: -.01em; }
h3 { font-size: 1.2rem; margin: 1.8rem 0 .5rem; }
h2 .h-num { color: var(--fg-muted); font-weight: 500; margin-right: .3em; }
.eyebrow { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; }
.lead { font-size: 1.15rem; color: var(--fg-muted); }
.muted { color: var(--fg-muted); }
.small { font-size: .88rem; }

/* ---------- callouts ---------- */
.callout { border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--bg-elev); border-radius: var(--radius); padding: 14px 18px; margin: 1.2rem 0; }
.callout > :first-child { margin-top: 0; } .callout > :last-child { margin-bottom: 0; }
.callout .c-title { font-weight: 700; display: block; margin-bottom: 4px; }
.callout.tip { border-left-color: var(--ok); }
.callout.warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-soft) 40%, var(--bg-elev)); }
.callout.analogy { border-left-color: var(--action); }
.callout.real { border-left-color: var(--topic); }
.callout.book { border-left-color: var(--param); }

.goals { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }
.goals ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.goals li { margin: .2rem 0; }

.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: .93rem; background: var(--bg-elev); border-radius: var(--radius); overflow: hidden; }
th, td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--bg-sunk); }
.table-wrap { overflow-x: auto; }

/* ---------- code blocks ---------- */
pre.code { background: var(--term-bg); color: var(--term-fg); padding: 14px 16px; border-radius: var(--radius); overflow-x: auto; position: relative; line-height: 1.5; font-size: 14px; }
pre.code .copy { position: absolute; top: 8px; right: 8px; background: #263041; color: #cbd5e1; border: 0; border-radius: 6px; font-size: 12px; padding: 3px 8px; cursor: pointer; opacity: .8; }
pre.code .copy:hover { opacity: 1; }
pre.code .cm { color: #7c8798; } pre.code .kw { color: #c792ea; } pre.code .st { color: #a5e075; } pre.code .nu { color: #f78c6c; } pre.code .fn { color: #82aaff; } pre.code .pr { color: var(--term-green); }
.cmd-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); margin-bottom: -6px; }

/* annotated code explorer */
.code-explorer { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 1.2rem 0; background: var(--bg-elev); }
.code-explorer .tabs { grid-column: 1 / -1; }
.code-explorer .lines { background: var(--term-bg); color: var(--term-fg); font-family: var(--mono); font-size: 13px; overflow: auto; max-height: 560px; padding: 8px 0; }
.code-explorer .ln { display: flex; white-space: pre; padding: 0 12px 0 0; cursor: pointer; border-left: 3px solid transparent; }
.code-explorer .ln .no { color: #4b5566; width: 38px; text-align: right; padding-right: 12px; user-select: none; flex: none; }
.code-explorer .ln.has { border-left-color: #334155; }
.code-explorer .ln.has:hover { background: #18202c; }
.code-explorer .ln.sel { background: #1e2a3d; border-left-color: var(--term-blue); }
.code-explorer .explain { padding: 18px; overflow: auto; max-height: 560px; font-size: 15px; }
.code-explorer .explain h4 { margin: 0 0 6px; }
@media (max-width: 760px) { .code-explorer { grid-template-columns: 1fr; } .code-explorer .explain { border-top: 1px solid var(--border); } }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); background: var(--bg-sunk); padding: 6px 6px 0; flex-wrap: wrap; }
.tabs button { border: 1px solid transparent; border-bottom: none; background: none; padding: 6px 12px; border-radius: 8px 8px 0 0; cursor: pointer; color: var(--fg-muted); font: inherit; font-size: 14px; }
.tabs button.on { background: var(--bg-elev); border-color: var(--border); color: var(--fg); font-weight: 600; }
.tabpanel { display: none; } .tabpanel.on { display: block; }
.tabbox { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-elev); margin: 1.2rem 0; }
.tabbox .tabpanel { padding: 14px 16px; }
.tabbox .tabpanel pre.code { margin: 0; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--fg); padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 14.5px; text-decoration: none; }
.btn:hover { background: var(--bg-sunk); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=number], select, textarea { font: inherit; font-size: 14.5px; background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; }
textarea { font-family: var(--mono); font-size: 13px; width: 100%; }
label.inline { display: inline-flex; gap: 6px; align-items: center; margin-right: 14px; font-size: 14.5px; }
input[type=range] { accent-color: var(--accent); }

/* ---------- quiz ---------- */
.quiz { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin: 1.4rem 0; box-shadow: var(--shadow); }
.quiz .q-head { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; }
.quiz .q { font-weight: 600; margin: 4px 0 10px; }
.quiz .opt { display: block; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--bg); color: var(--fg); border-radius: 8px; padding: 9px 12px; margin: 6px 0; cursor: pointer; font: inherit; font-size: 15px; }
.quiz .opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz .opt.right { border-color: var(--ok); background: var(--ok-soft); }
.quiz .opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.quiz .opt:disabled { cursor: default; }
.quiz .why { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--bg-sunk); font-size: 15px; display: none; }
.quiz .why.show { display: block; }
.quiz .retry { margin-top: 8px; }
.fill { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fill input { flex: 1; min-width: 220px; font-family: var(--mono); }

/* ---------- terminal simulator ---------- */
.lab { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; margin: 1.4rem 0; align-items: start; }
.lab.stack { grid-template-columns: 1fr; }
.lab > * { min-width: 0; }
body { overflow-x: hidden; }
@media (max-width: 900px) { .lab { grid-template-columns: 1fr; } }
.term { background: var(--term-bg); color: var(--term-fg); border-radius: var(--radius); overflow: hidden; font-family: var(--mono); font-size: 13.5px; box-shadow: 0 8px 30px rgba(0,0,0,.18); border: 1px solid #1f2937; }
.term-tabs { display: flex; align-items: center; background: #161c26; border-bottom: 1px solid #222b38; overflow-x: auto; }
.term-tabs .dots { display: flex; gap: 6px; padding: 0 12px; flex: none; }
.term-tabs .dots i { width: 11px; height: 11px; border-radius: 50%; background: #3a4454; display: block; }
.term-tabs .dots i:nth-child(1) { background: #ef4444aa; } .term-tabs .dots i:nth-child(2) { background: #f59e0baa; } .term-tabs .dots i:nth-child(3) { background: #22c55eaa; }
.term-tab { padding: 8px 12px; color: var(--term-dim); cursor: pointer; border-right: 1px solid #222b38; white-space: nowrap; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.term-tab.on { background: var(--term-bg); color: var(--term-fg); }
.term-tab .x { opacity: .5; } .term-tab .x:hover { opacity: 1; color: var(--term-red); }
.term-tab .busy { width: 7px; height: 7px; border-radius: 50%; background: var(--term-green); display: inline-block; }
.term-add { padding: 6px 12px; color: var(--term-dim); cursor: pointer; background: none; border: 0; font: inherit; font-size: 16px; }
.term-add:hover { color: var(--term-fg); }
.term-body { height: 380px; overflow-y: auto; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; cursor: text; }
.term-body .line { min-height: 1.4em; }
.term-body .p-user { color: var(--term-green); font-weight: 600; } .term-body .p-path { color: var(--term-blue); font-weight: 600; }
.term-body .err { color: var(--term-red); } .term-body .dim { color: var(--term-dim); } .term-body .info { color: var(--term-fg); } .term-body .warnl { color: var(--term-yellow); } .term-body .okl { color: var(--term-green); }
.term-input-row { display: flex; }
.term-input-row input { flex: 1; background: transparent; border: 0; outline: 0; color: var(--term-fg); font: inherit; padding: 0; caret-color: var(--term-green); }
.term-foot { display: flex; gap: 6px; padding: 6px 8px; background: #161c26; border-top: 1px solid #222b38; flex-wrap: wrap; }
.term-foot button { background: #222b38; color: #cbd5e1; border: 0; border-radius: 6px; padding: 3px 9px; font: inherit; font-size: 12px; cursor: pointer; }
.term-foot button:hover { background: #2d384a; }
.term-foot .hintline { color: var(--term-dim); font-size: 12px; margin-left: auto; align-self: center; }

.side { display: flex; flex-direction: column; gap: 12px; }
.tasks { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tasks h4 { margin: 0 0 8px; font-size: 15px; display: flex; justify-content: space-between; }
.tasks ol { margin: 0; padding-left: 0; list-style: none; counter-reset: t; }
.tasks li { counter-increment: t; padding: 8px 0 8px 34px; position: relative; border-top: 1px dashed var(--border); font-size: 14.5px; line-height: 1.45; }
.tasks li:first-child { border-top: 0; }
.tasks li::before { content: counter(t); position: absolute; left: 0; top: 8px; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border); display: grid; place-items: center; font-size: 12px; color: var(--fg-muted); }
.tasks li.done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
.tasks li.done .t-text { color: var(--fg-muted); }
.tasks li.current { }
.tasks li.current::before { border-color: var(--accent); color: var(--accent); }
.tasks .hint-btn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; font-size: 13px; }
.tasks .hint { display: none; margin-top: 6px; font-size: 13px; background: var(--bg-sunk); border-radius: 6px; padding: 6px 8px; }
.tasks .hint.show { display: block; }
.tasks .hint code { white-space: pre-wrap; word-break: break-all; }
.tasks .all-done { display: none; margin-top: 10px; padding: 10px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-weight: 600; font-size: 14px; }
.tasks.complete .all-done { display: block; }
.whp { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; font-size: 14.5px; }
.whp h4 { margin: 0 0 6px; font-size: 15px; }
.whp .whp-cmd { font-family: var(--mono); font-size: 12.5px; color: var(--fg-muted); word-break: break-all; margin-bottom: 6px; }
.whp p { margin: .4em 0; }

/* turtlesim window */
.turtle-win { background: #1b1f27; border-radius: var(--radius); overflow: hidden; border: 1px solid #1f2937; box-shadow: 0 8px 30px rgba(0,0,0,.18); }
.turtle-win .tw-title { background: #2a2f3a; color: #cbd5e1; font-size: 12.5px; padding: 6px 10px; display: flex; justify-content: space-between; font-family: var(--sans); }
.turtle-win canvas { display: block; width: 100%; aspect-ratio: 1 / 1; }
.turtle-win.off canvas { opacity: .15; }
.turtle-win .tw-off { display: none; color: #94a3b8; text-align: center; padding: 8px; font-size: 13px; font-family: var(--sans); }
.turtle-win.off .tw-off { display: block; }

/* rqt_graph panel */
.graph-panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.graph-panel .gp-title { background: var(--bg-sunk); font-size: 13px; padding: 6px 10px; display: flex; justify-content: space-between; align-items: center; }
.graph-panel svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--fg-muted); padding: 6px 10px; }
.legend span::before { content: ""; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--c); }

/* ---------- generic visual widgets ---------- */
.viz { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 1.4rem 0; box-shadow: var(--shadow); }
.viz .viz-title { font-weight: 700; margin-bottom: 4px; }
.viz .viz-sub { color: var(--fg-muted); font-size: 14.5px; margin-bottom: 12px; }
.viz .controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.viz svg text { font-family: var(--sans); }
.viz .readout { font-family: var(--mono); font-size: 13px; background: var(--bg-sunk); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; min-height: 2.6em; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg-sunk); border: 1px solid var(--border); }
.pill.node { color: var(--node); border-color: currentColor; } .pill.topic { color: var(--topic); border-color: currentColor; }
.pill.service { color: var(--service); border-color: currentColor; } .pill.action { color: var(--action); border-color: currentColor; } .pill.param { color: var(--param); border-color: currentColor; }
.verdict { padding: 10px 12px; border-radius: 8px; font-weight: 600; margin-top: 10px; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); } .verdict.bad { background: var(--bad-soft); color: var(--bad); } .verdict.warn { background: var(--warn-soft); color: var(--warn); }

.layer-stack { display: flex; flex-direction: column; gap: 6px; }
.layer { border-radius: 8px; padding: 10px 14px; cursor: pointer; border: 1px solid var(--border); background: var(--bg); transition: transform .1s; display: flex; justify-content: space-between; gap: 10px; }
.layer:hover { transform: translateX(4px); border-color: var(--accent); }
.layer.sel { border-color: var(--accent); background: var(--accent-soft); }
.layer .l-tag { font-size: 12px; color: var(--fg-muted); font-family: var(--mono); }

.file-tree { font-family: var(--mono); font-size: 13.5px; background: var(--bg-sunk); border-radius: 8px; padding: 10px; line-height: 1.75; }
.file-tree .f { cursor: pointer; padding: 1px 6px; border-radius: 5px; white-space: pre; display: block; }
.file-tree .f:hover { background: var(--accent-soft); }
.file-tree .f.sel { background: var(--accent); color: #fff; }

.timeline { display: flex; gap: 0; overflow-x: auto; padding: 10px 0; }
.timeline .tl { flex: 1; min-width: 110px; text-align: center; position: relative; padding-top: 26px; cursor: pointer; font-size: 13px; }
.timeline .tl::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 2px; background: var(--border); }
.timeline .tl::after { content: ""; position: absolute; top: 3px; left: calc(50% - 7px); width: 14px; height: 14px; border-radius: 50%; background: var(--bg-elev); border: 2px solid var(--fg-muted); }
.timeline .tl.lts::after { border-color: var(--ok); background: var(--ok); }
.timeline .tl.sel { font-weight: 700; color: var(--accent); }
.timeline .tl.sel::after { box-shadow: 0 0 0 4px var(--accent-soft); }

.drag-zone { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.chip { display: inline-block; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); margin: 4px; cursor: grab; font-size: 14px; }

/* lesson footer */
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 3rem; flex-wrap: wrap; }
.lesson-nav a { flex: 1; min-width: 200px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; text-decoration: none; color: var(--fg); background: var(--bg-elev); }
.lesson-nav a:hover { border-color: var(--accent); }
.lesson-nav a small { display: block; color: var(--fg-muted); }
.lesson-nav a.next { text-align: right; }
.complete-box { margin-top: 2.5rem; padding: 18px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; }

/* home */
.hero { padding: 24px 0 8px; }
.hero h1 { font-size: 2.7rem; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin: 1.2rem 0; }
.module-card { display: block; text-decoration: none; color: var(--fg); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; position: relative; transition: border-color .15s, transform .15s; }
.module-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.module-card .mc-num { font-family: var(--mono); color: var(--fg-muted); font-size: 13px; }
.module-card h3 { margin: 4px 0 6px; font-size: 1.05rem; }
.module-card p { margin: 0; font-size: 14px; color: var(--fg-muted); line-height: 1.5; }
.module-card .mc-done { position: absolute; top: 12px; right: 14px; color: var(--ok); font-weight: 700; display: none; }
.module-card.done .mc-done { display: block; }
.bar { height: 8px; background: var(--bg-sunk); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); width: 0; transition: width .4s; }

.anim-dot { transition: none; }
.flash { animation: flash .6s; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* long commands inside the narrow side panel must wrap */
.tasks code, .whp code, .callout code, .quiz code { white-space: normal; overflow-wrap: anywhere; }
.side { min-width: 0; }

/* keep the page inside the viewport on phones */
main { min-width: 0; }
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  :not(pre) > code { white-space: normal; overflow-wrap: anywhere; }
  h1, .hero h1 { font-size: 1.8rem; }
}
