html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171a20;
  --grid: #343d49;
  --ink: #f0f2f5;
  --ink-2: #c2cbd6;
  --mute: #a2adbb;
  --blue: #91baff;
  --red: #ff9189;
  --green: #8cdda0;
  --t0: #91baff;
  --t1: #ffc078;
  --t2: #c7a3ff;
  --t3: #8cdda0;
  --t4: #ff9dc8;
  --t5: #73d4dc;
  --t6: #ff9189;
  --t7: #aaaaff;
  --surface: #222831;
  --surface-2: #29313c;
  --surface-warm: #342f23;
  --highlight: #846214;
}
html[data-theme="dark"] body { background-color: var(--paper) !important; color: var(--ink) !important; }
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .site-header { background: rgba(23,26,32,.97); border-color: var(--ink); }
html[data-theme="dark"] .callout,
html[data-theme="dark"] .visual,
html[data-theme="dark"] .summary,
html[data-theme="dark"] .qa-answer,
html[data-theme="dark"] table,
html[data-theme="dark"] .quiz-intro,
html[data-theme="dark"] .question-card,
html[data-theme="dark"] .results-summary,
html[data-theme="dark"] .mode-button,
html[data-theme="dark"] .progress-bar,
html[data-theme="dark"] .memory-card,
html[data-theme="dark"] .answer-input,
html[data-theme="dark"] .qa-response,
html[data-theme="dark"] .order-row select,
html[data-theme="dark"] .match-row select,
html[data-theme="dark"] .options label,
html[data-theme="dark"] .word-popover,
html[data-theme="dark"] .module-map a,
html[data-theme="dark"] .german-target,
html[data-theme="dark"] .task-feedback {
  background: var(--surface);
  color: var(--ink);
}
html[data-theme="dark"] .btn.alt,
html[data-theme="dark"] .qa-answer,
html[data-theme="dark"] .game-room .btn.alt,
html[data-theme="dark"] .helper-options button { background: var(--surface-2); color: var(--ink); }
html[data-theme="dark"] .btn,
html[data-theme="dark"] .mode-button[aria-current="true"],
html[data-theme="dark"] .progress-fill,
html[data-theme="dark"] .piece,
html[data-theme="dark"] .helper-options button[aria-pressed="true"] {
  background-color: #574b28;
  color: #fff2c4;
}
html[data-theme="dark"] .extra,
html[data-theme="dark"] .summary,
html[data-theme="dark"] .result,
html[data-theme="dark"] .level-helper,
html[data-theme="dark"] .module-marker,
html[data-theme="dark"] .quiz-intro { background-color: var(--surface-warm); }
html[data-theme="dark"] .pattern .piece,
html[data-theme="dark"] .order-item,
html[data-theme="dark"] .word-hints span,
html[data-theme="dark"] .word-card { background-color: var(--surface-2); color: var(--ink); }
html[data-theme="dark"] th,
html[data-theme="dark"] .order-item { background-color: #303946; }
html[data-theme="dark"] .toc a[aria-current="location"],
html[data-theme="dark"] .section-nav a[aria-current="location"] { background: #273a54; color: var(--ink); }
html[data-theme="dark"] .section-nav a[aria-current="location"] { background: var(--ink); color: var(--paper); }
html[data-theme="dark"] .qa-answer,
html[data-theme="dark"] .callout,
html[data-theme="dark"] .course-card,
html[data-theme="dark"] .level-helper,
html[data-theme="dark"] .method-grid > div { background-color: var(--surface); }
html[data-theme="dark"] .course-card { border-color: var(--ink); }
html[data-theme="dark"] .a1 .card-art { background-color: #263956; color: #c5dcff; }
html[data-theme="dark"] .a2 .card-art { background-color: #403720; color: #ffe38a; }
html[data-theme="dark"] .b1 .card-art { background-color: #40334f; color: #dcc6ff; }
html[data-theme="dark"] .card-art { background-image: repeating-linear-gradient(0deg,transparent,transparent 23px,#65718430 23px,#65718430 24px); }
html[data-theme="dark"] .pill,
html[data-theme="dark"] .level-badge { background: var(--surface-2); color: var(--ink); }
html[data-theme="dark"] .mini-book.blue-book { background: #263956; color: #c5dcff; }
html[data-theme="dark"] .mini-book.yellow-book { background: #403720; color: #ffe38a; }
html[data-theme="dark"] .hero-description,
html[data-theme="dark"] .section-heading > p,
html[data-theme="dark"] .method-grid > div,
html[data-theme="dark"] footer { background: rgba(23,26,32,.9); color: var(--ink-2); }
html[data-theme="dark"] .hero-note,
html[data-theme="dark"] .card-content > p,
html[data-theme="dark"] .features,
html[data-theme="dark"] .section-heading > p,
html[data-theme="dark"] .method-grid p { color: var(--ink-2); }
html[data-theme="dark"] .game-navigation,
html[data-theme="dark"] .game-room { color: var(--ink); }
html[data-theme="dark"] .memory-card[data-matched="true"] { background: #24392c; }
html[data-theme="dark"] .ins li.current { background: #574b28; color: #fff2c4; }
html[data-theme="dark"] .module-map a { color: var(--blue); }
html[data-theme="dark"] .task-feedback[data-correct="true"] { border-color: var(--green); }
html[data-theme="dark"] .task-feedback[data-correct="false"] { border-color: var(--red); }
html[data-theme="dark"] .recommendation { color: var(--ink); }
svg text { fill: var(--ink); }
#overview .overview-box { fill: var(--overview-fill); }
#overview .overview-box.module-a21 { --overview-fill: #d2dff2; }
#overview .overview-box.module-a22 { --overview-fill: #e5daf1; }
#overview .overview-box > path:first-child { fill: var(--overview-fill); }
#overview .overview-box.module-a21 > path:not(:first-child),
#overview .overview-box.module-a21 > rect { stroke: var(--t0); }
#overview .overview-box.module-a22 > path:not(:first-child),
#overview .overview-box.module-a22 > rect { stroke: var(--t2); }
#overview > g:not(.overview-box) path { stroke: var(--ink); }
html[data-theme="dark"] #overview .overview-box.module-a21 { --overview-fill: #263956; }
html[data-theme="dark"] #overview .overview-box.module-a22 { --overview-fill: #40334f; }
html[data-theme="dark"] .word-help { color: var(--blue); }
html[data-theme="dark"] h1 em,
html[data-theme="dark"] h2 u { color: var(--ink); }
html[data-theme="dark"] .theme-toggle { background: var(--surface-2); color: var(--ink); }
html[data-theme="dark"] .button.primary { background: #574b28; color: #fff2c4; }
html[data-theme="dark"] .button.primary:hover { background: #6a5a31; }
html[data-theme="dark"] .word-popover .word-speak { background: #574b28; color: #fff2c4; }
html[data-theme="dark"] .rewards-card { background: var(--surface); }
html[data-theme="dark"] .fortune-wheel { background: conic-gradient(#263956 0deg 180deg,#403720 180deg 288deg,#24392c 288deg 342deg,#503a30 342deg 356.4deg,#40334f 356.4deg 360deg); }
html[data-theme="dark"] .wheel-pointer { color: var(--ink); }
html[data-theme="dark"] .credit-status { background: var(--surface); color: var(--ink-2); }
.theme-toggle { white-space: nowrap; }
.support-link { white-space: nowrap; text-decoration: none; }
.credit-status { margin:12px 0; padding:8px 12px; border:1px dashed var(--mute); color:var(--ink-2); font-size:14px; }
.word-help {
  display: inline;
  appearance: none;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  line-height: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}
.word-help:hover,.word-help:focus-visible { background: rgba(31,95,191,.12); }
.word-help:focus-visible { outline: 2px solid var(--t7); outline-offset: 2px; }
.word-popover {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: min(680px, calc(100vw - 24px));
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.word-popover[hidden] { display: none; }
.word-popover-text { min-width: 0; overflow-wrap: anywhere; }
.word-popover-text strong { display: block; }
.word-popover-text span { color: var(--ink-2); }
.word-speak { flex: 0 0 auto; padding: 5px 9px; }
@media (max-width: 620px) {
  .theme-toggle,.support-link { padding: 5px 8px; font-size: 13px; }
  .word-popover { bottom: 10px; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .word-help,.theme-toggle { transition: none !important; }
}
