/* Progressive single-select controls. The native field keeps form semantics. */
.ui-select { position: relative; display: inline-flex; flex-direction: column; width: 100%; min-width: 0; vertical-align: middle; }
body select.ui-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 1px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  pointer-events: none !important;
}
body .ui-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px #00000006;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
body .ui-select-trigger:hover:not(:disabled) { background: var(--field, var(--bg)); border-color: var(--muted); }
body .ui-select-trigger[aria-expanded="true"] { background: var(--field, var(--bg)); border-color: var(--muted); }
body .ui-select-trigger:focus-visible { outline: 2px solid var(--action, var(--accent)); outline-offset: 3px; }
body .ui-select-trigger:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
body .ui-select-trigger[aria-invalid="true"] { border-color: #dc405c; }
.ui-select-value { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select-chevron { width: 16px; height: 16px; flex: 0 0 16px; color: var(--muted); transition: transform .15s; pointer-events: none; }
.ui-select-trigger[aria-expanded="true"] .ui-select-chevron { transform: rotate(180deg); }
.ui-select-error { display: block; margin-top: 7px; font-size: 12px; line-height: 1.5; font-weight: 400; color: #dc405c; }
.ui-select-error:empty { display: none; }

.ui-select-menu {
  display: none;
  position: fixed;
  inset: auto;
  z-index: 1000;
  box-sizing: border-box;
  min-width: 160px;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 14px 44px #00000038, 0 3px 10px #00000014;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y pinch-zoom;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
}
.ui-select-menu:popover-open, .ui-select-menu[data-open="true"] { display: block; }
.ui-select-menu::backdrop { background: transparent; backdrop-filter: none; }
.ui-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 42px;
  padding: 10px 12px;
  margin: 2px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  overflow-wrap: anywhere;
}
.ui-select-option > span { min-width: 0; }
.ui-select-option:not([aria-disabled="true"]):hover, .ui-select-option.is-active { background: var(--field, var(--bg)); }
.ui-select-option[aria-selected="true"] {
  background: var(--soft, var(--bg));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  font-weight: 600;
}
.ui-select-option[aria-selected="true"].is-active { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.ui-select-option[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }
.ui-select-check { width: 16px; height: 16px; flex: 0 0 16px; color: var(--action, var(--ink)); pointer-events: none; }
.ui-select-option:not([aria-selected="true"]) .ui-select-check { visibility: hidden; }
.ui-select-group { margin: 0; padding: 0; }
.ui-select-group-label { padding: 12px 12px 5px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em; }

/* Compact discovery controls use the same visual system as form fields. */
.sort-form .ui-select { width: 184px; max-width: 100%; }
.flow-view-control .ui-select { width: 140px; }
.theme-flow .flow-toolbar .ui-select-trigger { min-height: 40px; padding: 9px 12px; font-size: 12px; border-radius: 10px; }
.theme-flow .flow-toolbar .ui-select-value { color: var(--ink); }
.video-timeline .ui-select { width: 58px; }
.video-timeline .ui-select-trigger { min-height: 30px; padding: 4px 6px; font-size: 11px; gap: 4px; }
.admin-content .ui-select-trigger { font-size: 14px; font-weight: 400; }
.admin-content .ui-select { max-width: 100%; }
.admin-page .ui-select-trigger:focus-visible { outline-color: var(--ink); }
.admin-page .ui-select-check { color: var(--ink); }
/* Sorting is already visually complete before its native field is enhanced. */
@media (min-width: 761px) {
  .theme-flow .flow-toolbar {
    --sort-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2362626e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
  .theme-flow[data-color="dark"] .flow-toolbar {
    --sort-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9a9b5' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
  .theme-flow .flow-toolbar .sort-form > select:not(.ui-select-native),
  .theme-flow .flow-toolbar .sort-form > .ui-select {
    box-sizing: border-box;
    width: 184px;
    min-width: 0;
    /* Earlier tablet rules constrain only native selects to 120px. */
    max-width: 100% !important;
  }
  .theme-flow .flow-toolbar .sort-form :is(select:not(.ui-select-native), .ui-select-trigger) {
    box-sizing: border-box;
    height: 40px;
    min-height: 40px;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background-color: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 2px #00000006;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    text-align: left;
  }
  .theme-flow .flow-toolbar .sort-form > select:not(.ui-select-native) {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 42px;
    background-image: var(--sort-chevron);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
  }
  .theme-flow .flow-toolbar .sort-form :is(select:not(.ui-select-native), .ui-select-trigger):hover:not(:disabled) { background-color: var(--field, var(--bg)); border-color: var(--muted); }
  .theme-flow .flow-toolbar .sort-form > select:not(.ui-select-native):focus-visible { outline: 2px solid var(--action, var(--accent)); outline-offset: 3px; }
  .theme-flow .flow-toolbar .sort-form > select:not(.ui-select-native):disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
}
@media (max-width: 760px) {
  .theme-flow .flow-toolbar .sort-form .ui-select { width: 168px; }
  .theme-flow .flow-toolbar .ui-select-trigger { min-height: 42px; padding: 10px 12px; background: #17171ee8; border-color: #ffffff24; color: #fff; box-shadow: 0 2px 10px #0003; }
  .theme-flow .flow-toolbar .ui-select-value { color: #fff; }
  .theme-flow .flow-toolbar .ui-select-chevron { color: #dedee5; }
  .theme-flow .flow-toolbar .ui-select-trigger:hover, .theme-flow .flow-toolbar .ui-select-trigger[aria-expanded="true"] { background: #252530; border-color: #ffffff4a; }
  .ui-select-option { min-height: 46px; padding: 12px; }
  body .ui-select-trigger { min-height: 46px; font-size: 15px; }
  .ui-select-menu { border-radius: 14px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  body .ui-select-trigger, .ui-select-chevron { transition: none; }
  .theme-flow .flow-toolbar .sort-form > select:not(.ui-select-native) { transition: none; }
}
@media (forced-colors: active) {
  body .ui-select-trigger, .ui-select-menu { border: 1px solid ButtonText; }
  .theme-flow .flow-toolbar .sort-form > select:not(.ui-select-native) { appearance: auto; -webkit-appearance: auto; background-image: none; border-color: ButtonText; }
  .ui-select-option.is-active { outline: 1px solid Highlight; }
  .ui-select-option[aria-selected="true"] { color: HighlightText; background: Highlight; }
  .ui-select-option[aria-selected="true"] .ui-select-check { color: HighlightText; }
}
