/* =========================================================
   Networking Course — Notion-inspired theme
   Clean, low-chrome, high-readability. Light + dark.
   ========================================================= */

:root {
  /* neutral surfaces (Notion-like) */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #f1f1ef;
  --ink: #37352f;
  --ink-soft: #5f5d57;
  --muted: #6b6a66;
  --line: #e9e9e7;
  --line-strong: #d7d5cf;

  /* accents */
  --brand: #1a6fd0;      /* primary blue  */
  --brand-2: #0f766e;    /* secondary teal*/
  --accent: #b45309;     /* orange        */
  --ok: #0f7b6c;         /* green         */
  --warn: #cb912f;
  --danger: #eb5757;     /* red           */

  /* solid brand for filled buttons/pills (white text) */
  --brand-solid: #1a6fd0;
  --on-brand: #ffffff;

  /* device fills used by diagrams */
  --server: #0969da;
  --server-2: #0b4f9e;
  --server-edge: #084c99;

  /* solid swatch fills for labelled bands (white text) */
  --sw-amber: #b45309;
  --sw-blue: #1a6fd0;
  --sw-teal: #0f766e;
  --sw-gray: #6b6a66;

  --code-bg: #f7f6f3;
  --code-ink: #eb5757;
  --code-block-bg: #f7f6f3;
  --code-block-ink: #37352f;

  /* tints for callouts */
  --tint-blue: #e7f0fd;
  --tint-teal: #e6f4f1;
  --tint-amber: #fbecdd;
  --tint-green: #eaf3ec;
  --tint-red: #fdebec;
  --tint-gray: #f4f4f2;
  --tint-purple: #f5f2f8;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(15,15,15,.03), 0 3px 8px rgba(15,15,15,.03);
  --shadow-pop: 0 6px 20px rgba(15,15,15,.10), 0 2px 6px rgba(15,15,15,.06);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", "Segoe UI Emoji", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #191919;
  --surface: #202020;
  --surface-2: #252525;
  --surface-3: #2f2f2f;
  --ink: #ededec;
  --ink-soft: #c3c2c0;
  --muted: #9b9a97;
  --line: #2f2f2f;
  --line-strong: #3f3f3f;

  --brand: #4d9de0;
  --brand-2: #2bbeb0;
  --accent: #e0a458;
  --ok: #4dab9a;
  --danger: #eb6f6f;

  --brand-solid: #2563eb;
  --on-brand: #ffffff;

  --server: #1f6feb;
  --server-2: #1a5cc4;
  --server-edge: #4c9aff;

  --sw-amber: #9a5b12;
  --sw-blue: #1f5fbf;
  --sw-teal: #0f766e;
  --sw-gray: #5f5e5a;

  --code-bg: #2f2f2f;
  --code-ink: #ff8f8f;
  --code-block-bg: #262626;
  --code-block-ink: #ededec;

  --tint-blue: #1f2c3d;
  --tint-teal: #16302d;
  --tint-amber: #35291a;
  --tint-green: #1b2b23;
  --tint-red: #38211f;
  --tint-gray: #2a2a2a;
  --tint-purple: #2a2433;

  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-pop: 0 8px 26px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}

.wrap { max-width: 820px; margin: 0 auto; padding: 6px 24px 96px; }

/* ---------------- Accessibility: skip link + focus ring ---------------- */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  padding: 10px 16px; font-weight: 650; font-size: 14px;
  border-radius: 0 0 var(--radius-sm) 0; text-decoration: none;
}
.skip:focus { left: 0; text-decoration: none; }

:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.progress { position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.progress .bar {
  display: block; height: 100%; width: 0;
  background: var(--brand);
  transition: width .1s linear;
}
.topbar .inner {
  max-width: 1180px; margin: 0 auto; padding: 9px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13.5px;
}
.crumbs { display: flex; align-items: center; gap: 7px; min-width: 0; overflow: hidden; white-space: nowrap; color: var(--muted); }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
.crumb-sep { color: var(--line-strong); }
.crumb-current { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.actions a.chip, .topnav a.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500; text-decoration: none;
  color: var(--ink-soft); border: 1px solid var(--line);
  padding: 4px 11px; border-radius: var(--radius-sm); background: var(--surface);
  transition: background .12s, border-color .12s, color .12s;
}
.actions a.chip:hover, .topnav a.chip:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line-strong); }
.actions a.chip.disabled, .topnav a.chip.disabled { opacity: .4; pointer-events: none; }

.theme-toggle {
  font-size: 15px; width: 32px; height: 32px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-soft);
  transition: background .12s, border-color .12s, color .12s;
}
.theme-toggle:hover { background: var(--surface-3); color: var(--ink); }

/* ---------------- Header ---------------- */
.lesson-head { padding: 46px 0 8px; }
.eyebrow {
  display: inline-block;
  font-size: 12.5px; letter-spacing: .04em;
  color: var(--brand); font-weight: 600; margin-bottom: 8px;
}
h1 { font-size: 2.35rem; line-height: 1.2; margin: 0 0 12px; font-weight: 700; letter-spacing: -.015em; }
.lede { font-size: 1.1rem; color: var(--ink-soft); margin: 0 0 16px; max-width: 62ch; line-height: 1.6; }

.meta-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 6px; }
.tag {
  display: inline-block; font-size: 12.5px; font-weight: 500;
  padding: 3px 9px; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--ink-soft);
}
.tag.exam { background: var(--tint-blue); color: var(--brand); }
.tag.ok { background: var(--tint-green); color: var(--ok); }

/* ---------------- Cards / blocks ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 26px; margin: 18px 0;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* ---------------- Visual explorer (home) ---------------- */
.visual-explorer {
  margin: 18px 0 24px; padding: 18px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
}
.visual-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.visual-pill {
  appearance: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); padding: 7px 14px; border-radius: var(--radius-sm); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s ease;
}
.visual-pill:hover { background: var(--surface-3); color: var(--ink); }
.visual-pill.is-active { background: var(--brand-solid); color: var(--on-brand); border-color: var(--brand-solid); }
.visual-stage {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px;
}
.role-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px; min-height: 150px;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
}
.role-card.is-active { border-color: var(--brand); box-shadow: 0 4px 16px color-mix(in srgb, var(--brand) 16%, transparent); }
.role-card svg { width: 100%; height: auto; display: block; }
.role-card .small-label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  text-align: center;
}
.role-copy { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.role-copy h3 { margin: 0 0 8px; }
.role-copy p { margin: 0; }
.role-graphic[hidden] { display: none; }

/* ---------------- Table of contents ---------------- */
.toc { font-size: 15px; background: var(--surface-2); border-color: transparent; box-shadow: none; }
.toc h2 { margin-top: 0; }
.toc ol { margin: 0; padding-left: 22px; columns: 2; column-gap: 40px; }
.toc li { margin: 5px 0; break-inside: avoid; }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--brand); }
.toc a.active { color: var(--brand); font-weight: 600; }
@media (max-width: 640px){ .toc ol { columns: 1; } }

/* ---------------- Headings & text ---------------- */
h2 {
  font-size: 1.55rem; margin: 52px 0 12px; font-weight: 700; letter-spacing: -.01em;
  scroll-margin-top: 70px;
}
h3 { font-size: 1.25rem; margin: 34px 0 8px; font-weight: 650; color: var(--ink); scroll-margin-top: 70px; }
h4 { font-size: 1.03rem; margin: 24px 0 6px; font-weight: 600; color: var(--ink); }
p { margin: 12px 0; }
ul, ol { padding-left: 26px; margin: 12px 0; }
li { margin: 5px 0; line-height: 1.62; }
li > ul, li > ol { margin: 5px 0; }
strong { font-weight: 650; }
hr { border: none; border-top: 1px solid var(--line); margin: 30px 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Callouts (simple docs style) ---------------- */
.callout {
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  padding: 13px 18px; margin: 18px 0;
}
.callout .callout-title {
  display: block; font-weight: 650; font-size: .95rem;
  margin-bottom: 4px; color: var(--ink);
}
.callout.def   { border-left-color: var(--brand-2); }
.callout.def .callout-title   { color: var(--brand-2); }
.callout.tip   { border-left-color: var(--ok); }
.callout.tip .callout-title   { color: var(--ok); }
.callout.warn  { border-left-color: var(--danger); }
.callout.warn .callout-title  { color: var(--danger); }
.callout.exam  { border-left-color: var(--accent); }
.callout.exam .callout-title  { color: var(--accent); }
.callout.note  { border-left-color: var(--brand); }
.callout.note .callout-title  { color: var(--brand); }
.callout > :last-child { margin-bottom: 0; }
.callout p:first-child { margin-top: 0; }

/* ---------------- Objectives ---------------- */
.objectives { background: var(--tint-blue); border-color: transparent; box-shadow: none; }
.objectives strong { display: block; margin-bottom: 4px; color: var(--brand); }
.objectives ul { margin: 6px 0 0; }

/* ---------------- Tables ---------------- */
table {
  width: 100%; border-collapse: collapse; margin: 18px 0;
  font-size: 15.5px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
thead th {
  background: var(--surface-2); color: var(--ink); text-align: left;
  padding: 9px 13px; font-weight: 600; font-size: 14px;
  border-bottom: 1px solid var(--line);
}
tbody td, tbody th { padding: 8px 13px; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:first-child td, tbody tr:first-child th { border-top: none; }
tbody th { text-align: left; font-weight: 600; }
.table-wrap, .fig-wrap { overflow-x: auto; }

/* ---------------- Code ---------------- */
code {
  font-family: var(--mono); font-size: .86em;
  background: var(--code-bg); padding: 2px 6px; border-radius: var(--radius-sm);
  color: var(--code-ink);
}
pre {
  background: var(--code-block-bg); color: var(--code-block-ink);
  padding: 16px 18px; border-radius: var(--radius); overflow-x: auto;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6;
  margin: 18px 0; border: 1px solid var(--line);
}
pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
pre .c { color: #6a737d; }
pre .p { color: #116329; }
pre .k { color: #9a3412; }
[data-theme="dark"] pre .c { color: #8b949e; }
[data-theme="dark"] pre .p { color: #3fb950; }
[data-theme="dark"] pre .k { color: #e3b341; }

pre.ascii {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
  font-size: 12.5px;
}

/* ---------------- Figures + diagrams ---------------- */
figure {
  margin: 22px 0; padding: 20px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); text-align: center;
}
figure svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
figcaption {
  margin-top: 14px; font-size: 14px; color: var(--muted);
  max-width: 70ch; margin-left: auto; margin-right: auto; line-height: 1.55;
}
.fig-wrap { overflow-x: auto; }

/* Unified diagram component classes.
   These must apply inside ANY inline SVG on the page - not only inside a
   <figure> - otherwise diagrams in the visual explorer, mini-diagram cards,
   role cards, etc. fall back to the SVG default (black fill + black text). */
svg .d-dev,svg .d-host,svg .d-switch,
svg .d-router,svg .d-server2,svg .d-cloud
  { stroke-width:1.8; stroke-linejoin:round; }
svg .d-cloud{fill:var(--surface-2);stroke:var(--muted)}
svg .d-dev{fill:var(--surface);stroke:var(--brand)}
svg .d-host{fill:var(--surface);stroke:var(--brand)}
svg .d-switch{fill:var(--surface);stroke:var(--brand-2)}
svg .d-router{fill:var(--surface);stroke:var(--accent)}
svg .d-server{fill:var(--server);stroke:var(--server-edge)}
svg .d-server2{fill:var(--server-2);stroke:var(--server)}
svg .d-wall{fill:#dc2626;stroke:#991b1b;stroke-width:1.8}
svg .d-dev,svg .d-host,svg .d-switch,svg .d-router,
svg .d-server,svg .d-server2,svg .d-cloud,svg .d-wall
  { filter:drop-shadow(0 1px 1.5px rgba(15,15,15,.12)); }
svg .d-line{stroke:var(--brand-2);stroke-width:2;fill:none;stroke-linecap:round}
svg .d-line-dash{stroke:var(--muted);stroke-width:1.8;stroke-dasharray:6 5;fill:none;stroke-linecap:round}
svg .d-arrow{stroke:var(--brand-2);stroke-width:2;fill:none;stroke-linecap:round;stroke-linejoin:round}
svg .d-t{font-family:var(--sans);font-size:13px;font-weight:600;fill:var(--ink)}
svg .d-s{font-family:var(--sans);font-size:11.5px;font-weight:400;fill:var(--muted)}
svg .d-h{font-family:var(--sans);font-size:11px;font-weight:700;fill:var(--accent)}
svg .d-lblw{font-family:var(--sans);font-size:12px;font-weight:600;fill:#ffffff}
svg .d-lbld{font-family:var(--sans);font-size:12px;font-weight:600;fill:var(--ink)}
svg .d-fillh{fill:var(--surface-2);stroke:var(--line)}
svg .d-eth{fill:var(--sw-amber);stroke:var(--sw-amber)}
svg .d-ip{fill:var(--sw-blue);stroke:var(--sw-blue)}
svg .d-tcp{fill:var(--sw-teal);stroke:var(--sw-teal)}
svg .d-data{fill:var(--surface-2);stroke:var(--line)}
svg .d-fcs{fill:var(--sw-gray);stroke:var(--sw-gray)}
svg .d-band{fill:var(--surface-2);stroke:var(--line)}
svg .d-tile{fill:var(--surface);stroke:var(--line);stroke-width:1.5}
svg .d-tile-accent{fill:var(--surface);stroke:var(--brand);stroke-width:2}
svg .d-cap{font-family:var(--sans);font-size:12px;font-weight:700;fill:var(--ink)}
svg use.ic{color:var(--brand)}
svg use.ic-teal{color:var(--brand-2)}
svg use.ic-amber{color:var(--accent)}
svg use.ic-red{color:var(--danger)}
svg use.ic-muted{color:var(--muted)}
@keyframes di-pulse { 0%,100%{opacity:.25} 50%{opacity:1} }
svg .d-flow{animation:di-pulse 1.6s ease-in-out infinite}
@media (prefers-reduced-motion: reduce){ svg .d-flow{animation:none} }

/* Device icon glyphs (sprite injected by app.js) */
.di {
  display:inline-block; width:1.15em; height:1.15em; vertical-align:-.22em;
  color:var(--brand); flex:none;
}
.di-router{color:var(--accent)}
.di-switch,.di-l3switch{color:var(--brand-2)}
.di-firewall,.di-shield{color:var(--danger)}
.di-cloud,.di-internet{color:var(--muted)}
figure svg use.di-glyph{pointer-events:none}
figure svg use.dv,.mini-diagram svg use.dv,.concept-visual svg use.dv,.role-card svg use.dv{pointer-events:none}
.di-icon-row {
  display:flex; flex-wrap:wrap; align-items:center; gap:8px 20px;
  margin:14px 0; padding:14px 16px; border:1px solid var(--line);
  border-radius:var(--radius); background:var(--surface-2);
}
.di-icon-row figure,
.di-icon-row .di-item { display:flex; align-items:center; gap:8px; margin:0; font-size:13.5px; font-weight:600; color:var(--ink-soft); }
.di-icon-row .di { width:2em; height:2em; }

/* ---------------- Check yourself ---------------- */
details.qa {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; margin: 10px 0;
}
details.qa summary { cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; }
details.qa summary::-webkit-details-marker { display: none; }
details.qa summary::before { content: "\25B8"; color: var(--muted); margin-right: 8px; display: inline-block; transition: transform .15s; }
details.qa[open] summary::before { transform: rotate(90deg); }
details.qa[open] summary { margin-bottom: 10px; }
details.qa .answer { border-top: 1px solid var(--line); padding-top: 10px; color: var(--ink-soft); }
details.qa:hover { border-color: var(--line-strong); }

/* ---------------- Checklist ---------------- */
ul.checklist { list-style: none; padding-left: 0; margin: 14px 0; }
ul.checklist li { position: relative; padding-left: 30px; margin: 9px 0; }
ul.checklist li::before {
  content: ""; position: absolute; left: 2px; top: .45em; width: 15px; height: 15px;
  border: 1.5px solid var(--line-strong); border-radius: 4px; background: var(--surface);
}
.no-overflow { overflow-x: auto; }

/* ---------------- Glossary ---------------- */
.glossary { margin: 14px 0; }
.glossary dt { font-weight: 650; margin-top: 14px; color: var(--ink); }
.glossary dd { margin: 2px 0 0 0; color: var(--ink-soft); }

/* ---------------- References ---------------- */
.refs { font-size: 14.5px; }
.refs ol { padding-left: 24px; }
.refs a { word-break: break-word; }
.refs li { margin: 8px 0; color: var(--ink-soft); }

/* ---------------- Lesson navigation ---------------- */
.lesson-nav {
  display: flex; justify-content: space-between; gap: 12px;
  margin: 52px 0 12px; flex-wrap: wrap;
}
.lesson-nav a {
  flex: 1 1 0; min-width: 200px;
  text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px;
  transition: background .12s ease, border-color .12s ease;
}
.lesson-nav a:hover { background: var(--surface-2); border-color: var(--line-strong); text-decoration: none; }
.lesson-nav .dir { display: block; font-size: 12px; color: var(--muted); }
.lesson-nav .title { font-weight: 650; color: var(--brand); }
.lesson-nav a.next { text-align: right; }
.lesson-nav a.disabled { opacity: .45; pointer-events: none; }

/* ---------------- Hub / index pages ---------------- */
.hero { padding: 44px 0 8px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px; margin: 18px 0;
}
.tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  transition: background .12s ease, border-color .12s ease;
}
.tile:hover { background: var(--surface-2); border-color: var(--line-strong); text-decoration: none; }
.tile .num { font-size: 12px; font-weight: 600; color: var(--muted); }
.tile .t { font-weight: 650; margin: 4px 0; color: var(--ink); }
.tile .d { font-size: 13.5px; color: var(--muted); }

.visual-learning {
  margin: 26px 0 22px; padding: 18px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.visual-learning .section-heading { margin: 4px 0 12px; }
.visual-learning .section-heading h2 { margin-top: 0; }
.concept-switcher { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.concept-btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); padding: 7px 14px; border-radius: var(--radius-sm); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s ease;
}
.concept-btn:hover { background: var(--surface-3); color: var(--ink); }
.concept-btn.is-active { background: var(--brand-solid); color: var(--on-brand); border-color: var(--brand-solid); }
.concept-showcase {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(270px, .9fr); gap: 18px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.concept-visual {
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
}
.concept-visual svg { display: block; width: 100%; height: auto; border-radius: 6px; background: var(--surface); }
.concept-copy h3 { margin-top: 0; }
.concept-copy ul { margin: 10px 0 0; padding-left: 20px; }
.concept-copy li { margin: 8px 0; }
.concept-layer[hidden] { display: none; }

.mini-diagram-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 20px 0 10px;
}
.mini-diagram {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.mini-diagram .mini-title {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--brand-2); margin-bottom: 8px;
}
.mini-diagram svg { display: block; width: 100%; height: auto; border-radius: 6px; background: var(--surface-2); }

@media (max-width: 760px) { .concept-showcase { grid-template-columns: 1fr; } }

.week-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 24px; margin: 16px 0;
}
.week-card h3 { margin-top: 0; }
.lesson-list { list-style: none; padding: 0; margin: 10px 0 0; }
.lesson-list li { border-top: 1px solid var(--line); padding: 8px 0; }
.lesson-list li:first-child { border-top: none; }
.lesson-list a { text-decoration: none; color: var(--ink); font-weight: 500; }
.lesson-list a:hover { color: var(--brand); text-decoration: underline; }
.lesson-list .kind { float: right; font-size: 12px; color: var(--muted); }

/* ---------------- Course map: two switchable views ---------------- */
.view-switch {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 6px 0 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.view-btn {
  border: 1px solid transparent; background: transparent; color: var(--ink-soft);
  font-family: var(--sans); font-size: 13.5px; font-weight: 600; cursor: pointer;
  padding: 8px 16px; border-radius: var(--radius-sm); transition: background .15s, color .15s;
}
.view-btn:hover { color: var(--ink); }
.view-btn.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.view-note { color: var(--muted); font-size: 14px; margin: 12px 2px 4px; max-width: 78ch; }
.course-map { margin-top: 6px; }
.domain-card h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.domain-weight {
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--brand); background: var(--tint-blue);
  border-radius: var(--radius-sm); padding: 3px 9px;
}
.extras-head {
  margin: 30px 2px 2px; font-size: 1rem; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 20px;
}
.extras-card { border-left: 3px solid var(--brand-2); }

.progress-note {
  font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--line);
  margin-top: 22px; padding-top: 14px;
}

/* ---------------- Interactive quiz engine ---------------- */
.quiz {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; margin: 20px 0;
}
.quiz + .quiz { margin-top: 16px; }
.quiz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.quiz-head .quiz-title { font-weight: 650; color: var(--ink); font-size: 1.02rem; }
.quiz-head .quiz-score { font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.quiz-head .quiz-score.done { color: var(--ok); }
.quiz-bar { height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 10px 0 4px; }
.quiz-bar > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s ease; }
.quiz .qlist { list-style: none; padding: 0; margin: 8px 0 0; counter-reset: qq; }
.quiz .q { border-top: 1px solid var(--line); padding: 16px 0 4px; }
.quiz .q:first-child { border-top: none; }
.quiz .qtext { font-weight: 600; margin: 0 0 12px; color: var(--ink); }
.quiz .qtext::before { counter-increment: qq; content: counter(qq) ". "; color: var(--brand); font-weight: 700; }
.quiz .opts { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.quiz .opt {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 14px;
  background: var(--surface); cursor: pointer; transition: background .1s ease, border-color .1s ease;
}
.quiz .opt:hover { background: var(--surface-2); }
.quiz .opt:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.quiz .opt .key { display: inline-block; min-width: 1.35em; font-weight: 700; color: var(--brand); margin-right: 4px; }
.quiz .opt.correct { border-color: var(--ok); background: var(--tint-green); }
.quiz .opt.correct .key { color: var(--ok); }
.quiz .opt.incorrect { border-color: var(--danger); background: var(--tint-red); }
.quiz .opt.incorrect .key { color: var(--danger); }
.quiz .opt.chosen { font-weight: 600; }
.quiz .q.answered .opt { cursor: default; }
.quiz .q.answered .opt:not(.correct):not(.incorrect) { opacity: .55; }
.quiz .explain {
  display: none; margin: 12px 0 0; font-size: 14.5px; color: var(--ink-soft);
  border-left: 3px solid var(--brand-2); padding: 2px 0 2px 12px;
}
.quiz .q.answered .explain { display: block; }
.quiz .quiz-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.quiz .quiz-reset {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  padding: 6px 14px; border-radius: var(--radius-sm);
}
.quiz .quiz-reset:hover { background: var(--surface-3); color: var(--ink); }

.quiz-status-line { margin: 8px 0 0; font-weight: 600; font-size: .9em; }
.quiz-status-line.ok { color: var(--ok); }
.quiz-status-line.no { color: var(--danger); }

.quiz-summary {
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px;
  font-weight: 600; color: var(--ink-soft); margin: 16px 0;
}
.quiz-summary.done { border-color: var(--ok); color: var(--ok); background: var(--tint-green); }

/* ---------------- Spaced-repetition study mode (flashcards) ---------------- */
.study-mode {
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin: 22px 0;
}
.study-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.study-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.study-stats .stat {
  position: relative; min-width: 74px; text-align: center; padding: 8px 12px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.study-stats .stat b { display: block; font-size: 1.35rem; line-height: 1.1; color: var(--brand); }
.study-stats .stat span { font-size: 11px; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.study-stats .stat-bar { min-width: 108px; }
.study-stats .stat-bar i { position: absolute; left: 0; bottom: 0; height: 3px; width: var(--pct, 0%); background: var(--brand); display: block; }
.study-card { margin-top: 18px; padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.study-domain {
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--brand-2); margin-bottom: 10px;
}
.study-front { font-size: 1.35rem; font-weight: 650; line-height: 1.35; color: var(--ink); }
.study-back {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 1.02rem; line-height: 1.6; color: var(--ink-soft);
}
.study-back code { font-size: .95em; }
.study-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grade-row { display: flex; gap: 10px; flex-wrap: wrap; }
.study-btn {
  font-family: var(--sans); font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: var(--radius-sm); transition: background .15s, border-color .15s;
}
.study-btn:hover { background: var(--surface-3); }
.study-btn.primary { background: var(--brand-solid); color: var(--on-brand); border-color: var(--brand-solid); }
.study-btn.primary:hover { background: color-mix(in srgb, var(--brand-solid) 88%, #000); }
.study-btn.again { color: var(--danger); }
.study-btn.good { color: var(--brand); }
.study-btn.easy { color: var(--brand-2); }
.study-btn.ghost { background: transparent; color: var(--muted); }
.kbd {
  display: inline-block; margin-left: 6px; padding: 1px 6px; font-size: 10.5px; font-weight: 700;
  border-radius: var(--radius-sm); background: var(--surface-3); color: var(--muted); vertical-align: 1px;
}
.study-feedback { margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--brand-2); min-height: 1em; opacity: 0; transition: opacity .2s; }
.study-feedback.show { opacity: 1; }
.study-empty { margin-top: 16px; color: var(--ink-soft); font-size: 14px; }
.study-controls { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.study-limit { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.study-limit select {
  font-family: var(--sans); font-size: 13px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); cursor: pointer;
}

/* ---------------- IOS CLI simulator ---------------- */
.cli { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #0d1117; margin: 18px 0; }
.cli-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 10px 14px; background: #161b22; border-bottom: 1px solid #23303f;
  color: #b9c6dc; font-size: 13px;
}
.cli-bar .cli-dev { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.cli-bar select {
  font-family: var(--sans); font-size: 13px; padding: 5px 8px; border-radius: var(--radius-sm);
  border: 1px solid #2c3a55; background: #0d1117; color: #e6edf7; cursor: pointer;
}
.cli-hint { margin-left: auto; color: #8494ad; }
.cli-hint code, .cli-bar code { color: #7fd8c9; }
.cli-clear {
  font-family: var(--sans); font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid #2c3a55;
  background: #16203a; color: #cdd8ea;
}
.cli-clear:hover { border-color: #7fd8c9; color: #fff; }
.cli-screen {
  height: 360px; overflow-y: auto; padding: 14px 16px; margin: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px; line-height: 1.55; color: #d7e2f3; white-space: pre-wrap; word-break: break-word;
}
.cli-line { min-height: 1.2em; }
.cli-line.cli-echo { color: #eaf1fb; }
.cli-line.sys { color: #7fd8c9; }
.cli-line.err { color: #ff8f8f; }
.cli-inputrow { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: #0d1117; border-top: 1px solid #23303f; }
.cli-prompt { color: #7fd8c9; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; font-weight: 700; white-space: nowrap; }
.cli-prompt.priv { color: #ffcf6b; }
.cli-input {
  flex: 1; border: none; outline: none; background: transparent; color: #eaf1fb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: 13px;
}
.cli-input::placeholder { color: #4c5b74; }
.cli kbd, .wrap kbd {
  font-family: var(--sans); font-size: 12px; font-weight: 700; padding: 1px 6px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-3); color: var(--ink);
}

/* ---------------- Progress dashboard ---------------- */
.dash-top {
  display: flex; flex-wrap: wrap; gap: 26px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
}
.dash-ring { position: relative; width: 148px; height: 148px; flex: none; }
.dash-ring svg { width: 148px; height: 148px; transform: rotate(-90deg); }
.dash-ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 9; }
.dash-ring-fg { fill: none; stroke: var(--brand); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.dash-ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dash-ring-label b { font-size: 1.7rem; color: var(--ink); line-height: 1; font-weight: 700; }
.dash-ring-label span { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-top: 4px; }
.dash-side { flex: 1; min-width: 260px; }
.dash-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.dash-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; min-width: 130px; }
.dash-stat b { display: block; font-size: 1.3rem; color: var(--ink); }
.dash-stat span { font-size: 12px; color: var(--muted); }
.dash-stat em { display: block; font-size: 11px; color: var(--brand-2); font-style: normal; margin-top: 2px; }
.dash-resume { margin-top: 14px; font-size: 14px; color: var(--ink-soft); }
.dash-resume a { color: var(--brand); font-weight: 600; }
.dash-resume-btn {
  display: inline-block; margin-left: 10px; padding: 6px 14px; border-radius: var(--radius-sm); font-weight: 600;
  background: var(--brand-solid); color: var(--on-brand) !important; text-decoration: none;
}
.dash-progress { margin-top: 14px; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.dash-progress i { display: block; height: 100%; background: var(--brand); transition: width .6s ease; }
.dash-note { font-size: 13.5px; color: var(--muted); margin: 16px 2px; }
.dashboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.dash-week { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.dash-week-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dash-week-head h3 { margin: 0; font-size: 1rem; }
.dash-week-pct { font-size: 12px; color: var(--muted); white-space: nowrap; }
.dash-week-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 10px 0 12px; }
.dash-week-bar i { display: block; height: 100%; background: var(--brand); }
.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; border-top: 1px solid var(--line); }
.dash-list li:first-child { border-top: none; }
.dash-list a { color: var(--ink-soft); text-decoration: none; }
.dash-list a:hover { color: var(--brand); text-decoration: underline; }
.dash-list .is-done a { color: var(--ink); font-weight: 600; }
.dash-check { width: 16px; text-align: center; color: var(--muted); flex: none; }
.dash-list .is-done .dash-check { color: var(--ok); font-weight: 800; }
.dash-qtitle { flex: 1; }
.dash-qscore { font-size: 12px; color: var(--muted); white-space: nowrap; }
.dash-domains { display: grid; gap: 14px; }
.dash-domain { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.dash-domain-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.dash-domain-name { font-weight: 650; }
.dash-domain-score { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.dash-domain-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 10px; }
.dash-domain-bar i { display: block; height: 100%; background: var(--brand); }
.dash-resetrow { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dash-reset-btn {
  font-family: var(--sans); font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--danger);
}
.dash-reset-btn:hover { background: var(--tint-red); }
.dash-reset-note { font-size: 12.5px; color: var(--muted); max-width: 60ch; }

/* ---------------- Packet flow & encapsulation ---------------- */
.flow {
  display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 18px 0;
}
.flow-svg { order: 1; width: 100%; height: auto; }
.flow-bar { order: 2; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 8px; }
.flow-btn {
  font-family: var(--sans); font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); transition: background .15s, border-color .15s;
}
.flow-btn:hover { background: var(--surface-3); }
.flow-btn.primary { background: var(--brand-solid); color: var(--on-brand); border-color: var(--brand-solid); }
.flow-btn:disabled { opacity: .45; cursor: not-allowed; }
.flow-stepnum { margin-left: auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.flow-link { stroke: var(--line-strong); stroke-width: 3; stroke-linecap: round; }
.flow-dev .flow-halo { fill: none; stroke: var(--brand-2); stroke-width: 2; opacity: 0; transition: opacity .2s; }
.flow-dev.is-active .flow-halo { opacity: 1; }
.flow-dev .flow-ic { color: var(--ink-soft); transition: color .2s; }
.flow-dev.is-active .flow-ic { color: var(--brand); }
.flow-name { fill: var(--ink-soft); font-family: var(--sans); font-size: 15px; font-weight: 650; }
.flow-dev.is-active .flow-name { fill: var(--brand); }
.flow-pkt-glow { fill: var(--brand-2); opacity: .28; }
.flow-pkt-body { fill: var(--brand); stroke: var(--surface); stroke-width: 1.5; }
.flow-caption { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin: 14px 0; }
.flow-caption strong { display: block; color: var(--brand); margin-bottom: 4px; }
.flow-caption p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }
.flow-ladder { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.flow-layer {
  flex: 1; min-width: 130px; background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; text-align: center; transition: border-color .2s, background .2s, transform .2s;
}
.flow-layer b { display: block; font-size: 11px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.flow-layer span { display: block; font-size: 1.05rem; font-weight: 700; color: var(--ink); margin: 3px 0; }
.flow-layer em { font-style: normal; font-size: 12px; color: var(--muted); }
.flow-layer.on { border-color: var(--brand-2); background: var(--tint-teal); transform: translateY(-2px); }
.flow-arrow { display: flex; align-items: center; color: var(--muted); font-size: 18px; }
@media (max-width: 700px) { .flow-arrow { display: none; } }

.encap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 18px 0; }
.encap-stack { display: flex; gap: 6px; flex-wrap: wrap; }
.encap-block {
  flex: 1; min-width: 120px; border-radius: var(--radius); padding: 14px 12px; text-align: center;
  border: 2px solid transparent; transition: opacity .3s, transform .3s, border-color .3s;
}
.encap-block b { display: block; font-size: 13.5px; font-weight: 700; }
.encap-block span { display: block; font-size: 11.5px; margin-top: 3px; }
.encap-block.off { opacity: .18; filter: grayscale(1); transform: scale(.96); }
.encap-block.on.l2 { background: var(--tint-amber); border-color: var(--accent); }
.encap-block.on.l3 { background: var(--tint-blue); border-color: var(--brand); }
.encap-block.on.l4 { background: var(--tint-green); border-color: var(--ok); }
.encap-block.on.l7 { background: var(--tint-purple); border-color: var(--brand-2); }
.encap-caption { margin: 16px 0 12px; font-size: 14.5px; color: var(--ink-soft); min-height: 2.6em; }
.encap-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.encap-stepnum { font-size: 12.5px; color: var(--muted); }

/* ---------------- Subnet calculator & trainer ---------------- */
.sc, .st { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 18px 0; }
.sc-inputs { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; }
.sc-inputs label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sc-inputs input[type=text] {
  font-family: var(--mono); font-size: 15px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); min-width: 210px;
}
.sc-pfx-range { display: flex; align-items: center; gap: 10px; }
.sc-pfx-range input[type=range] { width: 180px; accent-color: var(--brand); }
.sc-pfx-range b { font-family: var(--mono); color: var(--brand); min-width: 40px; }
.sc-out { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 22px; margin-top: 18px; }
.sc-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sc-k { color: var(--muted); }
.sc-v { font-family: var(--mono); color: var(--ink); text-align: right; }
.sc-binary { margin-top: 18px; font-family: var(--mono); font-size: 14px; letter-spacing: 1px; line-height: 1.9; }
.sc-bytegap { display: inline-block; width: 12px; }
.sc-netbit { color: var(--brand); font-weight: 700; }
.sc-hostbit { color: var(--brand-2); }
.sc-legend { margin-top: 8px; font-family: var(--sans); font-size: 12px; letter-spacing: 0; display: flex; gap: 18px; }
.sc-legend .sc-netbit, .sc-legend .sc-hostbit { font-weight: 600; }
.sc-note, .sc-err { margin-top: 14px; font-size: 13px; color: var(--muted); }
.sc-err { color: var(--danger); }

.st-bar { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 14px; }
.st-score, .st-streak { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.st-streak { color: var(--ink-soft); font-weight: 600; }
.st-types { display: flex; gap: 12px; flex-wrap: wrap; margin-left: auto; }
.st-types label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.st-q { font-size: 1.1rem; font-weight: 600; color: var(--ink); margin: 8px 0 16px; }
.st-answer { display: flex; gap: 10px; flex-wrap: wrap; }
.st-answer input {
  flex: 1; min-width: 220px; font-family: var(--mono); font-size: 15px; padding: 11px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.st-feedback { margin-top: 14px; font-size: 14.5px; min-height: 1.4em; }
.st-feedback.ok { color: var(--ok); font-weight: 600; }
.st-feedback.bad { color: var(--danger); font-weight: 600; }
.st-steps { margin-top: 14px; }
.st-steps summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.st-steps .answer { margin-top: 10px; }

/* ---------------- Seamless shell: transitions + navigator ---------------- */
@view-transition { navigation: auto; }
.topbar { view-transition-name: topbar; }
.wrap { view-transition-name: page; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(page) { animation: page-out .16s ease both; }
::view-transition-new(page) { animation: page-in .22s cubic-bezier(.2,.8,.2,1) both; }
@keyframes page-out { to { opacity: 0; transform: translateY(-5px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }

.actions .cn-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); border: 1px solid var(--line);
  padding: 3px 11px; border-radius: var(--radius-sm); background: var(--surface);
}
.actions .cn-btn:hover { background: var(--surface-3); color: var(--ink); }
.actions .cn-btn .glyph { font-size: 14px; line-height: 1; }
.actions .cn-btn .txt { display: inline; }
@media (max-width: 720px) { .actions .cn-btn .txt { display: none; } }
.actions .cn-btn kbd {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 5px; background: var(--surface-3);
}
@media (max-width: 900px) { .actions .cn-btn kbd { display: none; } }

.cn-overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(15,15,15,.42);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease;
}
.cn-overlay.open { opacity: 1; visibility: visible; }

.cn-panel {
  position: fixed; z-index: 81; top: 0; bottom: 0; left: 0;
  width: min(420px, 94vw); background: var(--surface); color: var(--ink);
  border-right: 1px solid var(--line); box-shadow: var(--shadow-pop);
  transform: translateX(-102%); transition: transform .24s cubic-bezier(.2,.85,.25,1), visibility .24s;
  display: flex; flex-direction: column; visibility: hidden;
}
.cn-panel.open { transform: none; visibility: visible; }

.cn-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.cn-head .cn-title { font-weight: 700; font-size: 1.02rem; }
.cn-head .cn-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.cn-close {
  margin-left: auto; cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); width: 32px; height: 32px; border-radius: var(--radius-sm); font-size: 16px; line-height: 1;
}
.cn-close:hover { background: var(--surface-3); color: var(--ink); }

.cn-search { padding: 12px 16px; }
.cn-search input {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.cn-search input:focus { outline: 2px solid var(--brand); outline-offset: 1px; background: var(--surface); }

.cn-continue {
  margin: 0 16px 8px; display: flex; gap: 10px; align-items: center; cursor: pointer;
  text-decoration: none; color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px; background: var(--surface-2);
}
.cn-continue:hover { background: var(--surface-3); }
.cn-continue .lbl { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--brand-2); }
.cn-continue .val { font-weight: 600; font-size: 14px; }

.cn-list { flex: 1; overflow-y: auto; padding: 4px 8px 26px; overscroll-behavior: contain; }
.cn-group-h {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); padding: 14px 10px 6px;
}
.cn-item {
  display: flex; gap: 10px; align-items: baseline; text-decoration: none; color: var(--ink);
  padding: 7px 10px; border-radius: var(--radius-sm); font-size: 14px;
}
.cn-item:hover, .cn-item.sel { background: var(--surface-2); }
.cn-item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.cn-item[aria-current="page"] { background: var(--tint-blue); color: var(--brand); font-weight: 600; }
.cn-item .badge {
  flex: none; font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1px 6px;
}
.cn-item[aria-current="page"] .badge { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.cn-item .tt { flex: 1; }
.cn-empty { padding: 26px 16px; color: var(--muted); font-size: 14.5px; }
.cn-foot {
  border-top: 1px solid var(--line); padding: 10px 16px;
  font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px;
}

/* Back to top */
.totop {
  position: fixed; right: 22px; bottom: 22px; z-index: 60; width: 42px; height: 42px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  box-shadow: var(--shadow-pop); cursor: pointer; font-size: 18px; line-height: 1;
  opacity: 0; visibility: hidden; transform: translateY(10px); transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
.totop.show { opacity: 1; visibility: visible; transform: none; }
.totop:hover { background: var(--surface-3); color: var(--ink); }

/* ---------------- Print ---------------- */
@media print {
  .topbar, .lesson-nav, .totop, .cn-overlay, .cn-panel, .actions .cn-btn { display: none !important; }
  body { background: #fff; font-size: 11pt; color: #000; }
  .card, .callout, figure, table, pre { box-shadow: none; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  h2 { break-after: avoid; }
  .wrap { padding: 0; max-width: none; }
  .callout, .objectives, .card { border: 1px solid #ddd; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  ::view-transition-old(*), ::view-transition-new(*), ::view-transition-group(*) { animation: none !important; }
  .cn-panel, .cn-overlay, .totop { transition: none !important; }
}
