@font-face {
  font-family: "Roboto Mono";
  src: url("/fonts/RobotoMono-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #0a0d12;
  --panel: #131820;
  --panel-2: #1b222d;
  --ink: #f3f7fb;
  --muted: #b8c5d1;
  --line: rgba(232, 237, 242, 0.14);
  --line-soft: rgba(232, 237, 242, 0.08);
  --cyan: #00deff;
  --magenta: #f300bf;
  --metal: #bdc3c7;
  --via: #6e7678;
  --green: #00c754;
  --orange: #ff8f00;
  --panel-padding: 24px;
  --stick-top: 88px;
  --radius: 0;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
}

body {
  min-height: 100%;
  margin: 0;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand,
.topnav,
.lesson-map li,
.lesson-map-button,
.sim-toolbar,
.checklist label {
  display: flex;
  align-items: center;
}

.brand {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: clamp(1.35rem, 2.4vw, 1.65rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
}

.brand-wordmark span:first-child {
  color: var(--magenta);
}

.brand-wordmark span:last-child {
  color: var(--cyan);
}

.topnav {
  gap: 4px;
  color: var(--muted);
  font-size: 0.94rem;
}

.topnav a,
.topnav-download-toggle {
  padding: 8px 12px;
}

.topnav-download {
  position: relative;
}

.topnav-download-toggle {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.topnav-download-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 148px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgb(0 0 0 / 28%);
}

.topnav-download-menu[hidden] {
  display: none !important;
}

.topnav-download-item {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
}

.topnav-link.is-current {
  background: var(--panel-2);
  color: var(--ink);
}

.topnav-support {
  font-size: 0.82rem;
  color: var(--metal);
  opacity: 0.72;
}

.topnav-support:hover,
.topnav-support:focus-visible {
  opacity: 1;
}

.topnav a:hover,
.topnav a:focus-visible,
.topnav-download-toggle:hover,
.topnav-download-toggle:focus-visible,
.lesson-map-button:focus-visible,
.button:focus-visible,
.sim-frame-corner-btn:focus-visible,
.sim-start-button:focus-visible {
  outline: 2px solid rgba(0, 222, 255, 0.55);
  outline-offset: 2px;
}

.topnav a:hover,
.topnav a:focus-visible,
.topnav-download-toggle:hover,
.topnav-download-toggle:focus-visible {
  background: var(--panel-2);
  color: var(--ink);
}

.topnav-download-item:hover,
.topnav-download-item:focus-visible {
  background: var(--panel-2);
  color: var(--ink);
}

.simulator-page {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}

.simulator-stage {
  min-height: 0;
  padding: 0;
}

.simulator-frame {
  --sim-width: 100vw;
  --sim-height: 100vh;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #101010;
  container-type: size;
}

.simulator-page #app {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--sim-width);
  height: var(--sim-height);
  transform: scale(calc(100cqw / var(--sim-width)));
  transform-origin: top left;
}

html.simulator-route .sidebar,
html.simulator-route .lesson-pane,
html.simulator-route .check-panel,
html.simulator-route .lesson-actions,
html.simulator-route .sim-reference,
body.simulator-view .sidebar,
body.simulator-view .lesson-pane,
body.simulator-view .check-panel,
body.simulator-view .lesson-actions,
body.simulator-view .sim-reference {
  display: none;
}

.sim-intro {
  display: none;
}

.sim-landing-head {
  display: none;
}

html.simulator-route .sim-intro,
body.simulator-view .sim-intro {
  display: block;
}

html.simulator-route .sim-landing-head,
body.simulator-view .sim-landing-head {
  display: block;
  padding: 4px 2px 0;
}

html.simulator-route .page,
body.simulator-view .page {
  display: block;
  width: min(1520px, 100%);
  max-width: none;
  min-height: 0;
  height: auto;
  margin: 0 auto;
  padding: 32px clamp(18px, 4vw, 48px) 56px;
}

html.simulator-route .content,
body.simulator-view .content {
  display: block;
  height: auto;
  min-height: 0;
}

html.simulator-route .workbench-sim,
body.simulator-view .workbench-sim {
  height: auto;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  align-self: start;
}

html.simulator-route .sim-layout,
body.simulator-view .sim-layout {
  grid-template-columns: 1fr;
  gap: 16px;
  height: auto;
  align-items: stretch;
}

html.simulator-route .sim-toolbar,
body.simulator-view .sim-toolbar {
  display: none;
}

html.simulator-route .sim-column,
body.simulator-view .sim-column {
  display: block;
  min-height: 0;
  border: 1px solid var(--line);
  background: rgba(16, 25, 35, 0.5);
}

html.simulator-route .sim-frame,
body.simulator-view .sim-frame {
  --sim-width: 833px;
  --sim-height: 468px;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: none;
  container-type: inline-size;
}

html.simulator-route body,
body.simulator-view {
  min-height: 100%;
  overflow: auto;
}

html.simulator-route,
body.simulator-view {
  min-height: 100%;
}

.page {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
  gap: 28px;
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 32px clamp(18px, 4vw, 48px) 56px;
}

.sidebar,
.lesson-head,
.workbench-sim,
.check-panel {
  border: 1px solid var(--line);
  background: var(--panel);
}

.sidebar {
  position: sticky;
  top: var(--stick-top);
  display: flex;
  flex-direction: column;
  align-self: start;
  max-height: calc(100dvh - var(--stick-top) - 24px);
  padding: var(--panel-padding);
  overflow: hidden;
}

.small-label {
  margin: 0 0 8px;
  color: var(--metal);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.small-label.cyan {
  color: var(--cyan);
}

.small-label.magenta {
  color: var(--magenta);
}

.small-label.orange {
  color: var(--orange);
}

.sidebar h1,
.lesson-head h2,
.check-panel h3 {
  margin: 0;
  line-height: 1.15;
}

.sidebar h1 {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.sidebar-intro,
.lesson-head p,
.check-panel p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.sidebar-credit {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--metal);
  font-size: 0.68rem;
  line-height: 1.45;
  opacity: 0.72;
}

.sidebar-credit-secondary {
  display: block;
  margin-top: 4px;
  font-size: 0.62rem;
  opacity: 0.85;
}

.sidebar-credit a {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: rgb(255 255 255 / 8%);
  text-underline-offset: 2px;
}

.sidebar-credit a:hover,
.sidebar-credit a:focus-visible {
  color: var(--cyan);
  text-decoration-color: currentColor;
}

.noscript-fallback {
  grid-column: 1 / -1;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  line-height: 1.6;
}

.noscript-fallback h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.2rem;
}

.noscript-fallback ul {
  margin: 12px 0;
  padding-left: 1.2rem;
}

.noscript-fallback a {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.lesson-map {
  display: grid;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 0 0;
  margin: 18px 0 0;
  border-top: 1px solid var(--line-soft);
  list-style: none;
  scrollbar-color: rgba(0, 222, 255, 0.45) rgba(232, 237, 242, 0.08);
}

.lesson-map li {
  min-height: 40px;
}

.lesson-map-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.94rem;
  text-align: left;
  cursor: pointer;
}

.lesson-map-button span {
  color: var(--via);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.lesson-map-button.current {
  border-left-color: var(--cyan);
  background: rgba(0, 222, 255, 0.06);
  color: var(--ink);
}

.lesson-map-button.current span {
  color: var(--cyan);
}

.lesson-map-button:hover,
.lesson-map-button:focus-visible {
  background: rgba(232, 237, 242, 0.04);
  color: var(--ink);
}

.content {
  display: grid;
  gap: 28px;
}

.lesson-pane {
  border: 1px solid var(--line);
  background: var(--panel);
}

.lesson-head {
  padding: clamp(24px, 4vw, 36px);
  border: 0;
  background: transparent;
}

.lesson-head h2 {
  max-width: 720px;
  font-size: clamp(1.85rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.lesson-head p {
  max-width: 640px;
  font-size: 1.02rem;
}

.lesson-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  min-height: 120px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
}

.workbench-task-title {
  margin: 0;
  min-height: 1.25em;
  font-size: 1.1rem;
  line-height: 1.25;
}

.workbench-steps {
  margin: 12px 0 0;
  padding-left: 1.25rem;
  min-height: 3.5em;
  max-width: 68ch;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.lesson-points:has(.lesson-point:first-child:nth-last-child(4)) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 1100px) {
  .lesson-points:has(.lesson-point:first-child:nth-last-child(4)) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.lesson-point {
  padding: 0;
  border: 0;
  border-top: 2px solid var(--line);
  padding-top: 14px;
  background: transparent;
}

.lesson-point.cyan {
  border-top-color: var(--cyan);
}

.lesson-point.magenta {
  border-top-color: var(--magenta);
}

.lesson-point h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.lesson-point p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.lesson-example {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.lesson-example h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.lesson-takeaway {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.lesson-takeaway p {
  margin: 8px 0 0;
  max-width: 640px;
  color: var(--ink);
  font-size: 0.98rem;
}

.check-panel h3 {
  font-size: 1.15rem;
}

.workbench {
  border-top: 1px solid var(--line-soft);
}

.workbench-sim {
  overflow: hidden;
  padding: 16px;
}

.lesson-map [data-lesson],
.lesson-map-button {
  cursor: pointer;
}

.workbench-task {
  padding: 20px var(--panel-padding) 24px;
}

.workbench-task-main .small-label {
  margin-bottom: 6px;
}

.workbench-steps li + li {
  margin-top: 8px;
}

.task-hint {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-left: 2px solid var(--cyan);
  background: rgba(0, 222, 255, 0.05);
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.sim-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(200px, 260px);
  gap: 16px;
  align-items: stretch;
}

.sim-reference {
  display: grid;
  gap: 12px;
  align-content: start;
}

.sim-intro-title {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.sim-landing-lead,
.sim-landing-started {
  margin: 10px 0 0;
  max-width: 68ch;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.6;
}

.sim-controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sim-intro .reference-card {
  padding: 16px;
}

.sim-intro .reference-card p:not(.small-label) {
  font-size: 0.9rem;
  line-height: 1.55;
}

.sim-intro .small-label {
  margin-bottom: 8px;
  font-size: 0.72rem;
}

.sim-intro-course-link {
  margin-top: 14px;
}

.sim-intro-course-link a {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sim-intro-course-link a:hover,
.sim-intro-course-link a:focus-visible {
  color: var(--ink);
}

.control-list {
  display: grid;
  gap: 10px;
  margin: 8px 0 0;
}

.control-list div {
  margin: 0;
}

.control-list dt {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
}

.control-list dd {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.control-list kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 0.35em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(232, 237, 242, 0.06);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.82em;
  line-height: 1.5;
  text-align: center;
}

.reference-card {
  padding: 18px;
  border: 1px solid var(--line-soft);
  background: rgba(16, 25, 35, 0.4);
}

.reference-card h3 {
  margin: 0;
  font-size: 1rem;
}

.reference-card p:not(.small-label) {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.truth-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  border: 1px solid var(--line-soft);
  background: rgba(16, 25, 35, 0.5);
}

.truth-table th,
.truth-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: center;
}

.truth-table th {
  color: var(--metal);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.truth-table tr:last-child td {
  border-bottom: 0;
}

.truth-bit {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}

.truth-bit.off {
  color: var(--muted);
}

.truth-bit.on {
  color: var(--green);
}

.sim-column {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(16, 25, 35, 0.5);
}

html.sim-immersive,
html.sim-immersive body {
  overflow: hidden;
  height: 100dvh;
}

html.sim-immersive .topbar,
html.sim-immersive .sidebar,
html.sim-immersive .lesson-pane,
html.sim-immersive .check-panel,
html.sim-immersive .lesson-actions,
html.sim-immersive .workbench,
html.sim-immersive .sim-reference,
html.sim-immersive .sim-intro,
html.sim-immersive .sim-landing-head {
  display: none !important;
}

html.sim-immersive .page {
  width: 100%;
  max-width: none;
  height: 100dvh;
  margin: 0;
  padding: 0;
}

html.sim-immersive .content,
html.sim-immersive .workbench-sim,
html.sim-immersive .sim-layout,
html.sim-immersive .sim-column {
  height: 100%;
  min-height: 0;
}

html.sim-immersive .workbench-sim {
  position: fixed;
  inset: 0;
  z-index: 40;
  margin: 0;
  padding: 0;
  border: 0;
  background: #101010;
}

html.sim-immersive .sim-toolbar {
  display: none;
}

html.sim-immersive .sim-layout {
  grid-template-columns: 1fr;
  gap: 0;
}

html.sim-immersive .sim-column {
  border: 0;
  background: transparent;
}

html.sim-immersive .sim-frame {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  max-height: none;
  container-type: size;
}

.sim-frame-corner-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 4;
  display: none;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(232, 237, 242, 0.18);
  background: rgba(10, 13, 18, 0.78);
  color: var(--ink);
  cursor: pointer;
}

.sim-frame-corner-btn:hover,
.sim-frame-corner-btn:focus-visible {
  border-color: rgba(0, 222, 255, 0.45);
  background: rgba(0, 222, 255, 0.12);
}

.sim-frame-fullscreen {
  display: none;
}

html:not(.sim-immersive) .sim-frame-fullscreen {
  display: grid;
}

html.sim-immersive .sim-frame-fullscreen {
  display: none !important;
}

html.sim-immersive .sim-immersive-exit {
  display: grid;
}

.sim-toolbar {
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.92rem;
}

.sim-toolbar .small-label {
  margin-bottom: 2px;
}

.sim-toolbar strong {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 600;
}

.sim-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.sim-frame {
  --sim-width: 833px;
  --sim-height: 468px;
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  position: relative;
  overflow: hidden;
  background: #101010;
}

.sim-start-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: #050708;
}

.sim-start-overlay[hidden] {
  display: none;
}

.sim-start-button {
  display: flex;
  gap: 0.6ch;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 4cqw, 3rem);
  font-weight: 700;
  cursor: pointer;
}

.sim-start-button:disabled {
  cursor: wait;
  opacity: 0.45;
}

.sim-start-button span:first-child {
  color: var(--magenta);
}

.sim-start-button span:last-child {
  color: var(--cyan);
}

#app {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--sim-width);
  height: var(--sim-height);
  transform: scale(calc(100cqw / var(--sim-width)));
  transform-origin: top left;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  touch-action: none;
}

.check-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 24px;
  padding: var(--panel-padding);
}

.checklist {
  display: grid;
  gap: 0;
  align-content: start;
  border: 1px solid var(--line-soft);
}

.checklist label {
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.4;
}

.checklist label:last-child {
  border-bottom: 0;
}

.checklist input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  flex-shrink: 0;
}

.lesson-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  padding-top: 4px;
}

.lesson-actions:has(.lesson-actions-center[hidden]) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lesson-actions-center {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.lesson-actions-center .button {
  flex: 1 1 0;
  min-width: 0;
}

.lesson-actions > .button {
  width: 100%;
  min-width: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.94rem;
  cursor: pointer;
  background: transparent;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--cyan);
  background: rgba(0, 222, 255, 0.14);
  color: var(--ink);
}

.button.secondary {
  color: var(--muted);
  border-color: var(--line-soft);
}

.button.secondary:hover:not(:disabled),
.button.secondary:focus-visible {
  color: var(--ink);
  border-color: var(--line);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

@media (max-width: 980px) {
  .page,
  .sim-layout,
  .check-panel {
    grid-template-columns: 1fr;
  }

  html.simulator-route .sim-layout,
  body.simulator-view .sim-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .lesson-points {
    grid-template-columns: 1fr;
  }

  .lesson-example {
    grid-template-columns: 1fr;
  }

  .sim-reference {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

@media (max-width: 620px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding-block: 14px;
  }

  .lesson-actions {
    grid-template-columns: 1fr;
  }

  .topnav {
    justify-content: space-between;
  }

  .sim-reference {
    grid-template-columns: 1fr;
  }
}
