:root {
  --paper: #f6f1e8;
  --paper-2: #efe7d6;
  --paper-3: #fffaf0;
  --ink: #1a1817;
  --ink-2: #3a3631;
  --ink-3: #6f6a62;
  --rule: rgba(26, 24, 23, .12);
  --primary: #1f4f86;
  --primary-soft: rgba(31, 79, 134, .08);
  --highlight: #f0c64a;
  --bg-top: #fbf6ec;
  --bg-bottom: #ebe1cf;
  --grain-opacity: .35;
  --grain-blend: multiply;
  --card-bg: rgba(255, 253, 247, .55);
  --surface-muted: #e8dcc1;
  --page-padding: clamp(1rem, 4vw, 3.5rem);
  --beaker-ink: #253033;
  --beaker-body: #c3d3d6;
  --beaker-interior: #f7faf9;
  --beaker-cut: #e6e8e5;
  --beaker-highlight: #e4a44b;
  --beaker-marker: #71380b;
  --beaker-plane: #385a86;
}

* { box-sizing: border-box; }
html { height: 100%; background: var(--paper); }
body {
  margin: 0;
  padding-top: var(--sim-nav-offset, 44px);
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, var(--bg-top) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 100%, var(--bg-bottom) 0%, transparent 50%),
    var(--paper);
  font-family: 'Lato', 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}

#root {
  height: calc(100vh - var(--sim-nav-offset, 44px));
  height: calc(100svh - var(--sim-nav-offset, 44px));
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.paper-grain, .grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  opacity: var(--grain-opacity); mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .09 0 0 0 0 .07 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.unit { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.overview-content { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem var(--page-padding) 2.5rem; }
.chapter-content { flex: 1; min-height: 0; overflow-y: auto; padding: .25rem var(--page-padding) 1rem; }
.loading { padding: 4rem 1.5rem; text-align: center; }

h1, h2, h3, h4, .serif {
  font-family: 'Fraunces', Georgia, serif;
  font-feature-settings: 'ss01';
  line-height: 1.2;
  font-weight: 600;
}
h1 { margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.4rem; margin: 0 0 .75rem; }
h3 { font-size: 1.1rem; margin: 0 0 .5rem; }
p { margin: 0 0 1rem; color: var(--ink-2); }
svg, img { max-width: 100%; }
a { color: var(--primary); text-underline-offset: 4px; }
button, input { font: inherit; }
button { cursor: pointer; color: inherit; background: none; border: none; }
button, a, input, summary { -webkit-tap-highlight-color: transparent; }
:is(button, a, input, summary):focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1:focus { outline: none; }
.mono { font-family: 'JetBrains Mono', monospace; }
.eyebrow { margin: 0 0 .5rem; font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.lead { font-size: .96rem; line-height: 1.6; max-width: 66ch; }

/* Design System: Cards */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(26,24,23,.03);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}

/* Design System: Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .8rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 500;
  white-space: nowrap;
  background: transparent;
}

/* Design System: Control Buttons */
.control-btn, .button, .cutaway-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1rem;
  min-height: 40px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
}
.control-btn svg, .button svg { width: 16px; height: 16px; flex-shrink: 0; }
.control-btn:hover, .button:hover, .cutaway-controls button:hover {
  background: var(--ink);
  color: var(--paper);
}
.control-btn.primary, .button.primary, .cutaway-controls button[data-action='cutaway-next'] {
  background: var(--ink);
  color: var(--paper);
}
.control-btn.primary:hover, .button.primary:hover, .cutaway-controls button[data-action='cutaway-next']:hover {
  background: var(--ink-2);
}
.control-btn:disabled, .control-btn.disabled-btn {
  opacity: .4;
  cursor: not-allowed;
  background: var(--paper-2);
  color: var(--ink-3);
  border-color: var(--rule);
}
.btn-counter-badge {
  font-size: .7rem;
  padding: 0 4px;
}

/* Design System: Stepper Dots & Lines */
.step-dot, .step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: .85rem;
  background: transparent;
  color: var(--ink);
  transition: all .25s ease;
  opacity: .35;
  flex-shrink: 0;
  padding: 0;
}
.step-dot.active, .step-circle.active {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
  opacity: 1;
}
.step-dot.done, .step-circle.done {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  opacity: 1;
}
.step-dot:hover:not(.done) {
  background: var(--paper-2);
  opacity: 1;
}
.step-line {
  height: 0;
  flex: 1;
  min-width: 8px;
  border-top: 2px dotted var(--ink);
  opacity: .25;
}
.step-line.solid {
  border-top-style: solid;
  border-top-width: 1.5px;
  opacity: .8;
}

/* Overview Intro */
.overview-intro {
  padding: 1.5rem;
  border-left: 4px solid var(--ink);
  margin-bottom: 1.5rem;
}
.overview-title-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.overview-intro h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  transition: opacity .15s ease;
}
.overview-intro h1:hover {
  opacity: .85;
}
.teacher-badge {
  font-size: .68rem;
  background: var(--ink);
  color: var(--paper);
  padding: .25rem .6rem;
  border-radius: 999px;
  letter-spacing: .05em;
  font-weight: 600;
}
.overview-intro p {
  margin: 0;
  font-size: .96rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section-heading h2 { font-size: 1.1rem; margin: 0; }
.progress-text { font-size: .76rem; color: var(--ink-3); }
.progress-track { height: 2px; background: var(--rule); margin: .75rem 0 1rem; border-radius: 2px; overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--ink); transition: width .4s ease; }

/* Station Tiles: Wider & Stationenlernen Style */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  padding-top: 4px;
}
.chapter-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: .5rem;
  padding: 1rem .85rem .85rem;
  cursor: pointer;
  border-radius: 8px;
  border: 1.5px solid var(--rule);
  background: var(--card-bg);
  transition: border-color .18s ease, background .18s ease, box-shadow .15s ease, transform .15s ease;
  text-align: center;
  position: relative;
  min-height: 180px;
  color: var(--ink);
  text-decoration: none;
  user-select: none;
}
.chapter-card:hover:not(.locked) {
  border-color: var(--ink-3);
  box-shadow: 0 8px 24px rgba(26,24,23,.1);
  transform: translateY(-2px);
}
.chapter-card.completed {
  border-color: var(--ink);
  background: var(--paper-2);
}
.chapter-card.locked {
  opacity: .6;
  cursor: not-allowed;
  background: var(--paper-2);
  border-color: var(--rule);
}
.chapter-number {
  font-size: .62rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.chapter-icon {
  flex: 1;
  width: 100%;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
}
.chapter-icon img {
  width: 84px;
  height: 84px;
  object-fit: contain;
}
.chapter-card-copy h3 {
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 .25rem;
  color: var(--ink);
}
.chapter-subtitle {
  font-size: .72rem;
  color: var(--ink-3);
  margin: 0;
  line-height: 1.3;
}
.chapter-prereq {
  font-size: .68rem;
  color: var(--ink-3);
  margin: 2px 0 0;
  font-weight: 500;
}
.chapter-state {
  width: 100%;
  border-top: 1px solid var(--rule);
  padding-top: .55rem;
  margin-top: auto;
  font-size: .74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chapter-state-done {
  color: var(--ink);
}
.chapter-state-start {
  color: var(--primary);
}
.chapter-state-locked {
  color: var(--ink-3);
  font-weight: 600;
}

/* Note Box */
.note {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  padding: 1.1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
}
.note > svg { width: 25px; height: 25px; flex-shrink: 0; }
.note h3 { margin: 0 0 .3rem; }
.note p { margin: 0; font-size: .88rem; }
.unit-footer { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }

/* Chapter Header */
.chapter-header {
  flex-shrink: 0;
  padding: .6rem var(--page-padding) .65rem;
}
.chapter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.chapter-title-group {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.chapter-title-group h1 {
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0;
  line-height: 1.1;
}

/* Chapter Footer */
.chapter-footer {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: .55rem var(--page-padding) .65rem;
  border-top: 1px solid var(--rule);
}
.chapter-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.chapter-nav { display: flex; align-items: center; flex: 1; gap: .4rem; min-width: 250px; }
.chapter-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  color: var(--ink);
  text-decoration: none;
  min-width: 44px;
}
.chapter-step.disabled {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}
.chapter-step-label { font-size: .62rem; line-height: 1.2; color: var(--ink-3); }
.chapter-step.active .chapter-step-label { color: var(--ink); font-weight: 700; }

/* Station 1: Cutaway (Centered Symmetrical Progress) */
.cutaway { display: flex; flex-direction: column; min-height: 100%; }
.cutaway-progress-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: .35rem 0 .9rem;
}
.cutaway-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(.6rem, 2.2vw, 1.6rem);
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 760px;
  width: 100%;
}
.cutaway-step-item {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  color: var(--ink-3);
  white-space: nowrap;
}
.cutaway-step-item[aria-current='step'] {
  color: var(--ink);
  font-weight: 700;
}
.cutaway-step-label {
  font-size: .76rem;
}
.cutaway-demonstration {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 1.5rem;
  min-height: 360px;
}
.cutaway-visual, .cutaway-copy {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(26,24,23,.03);
}
.cutaway-visual { position: relative; min-width: 0; min-height: 360px; overflow: hidden; }
.cutaway-scene { position: absolute; inset: 0; }
.cutaway-scene[hidden] { display: none; }
.cutaway-fallback { width: 100%; height: 100%; min-height: 360px; display: block; }
.cutaway-fallback-model { opacity: 1; transition: opacity 800ms ease; }
.cutaway[data-step='4'] .cutaway-fallback-model { opacity: 0; visibility: hidden; transition: opacity 800ms ease, visibility 0s 800ms; }
.cutaway[data-renderer='svg'] .cutaway-drawing { opacity: 0; visibility: hidden; transition: opacity 800ms ease, visibility 0s 800ms; }
.cutaway[data-renderer='svg'][data-step='4'] .cutaway-drawing { opacity: 1; visibility: visible; transition: opacity 800ms ease 400ms; }
@media (prefers-reduced-motion: reduce) {
  .cutaway-fallback-model, .cutaway[data-renderer='svg'] .cutaway-drawing,
  .cutaway[data-step='4'] .cutaway-fallback-model,
  .cutaway[data-renderer='svg'][data-step='4'] .cutaway-drawing { transition: none; }
}
.cutaway-drawing { display: flex; position: absolute; inset: 0; justify-content: center; align-items: center; }
.cutaway-drawing img,
.cutaway-drawing .cutaway-drawing-svg {
  display: block;
  width: min(100%, 440px);
  height: auto;
  max-height: 90%;
  object-fit: contain;
  color: var(--ink);
}
.cutaway-copy { padding: 1.5rem; display: flex; flex-direction: column; justify-content: center; }
.cutaway-copy h4 { margin: .35rem 0 .7rem; font-size: 1.5rem; }
.cutaway-copy p { margin: 0; line-height: 1.6; font-size: .94rem; }
.cutaway-kicker { font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }
.cutaway-controls { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.cutaway-controls button[data-action='cutaway-reset'] { margin-left: auto; }

/* Station 2: Rules */
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.rule-card { padding: 1.25rem; display: flex; flex-direction: column; }
.rule-title { display: flex; align-items: center; gap: .75rem; }
.rule-title h2 { font-size: 1.15rem; margin: 0; }
.rule-card > p { font-size: .88rem; margin: 1rem 0; }
.rule-examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-top: auto; }
.rule-example-figure { min-width: 0; margin: 0; display: flex; flex-direction: column; align-items: center; }
.rule-example { display: block; width: 100%; max-width: 210px; height: auto; background: transparent; color: var(--ink); }
.example-label { text-align: center; font-size: .72rem; line-height: 1.4; padding-top: .5rem; color: var(--ink-3); }
.example-label.good { color: var(--primary); }

/* Station 3 & 4: Exercise Instructions with Checkable Steps */
.exercise-intro { margin: .5rem 0 1.25rem; }
.exercise-instructions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .85rem;
}
.instruction-step-card {
  padding: .85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  background: var(--card-bg);
  cursor: pointer;
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  user-select: none;
  transition: all .2s ease;
  min-height: 72px;
}
.instruction-step-card:hover {
  border-color: var(--ink-3);
  box-shadow: 0 4px 16px rgba(26,24,23,.06);
}
.instruction-step-card.checked {
  background: var(--paper-2);
  border-color: var(--ink);
}
.instruction-step-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.instruction-step-card p {
  margin: 0;
  font-size: .82rem;
  line-height: 1.4;
  color: var(--ink);
}
.step-check-label {
  font-size: .68rem;
  font-weight: 600;
  color: var(--ink-3);
}
.instruction-step-card.checked .step-check-label {
  color: var(--ink);
}

/* Gated Notice & Content */
.instructions-gate-notice {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  background: var(--paper-2);
  border-left: 4px solid var(--ink);
  margin-bottom: 1.25rem;
  border-radius: 8px;
}
.gate-lock-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}
.instructions-gate-notice h3 {
  margin: 0 0 .2rem;
  font-size: 1.05rem;
}
.instructions-gate-notice p {
  margin: 0;
  font-size: .84rem;
  line-height: 1.45;
  color: var(--ink-2);
}
.locked-exercise-content {
  opacity: .28;
  filter: grayscale(85%) blur(1px);
  pointer-events: none;
  user-select: none;
  transition: opacity .3s ease, filter .3s ease;
}

/* Device Grid & Cards */
.device-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .85rem;
}
.device-card {
  padding: .9rem .75rem .85rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  position: relative;
  background: var(--card-bg);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.device-card:hover {
  border-color: var(--ink-3);
  box-shadow: 0 8px 24px rgba(26,24,23,.08);
  transform: translateY(-2px);
}
.device-card.completed {
  border-color: var(--ink);
}
.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .3rem;
  min-height: 22px;
}
.device-number {
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.device-done-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .65rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* Centered Drawing Frame inside Device Card */
.drawing-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--ink-3);
  text-align: center;
}
.drawing-frame {
  width: 100%;
  height: 185px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  margin: 0 auto;
}
.drawing-frame img.equipment-drawing {
  display: block;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 360 / 260;
  object-fit: contain;
  margin: 0 auto;
  color: var(--ink);
  transition: transform .2s ease;
}
.drawing-frame .labeled-drawing {
  display: block;
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 620 / 320;
  margin: 0 auto;
  color: var(--ink);
  transition: transform .2s ease;
}
.labeled-drawing > img {
  position: absolute;
  left: 0;
  top: 9.375%;
  width: 58.0645%;
  height: 81.25%;
  object-fit: contain;
}
.drawing-label-line {
  position: absolute;
  border-top: 2px solid currentColor;
}
.drawing-label-text {
  position: absolute;
  left: 63.2258%;
  transform: translateY(-50%);
  color: var(--ink);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}
.drawing-button:hover .drawing-frame img,
.drawing-button:hover .drawing-frame svg,
.drawing-button:hover .drawing-frame .labeled-drawing {
  transform: scale(1.02);
}
.enlarge-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .68rem;
  color: var(--ink-3);
  margin-top: .35rem;
  transition: color .15s;
}
.drawing-button:hover .enlarge-hint {
  color: var(--primary);
}

/* Touch-Friendly Action Buttons */
.device-card-actions {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin-top: .75rem;
  padding-top: .65rem;
  border-top: 1px solid var(--rule);
}
.check-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  width: 100%;
  min-height: 44px;
  padding: .6rem .8rem;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.check-button:hover {
  background: var(--paper-2);
}
.check-button.checked {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.check-box-indicator {
  width: 19px;
  height: 19px;
  border-radius: 4px;
  border: 1.5px solid currentColor;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  font-weight: bold;
}
.check-button.checked .check-box-indicator {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}

/* Solution Button: Small & Compact */
.solution-compact-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  width: 100%;
  min-height: 30px;
  padding: .3rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-3);
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.solution-compact-btn svg {
  width: 13px;
  height: 13px;
}
.solution-compact-btn:hover {
  border-color: var(--ink-3);
  color: var(--ink);
  background: var(--paper-2);
}
.solution-compact-btn.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* Word Bank */
.word-bank {
  margin: 1.5rem 0;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--card-bg);
}
.word-bank h2 {
  font-size: .72rem;
  font-weight: 600;
  margin-bottom: .85rem;
  letter-spacing: .15em;
}
.word-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.word.pill {
  padding: .35rem .85rem;
  background: var(--paper-3);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: .82rem;
  letter-spacing: normal;
  text-transform: none;
  font-weight: 500;
}

/* Quality Checklist */
.quality-check {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  padding: 1.5rem;
  gap: 1.75rem;
  margin-top: 1.5rem;
}
.quality-check h2 { font-size: 1.35rem; }
.quality-check p { font-size: .86rem; margin: 0; }
.checklist { display: flex; flex-direction: column; gap: .4rem; }
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .6rem 0;
  font-size: .84rem;
  cursor: pointer;
  border-bottom: 1px solid var(--rule);
}
.checklist-item:last-child { border-bottom: 0; }
.checklist-item input { margin-top: 3px; accent-color: var(--ink); }
.finish-note { background: var(--card-bg); border-color: var(--ink); }

/* Dialogs */
dialog {
  color: var(--ink);
  background: var(--paper-3);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.75rem;
  box-shadow: 0 20px 100px rgba(26,24,23,.25);
  max-width: calc(100vw - 24px);
  max-height: calc(100svh - 24px);
  overflow: auto;
}
dialog::backdrop { background: rgba(26,24,23,.48); backdrop-filter: blur(3px); }
.drawing-dialog {
  box-sizing: border-box;
  width: 80vh;
  height: 80vh;
  width: min(80vh, calc(100vw - 24px));
  height: min(80vh, calc(100vw - 24px));
  flex-direction: column;
  background: var(--paper-3);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.drawing-dialog[open] { display: flex; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dialog-heading h2 { font-size: 1.5rem; margin: 0; }
.dialog-drawing {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--paper-2);
}
.dialog-drawing img {
  display: block;
  max-width: 100%;
  max-height: 55svh;
  aspect-ratio: 360 / 260;
  object-fit: contain;
  margin: 0 auto;
  color: var(--ink);
}
.dialog-drawing .labeled-drawing {
  display: block;
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: 55svh;
  aspect-ratio: 620 / 320;
  margin: 0 auto;
  color: var(--ink);
}
.dialog-actions-center {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}
.reset-dialog { width: 510px; }
.reset-dialog h2 { font-size: 1.5rem; }
.reset-dialog p { font-size: .92rem; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; margin-top: 1.5rem; }

/* Micro-animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp .35s cubic-bezier(0.16, 1, 0.3, 1) both; }

/* Responsive Adjustments */
@media (max-width: 1150px) {
  .device-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .cutaway-demonstration { grid-template-columns: 1fr; gap: 1rem; }
  .cutaway { min-height: auto; }
  .cutaway-copy { padding: 1.1rem; }
  .cutaway-progress { flex-wrap: wrap; }
}
@media (max-width: 800px) {
  .chapter-footer { gap: .6rem; }
  .chapter-nav { flex-basis: 100%; }
  .chapter-actions { width: 100%; justify-content: space-between; }
  .quality-check { grid-template-columns: 1fr; gap: 1rem; }
  .device-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rules-grid { gap: .75rem; }
  .rule-card { padding: 1rem; }
  .exercise-instructions-grid { grid-template-columns: 1fr; gap: .6rem; }
}
@media (max-width: 560px) {
  .overview-intro { padding: 1.1rem; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: .5rem; }
  .chapter-header { padding-bottom: .6rem; }
  .chapter-actions { gap: .4rem; }
  .chapter-actions .control-btn { font-size: .7rem; padding: .45rem .65rem; }
  .rules-grid, .device-grid { grid-template-columns: 1fr; }
  .device-card { padding: 1rem; }
  .note, .word-bank, .quality-check { padding: 1.1rem; }
  .cutaway-visual, .cutaway-fallback { min-height: 280px; }
  .cutaway-copy h4 { font-size: 1.3rem; }
  dialog { padding: 1.1rem; }
  .dialog-heading h2 { font-size: 1.2rem; }
}

/* Dark Mode (Aligned with Stationenlernen) */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121518;
    --paper-2: #1a1e22;
    --paper-3: #1d2126;
    --ink: #e4e2de;
    --ink-2: #c8c4bc;
    --ink-3: #9b978f;
    --rule: rgba(228, 226, 222, .12);
    --bg-top: #1b2025;
    --bg-bottom: #0f1215;
    --grain-opacity: .18;
    --grain-blend: screen;
    --card-bg: rgba(24, 28, 33, .78);
    --surface-muted: #2a3138;
    --primary: #6ea8e0;
    --primary-soft: rgba(110, 168, 224, .1);
    --beaker-ink: #c7d5d9;
    --beaker-body: #56727a;
    --beaker-interior: #243138;
    --beaker-cut: #8d9d9d;
    --beaker-highlight: #dca44b;
    --beaker-marker: #512e10;
    --beaker-plane: #6ea8e0;
  }
  body { color-scheme: dark; }
  img.equipment-drawing, .chapter-icon-image { filter: invert(1); }
  .cutaway-drawing-svg { filter: none; color: var(--ink); }
}

:root[data-theme="dark"], body.dark, [data-theme="dark"] {
  --paper: #121518;
  --paper-2: #1a1e22;
  --paper-3: #1d2126;
  --ink: #e4e2de;
  --ink-2: #c8c4bc;
  --ink-3: #9b978f;
  --rule: rgba(228, 226, 222, .12);
  --bg-top: #1b2025;
  --bg-bottom: #0f1215;
  --grain-opacity: .18;
  --grain-blend: screen;
  --card-bg: rgba(24, 28, 33, .78);
  --surface-muted: #2a3138;
  --primary: #6ea8e0;
  --primary-soft: rgba(110, 168, 224, .1);
  --beaker-ink: #c7d5d9;
  --beaker-body: #56727a;
  --beaker-interior: #243138;
  --beaker-cut: #8d9d9d;
  --beaker-highlight: #dca44b;
  --beaker-marker: #512e10;
  --beaker-plane: #6ea8e0;
  color-scheme: dark;
}
:root[data-theme="dark"] img.equipment-drawing,
body.dark img.equipment-drawing {
  filter: invert(1);
}
:root[data-theme="dark"] img.equipment-drawing,
:root[data-theme="dark"] .chapter-icon-image,
body.dark img.equipment-drawing,
body.dark .chapter-icon-image {
  filter: invert(1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

@media print {
  :root { --paper: #fff; --paper-2: #f6f1e8; --paper-3: #fff; --ink: #111; --ink-2: #333; --ink-3: #555; --rule: rgba(0,0,0,.15); --card-bg: transparent; --primary: #1f4f86; --primary-soft: transparent; }
  .sim-nav, .paper-grain, .chapter-nav, .chapter-top, .chapter-footer, .unit-footer, .cutaway-controls, .device-card-actions { display: none !important; }
  body { padding: 0; background: white; color: #111; height: auto; overflow: visible; }
  #root, .unit, .chapter-content, .overview-content { height: auto; overflow: visible; }
  .chapter-header, .chapter-content, .overview-content { padding: 0; }
  .device-grid { grid-template-columns: repeat(3, 1fr); }
  .equipment-drawing, .cutaway-drawing img { filter: none; }
  .card, .word-bank, .note, .cutaway-demonstration { break-inside: avoid; box-shadow: none; }
}
