/* Dark mode and its switch. Loaded after the page stylesheet on every page. */

.theme-btn {
    margin-left: auto;
    min-width: 40px;
    height: 36px;
    padding: 0 10px;
    background: var(--card);
    border: 1.5px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
  }
  .theme-btn:hover {
    border-color: var(--accent-dark);
    color: var(--accent-dark);
  }

  /* Inline SVGs follow the theme colours */
  .search-icon circle, .search-icon path { stroke: var(--ink-soft); }
  .nav-btn svg path { stroke: currentColor; }

  /* Dark mode: explicitly chosen ... */
  :root[data-theme="dark"] {
    --accent: #72bf44;
    --accent-dark: #8fd166;
    --ink: #ececea;
    --ink-soft: #a5a8a3;
    --line: #34382f;
    --bg: #151714;
    --card: #1e211c;
    color-scheme: dark;
  }
  /* ... or taken from the system setting */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --accent: #72bf44;
      --accent-dark: #8fd166;
      --ink: #ececea;
      --ink-soft: #a5a8a3;
      --line: #34382f;
      --bg: #151714;
      --card: #1e211c;
      color-scheme: dark;
    }
    :root:not([data-theme="light"]) .site-logo { filter: invert(1) hue-rotate(180deg); }
    :root:not([data-theme="light"]) .filters select {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23ececea' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    }
  }
  :root[data-theme="dark"] .site-logo { filter: invert(1) hue-rotate(180deg); }
  :root[data-theme="dark"] .filters select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23ececea' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
