/* Automatic dark mode based on OS preference */
@media (prefers-color-scheme: dark) {

  /* Make sure the root and body are dark */
  html,
  body {
    background-color: #0d1117 !important;
    color: #e6edf3 !important;
  }

  /* All “main content” containers – be aggressive here */
  #book,
  .book,
  .book-body,
  .page-wrapper,
  .page-inner,
  .chapter,
  .content,
  .main,
  .page {
    background-color: #0d1117 !important;
    color: #e6edf3 !important;
  }

  /* Sidebar / TOC / header / footer */
  .book-summary,
  .sidebar,
  .site-header,
  .site-footer,
  .book-header,
  .navigation,
  nav {
    background-color: #0d1117 !important;
    color: #e6edf3 !important;
    border-color: #30363d !important;
  }

  .book-summary a,
  .sidebar a,
  .site-header a,
  .site-footer a,
  .book-header a,
  nav a {
    color: #e6edf3 !important;
  }

  a {
    color: #58a6ff !important;
  }

  /* Code blocks and inline code */
  pre,
  code {
    background-color: #161b22 !important;
    color: #e6edf3 !important;
  }

  /* Tables */
  table {
    background-color: #0d1117 !important;
    color: #e6edf3 !important;
  }

  th,
  td {
    border-color: #30363d !important;
  }

  /* Horizontal rules */
  hr {
    border-color: #30363d !important;
  }

  /* Force footer to be dark as well */
  footer,
  .footer,
  .site-footer,
  .page-footer,
  .book-footer {
    background-color: #0d1117 !important;
    color: #e6edf3 !important;
    border-top: 1px solid #30363d !important;
  }

  footer a,
  .footer a,
  .site-footer a,
  .page-footer a,
  .book-footer a {
    color: #e6edf3 !important;
  }

  /* Make sure the main text is bright enough in dark mode */
  body,
  #book,
  .book,
  .book-body,
  .page-wrapper,
  .page-inner,
  .chapter,
  .content,
  .main,
  .page {
    color: #e6edf3 !important;
  }

  p,
  li,
  h1, h2, h3, h4, h5, h6 {
    color: #e6edf3 !important;
  }

  /* Abstract box should match dark theme */
  .abstract,
  .chapter-abstract,
  .abstract p {
    background-color: #161b22 !important;
    color: #e6edf3 !important;
    border-color: #30363d !important;
  }

  /* Optional: add a subtle border or rounded corners if you like */
  .abstract {
    border: 1px solid #30363d !important;
    border-radius: 6px;
  }


}

