@import url("https://fonts.googleapis.com/css2?family=Miriam+Libre:wght@400..700&display=swap");

/* palette taken from the course's VAD tool */
:root {
  --paper: #fcf1ee; /* page */
  --panel: #ffffff; /* cards */
  --ink: #272120; /* text */
  --frame: #4a4848; /* borders + hard shadow */
  --muted: #6b6261;
  --line: #e6d9d4;
  --blue: #40769b; /* dominance / agency */
  --blue-dark: #2b526d;
  --sky: #519ec6; /* arousal */
  --orange: #da8446; /* valence */
  --tag: #e4ddd0;
  --blush: #f6e1de;
  --red: #b5342a;
  --shadow: 2px 2px 0 var(--frame);
  --head: "Miriam Libre", Arial, sans-serif;
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: 30px;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Miriam Libre", Arial, sans-serif;
  font-size: 19px;
  line-height: 1.7;
}
a {
  color: var(--blue);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--blue-dark);
}
.progress {
  position: fixed;
  top: 0;
  right: 0;
  height: 5px;
  background: var(--orange);
  width: 0;
  z-index: 5;
}
.skip {
  position: absolute;
  top: -80px;
  right: 15px;
  background: var(--panel);
  padding: 10px;
  z-index: 10;
  border: 2px solid var(--frame);
}
.skip:focus {
  top: 10px;
}
:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

/* ---------- header ---------- */
header {
  max-width: 1360px;
  margin: 0 auto;
  padding: 34px 32px 6px;
}
.titleblock {
  border-right: 7px solid var(--blue);
  padding: 4px 24px 6px 0;
  margin-top: 6px;
}
.eyebrow {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.02em;
}
h1 {
  font-family: var(--head);
  font-weight: 500;
  font-size: clamp(38px, 5.4vw, 66px);
  line-height: 1.05;
  margin: 6px 0 14px;
  color: var(--ink);
}
header p {
  max-width: 820px;
  font-size: 21px;
  color: var(--muted);
  margin: 0;
  line-height: 1.3;
}
.tags {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.tags span {
  background: var(--tag);
  border-radius: 50px;
  padding: 3px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

/* course toolbar */
.course-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow: var(--shadow);
  border-radius: 4px;
  padding: 10px 18px;
  margin: 0 0 30px;
  font-size: 16px;
}
.course-bar .home {
  font-family: var(--head);
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  margin-left: 10px;
}
.course-bar a.lesson {
  color: var(--ink);
  text-decoration: none;
  background: var(--panel);
  border: 2px solid var(--frame);
  border-radius: 6px;
  padding: 0px 16px;
  font-weight: 700;
  box-shadow: 2px 2px 0 var(--frame);
  transition: transform 0.08s;
}
.course-bar a.lesson:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--frame);
}
.course-bar a.lesson[aria-current] {
  background: var(--blue);
  color: #fff;
}
.course-bar .new {
  font-size: 12px;
  background: var(--orange);
  color: #fff;
  border-radius: 50px;
  padding: 0 8px;
  margin-right: 8px;
  vertical-align: 1px;
}

/* ---------- layout ---------- */
.layout {
  max-width: 1360px;
  margin: auto;
  display: grid;
  grid-template-columns: 290px minmax(0, 920px);
  gap: 30px;
  padding: 20px 32px 80px;
}
nav {
  position: sticky;
  top: 22px;
  align-self: start;
  max-height: 92vh;
  overflow: auto;
  font-size: 15px;
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow: var(--shadow);
  border-radius: 4px;
  padding: 14px 12px;
}
nav strong {
  display: block;
  margin: 4px 8px 12px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
nav a {
  display: block;
  text-decoration: none;
  color: var(--ink);
  padding: 6px 10px;
  border: 2px solid transparent;
  border-radius: 4px;
  line-height: 1.45;
  margin-bottom: 2px;
}
nav a:hover {
  background: var(--paper);
}
nav a.active {
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 700;
  background: var(--panel);
}
.print {
  font: inherit;
  font-weight: 700;
  background: var(--panel);
  color: var(--ink);
  border: 2px solid var(--frame);
  box-shadow: 2px 2px 0 var(--frame);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  margin: 16px 8px 6px;
}
.print:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--frame);
}
main {
  min-width: 0;
}

/* ---------- panels ---------- */
.intro {
  padding: 14px 20px;
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow: var(--shadow);
  border-radius: 4px;
  font-size: 17px;
  margin-bottom: 30px;
}
.intro p {
  margin: 0;
}
.audio-native {
  margin: 0 0 30px;
}
section {
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow: var(--shadow);
  border-radius: 4px;
  padding: 14px 20px 30px;
  margin-bottom: 30px;
}
h2 {
  font-family: var(--head);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.35;
  color: var(--ink);
  margin: 0 0 22px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
}
h3 {
  font-size: 22px;
  font-weight: 700;
  margin: 30px 0 8px;
  color: var(--blue-dark);
}
p {
  margin: 0 0px 10px;
}
section ul,
section ol {
  padding-right: 24px;
}
li {
  padding-right: 5px;
  margin-bottom: 0px;
}

/* figures */
figure {
  margin: 26px 0;
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: hidden;
}
figure img {
  display: block;
  width: 100%;
  max-height: 610px;
  object-fit: contain;
}
figcaption {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  padding: 12px 18px;
  border-top: 2px solid var(--line);
  background: var(--paper);
}
.zoom {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--panel);
  border: 0;
  cursor: zoom-in;
}
.gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.gallery figure {
  margin: 8px 0 22px;
}
.gallery img {
  height: 245px;
  object-fit: contain;
}
.video-frame {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--ink);
}
.video-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.three {
  grid-template-columns: repeat(3, 1fr);
}
.three img {
  height: 165px;
}
.traps img {
  height: 220px;
}

/* callouts */
.key {
  background: var(--paper);
  border: 2px solid var(--frame);
  border-right: 8px solid var(--blue);
  border-radius: 4px;
  padding: 18px 24px;
  margin: 26px 0;
  font-size: 21px;
  line-height: 1.6;
  font-weight: 600;
}
aside {
  padding: 16px 22px;
  border: 2px solid var(--frame);
  border-right: 8px solid var(--orange);
  border-radius: 4px;
  background: #fdf6f1;
  color: var(--ink);
  font-size: 17px;
  margin: 24px 0;
}
aside strong {
  color: #a5521c;
}
blockquote {
  margin: 24px 0;
  padding: 30px;
  text-align: center;
  background: var(--paper);
  border: 2px solid var(--frame);
  border-radius: 4px;
  font-size: 26px;
  line-height: 1.55;
  font-family: var(--head);
}
blockquote span {
  display: block;
}
cite {
  display: block;
  font-style: normal;
  font-family: "Miriam Libre", sans-serif;
  font-size: 15px;
  color: var(--muted);
  margin-top: 12px;
}
.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 12px;
  margin: 24px 0;
  background: var(--paper);
  border: 2px dashed var(--line);
  border-radius: 4px;
  font-size: 16px;
}
.flow span {
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow: 2px 2px 0 var(--frame);
  padding: 7px 13px;
  border-radius: 6px;
  font-weight: 600;
}
.flow b {
  color: var(--orange);
  font-size: 20px;
}

/* code + tables */
code {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--blush);
  border-radius: 3px;
  padding: 0 6px;
  color: var(--ink);
}
pre {
  direction: ltr;
  text-align: left;
  background: var(--ink);
  color: #f6ece9;
  padding: 18px 22px;
  border: 2px solid var(--frame);
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: auto;
  font-size: 15px;
  line-height: 1.65;
  margin: 22px 0;
}
pre code {
  background: none;
  color: inherit;
  padding: 0;
  display: block;
  font-size: inherit;
}
.table-wrap {
  overflow: auto;
  margin: 22px 0;
  border: 2px solid var(--frame);
  border-radius: 4px;
  box-shadow: var(--shadow);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 17px;
  margin: 0;
  background: var(--panel);
}
th,
td {
  text-align: right;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  vertical-align: top;
}
th {
  background: var(--tag);
  font-weight: 700;
}
tr:last-child td {
  border-bottom: 0;
}
td:last-child,
th:last-child {
  border-left: 0;
}

/* assignment, details, glossary */
.assignment {
  background: var(--paper);
  border: 2px solid var(--frame);
  border-right: 8px solid var(--orange);
  border-radius: 4px;
  padding: 6px 24px 14px;
}
details {
  margin: 24px 0;
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow: 2px 2px 0 var(--frame);
  padding: 12px 20px;
  border-radius: 4px;
}
summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--blue);
}
dl {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px 22px;
}
dt {
  font-weight: 700;
  color: var(--blue);
}
dd {
  margin: 0;
}
footer {
  font-size: 15px;
  color: var(--muted);
  padding: 6px 4px 0;
}

/* image placeholders */
.ph {
  border: 2px dashed var(--sky);
  background: #f2f8fb;
  border-radius: 4px;
  padding: 28px 22px;
  text-align: center;
  margin: 26px 0;
  color: var(--muted);
  box-shadow: none;
  overflow: visible;
}
.ph .ph-label {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  border-radius: 50px;
  padding: 2px 12px;
  margin-bottom: 10px;
  background: var(--panel);
  border: 2px solid var(--sky);
  color: var(--blue-dark);
}
.ph .ph-title {
  font-weight: 700;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.5;
}
.ph p {
  margin: 8px 0 0;
  font-size: 16px;
  line-height: 1.6;
}
.ph.cta {
  border-color: var(--orange);
  background: #fdf3ea;
}
.ph.cta .ph-label {
  border-color: var(--orange);
  color: #a5521c;
}
.gallery .ph {
  margin: 8px 0 22px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* pager */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.pager a {
  flex: 1 1 220px;
  display: block;
  text-decoration: none;
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow: var(--shadow);
  border-radius: 4px;
  padding: 14px 18px;
  color: var(--ink);
  font-weight: 700;
}
.pager a small {
  display: block;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
}
.pager a:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--frame);
}
.pager .next {
  text-align: left;
}

/* image viewer */
dialog {
  border: 2px solid var(--frame);
  padding: 48px 15px 15px;
  background: var(--panel);
  max-width: 96vw;
  max-height: 95vh;
  border-radius: 4px;
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: rgba(39, 33, 32, 0.82);
}
dialog img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
}
#close {
  position: absolute;
  left: 12px;
  top: 10px;
  border: 2px solid var(--frame);
  background: var(--panel);
  box-shadow: 2px 2px 0 var(--frame);
  border-radius: 6px;
  padding: 3px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .layout {
    display: block;
    max-width: 920px;
    padding: 24px 22px;
  }
  nav {
    position: static;
    max-height: none;
    margin-bottom: 26px;
  }
  nav .links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 8px;
  }
  nav a {
    font-size: 14px;
  }
}
@media (max-width: 600px) {
  body {
    font-size: 17px;
  }
  header {
    padding: 22px 16px 0;
  }
  .titleblock {
    padding-right: 16px;
    border-right-width: 5px;
  }
  header p {
    font-size: 18px;
  }
  .layout {
    padding: 20px 16px;
  }
  section {
    padding: 20px 18px 22px;
  }
  h2 {
    font-size: 25px;
  }
  .gallery,
  .three {
    grid-template-columns: 1fr;
  }
  .gallery img {
    height: auto;
    max-height: 330px;
  }
  .key {
    font-size: 18px;
    padding: 14px 16px;
  }
  dl {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  dd {
    margin-bottom: 14px;
  }
  nav .links {
    grid-template-columns: 1fr 1fr;
  }
  nav a {
    font-size: 13px;
    padding: 5px 6px;
  }
  .print {
    display: none;
  }
  .flow {
    gap: 7px;
    font-size: 14px;
  }
  .flow span {
    padding: 5px 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
@media print {
  body {
    font-size: 11pt;
    background: #fff;
  }
  header {
    padding: 0 0 12px;
  }
  .tags,
  nav,
  .progress,
  .skip,
  dialog,
  .course-bar,
  .pager {
    display: none;
  }
  .layout {
    display: block;
    padding: 12px 0;
    max-width: none;
  }
  section,
  .intro,
  figure,
  .table-wrap,
  pre {
    box-shadow: none;
  }
  section {
    border: 0;
    padding: 10px 0;
    border-bottom: 1px solid #999;
    border-radius: 0;
  }
  h2 {
    font-size: 19pt;
    break-after: avoid;
  }
  h3 {
    break-after: avoid;
  }
  figure,
  .key,
  aside,
  tr,
  .ph,
  pre {
    break-inside: avoid;
  }
  .gallery img {
    max-height: 200px;
  }
  figure img {
    max-height: 340px;
  }
  figcaption {
    font-size: 9pt;
  }
  p {
    orphans: 3;
    widows: 3;
  }
  pre {
    background: #f3f3f3;
    color: #000;
  }
  details {
    display: none;
  }
  @page {
    size: A4;
    margin: 18mm;
  }
}

/* Code in the Arduino IDE 2 dark theme (arduino-ide: dark.color-theme.json). Shared by lesson pages and the deck. */
.ide {
  direction: ltr;
  text-align: left;
  background: #1f272a;
  border: 2px solid var(--frame);
  box-shadow: var(--shadow);
  border-radius: 6px;
  overflow: hidden;
  margin: 22px 0;
}
.ide-bar {
  background: #171e21;
  color: #dae3e3;
  font:
    600 13px/1 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  padding: 9px 14px;
  display: flex;
  gap: 7px;
  align-items: center;
}
.ide-bar i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #0ca1a6;
  display: inline-block;
}
.ide-bar i:nth-child(2) {
  background: #434f54;
}
.ide-bar span {
  margin-left: 8px;
  border-bottom: 2px solid #0ca1a6;
  padding-bottom: 3px;
}
.ide pre {
  margin: 0;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  background: transparent;
  color: #dae3e3;
  font-size: 15px;
  line-height: 1.6;
  padding: 14px 18px;
  white-space: pre;
  overflow: auto;
}
.ide .ln {
  display: inline-block;
  width: 2.2em;
  color: #434f54;
  user-select: none;
  text-align: right;
  margin-right: 1.2em;
}
.ide .ty {
  color: #0ca1a6;
}
.ide .fn {
  color: #f39c12;
}
.ide .co {
  color: #7fcbcd;
}
.ide .kw {
  color: #c586c0;
}
.ide .cm {
  color: #7f8c8d;
}
.ide .q {
  color: #f39c12;
  font-weight: 700;
}
.ide bdi {
  unicode-bidi: isolate;
}
@media print {
  .ide {
    box-shadow: none;
    border-color: #999;
  }
  .ide pre {
    color: #222;
    background: #fff;
  }
  .ide .cm {
    color: #666;
  }
}

/* Thermometer simulation: schematic thermometer + code + Serial Monitor (assets/sim.js) */
.sim {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 0;
  overflow: visible;
}
.sim-thermo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: var(--blush);
  border-left: 2px solid var(--frame);
}
.sim-label {
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}
.sim-label small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}
.thermo {
  width: 150px;
  height: auto;
  touch-action: none;
  cursor: ns-resize;
  user-select: none;
}
.thermo .glass {
  fill: #fff;
  stroke: var(--frame);
  stroke-width: 2;
}
.thermo .tick-mark {
  stroke: var(--frame);
  stroke-width: 1.5;
}
.thermo .scale {
  font:
    12px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  fill: var(--ink);
  direction: ltr;
}
.thermo .thr {
  stroke: var(--orange);
  stroke-width: 2;
  stroke-dasharray: 5 4;
}
.thermo .thr-label,
.thermo .thr-head {
  font:
    700 12px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  fill: var(--orange);
  text-anchor: end;
}
.thermo .thr-head {
  font-family: inherit;
  font-weight: 700;
}
.sim-range {
  width: 100%;
}
.sim-range input {
  width: 100%;
  accent-color: var(--blue);
}
.sim-readout {
  font:
    700 26px/1 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  color: var(--blue-dark);
}
.sim-io {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #1f272a;
}
.sim .ide {
  margin: 0;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}
.sim .ide-bar .tick {
  margin-left: auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #434f54;
}
.sim .ide-bar .tick.on {
  animation: simTick 1s ease-out;
}
@keyframes simTick {
  0% {
    background: #0ca1a6;
    box-shadow: 0 0 8px #0ca1a6;
  }
  100% {
    background: #434f54;
    box-shadow: none;
  }
}
.sim pre.rows {
  padding: 10px 0;
  font-size: 14px;
}
.sim .row {
  display: block;
  min-height: 1.6em;
  padding: 0 14px;
  border-left: 3px solid transparent;
}
.sim .row.run {
  background: rgba(12, 161, 166, 0.16);
  border-left-color: #0ca1a6;
}
.sim .row.pass {
  background: rgba(127, 140, 141, 0.08);
}
.serial {
  border-top: 2px solid #0b1012;
  display: flex;
  flex-direction: column;
}
.serial-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #171e21;
  color: #dae3e3;
  font:
    600 13px/1 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  padding: 8px 14px;
  direction: ltr;
}
.serial-bar small {
  color: #7f8c8d;
  font-weight: 400;
}
.serial-bar .clear {
  margin-left: auto;
  font: inherit;
  font-size: 12px;
  background: transparent;
  color: #dae3e3;
  border: 1px solid #434f54;
  border-radius: 4px;
  padding: 3px 9px;
  cursor: pointer;
}
.serial-bar .clear:hover {
  border-color: #0ca1a6;
}
.serial-out {
  height: 132px;
  overflow: auto;
  padding: 8px 14px;
  color: #dae3e3;
  font:
    14px/1.6 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  text-align: left;
}
.serial-out div {
  direction: ltr;
  text-align: left;
  white-space: nowrap;
}
.serial-out .ts {
  color: #7f8c8d;
}
.serial-out bdi {
  unicode-bidi: isolate;
  direction: rtl;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
@media (max-width: 640px) {
  .sim {
    grid-template-columns: 1fr;
  }
  .sim-thermo {
    border-left: 0;
    border-bottom: 2px solid var(--frame);
    display: grid;
    grid-template-columns: 110px 1fr;
    grid-template-areas: "svg label" "svg range" "svg out";
    align-items: center;
    justify-items: start;
  }
  .sim-thermo .thermo {
    grid-area: svg;
    width: 110px;
  }
  .sim-label {
    grid-area: label;
    text-align: right;
  }
  .sim-range {
    grid-area: range;
  }
  .sim-readout {
    grid-area: out;
  }
}
@media print {
  .sim {
    grid-template-columns: 1fr;
  }
  .sim-thermo,
  .serial {
    display: none;
  }
  .sim-io {
    background: #fff;
  }
}

/* Condition answer label in simulations: an annotation, not code */
.sim .ev {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  direction: rtl;
  margin-left: 16px;
  padding: 1px 9px;
  border-radius: 4px;
  font:
    700 12px/1.6 "Miriam Libre",
    system-ui,
    sans-serif;
  vertical-align: 1px;
  user-select: none;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}
.sim .ev:empty {
  display: none;
}
.sim .ev::before {
  content: "תשובה:";
  font-weight: 400;
}
.sim .ev.yes {
  background: #fcf1ee;
  color: #1d5d3b;
  border: 1.5px solid #3fa66b;
}
.sim .ev.no {
  background: #fcf1ee;
  color: #6b5d58;
  border: 1.5px dashed #9a8c87;
}

/* Copyable prompt */
.prompt {
  margin: 18px 0;
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: hidden;
}
.prompt-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--tag);
  border-bottom: 2px solid var(--frame);
  font-weight: 700;
}
.prompt-bar .copy {
  font: inherit;
  font-size: 14px;
  background: var(--panel);
  color: var(--ink);
  border: 2px solid var(--frame);
  box-shadow: 2px 2px 0 var(--frame);
  border-radius: 6px;
  padding: 2px 12px;
  cursor: pointer;
}
.prompt-text {
  margin: 0;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font:
    15px/1.7 "Miriam Libre",
    system-ui,
    sans-serif;
  white-space: pre-wrap;
  direction: rtl;
  text-align: right;
  padding: 14px 18px;
  max-height: 420px;
  overflow: auto;
}

/* Type finder */
.typer {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}
.typer-in {
  padding: 18px;
  background: var(--blush);
  border-left: 2px solid var(--frame);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.typer-in label {
  font-weight: 700;
}
.typer-in input {
  font:
    20px/1.4 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  padding: 8px 12px;
  border: 2px solid var(--frame);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--frame);
  width: 100%;
  box-sizing: border-box;
}
.typer-in input:focus {
  outline: 3px solid var(--sky);
  outline-offset: 1px;
}
.typer-ex {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 14px;
  color: var(--muted);
}
.typer-ex button {
  font:
    14px/1.4 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  background: var(--panel);
  color: var(--ink);
  border: 1.5px solid var(--frame);
  border-radius: 14px;
  padding: 1px 10px;
  cursor: pointer;
}
.typer-ex button:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.typer-out {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.typer-type {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.typer-type small {
  color: var(--muted);
  font-size: 14px;
}
.typer-kind {
  font:
    700 32px/1.1 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  color: var(--blue-dark);
  background: none;
  padding: 0;
  direction: ltr;
}
.typer-why {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  min-height: 3.2em;
}
.typer .ide {
  margin: 0;
}
@media (max-width: 640px) {
  .typer {
    grid-template-columns: 1fr;
  }
  .typer-in {
    border-left: 0;
    border-bottom: 2px solid var(--frame);
  }
}

/* AI-draft notice at the top of each lesson summary */
main aside.ai-note {
  margin: 0 0 18px;
  padding: 10px 14px;
  background: var(--panel);
  border: 2px dashed var(--muted);
  border-right: 2px dashed var(--muted);
  border-radius: 4px;
  box-shadow: none;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}
/* lesson abstract (top of each summary) */
.abstract {
  padding: 16px 22px 18px;
  background: var(--panel);
  border: 2px solid var(--frame);
  border-right: 8px solid var(--blue);
  box-shadow: var(--shadow);
  border-radius: 4px;
  margin-bottom: 30px;
}
.abstract h2 {
  font-size: 24px;
  margin: 0 0 12px;
  padding-bottom: 8px;
}
.abstract h2 small {
  display: block;
  font-size: 14px;
  color: var(--blue);
  letter-spacing: 0.02em;
}
.abstract-lead {
  font-size: 18px;
}
.abstract-points {
  list-style: none;
  padding: 0;
  margin: 14px 0;
  display: grid;
  gap: 10px;
}
.abstract-points li {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 0;
}
.abstract-points b {
  font-size: 14px;
  text-align: center;
  background: var(--tag);
  color: var(--blue-dark);
  border-radius: 50px;
  padding: 2px 8px;
}
.abstract-q {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 2px solid var(--line);
  font-weight: 700;
  color: var(--blue-dark);
}
@media (max-width: 600px) {
  .abstract-points li {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .abstract-points b {
    justify-self: start;
  }
}

/* ── lesson 4 summary: components around the demos (assets/demos.css) ── */
.deck-frame{position:relative;aspect-ratio:16/9;background:var(--panel);border:2px solid var(--frame);box-shadow:var(--shadow);border-radius:4px;overflow:hidden;margin:8px 0 14px}
.deck-frame iframe{position:absolute;top:0;left:0;width:1280px;height:720px;border:0;transform-origin:0 0}
.deck-frame.native{aspect-ratio:auto;height:78vh}
.deck-frame.native iframe{width:100%;height:100%;transform:none}
.deck-actions{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin-bottom:8px}
.deck-actions a.btn{display:inline-block;font-weight:700;background:var(--panel);color:var(--ink);border:2px solid var(--frame);box-shadow:2px 2px 0 var(--frame);border-radius:6px;padding:6px 16px;text-decoration:none}
.deck-actions small{color:var(--muted)}
.ide-bar .copy{margin-left:auto;font:inherit;font-size:13px;font-weight:700;background:#0ca1a6;color:#fff;border:0;border-radius:4px;padding:3px 12px;cursor:pointer}
.photo-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin:14px 0}
.photo-grid figure{margin:0}
.photo-grid img{width:100%;height:170px;object-fit:cover}
.photo-grid img[src*="food-processor"]{object-position:50% 85%}
.photo-grid figcaption{font-size:15px;line-height:1.45}
.photo-grid figcaption small{display:block;color:var(--muted);font-size:12px;margin-top:3px}
.photo-grid figcaption a{color:inherit}
.micro-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,300px);gap:18px;align-items:start}
.micro-row .lab{margin:0}
@media (max-width:700px){.photo-grid,.micro-row{grid-template-columns:1fr}.photo-grid img{height:200px}}

/* seesaw: pull-down / pull-up */
.seesaw{display:flex;flex-direction:column;gap:.5em}
.ss-modes{display:flex;flex-wrap:wrap;gap:.4em;align-items:center;font-size:.7em}
.ss-modes span{font-weight:700}
.ss-modes button{font:inherit;font-weight:700;background:var(--panel);color:var(--ink);border:2px solid var(--frame);border-radius:6px;padding:.2em .7em;cursor:pointer;box-shadow:2px 2px 0 var(--frame)}
.ss-modes button[aria-pressed=true]{background:var(--blue);color:#fff}
.seesaw svg{width:100%;max-width:520px;height:auto;align-self:center}
.seesaw .ss-base{fill:var(--frame)}
.seesaw .ss-plank{transition:transform .25s ease-out}
.seesaw .ss-plank rect{fill:#c9a24a;stroke:#7a5f22;stroke-width:2}
.seesaw .kid-small circle{fill:var(--sky);stroke:var(--blue-dark);stroke-width:2}
.seesaw .kid-big circle{fill:var(--orange);stroke:#8a4a1f;stroke-width:2}
.seesaw .kid-small,.seesaw .kid-big{transition:opacity .2s}
.seesaw svg text{font:700 13px 'Miriam Libre',sans-serif;fill:var(--ink)}
.seesaw svg text.side{font:700 14px ui-monospace,Menlo,Consolas,monospace;fill:var(--muted)}
.ss-ctrl{display:flex;align-items:center;justify-content:center;gap:1.6em}
.ss-out{font-size:.85em}
.ss-read{font:700 1.3em ui-monospace,Menlo,Consolas,monospace;color:var(--blue-dark)}
.ss-read.noise{color:var(--orange)}
.ss-note{font-size:.68em;margin:0;min-height:3em;text-align:center}

/* breadboard */
.bboard svg{width:100%;max-width:560px;height:auto;display:block;margin:0 auto}
.bboard .bb{fill:#f4f1ea;stroke:#c9c1b3;stroke-width:2}
.bboard .chan{fill:#e2dccf}
.bboard .holes rect{fill:#5d5a55}
.bboard .nums text{font:11px ui-monospace,Menlo,Consolas,monospace;fill:var(--muted)}
.bboard .strip{opacity:.35;transition:fill .15s}
.bboard .s-a{fill:var(--sky)}
.bboard .s-b{fill:var(--orange)}
.bboard svg.pressed .strip{fill:#2e9b5f;opacity:.45}
.bboard .bb-btn{cursor:pointer;touch-action:none;outline:none}
.bboard .bbody{fill:#2b2b2b;opacity:.92}
.bboard .bcap{fill:#555;stroke:#777;stroke-width:2}
.bboard svg.pressed .bcap{fill:#3a3a3a}
.bboard .bb-btn:focus-visible .bcap{stroke:var(--sky);stroke-width:4}
.bboard .leg{fill:#c9d0d2;stroke:#2b2b2b;stroke-width:1.5}
.bb-msg{font-size:.7em;text-align:center;min-height:2.6em;padding-top:.4em}
.bb-key{font-size:.62em;color:var(--muted);text-align:center;margin:.2em 0 0}
.bb-key .k{display:inline-block;width:.9em;height:.9em;border-radius:3px;vertical-align:-.1em;margin:0 .3em 0 .2em}
.k-a{background:var(--sky)}.k-b{background:var(--orange)}

/* global vs local variables */
.scopes{font-size:.75em}
.sc-band{background:var(--blue);color:#fff;border-radius:4px 4px 0 0;padding:.35em .8em}
.sc-band span{opacity:.9;font-size:.9em}
.sc-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));column-gap:10px}
.sc-val{background:rgba(64,118,155,.12);border-inline:1px dashed rgba(64,118,155,.4);padding:.5em;display:flex;flex-direction:column;gap:.2em;align-items:center}
.sc-val:first-child{border-right:0}.sc-val:nth-child(3){border-left:0}
.sc-val code,.sc-local code{direction:ltr;font-size:.95em}
.sc-round{margin-top:10px;border:2px solid var(--frame);border-radius:4px;padding:.5em;display:flex;flex-direction:column;align-items:center;gap:.3em;background:var(--panel)}
.sc-round small{color:var(--muted)}
.sc-local{background:#fde8d6;border:1.5px dashed var(--orange);border-radius:4px;padding:.1em .5em}
.sc-round em{font-style:normal;font-size:.85em;color:var(--muted)}
.scopes figcaption{margin-top:.7em;font-size:.95em}
.sc-k{display:inline-block;width:.9em;height:.9em;border-radius:3px;vertical-align:-.1em;margin:0 .5em 0 .3em}
.sc-kg{background:rgba(64,118,155,.5)}.sc-kl{background:#fde8d6;border:1.5px dashed var(--orange)}
@media (max-width:600px){.sc-grid{grid-template-columns:1fr}.sc-val,.sc-round{border-inline:1px dashed rgba(64,118,155,.4)}}
.seesaw svg,.bboard svg{direction:ltr}
.ide-bar .copy{white-space:nowrap}
.lab .verify .ide-bar .copy + .verify-btn{margin-left:8px}
.lab .sim .ide-bar{display:flex;align-items:center;gap:6px}
.copy-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:-6px 0 16px}
.copy-row .copy{font:inherit;font-size:14px;font-weight:700;background:#0ca1a6;color:#fff;border:0;border-radius:4px;padding:4px 14px;cursor:pointer}
.copy-row small{color:var(--muted);font-size:14px}
.copy-manual{background:var(--panel);border:2px solid var(--orange);border-radius:4px;padding:10px 12px;margin:-4px 0 16px}
.copy-manual p{margin:0 0 6px;font-size:15px}
.copy-manual kbd{font:700 13px ui-monospace,Menlo,Consolas,monospace;background:var(--tag);border-radius:3px;padding:0 5px}
.copy-manual textarea{display:block;width:100%;box-sizing:border-box;font:14px/1.5 ui-monospace,Menlo,Consolas,monospace;background:#1f272a;color:#dae3e3;border:0;border-radius:4px;padding:8px 10px;resize:vertical}
.copy-manual button{margin-top:6px;font:inherit;font-size:14px;background:var(--panel);border:2px solid var(--frame);border-radius:6px;padding:2px 12px;cursor:pointer}

/* ── print: paper layout for lesson summaries ──
   Hide what only works on screen; keep illustrations that still explain something on paper. */
@media screen {
  .print-only { display: none; }
}
@media print {
  @page { size: A4; margin: 16mm 14mm 18mm; }
  html, body { background: #fff !important; }
  a { color: inherit; }

  /* interactive-only */
  .screen-only, .print, .copy, .copy-row, .copy-manual, .ph.cta,
  .vbtn, .bs-press, .bs-panel, .speed, .waitnote, .chip, .clear,
  .verify-btn, .ide-out,
  .sim-thermo, .sim .serial, .sim-io .serial,
  .pinsel, .floatsim, .loopcount, .flipper, .scope-ctrl,
  .ss-modes, .sw-row, .sw-ctrl, .sw-lamp, .sw-svg .hint,
  .typer, .deck-frame, .deck-actions { display: none !important; }

  /* demos become static figures */
  .lab { font-size: 10.5pt; margin: 8pt 0; }
  .sim, .lab .sim, .lab .bsim { display: block !important; background: #fff !important; border: 1px solid #999 !important; box-shadow: none !important; }
  .sim .row.run, .sim .row.wait, .sim .row.err, .verify .row.err { background: none !important; border-left-color: transparent !important; }
  .sim .ev { display: none !important; }
  .lab .scope { display: block; }
  .lab .plot svg { background: #fff !important; border: 1px solid #999; }
  .lab .plot .sig { stroke: #222; }
  .lab .plot text { fill: #444; }
  .seesaw .ss-ctrl { justify-content: center; }
  .lab .svgfig, .lab .panel, .seesaw, .bboard, .scopes, .sw-demo, .photo-grid figure { box-shadow: none !important; }

  /* code: light theme, saves ink and reads well on paper */
  .ide, .sim .ide, .lab .ide { background: #fff !important; border: 1px solid #999 !important; box-shadow: none !important; }
  .ide-bar { background: #f0f0f0 !important; color: #333 !important; border-bottom: 1px solid #ccc; }
  .ide-bar span { color: #333 !important; border-color: #999 !important; }
  .ide-bar i { display: none; }
  .ide pre, .ide pre code, .sim pre.rows { background: #fff !important; color: #222 !important; }
  .ide .ln { color: #999 !important; }
  .ide .ty { color: #00686b !important; }
  .ide .fn { color: #9a4f00 !important; }
  .ide .co { color: #006064 !important; }
  .ide .kw { color: #7b2f78 !important; }
  .ide .cm { color: #5f6b6d !important; }

  /* page breaks */
  .lab, .sim, .ide, .seesaw, .bboard, .scopes, .svgfig, .sw-demo, .photo-grid figure,
  .table-wrap, .micro-row, .abstract-points li, dl dt, dl dd { break-inside: avoid; }
  h2, h3, .abstract h2 { break-after: avoid; }
  section { break-before: auto; }
  .photo-grid img { height: 120px; }
  .swlab, .lab .swlab { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .micro-row { grid-template-columns: minmax(0, 1fr) 220px; }
  .assignment { box-shadow: none !important; }
}
@media print {
  .lab .svgfig svg, .lab .bboard svg, .lab .seesaw svg { width: auto !important; max-width: 100%; max-height: 6.2cm !important; margin: 0 auto; display: block; }
  .lab .micro-svg { max-height: 4.5cm !important; }
  .lab .plot svg { max-height: 3.6cm !important; width: auto; margin: 0 auto; }
  .lab .sw-svg { height: 2.2cm !important; }
  figure img { max-height: 7cm; width: auto; max-width: 100%; margin: 0 auto; display: block; }
  .photo-grid img { width: 100%; height: 3.2cm; }
}

/* ---------- circuit diagrams (assets/circuit.js) ---------- */
figure.circuit .circuit-svg{padding:12px;direction:ltr;background:var(--panel)}
figure.circuit .circuit-svg svg{display:block;width:100%;height:auto;max-height:520px}
figure.circuit .circuit-err{direction:rtl;color:var(--red);font-size:14px;margin:6px 0 0}
figure.circuit .circuit-bar{display:flex;flex-wrap:wrap;gap:8px;padding:0 12px 12px}
figure.circuit .circuit-bar button{font:inherit;font-size:14px;font-weight:700;background:#0ca1a6;color:#fff;border:0;border-radius:4px;padding:4px 14px;cursor:pointer}
figure.circuit .circuit-bar button+button{background:var(--panel);color:var(--ink);border:2px solid var(--frame)}
figure.circuit .circuit-hint{display:none;margin:6px 0 0;font-size:13px;color:var(--muted);text-align:center;direction:rtl}
@media (max-width:700px){figure.circuit .circuit-svg{cursor:zoom-in}figure.circuit .circuit-hint{display:block}}
.circuit-zoom{position:fixed;inset:0;z-index:1000;background:var(--paper);display:flex;flex-direction:column}
.circuit-zoom .cz-close{align-self:flex-start;margin:10px 16px;font:inherit;font-size:15px;font-weight:700;background:var(--panel);color:var(--ink);border:2px solid var(--frame);border-radius:6px;padding:4px 14px;cursor:pointer}
.circuit-zoom .cz-scroll{flex:1;overflow:auto;direction:ltr;-webkit-overflow-scrolling:touch;padding:8px 16px 24px}
.circuit-zoom svg{display:block;width:900px;max-width:none;height:auto}
@media print{figure.circuit .circuit-bar,figure.circuit .circuit-hint{display:none}}
