/* Loaded after site.css. Covers share one footprint in both schemes. */
.category-art-wrap {
  display: block;
  width: 100%;
  height: 100%;
}

.category-art-wrap > .category-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-art-wrap > .art-light { display: var(--category-art-light, block); }
.category-art-wrap > .art-dark { display: var(--category-art-dark, none); }

/* Keep explicit overrides and the system fallback equivalent without style-query support. */
@media screen {
  :root[data-theme=dark] {
    color-scheme: dark;
    --bg: #10131b;
    --surface: #191d26;
    --surface-soft: #222732;
    --code: #141820;
    --ink: #e6e9f0;
    --muted: #b5bdcb;
    --quiet: #a0a9b8;
    --line: #303644;
    --line-strong: #485062;
    --control-edge: #687387;
    --blue: #a0b6ff;
    --blue-hover: #c2d0ff;
    --blue-wash: #28344f;
    --focus: #b3c4ff;
    --action: #3159de;
    --action-hover: #3c62e4;
    --action-pressed: #2748ba;
    --action-edge: #7692f2;
    --on-blue: #fff;
    --shadow: 0 16px 40px -20px rgb(0 0 0 / .56);
    --lifted-shadow: 0 18px 42px -20px rgb(0 0 0 / .72);

    --glass-nav: rgb(20 23 30 / .79);
    --glass-panel: rgb(25 29 38 / .97);
    --glass-menu: rgb(25 29 38 / .94);
    --glass-edge: rgb(174 183 201 / .23);
    --glass-highlight: rgb(231 235 244 / .06);
    --glass-shadow: 0 22px 65px -26px rgb(0 0 0 / .73);

    --category-art-light: none;
    --category-art-dark: block;
    scrollbar-color: var(--control-edge) var(--bg);
  }

  /* Controls, reading states, and keyboard focus. */
  :root[data-theme=dark] :focus-visible {
    outline-color: var(--focus);
  }

  :root[data-theme=dark] :is(.prose a:not(.heading-link), .text-link):hover {
    color: var(--blue-hover);
  }

  :root[data-theme=dark] :is(.btn-primary, .skip-link, .brand-mark, .about-logo,
    .filter-bar button[aria-pressed=true]) {
    background: var(--action);
    color: var(--on-blue);
  }

  :root[data-theme=dark] .btn-primary {
    border-color: var(--action-edge);
    box-shadow: 0 6px 15px -8px rgb(0 0 0 / .65);
  }

  :root[data-theme=dark] :is(.btn-primary, .skip-link, .filter-bar button[aria-pressed=true]):hover {
    background: var(--action-hover);
  }

  :root[data-theme=dark] :is(.btn-primary, .skip-link, .filter-bar button[aria-pressed=true]):active {
    background: var(--action-pressed);
    box-shadow: inset 0 0 0 1px var(--action-edge);
  }

  :root[data-theme=dark] .filter-bar button[aria-pressed=true] {
    box-shadow: inset 0 0 0 1px var(--action-edge);
  }

  :root[data-theme=dark] .filter-bar button span {
    opacity: 1;
  }

  :root[data-theme=dark] :is(.btn-secondary, .icon-button, .search-trigger, .search-input-wrap,
    .search-presets button, .mobile-menu summary, .copy-btn, .tag, .toc-mobile, kbd) {
    border-color: var(--control-edge);
  }

  :root[data-theme=dark] :is(.btn-secondary, .icon-button, .search-trigger, .search-presets button,
    .mobile-menu summary, .copy-btn, .tag):hover,
  :root[data-theme=dark] .mobile-menu[open] summary {
    background: var(--blue-wash);
    border-color: var(--blue);
    color: var(--blue);
  }

  :root[data-theme=dark] :is(.font-controls button, .share-button, .filter-bar button):active {
    box-shadow: inset 0 0 0 1px var(--blue);
  }

  :root[data-theme=dark] .search-panel-head .icon-button:hover {
    background: var(--blue-wash);
  }

  :root[data-theme=dark] .search-input-wrap:focus-within {
    border-color: var(--focus);
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  :root[data-theme=dark] :is(.toc-item a, .post-pager > a, .copy-btn, .filter-bar button):focus-visible {
    outline-offset: -2px;
  }

  :root[data-theme=dark] .toc-item a:hover {
    background: var(--surface-soft);
    color: var(--blue);
  }

  :root[data-theme=dark] .toc-item a.is-active {
    background: var(--blue-wash);
    border-left-color: var(--blue);
    color: var(--blue);
  }

  :root[data-theme=dark] .prose :is(th, tbody tr:hover) {
    background: var(--surface-soft);
  }

  :root[data-theme=dark] .prose tbody tr:nth-child(even):not(:hover) {
    background: #1d212b;
  }

  :root[data-theme=dark] .copy-btn.is-done {
    color: #9ed8ba;
    border-color: #6b9d86;
  }

  :root[data-theme=dark] .copy-btn.is-failed {
    color: #f3a6a1;
    border-color: #a76b6b;
  }

  :root[data-theme=dark] .toast {
    background: var(--surface-soft);
    color: var(--ink);
    box-shadow: var(--shadow), 0 0 0 1px var(--line-strong);
  }

  /* Cover-adjacent icons and category labels retain their semantic hues. */
  :root[data-theme=dark] :is(.tone-workbuddy, .category-workbuddy) { color: var(--blue); }
  :root[data-theme=dark] :is(.tone-dsh, .category-dsh) { color: #91cdc2; }
  :root[data-theme=dark] :is(.tone-review, .category-review) { color: #c5b1f0; }
  :root[data-theme=dark] :is(.tone-pitfalls, .category-pitfalls, .rss-tile) { color: #edb78c; }
  :root[data-theme=dark] :is(.tone-method, .category-method) { color: #a3bcdf; }
  :root[data-theme=dark] .tone-workbuddy { background: #282e49; }
  :root[data-theme=dark] .tone-dsh { background: #203431; }
  :root[data-theme=dark] .tone-review { background: #30283e; }
  :root[data-theme=dark] :is(.tone-pitfalls, .rss-tile) { background: #372b24; }
  :root[data-theme=dark] .tone-method { background: #273242; }

  /* Article syntax colors are paired with the darker code well. */
  :root[data-theme=dark] :is(.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in) { color: #c9aef5; }
  :root[data-theme=dark] :is(.hljs-string, .hljs-regexp) { color: #98d2b2; }
  :root[data-theme=dark] :is(.hljs-comment, .hljs-quote, .hljs-meta) { color: var(--quiet); }
  :root[data-theme=dark] :is(.hljs-number, .hljs-attr, .hljs-attribute) { color: #edba90; }
  :root[data-theme=dark] :is(.hljs-title, .hljs-section, .hljs-variable, .hljs-type) { color: #a5baff; }

  /* Keep the benchmark legible without setting it on a navy panel. */
  :root[data-theme=dark] .feature-visual {
    background: #181e29;
    color: var(--ink);
  }

  :root[data-theme=dark] .benchmark-top .icon { color: var(--blue); }
  :root[data-theme=dark] :is(.visual-chip, .task-flow > span, .task-flow > div span) {
    background: var(--surface-soft);
    border-color: var(--control-edge);
    color: var(--muted);
  }

  :root[data-theme=dark] .task-flow { color: var(--muted); }
  :root[data-theme=dark] .flow-lines i,
  :root[data-theme=dark] .flow-join::after { background: var(--control-edge); }
  :root[data-theme=dark] .flow-join { border-color: var(--control-edge); }
  :root[data-theme=dark] .bench-chart { border-color: var(--line-strong); }
  :root[data-theme=dark] :is(.bench-chart > div, .bench-note) { color: var(--muted); }
  :root[data-theme=dark] .bench-chart strong { color: var(--ink); }
  :root[data-theme=dark] .bench-track { background: var(--surface-soft); }
  :root[data-theme=dark] .bench-track i { background: #7b96eb; }
  :root[data-theme=dark] .bench-chart > div:last-child .bench-track i { background: #80bcb7; }
  :root[data-theme=dark] .visual-dot { background: #80bcb7; }

  /* Keep the base header sampling on ::before. These rules only refine its material. */
  :root[data-theme=dark] .search-dialog::backdrop { background: rgb(7 9 14 / .63); }

  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :root[data-theme=dark] .site-header::before {
      -webkit-backdrop-filter: blur(22px) saturate(115%);
      backdrop-filter: blur(22px) saturate(115%);
    }

    :root[data-theme=dark] .back-top {
      box-shadow: 0 8px 25px -10px rgb(0 0 0 / .68), inset 0 1px 0 var(--glass-highlight);
    }
  }

  @media (prefers-reduced-transparency: reduce), (forced-colors: active) {
    :root[data-theme=dark] .site-header::before {
      content: none;
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
    :root[data-theme=dark] :is(.site-header, .search-dialog, .mobile-menu nav, .back-top) {
      background: var(--surface);
      border-color: var(--control-edge);
      box-shadow: none;
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }

  @media (forced-colors: active) {
    :root[data-theme=dark] :is(.btn, .icon-button, .search-trigger, .search-input-wrap, .tag,
      .mobile-menu summary, .filter-bar button, .copy-btn, .search-presets button) {
      border-color: ButtonText;
      box-shadow: none;
    }

    :root[data-theme=dark] .filter-bar button[aria-pressed=true] { outline: 1px solid Highlight; }
    :root[data-theme=dark] :is(:focus-visible, .search-input-wrap:focus-within) { outline-color: Highlight; }
    :root[data-theme=dark] .bench-track i,
    :root[data-theme=dark] .bench-chart > div:last-child .bench-track i { background: Highlight; }
  }

  /* Paint changes are immediate. Motion is limited to pointer feedback. */
  :root[data-theme=dark] :is(.home-hero, .feature-visual .flow-lines, .feature-visual .bench-track i) {
    animation: none;
  }

  :root[data-theme=dark] :is(.btn, .feature-card, .library-card, .starter-card, .topic-link,
    .toc-item a, .text-link .icon, .card-art img, .post-item-art img) {
    transition: none;
  }

  :root[data-theme=dark] :is(.btn-primary:hover, .feature-card:hover, .library-card:hover, .starter-card:hover,
    .text-link:hover .icon, .library-card:hover .card-art img, .post-item:hover .post-item-art img) {
    transform: none;
  }

  :root[data-theme=dark] .feature-card:hover { box-shadow: var(--lifted-shadow); }

  @media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    :root[data-theme=dark] :is(.btn, .feature-card, .library-card, .starter-card, .topic-link,
      .text-link .icon, .card-art img, .post-item-art img) {
      transition: transform .18s var(--ease);
    }

    :root[data-theme=dark] :is(.btn-primary, .feature-card, .library-card, .starter-card, .topic-link):hover {
      transform: translateY(-2px);
    }

    :root[data-theme=dark] :is(.btn-primary, .feature-card, .starter-card, .topic-link):active {
      transform: translateY(0);
    }

    :root[data-theme=dark] .text-link:hover .icon { transform: translateX(3px); }
    :root[data-theme=dark] :is(.library-card:hover .card-art img, .post-item:hover .post-item-art img) {
      transform: scale(1.025);
    }
  }
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #10131b;
    --surface: #191d26;
    --surface-soft: #222732;
    --code: #141820;
    --ink: #e6e9f0;
    --muted: #b5bdcb;
    --quiet: #a0a9b8;
    --line: #303644;
    --line-strong: #485062;
    --control-edge: #687387;
    --blue: #a0b6ff;
    --blue-hover: #c2d0ff;
    --blue-wash: #28344f;
    --focus: #b3c4ff;
    --action: #3159de;
    --action-hover: #3c62e4;
    --action-pressed: #2748ba;
    --action-edge: #7692f2;
    --on-blue: #fff;
    --shadow: 0 16px 40px -20px rgb(0 0 0 / .56);
    --lifted-shadow: 0 18px 42px -20px rgb(0 0 0 / .72);

    --glass-nav: rgb(20 23 30 / .79);
    --glass-panel: rgb(25 29 38 / .97);
    --glass-menu: rgb(25 29 38 / .94);
    --glass-edge: rgb(174 183 201 / .23);
    --glass-highlight: rgb(231 235 244 / .06);
    --glass-shadow: 0 22px 65px -26px rgb(0 0 0 / .73);

    --category-art-light: none;
    --category-art-dark: block;
    scrollbar-color: var(--control-edge) var(--bg);
  }

  /* Controls, reading states, and keyboard focus. */
  :root:not([data-theme]) :focus-visible {
    outline-color: var(--focus);
  }

  :root:not([data-theme]) :is(.prose a:not(.heading-link), .text-link):hover {
    color: var(--blue-hover);
  }

  :root:not([data-theme]) :is(.btn-primary, .skip-link, .brand-mark, .about-logo,
    .filter-bar button[aria-pressed=true]) {
    background: var(--action);
    color: var(--on-blue);
  }

  :root:not([data-theme]) .btn-primary {
    border-color: var(--action-edge);
    box-shadow: 0 6px 15px -8px rgb(0 0 0 / .65);
  }

  :root:not([data-theme]) :is(.btn-primary, .skip-link, .filter-bar button[aria-pressed=true]):hover {
    background: var(--action-hover);
  }

  :root:not([data-theme]) :is(.btn-primary, .skip-link, .filter-bar button[aria-pressed=true]):active {
    background: var(--action-pressed);
    box-shadow: inset 0 0 0 1px var(--action-edge);
  }

  :root:not([data-theme]) .filter-bar button[aria-pressed=true] {
    box-shadow: inset 0 0 0 1px var(--action-edge);
  }

  :root:not([data-theme]) .filter-bar button span {
    opacity: 1;
  }

  :root:not([data-theme]) :is(.btn-secondary, .icon-button, .search-trigger, .search-input-wrap,
    .search-presets button, .mobile-menu summary, .copy-btn, .tag, .toc-mobile, kbd) {
    border-color: var(--control-edge);
  }

  :root:not([data-theme]) :is(.btn-secondary, .icon-button, .search-trigger, .search-presets button,
    .mobile-menu summary, .copy-btn, .tag):hover,
  :root:not([data-theme]) .mobile-menu[open] summary {
    background: var(--blue-wash);
    border-color: var(--blue);
    color: var(--blue);
  }

  :root:not([data-theme]) :is(.font-controls button, .share-button, .filter-bar button):active {
    box-shadow: inset 0 0 0 1px var(--blue);
  }

  :root:not([data-theme]) .search-panel-head .icon-button:hover {
    background: var(--blue-wash);
  }

  :root:not([data-theme]) .search-input-wrap:focus-within {
    border-color: var(--focus);
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  :root:not([data-theme]) :is(.toc-item a, .post-pager > a, .copy-btn, .filter-bar button):focus-visible {
    outline-offset: -2px;
  }

  :root:not([data-theme]) .toc-item a:hover {
    background: var(--surface-soft);
    color: var(--blue);
  }

  :root:not([data-theme]) .toc-item a.is-active {
    background: var(--blue-wash);
    border-left-color: var(--blue);
    color: var(--blue);
  }

  :root:not([data-theme]) .prose :is(th, tbody tr:hover) {
    background: var(--surface-soft);
  }

  :root:not([data-theme]) .prose tbody tr:nth-child(even):not(:hover) {
    background: #1d212b;
  }

  :root:not([data-theme]) .copy-btn.is-done {
    color: #9ed8ba;
    border-color: #6b9d86;
  }

  :root:not([data-theme]) .copy-btn.is-failed {
    color: #f3a6a1;
    border-color: #a76b6b;
  }

  :root:not([data-theme]) .toast {
    background: var(--surface-soft);
    color: var(--ink);
    box-shadow: var(--shadow), 0 0 0 1px var(--line-strong);
  }

  /* Cover-adjacent icons and category labels retain their semantic hues. */
  :root:not([data-theme]) :is(.tone-workbuddy, .category-workbuddy) { color: var(--blue); }
  :root:not([data-theme]) :is(.tone-dsh, .category-dsh) { color: #91cdc2; }
  :root:not([data-theme]) :is(.tone-review, .category-review) { color: #c5b1f0; }
  :root:not([data-theme]) :is(.tone-pitfalls, .category-pitfalls, .rss-tile) { color: #edb78c; }
  :root:not([data-theme]) :is(.tone-method, .category-method) { color: #a3bcdf; }
  :root:not([data-theme]) .tone-workbuddy { background: #282e49; }
  :root:not([data-theme]) .tone-dsh { background: #203431; }
  :root:not([data-theme]) .tone-review { background: #30283e; }
  :root:not([data-theme]) :is(.tone-pitfalls, .rss-tile) { background: #372b24; }
  :root:not([data-theme]) .tone-method { background: #273242; }

  /* Article syntax colors are paired with the darker code well. */
  :root:not([data-theme]) :is(.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in) { color: #c9aef5; }
  :root:not([data-theme]) :is(.hljs-string, .hljs-regexp) { color: #98d2b2; }
  :root:not([data-theme]) :is(.hljs-comment, .hljs-quote, .hljs-meta) { color: var(--quiet); }
  :root:not([data-theme]) :is(.hljs-number, .hljs-attr, .hljs-attribute) { color: #edba90; }
  :root:not([data-theme]) :is(.hljs-title, .hljs-section, .hljs-variable, .hljs-type) { color: #a5baff; }

  /* Keep the benchmark legible without setting it on a navy panel. */
  :root:not([data-theme]) .feature-visual {
    background: #181e29;
    color: var(--ink);
  }

  :root:not([data-theme]) .benchmark-top .icon { color: var(--blue); }
  :root:not([data-theme]) :is(.visual-chip, .task-flow > span, .task-flow > div span) {
    background: var(--surface-soft);
    border-color: var(--control-edge);
    color: var(--muted);
  }

  :root:not([data-theme]) .task-flow { color: var(--muted); }
  :root:not([data-theme]) .flow-lines i,
  :root:not([data-theme]) .flow-join::after { background: var(--control-edge); }
  :root:not([data-theme]) .flow-join { border-color: var(--control-edge); }
  :root:not([data-theme]) .bench-chart { border-color: var(--line-strong); }
  :root:not([data-theme]) :is(.bench-chart > div, .bench-note) { color: var(--muted); }
  :root:not([data-theme]) .bench-chart strong { color: var(--ink); }
  :root:not([data-theme]) .bench-track { background: var(--surface-soft); }
  :root:not([data-theme]) .bench-track i { background: #7b96eb; }
  :root:not([data-theme]) .bench-chart > div:last-child .bench-track i { background: #80bcb7; }
  :root:not([data-theme]) .visual-dot { background: #80bcb7; }

  /* Keep the base header sampling on ::before. These rules only refine its material. */
  :root:not([data-theme]) .search-dialog::backdrop { background: rgb(7 9 14 / .63); }

  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :root:not([data-theme]) .site-header::before {
      -webkit-backdrop-filter: blur(22px) saturate(115%);
      backdrop-filter: blur(22px) saturate(115%);
    }

    :root:not([data-theme]) .back-top {
      box-shadow: 0 8px 25px -10px rgb(0 0 0 / .68), inset 0 1px 0 var(--glass-highlight);
    }
  }

  @media (prefers-reduced-transparency: reduce), (forced-colors: active) {
    :root:not([data-theme]) .site-header::before {
      content: none;
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
    :root:not([data-theme]) :is(.site-header, .search-dialog, .mobile-menu nav, .back-top) {
      background: var(--surface);
      border-color: var(--control-edge);
      box-shadow: none;
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }

  @media (forced-colors: active) {
    :root:not([data-theme]) :is(.btn, .icon-button, .search-trigger, .search-input-wrap, .tag,
      .mobile-menu summary, .filter-bar button, .copy-btn, .search-presets button) {
      border-color: ButtonText;
      box-shadow: none;
    }

    :root:not([data-theme]) .filter-bar button[aria-pressed=true] { outline: 1px solid Highlight; }
    :root:not([data-theme]) :is(:focus-visible, .search-input-wrap:focus-within) { outline-color: Highlight; }
    :root:not([data-theme]) .bench-track i,
    :root:not([data-theme]) .bench-chart > div:last-child .bench-track i { background: Highlight; }
  }

  /* Paint changes are immediate. Motion is limited to pointer feedback. */
  :root:not([data-theme]) :is(.home-hero, .feature-visual .flow-lines, .feature-visual .bench-track i) {
    animation: none;
  }

  :root:not([data-theme]) :is(.btn, .feature-card, .library-card, .starter-card, .topic-link,
    .toc-item a, .text-link .icon, .card-art img, .post-item-art img) {
    transition: none;
  }

  :root:not([data-theme]) :is(.btn-primary:hover, .feature-card:hover, .library-card:hover, .starter-card:hover,
    .text-link:hover .icon, .library-card:hover .card-art img, .post-item:hover .post-item-art img) {
    transform: none;
  }

  :root:not([data-theme]) .feature-card:hover { box-shadow: var(--lifted-shadow); }

  @media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    :root:not([data-theme]) :is(.btn, .feature-card, .library-card, .starter-card, .topic-link,
      .text-link .icon, .card-art img, .post-item-art img) {
      transition: transform .18s var(--ease);
    }

    :root:not([data-theme]) :is(.btn-primary, .feature-card, .library-card, .starter-card, .topic-link):hover {
      transform: translateY(-2px);
    }

    :root:not([data-theme]) :is(.btn-primary, .feature-card, .starter-card, .topic-link):active {
      transform: translateY(0);
    }

    :root:not([data-theme]) .text-link:hover .icon { transform: translateX(3px); }
    :root:not([data-theme]) :is(.library-card:hover .card-art img, .post-item:hover .post-item-art img) {
      transform: scale(1.025);
    }
  }
}
