/* Keep the real form control, including its native validation and accessible name. */
@media screen {
  @supports (appearance: base-select) and selector(::picker(select)) {
    select:not([multiple], [size]:not([size="0"], [size="1"]), [data-native-select]),
    select:not([multiple], [size]:not([size="0"], [size="1"]), [data-native-select])::picker(select) {
      appearance: base-select;
    }
    select:not([multiple], [size]:not([size="0"], [size="1"]), [data-native-select])::picker(select) {
      box-sizing: border-box;
      max-inline-size: calc(100vw - 16px);
      max-block-size: min(21rem, 52dvh);
      overflow: auto;
      overscroll-behavior: contain;
      margin-block: 4px;
      padding: 4px;
      border: 1px solid var(--line, GrayText);
      border-radius: var(--ui-control-radius, 10px);
      background: var(--white, Canvas);
      color: var(--ink, CanvasText);
      box-shadow: 0 6px 20px var(--shadow, #0002);
      font: inherit;
    }
    select:not([multiple], [size]:not([size="0"], [size="1"]), [data-native-select])::picker-icon {
      margin-inline-start: auto;
      color: var(--sub, GrayText);
    }
    select:not([multiple], [size]:not([size="0"], [size="1"]), [data-native-select]) option:not([hidden]) {
      display: flex;
      align-items: center;
      gap: .55rem;
      min-block-size: 36px;
      padding: 6px 10px;
      border-radius: 6px;
      white-space: normal;
      overflow-wrap: anywhere;
    }
    select:not([multiple], [size]:not([size="0"], [size="1"]), [data-native-select]) option:checked {
      color: var(--ink, CanvasText);
      background: var(--accent-light, Highlight);
      font-weight: 600;
    }
    select:not([multiple], [size]:not([size="0"], [size="1"]), [data-native-select]) option:focus-visible:enabled {
      outline: 2px solid var(--focus, Highlight);
      outline-offset: -2px;
      background: var(--hover, ButtonFace);
    }
    @media (pointer: coarse) {
      select:not([multiple], [size]:not([size="0"], [size="1"]), [data-native-select]) option:not([hidden]) {
        min-block-size: 44px;
      }
    }
  }

  /* Used only by browsers without customizable native pickers. */
  .themed-select-list {
    box-sizing: border-box;
    position: fixed;
    inset: auto;
    z-index: 2147483647;
    overflow: auto;
    overscroll-behavior: contain;
    margin: 0;
    padding: 4px;
    border: 1px solid var(--line, GrayText);
    border-radius: var(--ui-control-radius, 10px);
    background: var(--white, Canvas);
    color: var(--ink, CanvasText);
    box-shadow: 0 6px 20px var(--shadow, #0002);
    font: inherit;
    outline: none;
  }
  .themed-select-list [role=option] {
    border-radius: 6px;
    min-height: 36px;
    padding: 7px 10px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    overflow-wrap: anywhere;
    cursor: pointer;
  }
  .themed-select-list [role=option][aria-selected=true] { background: var(--accent-light, Highlight); font-weight: 600; }
  .themed-select-list [role=option][data-active] { outline: 2px solid var(--focus, Highlight); outline-offset: -2px; }
  .themed-select-list [role=option][aria-disabled=true] { color: var(--muted, GrayText); cursor: default; }
  .themed-select-group { padding: 6px 10px 3px; font-size: .85em; font-weight: 600; color: var(--sub, GrayText); }
  @media (pointer: coarse) {
    .themed-select-list [role=option] { min-height: 44px; }
  }
}
