:root {
  --select-accent: #ea580c;
  --select-accent-hover: #c2410c;
  --select-accent-subtle: #fff7ed;
}

html.dark {
  --select-accent: #8b5cf6;
  --select-accent-hover: #7c3aed;
  --select-accent-subtle: rgba(139, 92, 246, 0.14);
}

.aap-custom-select {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}

.aap-custom-select.is-full-width {
  width: 100% !important;
}

.aap-native-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.aap-custom-select-button,
.aap-shell .aap-custom-select-button,
.aap-report .aap-custom-select-button {
  display: flex !important;
  width: 100% !important;
  min-height: 42px !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  border: 1px solid color-mix(in srgb, var(--select-accent) 45%, var(--border-default)) !important;
  border-radius: var(--radius-md) !important;
  background: color-mix(in srgb, var(--select-accent-subtle) 50%, var(--bg-sunken)) !important;
  padding: 0 38px 0 12px !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
  font: inherit !important;
  font-size: var(--text-base) !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  text-align: left !important;
  cursor: pointer !important;
  position: relative !important;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease !important;
}

.aap-custom-select-button:hover {
  border-color: var(--select-accent) !important;
  background: color-mix(in srgb, var(--select-accent) 10%, var(--bg-sunken)) !important;
}

.aap-custom-select.open .aap-custom-select-button,
.aap-custom-select-button:focus,
.aap-custom-select-button:focus-visible {
  border-color: var(--select-accent) !important;
  background: color-mix(in srgb, var(--select-accent) 12%, var(--bg-sunken)) !important;
  box-shadow: 0 0 0 3px var(--select-accent-subtle) !important;
  outline: none !important;
}

.aap-custom-select-button:disabled {
  cursor: not-allowed !important;
  opacity: .55 !important;
}

.aap-custom-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aap-custom-select-chevron {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--select-accent);
  border-bottom: 2px solid var(--select-accent);
  transform: translateY(-70%) rotate(45deg);
  transition: transform .15s ease;
  pointer-events: none;
}

.aap-custom-select.open .aap-custom-select-chevron {
  transform: translateY(-30%) rotate(225deg);
}

.aap-custom-select-menu {
  position: fixed;
  z-index: 10000;
  max-height: min(320px, 48vh);
  overflow-y: auto;
  border: 1px solid var(--select-accent) !important;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--select-accent) 4%, var(--bg-surface)) !important;
  padding: 5px;
  box-shadow: 0 14px 30px color-mix(in srgb, var(--select-accent) 12%, rgba(0,0,0,.18));
}

html.dark .aap-custom-select-menu {
  background: color-mix(in srgb, var(--select-accent) 7%, var(--bg-elevated)) !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .5);
}

.aap-custom-select-menu[hidden] {
  display: none !important;
}

.aap-custom-select-option,
.aap-shell .aap-custom-select-option,
.aap-report .aap-custom-select-option {
  display: flex !important;
  width: 100% !important;
  min-height: 38px !important;
  align-items: center !important;
  border: 1px solid transparent !important;
  border-radius: calc(var(--radius-md) - 3px) !important;
  background: transparent !important;
  padding: 8px 11px !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
  font: inherit !important;
  font-size: var(--text-base) !important;
  font-weight: 500 !important;
  line-height: 1.25 !important;
  text-align: left !important;
  cursor: pointer !important;
}

/* These selectors intentionally outrank the generic global button rule. */
html body .aap-custom-select-menu button.aap-custom-select-option.aap-custom-select-option[role="option"]:hover,
html body .aap-custom-select-menu button.aap-custom-select-option.aap-custom-select-option[role="option"].is-active:not(.is-selected) {
  border-color: color-mix(in srgb, var(--select-accent) 75%, transparent) !important;
  background: var(--select-accent) !important;
  color: #ffffff !important;
}

html body .aap-custom-select-menu button.aap-custom-select-option.aap-custom-select-option[role="option"].is-selected[aria-selected="true"],
html body .aap-custom-select-menu button.aap-custom-select-option.aap-custom-select-option[role="option"][aria-selected="true"] {
  border-color: var(--select-accent) !important;
  background: var(--select-accent) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
}

html body .aap-custom-select-menu button.aap-custom-select-option.aap-custom-select-option[role="option"].is-selected[aria-selected="true"]:hover,
html body .aap-custom-select-menu button.aap-custom-select-option.aap-custom-select-option[role="option"].is-selected[aria-selected="true"].is-active {
  border-color: var(--select-accent-hover) !important;
  background: var(--select-accent-hover) !important;
  color: #ffffff !important;
}

.aap-custom-select-option:disabled {
  cursor: not-allowed !important;
  opacity: .45 !important;
}

.aap-custom-select-optgroup {
  padding: 8px 11px 4px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.aap-custom-select.invalid .aap-custom-select-button {
  border-color: var(--color-danger) !important;
}
