:root {
  --bg: #f6f3f8;
  --panel: #ffffff;
  --ink: #1f1a24;
  --muted: #5c5363;
  --pink: #cb287a;
  --pink-hot: #e91e8c;
  --purple: #5a3e9d;
  --purple-deep: #3d2b8c;
  --action: #1c2430;
  --action-hover: #0b6e73;
  --header: #0d0b10;
  --border: #e4dcec;
  --code-bg: #1f272a;
  /* Previous: #abb2bf. Lighter: #dae3e3. */
  --code-fg: #bcc4ce;
  --warn-bg: #fff3f3;
  --tip-bg: #fff8e6;
  --note-bg: #f3e8ff;
  --ok-bg: #eef8f0;
  --shadow: 0 8px 24px rgba(45, 20, 60, 0.08);
  --radius: 12px;
  --max: 1100px;
  --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --mono: Consolas, Monaco, "Courier New", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 1.05rem;
}

a { color: var(--purple); text-decoration: none; }
a:hover { color: var(--pink); text-decoration: underline; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header);
  color: #fff;
  border-bottom: 1px solid #2a2233;
}
.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: #fff; }
.brand img { height: 36px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.05rem; letter-spacing: 0.04em; }
.brand-text span { font-size: 0.82rem; color: #c9b7d8; }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: transparent;
  border: 1px solid #5a456e;
  color: #fff;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}
.top-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.top-nav a {
  color: #e8ddf2;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.92rem;
  text-decoration: none;
}
.top-nav a:hover,
.top-nav a.active {
  background: #2a3140;
  color: #fff;
  text-decoration: none;
}

.layout {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
}
.layout.home-layout { grid-template-columns: 1fr; }

.sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 100px);
  overflow: auto;
}
.sidebar h2 {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.sidebar a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.92rem;
  text-decoration: none;
}
.sidebar a:hover { background: #f4eaf8; color: var(--pink); text-decoration: none; }
.sidebar a.visited::after { content: "✓"; float: right; color: #3d9b5f; font-weight: 700; }
.sidebar a.active {
  background: linear-gradient(135deg, rgba(233,30,140,0.14), rgba(90,62,157,0.14));
  color: var(--purple-deep);
  font-weight: 650;
}
.sidebar .group { margin-top: 0.9rem; margin-bottom: 0.25rem; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.9rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.content h1 {
  margin: 0 0 0.75rem;
  font-size: 1.9rem;
  color: var(--ink);
  border-bottom: 3px solid var(--action-hover);
  padding-bottom: 0.55rem;
}
.content h2 {
  margin: 1.8rem 0 0.7rem;
  color: var(--purple-deep);
  font-size: 1.35rem;
}
.content h3 {
  margin: 1.3rem 0 0.5rem;
  color: var(--pink);
  font-size: 1.08rem;
}
.content p, .content li { color: var(--ink); }
.content ul, .content ol { padding-left: 1.25rem; }
.lead { font-size: 1.12rem; color: var(--muted); }
.learning-goals {
  margin: 1.25rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid #c9d8f7;
  border-radius: 10px;
  background: #f2f7ff;
}
.learning-goals h2 { margin: 0 0 0.35rem; color: #224b86; font-size: 1.05rem; }
.learning-goals p { margin: 0; }
.parts-list, .troubleshoot {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.parts-list summary, .troubleshoot summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: var(--purple-deep);
  font-weight: 700;
}
.parts-list p, .troubleshoot p { margin: 0; padding: 0 1rem 0.9rem; }
.expected, .challenge {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border-radius: 10px;
}
.expected { border-left: 5px solid #3d9b5f; background: var(--ok-bg); }
.challenge { border-left: 5px solid var(--pink); background: #fff1f8; }
.diagram-placeholder {
  display: grid;
  gap: 0.25rem;
  place-items: center;
  min-height: 150px;
  padding: 1rem;
  margin: 1.25rem 0;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #cdbedd;
  border-radius: 10px;
  background: #faf7fc;
}
.diagram-placeholder strong { color: var(--purple-deep); }
.diagram-icon { font-size: 2rem; color: var(--pink); }

.hero {
  background: linear-gradient(145deg, #120f18, #2a1640 55%, #4a1d55);
  color: #fff;
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.hero h1 {
  color: #fff;
  border: none;
  margin-bottom: 0.4rem;
}
.hero p { color: #e7d7f2; max-width: 52ch; }
.hero-brand { height: 72px; margin-bottom: 1rem; }
.course-intro {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}
.course-intro > div {
  padding: 1rem;
  border-radius: 10px;
  background: #faf7fc;
  border: 1px solid var(--border);
}
.course-intro h3 { margin-top: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--pink);
  text-decoration: none;
  color: inherit;
}
.card .num {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  background: var(--action);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}
.card h3 { margin: 0 0 0.35rem; color: var(--purple-deep); font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #f3e8ff;
  color: var(--purple);
  margin-right: 0.35rem;
}

.note, .tip, .warn, .checkpoint {
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
}
.note { background: var(--note-bg); border-left: 5px solid var(--purple); }
.tip { background: var(--tip-bg); border-left: 5px solid #d4a017; }
.warn { background: var(--warn-bg); border-left: 5px solid #d9534f; }
.checkpoint { background: var(--ok-bg); border-left: 5px solid #3d9b5f; }

figure.fig {
  margin: 1.25rem 0;
  text-align: center;
}
figure.fig img,
figure.fig svg {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
figure.fig-photo img {
  background: #f4f6f8;
  width: min(100%, 420px);
  margin-left: auto;
  margin-right: auto;
  display: block;
}
a.zoom-image {
  display: inline-block;
  cursor: zoom-in;
  text-decoration: none;
}
body.lightbox-open {
  overflow: hidden;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem 1.25rem;
  background: rgba(12, 16, 22, 0.78);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.lightbox[hidden] {
  display: none;
}
.lightbox.is-open {
  opacity: 1;
}
.lightbox-img {
  max-width: min(92vw, 1100px);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  transform: scale(0.96);
  transition: transform 0.18s ease;
}
.lightbox.is-open .lightbox-img {
  transform: scale(1);
}
.lightbox-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2.6rem;
  height: 2.6rem;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #1c2430;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: #f3f5f7;
  outline: 2px solid #0ca1a6;
  outline-offset: 2px;
}
figure.fig-breadboard {
  margin: 0.85rem 0 1.25rem;
}
figure.fig-breadboard img {
  display: block;
  width: min(100%, 720px);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #f4f6f8;
  box-shadow: 0 1px 3px rgba(28, 36, 48, 0.08);
}
@media (max-width: 720px) {
  figure.fig-breadboard img {
    width: 100%;
  }
}
figure.fig figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}
figure.fig .fig-credit {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
}

/* Library guide (Lesson 32) — sit flush in the lesson panel */
.library-guide {
  margin-top: 0.35rem;
}
.library-guide a.zoom-image,
.library-guide .diagram a {
  cursor: zoom-in;
}

table.info {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.98rem;
}
table.info th, table.info td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
table.info th {
  background: #f3e8ff;
  color: var(--purple-deep);
}

.pre-wrap { position: relative; margin: 1rem 0; }
.pre-wrap button.copy {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  background: #2c353a;
  color: #dae3e3;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.pre-wrap button.copy:hover { background: #0ca1a6; color: #101618; }
pre.code {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 2.65rem 1.2rem 1.1rem;
  border-radius: 10px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.5;
  border: 1px solid #434f54;
  margin: 0;
}
/* Arduino IDE 2 inspired dark syntax palette */
.pre-wrap::before {
  content: attr(data-language);
  position: absolute;
  top: 0.65rem;
  left: 0.85rem;
  z-index: 1;
  color: #7f8c8d;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
}
.tok-keyword { color: #c586c0; }
.tok-type { color: #0ca1a6; }
.tok-function { color: #f39c12; }
.tok-string { color: #7fcbcd; }
.tok-number { color: #7fcbcd; }
.tok-comment { color: #5c6370; font-style: italic; }
.tok-preprocessor { color: #c586c0; }
.tok-constant { color: #7fcbcd; }
pre.code code { color: #bcc4ce; /* Previous: #abb2bf. Lighter: #dae3e3. */ }
pre.code ::selection { background: #00818480; color: #fff; }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.pager a {
  display: inline-block;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  background: #eef1f4;
  color: var(--action);
  font-weight: 650;
  text-decoration: none;
}
.pager a:hover { background: var(--action); color: #fff; text-decoration: none; }

.answers-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #f3e8ff;
  border: 1px solid #d7c4ef;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin: 1rem 0 1.5rem;
  cursor: pointer;
  font-weight: 700;
  color: var(--purple-deep);
}
.answers-toggle input { width: 18px; height: 18px; accent-color: var(--pink); }
.answer { display: none; margin-top: 0.6rem; }
body.show-answers .answer { display: block; }

.site-footer {
  background: #fff;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.4rem 1.25rem 1.8rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.footer-inner img { height: 48px; width: auto; }
.footer-copy { color: var(--muted); font-size: 0.92rem; max-width: 55ch; }
.footer-copy a { font-weight: 650; }

.wiring-list { background: #faf7fc; border-left: 5px solid var(--purple); padding: 0.9rem 1.1rem; border-radius: 8px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; display: none; }
  body.nav-open .sidebar { display: block; }
  .nav-toggle { display: inline-block; }
  .top-nav { display: none; width: 100%; }
  body.nav-open .top-nav { display: flex; }
  .content { padding: 1.25rem; }
}

/* Complete self-study course */
.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  transform: translateY(-150%);
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  background: #fff;
  color: var(--purple-deep);
  font-weight: 700;
}
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid #ffb000; outline-offset: 3px; }

.course-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  gap: 1.25rem;
}
.course-shell .content { max-width: 1050px; width: 100%; }
.home-shell .content { max-width: none; }
.course-nav {
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.nav-progress { display: grid; gap: 0.35rem; margin-bottom: 0.9rem; }
.nav-progress span { color: var(--muted); font-size: 0.85rem; }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: #e8e1ed; }
.progress-track > span { display: block; width: 0; height: 100%; background: var(--action-hover); transition: width 0.2s ease; }
.nav-search, .course-search { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.nav-search input, .course-search input {
  width: 100%;
  min-height: 42px;
  padding: 0.6rem 0.75rem;
  border: 1px solid #cfc3d8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.nav-group h3 {
  margin: 1.1rem 0 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.nav-group a {
  display: block;
  padding: 0.42rem 0.5rem;
  border-radius: 7px;
  color: var(--ink);
  font-size: 0.84rem;
}
.nav-group a:hover, .nav-group a.active { background: #eef2f5; color: var(--action); text-decoration: none; }
.nav-group a.completed::after { content: "✓"; float: right; color: #267a45; font-weight: 800; }
.reset-progress {
  width: 100%;
  margin-top: 1rem;
  padding: 0.55rem;
  border: 1px solid #c5ced6;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.breadcrumbs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; color: var(--muted); font-size: 0.85rem; }
.lesson-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 1.2rem; }
.lesson-header h1 { margin-top: 0.3rem; border: 0; padding: 0; }
.unit-label, .eyebrow { color: var(--pink); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.lesson-meta { display: grid; align-content: start; justify-items: end; gap: 0.7rem; color: var(--muted); font-size: 0.86rem; }
.complete-button, .primary-action, .download-sketch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.55rem 0.85rem;
  border: 0;
  border-radius: 8px;
  background: var(--action);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.complete-button:hover, .primary-action:hover, .download-sketch:hover {
  background: var(--action-hover);
  color: #fff;
  text-decoration: none;
  filter: none;
}
.complete-button.completed { background: #287a48; }
.lesson-start { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.2rem 0; }
.lesson-start > div { margin: 0; }
.prerequisites { padding: 1rem 1.15rem; border-radius: 10px; border: 1px solid #ead9bc; background: #fffaf0; }
.prerequisites h2 { margin: 0 0 0.35rem; color: #755311; font-size: 1.05rem; }
.prerequisites p { margin: 0.35rem 0; }
.libraries-box {
  margin: 1.25rem 0;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  border: 1px solid #b9d8dc;
  background: #f3fbfc;
}
.libraries-box h2 { margin-top: 0; color: #0b6e73; }
.libraries-box table.info th { background: #d8f0f2; color: #0b6e73; }
.on-this-page { padding: 0.9rem 1rem; border-left: 4px solid var(--purple); background: #faf7fc; }
.on-this-page ol { columns: 2; margin: 0.45rem 0 0; padding-left: 1.25rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.download-sketch:hover, .primary-action:hover { color: #fff; text-decoration: none; }
.code-explanation { padding: 0.8rem 1rem; border: 1px solid #d9d1e0; border-radius: 10px; background: #faf9fb; }
.code-explanation h3 { margin-top: 0; }
.test-panel { padding: 1rem; border: 1px solid #bcd9c5; border-radius: 12px; background: #f6fcf8; }
.test-panel h2 { margin-top: 0; color: #23633a; }
.test-panel label { display: block; margin: 0.45rem 0; }
.test-panel input { width: 18px; height: 18px; vertical-align: middle; accent-color: #267a45; }
.quiz-item { padding: 0.8rem 0; border-bottom: 1px solid var(--border); }
.quiz-item details { margin-left: 1rem; }
.quiz-item summary { color: var(--purple); cursor: pointer; font-weight: 700; }
table.info { display: block; max-width: 100%; overflow-x: auto; }

.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr); align-items: center; gap: 2rem; }
.hero h1 { max-width: 19ch; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.08; }
.hero p { font-size: 1.15rem; }
.hero img { width: 100%; border-radius: 12px; background: #fff; }
.hero-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.2rem; }
.hero-actions > a:not(.primary-action) { color: #c5d0d8; font-weight: 700; }
.extension-spotlight {
  margin: 1.25rem 0 1.75rem;
  padding: 1.25rem 1.4rem;
  border-radius: 12px;
  border: 1px solid #9ec5c9;
  background: linear-gradient(180deg, #f3fbfc 0%, #e7f4f5 100%);
  display: grid;
  gap: 1rem;
}
.extension-spotlight h2 { margin: 0.25rem 0 0.55rem; color: #0b6e73; }
.extension-spotlight p { margin: 0.4rem 0; }
.extension-spotlight .primary-action { margin-top: 0.35rem; }
.read-first {
  margin: 1rem 0 1.25rem;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  border: 1px solid #c4b5e0;
  background: linear-gradient(180deg, #faf7ff 0%, #f3eefc 100%);
}
.read-first strong { display: block; color: var(--purple); font-size: 1.05rem; margin-bottom: 0.35rem; }
.read-first p { margin: 0.35rem 0; }
.read-first ul { margin: 0.5rem 0 0.35rem 1.1rem; padding: 0; }
.read-first li { margin: 0.25rem 0; }
.read-first a { font-weight: 700; }
.read-first-all { margin-top: 0.65rem !important; }
.attribution-note {
  margin: 0.5rem 0 1.25rem;
  font-size: 0.92rem;
  color: #8b97a3;
}
.ref-source {
  margin: 1.5rem 0 0;
  font-size: 0.75rem;
  color: #9aa5b0;
  line-height: 1.35;
}

/* Theory Reference - technical document layout */
.ref-hero {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
}
.ref-hero h1 { margin: 0.25rem 0 0.5rem; border: 0; padding: 0; font-size: clamp(1.85rem, 4vw, 2.6rem); }
.ref-hero .lead { margin: 0; max-width: 62ch; }
.ref-toc {
  margin: 0 0 1.75rem;
  padding: 1.1rem 1.2rem 1.25rem;
  border: 1px solid #d5cce3;
  border-radius: 14px;
  background: linear-gradient(180deg, #fbf8ff 0%, #f4eefb 100%);
}
.ref-toc > strong {
  display: block;
  color: var(--purple);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin-bottom: 0.85rem;
}
.ref-toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.25rem;
}
.ref-toc-chapter strong { color: #1c2430; font-size: 0.95rem; }
.ref-toc-chapter ul {
  margin: 0.4rem 0 0;
  padding-left: 1.05rem;
  font-size: 0.9rem;
}
.ref-toc-chapter li { margin: 0.2rem 0; }
.ref-doc { display: flex; flex-direction: column; gap: 2rem; }
.ref-chapter {
  margin: 0;
  padding: 0;
  border: 0;
}
.ref-chapter > h2 {
  margin: 0 0 0.45rem;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid #0b6e73;
  color: #0b6e73;
}
.ref-chapter-intro {
  margin: 0 0 1rem;
  max-width: 70ch;
  color: #4a5560;
}
.ref-entry-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}
.ref-entry {
  margin: 0;
  padding: 1rem 1.15rem 1.1rem;
  border: 1px solid #dfe5ea;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(28, 36, 48, 0.04);
}
.ref-entry.kind-api { border-left: 4px solid #0b6e73; }
.ref-entry.kind-syntax { border-left: 4px solid #7b5ea7; }
.ref-entry.kind-type { border-left: 4px solid #2f6fed; }
.ref-entry.kind-circuit { border-left: 4px solid #c45c26; }
.ref-entry.kind-concept { border-left: 4px solid #3d7a8c; }
.ref-entry.kind-note,
.ref-entry.kind-table,
.ref-entry.kind-glossary { border-left: 4px solid #8b97a3; }
.ref-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.55rem 0.75rem;
  margin-bottom: 0.55rem;
}
.ref-entry-head h3 {
  margin: 0;
  font-size: 1.12rem;
  color: #1c2430;
}
.ref-kind {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: #eef3f5;
  color: #44505c;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ref-sig-wrap { margin: 0 0 0.75rem; }
.ref-sig-wrap .ref-sig {
  margin: 0;
  padding-top: 2.35rem;
  font-size: 0.86rem;
}
.ref-entry > p { margin: 0.35rem 0 0.55rem; max-width: 72ch; }
.ref-section { margin: 0.85rem 0 0.35rem; }
.ref-section h4 {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  color: #0b6e73;
}
.ref-defs {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.ref-def {
  display: grid;
  grid-template-columns: minmax(7.5rem, 11rem) minmax(0, 1fr);
  gap: 0.35rem 1rem;
  align-items: start;
  padding: 0.7rem 0.85rem;
  border: 1px solid #e4e9ed;
  border-radius: 10px;
  background: #fafbfc;
}
.ref-def-term {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.ref-def-term code {
  display: inline-block;
  width: fit-content;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: #1f272a;
  color: #7fcbcd;
  font-size: 0.9rem;
}
.ref-def-term strong {
  color: #1c2430;
  font-size: 0.92rem;
}
.ref-def p {
  margin: 0;
  max-width: none;
  line-height: 1.55;
}
@media (max-width: 720px) {
  .ref-def { grid-template-columns: 1fr; }
}
.ref-related {
  margin: 0.75rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px dashed #d5dde3;
  font-size: 0.92rem;
}
.ref-related span {
  font-weight: 700;
  color: #0b6e73;
  margin-right: 0.35rem;
}
.ref-table { margin-top: 0.65rem; }
.ref-glossary {
  display: grid;
  grid-template-columns: minmax(7rem, 10rem) 1fr;
  gap: 0.45rem 1rem;
  margin: 0.65rem 0 0;
}
.ref-glossary dt {
  margin: 0;
  font-weight: 700;
  color: #0b6e73;
}
.ref-glossary dd { margin: 0; }
.ref-revision {
  margin: 2rem 0 1.25rem;
  padding: 1.15rem 1.25rem;
  border-radius: 14px;
  border: 1px solid #c5d5d8;
  background: #f7fbfb;
}
.ref-revision .section-heading { margin-bottom: 0.65rem; }

@media (min-width: 900px) {
  .ref-chapter#data-and-variables .ref-entry-grid,
  .ref-chapter#digital-io .ref-entry-grid,
  .ref-chapter#analogue-io .ref-entry-grid,
  .ref-chapter#circuit-notes .ref-entry-grid {
    grid-template-columns: 1fr 1fr;
  }
  .ref-chapter#data-and-variables .ref-entry:first-child,
  .ref-chapter#digital-io .ref-entry:first-child,
  .ref-chapter#digital-io .ref-entry.ref-span-2,
  .ref-chapter#circuit-notes .ref-entry:last-child {
    grid-column: 1 / -1;
  }
}
.ref-block {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid #e5ebef;
}
.ref-block h4 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  color: #1c2430;
}
.ref-block > p {
  margin: 0.35rem 0 0.55rem;
  max-width: 72ch;
}
.ref-toc-nested {
  padding-left: 0.75rem;
}

@media (max-width: 720px) {
  .ref-hero { flex-direction: column; }
  .ref-glossary { grid-template-columns: 1fr; gap: 0.15rem 0; }
  .ref-glossary dt { margin-top: 0.45rem; }
}

.home-spotlight {
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, 0.6fr);
  align-items: center;
}
.spotlight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
  margin-top: 0.85rem !important;
}
.spotlight-actions > a:not(.primary-action) {
  color: #0b6e73;
  font-weight: 700;
}
.spotlight-points {
  margin: 0;
  padding: 0.9rem 0.9rem 0.9rem 1.4rem;
  background: #fff;
  border: 1px solid #c5e0e3;
  border-radius: 10px;
  color: #1c2430;
}
.nav-extras a {
  font-weight: 700;
  color: #0b6e73 !important;
}
.dashboard-progress { margin: 1rem 0 2rem; padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.dashboard-progress > div:first-child { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.feature-grid, .unit-grid, .kit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.feature-grid article, .kit-grid > div, .unit-card { padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.feature-grid h3, .kit-grid h3 { margin-top: 0; }
.unit-card { display: block; color: inherit; }
.unit-card span { color: var(--pink); font-size: 0.76rem; font-weight: 800; text-transform: uppercase; }
.unit-card h3 { margin: 0.35rem 0; color: var(--purple-deep); }
.unit-card:hover { border-color: var(--pink); text-decoration: none; transform: translateY(-2px); }
.card-unit, .card-time { display: block; color: var(--muted); font-size: 0.75rem; }
.card-time { margin-top: 0.8rem; }
.lesson-card.completed { border-color: #6eb787; background: #f5fcf7; }
.lesson-card.completed::after { content: "Completed ✓"; display: block; margin-top: 0.5rem; color: #267a45; font-weight: 800; font-size: 0.8rem; }
.lesson-card[hidden], .nav-group a[hidden] { display: none; }

@media (max-width: 1050px) {
  .course-shell { grid-template-columns: 1fr; }
  .course-nav { position: static; max-height: none; display: none; }
  body.nav-open .course-nav { display: block; }
  .nav-toggle { display: inline-block; }
  .top-nav { display: none; width: 100%; }
  body.nav-open .top-nav { display: flex; }
  .nav-group a { min-height: 44px; padding: 0.68rem; }
}
@media (max-width: 720px) {
  body { font-size: 1rem; }
  .course-shell { padding: 0.7rem; }
  .content { padding: 1rem; }
  .lesson-header, .lesson-start, .hero { grid-template-columns: 1fr; }
  .lesson-meta { justify-items: start; }
  .on-this-page ol { columns: 1; }
  .hero img { display: none; }
  pre.code { font-size: 0.82rem; }
}
@media (max-width: 800px) {
  .home-spotlight { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
@media print {
  .site-header, .course-nav, .site-footer, .complete-button, .copy, .pager, .download-sketch { display: none !important; }
  .course-shell { display: block; padding: 0; }
  .content { max-width: none; border: 0; box-shadow: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
  pre.code { white-space: pre-wrap; }
}
