.theme-toggle {
  min-height: 42px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.2;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--teal); }
.theme-toggle:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.theme-icon { font-size: 19px; line-height: 1; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #ecf5f4;
  --muted: #b3c6c8;
  --teal: #70d9e6;
  --teal-deep: #a6eaf0;
  --paper: #101c24;
  --line: #3b5059;
  --white: #192a33;
  --shadow: 0 20px 55px rgba(0, 0, 0, .3);
}

[data-theme="dark"] .brand-mark,
[data-theme="dark"] .featured-card,
[data-theme="dark"] .speaker,
[data-theme="dark"] .filter.active,
[data-theme="dark"] .button.primary,
[data-theme="dark"] .level-cover,
[data-theme="dark"] .book-cover { color: #fff; background-color: #176b80; }
[data-theme="dark"] .level-4 .level-cover { background: #3d587d; }
[data-theme="dark"] .level-5 .level-cover { background: #514c7c; }
[data-theme="dark"] .level-6 .level-cover { background: #302d56; }
[data-theme="dark"] .download-link,
[data-theme="dark"] .download-button,
[data-theme="dark"] .level-actions .download-file { color: #102c34; background: #bcebf1; }
[data-theme="dark"] .button.light { color: #073b49; background: #e5fbfd; }

/* Home page and lesson dialog */
[data-theme="dark"] .intro-shell { background: #22353e; }
[data-theme="dark"] .intro-shell::after { background: rgba(112, 217, 230, .09); }
[data-theme="dark"] .lede { color: #c5d8d9; }
[data-theme="dark"] .button.secondary { border-color: var(--line); background: #263a43; }
[data-theme="dark"] .stats div { border-color: var(--line); }
[data-theme="dark"] .level-card,
[data-theme="dark"] .lesson-card,
[data-theme="dark"] dialog,
[data-theme="dark"] .filter,
[data-theme="dark"] .lesson-nav button { background: var(--white); color: var(--ink); }
[data-theme="dark"] .level-cover { box-shadow: -5px 5px 0 #324750; }
[data-theme="dark"] .level-tag,
[data-theme="dark"] .category { background: #294a54; }
[data-theme="dark"] .lesson-card[data-accent] .category { background: #344454; color: #c9e9ed; }
[data-theme="dark"] .search-box,
[data-theme="dark"] .icon-button,
[data-theme="dark"] .dialogue-line { background: #253a43; }
[data-theme="dark"] .dialogue-line:nth-child(even) { background: #29434d; }
[data-theme="dark"] .dialog-header { background: rgba(25, 42, 51, .96); }
[data-theme="dark"] th { background: #263d46; color: var(--ink); }
[data-theme="dark"] td:first-child { color: var(--teal-deep); }
[data-theme="dark"] .practice-box { background: #194650; color: #d9f8fa; }
[data-theme="dark"] .answer-box { background: #403929; border-color: #826c41; }
[data-theme="dark"] .number { color: #a8bdc2; }

/* Book reader */
[data-theme="dark"] .reader-header { background: rgba(25, 42, 51, .96); }
[data-theme="dark"] .reader-sidebar,
[data-theme="dark"] .book-page,
[data-theme="dark"] .level-picker select,
[data-theme="dark"] .search-input-wrap input,
[data-theme="dark"] footer { background: var(--white); color: var(--ink); }
[data-theme="dark"] .book-toc a { color: #c2d4d6; }
[data-theme="dark"] .book-toc a:hover,
[data-theme="dark"] .book-toc a:focus-visible { color: var(--teal); background: #294651; }
[data-theme="dark"] tbody tr:nth-child(even) { background: #223740; }
[data-theme="dark"] .answer-vault { background: #233943; border-color: #49606a; }
[data-theme="dark"] mark { color: #fff; background: #715321; }

@media (max-width: 820px) {
  .site-header nav a:not(.download-link) { display: none; }
}
@media (max-width: 640px) {
  .theme-toggle { width: 42px; padding: 8px; }
  .theme-label { display: none; }
  .reader-controls { gap: 7px; }
}
@media (max-width: 430px) {
  .site-header .download-link { display: none; }
}
