/* Dark mode overrides applied when <html> has class "dark" */
html.dark, html.dark body {
  background: #0b0c0d !important;
  color: #e6eef5 !important;
}

html.dark .book-page,
html.dark .book-menu,
html.dark .book-header,
html.dark .book-footer {
  background: transparent !important;
  color: inherit !important;
}

html.dark a { color: #7fb3ff !important; }
html.dark a:visited { color: #9bbcff !important; }

html.dark pre, html.dark code, html.dark .book-article pre, html.dark .book-article code {
  background: #071017 !important;
  color: #dbeafc !important;
}

/* Cards, hero and muted panels */
html.dark .card, html.dark .hero, html.dark .cards .card, html.dark .card.muted {
  background: rgba(255,255,255,0.03) !important;
  border-color: rgba(255,255,255,0.04) !important;
}

/* Menu separator / borders */
html.dark .book-menu, html.dark .book-header, html.dark .book-footer {
  border-color: rgba(255,255,255,0.04) !important;
}

/* Theme toggle button */
.book-theme-toggle {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

/* SVG crescent: color is driven by `currentColor` so we toggle via `color` */
.book-theme-toggle .theme-icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; color: #000; transition: color 160ms ease, transform 160ms ease; }
html.dark .book-theme-toggle .theme-icon { color: #fff; }
.book-theme-toggle:active .theme-icon { transform: scale(0.95); }

/* Light-mode tweak: make border darker on light backgrounds */
.book-theme-toggle:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.9);
  outline-offset: 2px;
  border-radius: 8px;
}

.book-theme-toggle:hover { background: rgba(0,0,0,0.04); }

/* Search box styling in dark mode */
html.dark .book-search { background: transparent; }
html.dark .book-search input#book-search-input {
  background: #071017;
  color: #e6eef5;
  border: 1px solid rgba(255,255,255,0.06);
}
html.dark .book-search input#book-search-input::placeholder { color: rgba(230,238,245,0.55); }
html.dark .book-search-spinner { background: rgba(255,255,255,0.03); }
html.dark #book-search-results {
  background: #071017;
  color: #dbeafc;
  border: 1px solid rgba(255,255,255,0.04);
}

/* Header placement tweaks */
.header-title { gap: 8px; }
.header-toggle { padding: 4px; border-radius: 6px; }
.header-toggle .theme-icon { width: 20px; height: 20px; }

/* Slightly pull the toggle left so it visually sits just before the title */
.header-title h3 { margin: 0; font-weight: 700; }

@media (max-width: 640px) {
  /* hide extra toggle in very small screens if desired */
  .header-toggle { display: inline-flex; }
}

/* Brand toggle styling (left/top near title) */
.brand-toggle { margin-right: 8px; padding: 4px; border-radius: 6px; }
.brand-toggle .theme-icon { width: 18px; height: 18px; }

.book-brand a { align-items: center; }

/* Small accessibility improvements for dark mode */
html.dark .btn.primary { background-color: #1f6feb !important; color: #fff !important; }
