/* A shared treatment for the closed control and its list of choices.
   Native select semantics retain labels, keyboard navigation, validation and
   the platform picker as a fallback where customizable selects are unavailable. */
:root {
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%235f7067' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
[data-theme="dark"] {
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23b4c6ba' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* The declarations with !important override compact feature-specific controls
   without changing their colours, widths, status meaning or form behaviour. */
select:not([multiple]):not([size]) {
  appearance: none !important;
  -webkit-appearance: none !important;
  background-image: var(--select-arrow) !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 16px !important;
  padding-inline-end: 38px !important;
  min-height: 32px;
  max-width: 100%;
  cursor: pointer;
}
select:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 3px !important;
}
select:disabled { cursor: not-allowed; opacity: .55; }

@supports (appearance: base-select) {
  select:not([multiple]):not([size]),
  select:not([multiple]):not([size])::picker(select) {
    appearance: base-select !important;
    -webkit-appearance: base-select !important;
  }
  select:not([multiple]):not([size]) {
    background-image: none !important;
    padding-inline-end: 12px !important;
    align-items: center;
    gap: 16px;
  }
  select::picker-icon {
    content: '';
    width: 16px;
    height: 16px;
    flex: none;
    margin-inline-start: auto;
    background: var(--select-arrow) center / 16px no-repeat;
    transition: rotate .15s ease;
  }
  select:open::picker-icon { rotate: 180deg; }
  select::picker(select) {
    margin-block: 7px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
    box-shadow: 0 10px 36px #10281d24, 0 2px 6px #10281d10;
    font: 13px/1.5 var(--font-ui);
    max-height: min(360px, 60dvh);
    max-width: calc(100vw - 24px);
    overflow: auto;
    scrollbar-width: thin;
  }
  select option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    min-height: 40px;
    border-radius: 7px;
    color: var(--text);
    background: transparent;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
  }
  select option + option { margin-top: 2px; }
  select option:is(:hover, :focus-visible) { background: var(--bg-soft); outline: none; }
  select option:checked { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
  select option::checkmark { order: 1; margin-inline-start: auto; color: var(--accent); }
  select option:disabled { color: var(--text-soft); opacity: .55; cursor: not-allowed; }
  select optgroup { padding: 6px 0; }
  select optgroup::before { padding: 6px 12px; color: var(--text-soft); font-size: 11px; }
}

@media (pointer: coarse) {
  select:not([multiple]):not([size]) { min-height: 44px; }
  select option { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  select::picker-icon { transition: none; }
}
@media (forced-colors: active) {
  select::picker-icon { background: none; border-bottom: 2px solid ButtonText; border-right: 2px solid ButtonText; width: 8px; height: 8px; rotate: 45deg; }
  select:open::picker-icon { rotate: 225deg; }
  select option:checked { outline: 1px solid Highlight; }
}
