/* Apply before the first paint; surfaces share the app's existing tokens. */
:root[data-theme="dark"],
:root[data-theme="dark"] body.night {
  --bg: #000000;
  --surface: #151515;
  --surface-soft: #222222;
  --text: #f2f2f2;
  --muted: #aaaaaa;
  --line: #303030;
  --tint: #33241e;
  --shadow: 0 18px 60px #0006;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
html { background: var(--bg); }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  min-height: 40px;
}
.theme-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}
.theme-toggle .theme-option svg { width: 16px; height: 16px; }
[data-theme="dark"] .theme-night,
[data-theme="light"] .theme-day {
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 650;
}
.theme-toggle:hover { border-color: var(--accent); }
[data-theme="dark"] :is(.nav-item:not(.active),.sidebar-bottom p,.sidebar-tagline,.search-trigger,.search-trigger svg,.search-trigger kbd) { color: var(--muted); }
[data-theme="dark"] .search-trigger { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .search-trigger kbd { background: var(--surface-soft); border-color: var(--line); }
[data-theme="dark"] .avatar-button { background: var(--tint); color: #ffb896; }
[data-theme="dark"] .header-member-entry { color: #f0cd8b; border-color: #806437; }
[data-theme="dark"] :is(.member-error,.content-inline-error) { color: #ffaf8f; }
[data-theme="dark"] .member-success { color: #8bdbb3; }
@media (max-width: 1180px) and (min-width: 768px) {
  .global-header .search-trigger { width: 180px; }
}
@media (max-width: 767px) {
  .global-header { justify-content: space-between; }
  .global-header .header-actions { margin-inline-start: auto; gap: 7px; justify-content: flex-end; }
  .theme-toggle { min-height: 36px; padding: 3px; gap: 0; }
  .theme-option { padding: 4px 7px; }
  .theme-option > span { display: none; }
  .global-header .language-select { min-width: 0; width: 84px; max-width: 100px; }
  .global-header .search-trigger { width: 30px; padding: 5px; }
}
@media (max-width: 420px) {
  .global-header { column-gap: 8px; }
  .global-header .mobile-brand { gap: 6px; }
  .global-header .mobile-brand strong { font-size: 18px; }
  .global-header .mobile-brand img { width: 28px; height: 28px; }
}
