/* Shared by the viewport, body-level portals and native pickers. This small
   static sheet keeps the browser-supported chained ::picker(select) scrollbar
   selectors intact (the CSS minifier cannot parse them). No JS or overflow
   changes: the browser owns scrolling and the existing gutter. */
:root {
  --scrollbar-size: 6px;
  --scrollbar-radius: 4px;
  --scrollbar-thumb: #d2d2d7;
  --scrollbar-thumb-hover: #aaaab1;
}
:root[data-theme="dark"] {
  --scrollbar-thumb: #58585f;
  --scrollbar-thumb-hover: #777781;
}

/* In Chromium, setting standard width/color to non-auto would replace these
   parts with the native Windows scrollbar, including its arrow buttons. */
@media not (forced-colors: active) {
  @supports selector(::-webkit-scrollbar) {
    ::-webkit-scrollbar { width: var(--scrollbar-size); height: var(--scrollbar-size); }
    ::-webkit-scrollbar-track,
    ::-webkit-scrollbar-corner { background: transparent; }
    ::-webkit-scrollbar-thumb {
      background: var(--scrollbar-thumb);
      border: 0;
      border-radius: var(--scrollbar-radius);
    }
    ::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
    ::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
  }

  /* A customizable native select scrolls its top-layer picker, not the select
     element. Separate these selectors so older engines keep the rules above. */
  @supports selector(select::picker(select)::-webkit-scrollbar) {
    select::picker(select)::-webkit-scrollbar { width: var(--scrollbar-size); height: var(--scrollbar-size); }
    select::picker(select)::-webkit-scrollbar-track,
    select::picker(select)::-webkit-scrollbar-corner { background: transparent; }
    select::picker(select)::-webkit-scrollbar-thumb {
      background: var(--scrollbar-thumb);
      border: 0;
      border-radius: var(--scrollbar-radius);
    }
    select::picker(select)::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
    select::picker(select)::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
  }

  /* Engines without scrollbar parts use system thin bars. Low specificity
     leaves deliberately hidden bars (e.g. the sidebar) alone. */
  @supports not selector(::-webkit-scrollbar) {
    :where(*) { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
  }
}
