:root {
  color-scheme: dark;
  --page-bg: #0f1117;
  --text: #e8eaf0;
  --secondary-text: #d1d5db;
  --muted: #9ca3af;
  --surface: #1a1d2e;
  --surface-hover: #202638;
  --border: #343d51;
  --strong-border: #64748b;
  --track: #252c3b;
  --progress: #94a3b8;
  --selected-bg: #1f2937;
  --selection-border: #d1d5db;
  --tag-bg: #273147;
  --button-bg: #374151;
  --button-text: #ffffff;
  --focus: #a5b4fc;
  --success: #34d399;
  --error: #f87171;
  --accent: #c4b5fd;
  --accent-bg: #252046;
  --topic-text: #ffffff;
  --topic-shadow: 0 1px 8px rgba(0, 0, 0, .65);
  --topic-check-bg: #ffffff;
  --topic-check-text: #111827;
  --topic-a-lightness: 30%;
  --topic-b-lightness: 18%;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page-bg: #f7f9fc;
  --text: #172033;
  --secondary-text: #334155;
  --muted: #526174;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #cbd5e1;
  --strong-border: #64748b;
  --track: #e2e8f0;
  --progress: #475569;
  --selected-bg: #eaf1ff;
  --selection-border: #2563eb;
  --tag-bg: #e8eef6;
  --button-bg: #334155;
  --button-text: #ffffff;
  --focus: #2563eb;
  --success: #15803d;
  --error: #b91c1c;
  --accent: #6d28d9;
  --accent-bg: #f0eaff;
  --topic-text: #172033;
  --topic-shadow: none;
  --topic-check-bg: #2563eb;
  --topic-check-text: #ffffff;
  --topic-a-lightness: 92%;
  --topic-b-lightness: 85%;
}
html { background: var(--page-bg); }
.theme-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.theme-toolbar .dev-toggle { position: static; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-hover); border-color: var(--strong-border); }
.theme-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
select { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 4px; }
input[type="checkbox"] { accent-color: var(--selection-border); }
