/* Keep native selection, validation and form submission while styling the picker. */
@supports (appearance: base-select) {
  select:not([multiple]):not([size]):not(.select2-hidden-accessible),
  select:not([multiple]):not([size]):not(.select2-hidden-accessible)::picker(select) {
    appearance: base-select;
  }

  select:not([multiple]):not([size]):not(.select2-hidden-accessible) {
    align-items: center;
    gap: 16px;
    cursor: pointer;
    text-align: start;
  }

  select::picker(select) {
    margin-block: 7px;
    padding: 6px;
    max-block-size: min(420px, 60dvh);
    max-inline-size: calc(100vw - 24px);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 10px 30px color-mix(in srgb, var(--ink) 12%, transparent);
    font: 13px/1.5 var(--font-family-primary, 'Microsoft YaHei', sans-serif);
    scrollbar-width: thin;
    scrollbar-color: var(--selected-line) transparent;
    overscroll-behavior: contain;
  }

  select::picker-icon {
    content: '';
    width: 7px;
    height: 7px;
    margin-inline: auto 3px;
    border: solid var(--muted);
    border-width: 0 1.5px 1.5px 0;
    transform: translateY(-2px) rotate(45deg);
  }

  select:open::picker-icon {
    transform: translateY(2px) rotate(225deg);
  }

  select:disabled {
    cursor: not-allowed;
    opacity: .6;
  }

  select:not([multiple]) optgroup {
    margin: 0;
    padding: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
  }

  select:not([multiple]) optgroup + optgroup {
    margin-block-start: 6px;
    border-block-start: 1px solid var(--line);
  }

  select:not([multiple]) option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-block-size: 38px;
    margin: 2px 0;
    padding: 9px 12px;
    border-radius: 9px;
    background: transparent;
    color: var(--ink);
    font-size: 13px;
    font-weight: 400;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
  }

  select:not([multiple]) option:checked {
    background: var(--soft);
    color: var(--link);
    font-weight: 500;
  }

  select:not([multiple]) option:hover,
  select:not([multiple]) option:focus-visible {
    background: var(--hover);
    outline: none;
  }

  select:not([multiple]) option::checkmark {
    order: 1;
    margin-inline-start: auto;
    color: var(--link);
  }

  select:not([multiple]) option:disabled {
    color: var(--muted);
    opacity: .6;
    cursor: not-allowed;
  }

  @media (max-width: 700px) {
    select:not([multiple]) option { min-block-size: 44px; }
  }
}
