/* Dark mode: follows the visitor's system/browser setting (prefers-color-scheme).
   Loaded after w3.css on every page. Light mode is unchanged. */
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; }
  html, body { background-color: #121212; color: #e6e6e6; }
  hr { border-color: #3a3a3a; }
  a { color: inherit; }
  a:hover { color: #ffffff; }

  /* nav bar + buttons */
  .w3-light-grey, .w3-hover-light-grey:hover { background-color: #2b2b2b !important; color: #e6e6e6 !important; }
  .w3-button:hover { background-color: #444 !important; color: #fff !important; }

  /* post cards on the home / all-posts pages */
  .w3-card-4 { background-color: #1c1c1c; box-shadow: 0 4px 10px 0 rgba(0,0,0,.6), 0 4px 20px 0 rgba(0,0,0,.5); }

  /* code */
  .w3-codespan { background-color: #2b2b2b; color: #f0f0f0; }
  .w3-code, .w3-code.notranslate { background-color: #1e1e1e; color: #e6e6e6; border-left-color: #4caf50; }

  /* tables */
  .w3-striped tbody tr:nth-child(even) { background-color: #1c1c1c; }
  .w3-bordered tr { border-bottom-color: #3a3a3a; }

  /* footer is already black; keep its text readable */
  footer.w3-black { background-color: #000 !important; }

  /* soften bright charts/photos so they don't glare against the dark page */
  img { filter: brightness(0.92); }
}
