/*
 * Shared surfaces left behind by the original light palette. Keep this sheet
 * after the shared styles; subject adapters retain their own semantic diagrams.
 * Every rule is theme-scoped so the established light appearance is unchanged.
 */
:root[data-theme="dark"] {
  --state-positive-bg: #203e36;
  --state-positive-ink: #a6e5ca;
  --state-positive-line: #437d68;
  --state-negative-bg: #482b38;
  --state-negative-ink: #ffd0dc;
  --state-negative-line: #a76980;
  --state-warning-bg: #443224;
  --state-warning-ink: #f3c390;
}

/* Topic lists, study cards and standalone exercises share one surface token. */
[data-theme="dark"] :is(.lesson-row, .simulation-card) {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
[data-theme="dark"] #mixed-quiz > .quiz-card,
[data-theme="dark"] #topic-exercises > .exercise-card {
  background: var(--surface);
  border-color: var(--line);
}
[data-theme="dark"] .lesson-row:hover {
  border-color: var(--accent);
}
[data-theme="dark"] .lesson-index {
  background: var(--accent-soft);
  color: var(--muted);
}
[data-theme="dark"]
  :is(
    .topic-heading .eyebrow,
    .topic-nav a > span,
    .topic-number,
    .topic-symbol
  ) {
  color: color-mix(in srgb, var(--topic, var(--accent)) 70%, var(--ink));
}
[data-theme="dark"] :is(.lesson-index.done, .mini-check.done) {
  background: var(--state-positive-bg);
  border-color: var(--state-positive-line);
  color: var(--state-positive-ink);
}
[data-theme="dark"] .mini-check,
[data-theme="dark"] .plan-lessons a {
  border-color: var(--line);
}
[data-theme="dark"] :is(.practice-promo, .plan-topic-title .pill) {
  background: var(--accent-soft);
  border-color: var(--line);
}
[data-theme="dark"] .plan-topic-title .pill {
  color: var(--ink);
}
[data-theme="dark"] .practice-promo .pill {
  background: var(--surface);
  color: var(--accent);
}
[data-theme="dark"] .source-note p {
  color: var(--muted);
}
[data-theme="dark"] .sim-caption {
  background: var(--bg);
  color: var(--muted);
}
[data-theme="dark"] .result-box {
  background: var(--state-positive-bg);
  border-color: var(--state-positive-line);
  color: var(--state-positive-ink);
}
[data-theme="dark"] .result-box :is(h3, p, span, strong) {
  color: var(--state-positive-ink);
}

/* This is the real controls class, shared by both simulation families. */
[data-theme="dark"] :is(.sim-controls, .trace-status) {
  background: var(--bg);
  border-color: var(--line);
}
[data-theme="dark"] :is(.trace-status p, .sim-controls > label) {
  color: var(--muted);
}
[data-theme="dark"] :is(.field, textarea, .speed-label select) {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
[data-theme="dark"] :is(input, textarea)::placeholder {
  color: var(--muted);
  opacity: 1;
}
[data-theme="dark"] option {
  background: var(--surface);
  color: var(--ink);
}
[data-theme="dark"] .sim-error {
  color: var(--state-negative-ink);
}

/* Preserve actual hover, selection and semantic feedback in the dark palette. */
[data-theme="dark"] :is(.button, .icon-button):hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
[data-theme="dark"] .button.primary:hover {
  background: #8170f4;
  color: #fff;
}
[data-theme="dark"] .button.ghost {
  background: transparent;
  border-color: transparent;
}
[data-theme="dark"] .button.completed:hover {
  background: var(--state-positive-bg);
  border-color: var(--state-positive-ink);
  color: var(--state-positive-ink);
}
[data-theme="dark"] .quiz-option.correct:hover {
  background: var(--state-positive-bg);
  border-color: var(--state-positive-ink);
  color: var(--state-positive-ink);
}
[data-theme="dark"] .quiz-option.incorrect:hover {
  background: var(--state-negative-bg);
  border-color: var(--state-negative-ink);
  color: var(--state-negative-ink);
}
[data-theme="dark"] .area-filters button.active,
[data-theme="dark"] .enroll-button.enrolled {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* SVG masks/tracks use the current surface; scientific class colours remain. */
[data-theme="dark"] .progress-ring circle:first-child {
  stroke: var(--line);
}
[data-theme="dark"] .progress-ring circle:last-child {
  stroke: var(--accent);
}
[data-theme="dark"] .course-visual pattern circle {
  fill: var(--line);
}
[data-theme="dark"] .course-visual g[fill="#6d7286"] {
  fill: var(--muted);
}
[data-theme="dark"] .course-visual circle[fill="#e9e7ff"] {
  fill: var(--accent-soft);
  stroke: var(--accent);
}
[data-theme="dark"] .course-visual circle[fill="#def5ee"] {
  fill: var(--state-positive-bg);
  stroke: var(--state-positive-line);
}
[data-theme="dark"] .course-visual circle[fill="#e7edf9"] {
  fill: #25364c;
  stroke: #7799cf;
}
[data-theme="dark"] .course-visual text[fill="#138470"] {
  fill: var(--state-positive-ink);
}
[data-theme="dark"] .course-visual text[fill="#356acc"] {
  fill: #b7d1fa;
}
[data-theme="dark"] .dl-figure circle[stroke="#25334c"] {
  stroke: var(--ink);
}
