.custom-select {
  position: relative;
  width: 100%;
  min-width: 0;
  color: var(--text);
  font: inherit;
}

.custom-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  clip-path: inset(50%) !important;
  pointer-events: none !important;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 42px 10px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  background: var(--s2);
  color: var(--text);
  font: inherit;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  outline: none;
  user-select: none;
  transition:
    border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

.custom-select-trigger:hover {
  border-color: var(--pink);
  background: var(--s3);
}

.custom-select-trigger:focus-visible,
.custom-select.is-open .custom-select-trigger {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-soft);
}

.custom-select.is-invalid .custom-select-trigger,
.custom-select-trigger[aria-invalid="true"] {
  border-color: var(--danger-text);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.custom-select.is-disabled .custom-select-trigger,
.custom-select-trigger[aria-disabled="true"] {
  border-color: var(--border);
  background: var(--s1);
  color: var(--text-3);
  cursor: not-allowed;
  opacity: 0.72;
}

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

.custom-select.is-placeholder .custom-select-value {
  color: var(--text-3);
}

.custom-select-chevron {
  position: absolute;
  top: 50%;
  right: 15px;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  color: var(--text-2);
  pointer-events: none;
  transform: rotate(45deg);
  transform-origin: 65% 65%;
  transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.custom-select.is-open .custom-select-chevron {
  color: var(--pink);
  transform: rotate(225deg);
}

.custom-select-menu {
  position: fixed;
  z-index: 1000;
  display: none;
  top: var(--custom-select-top, 12px);
  left: var(--custom-select-left, 12px);
  width: var(--custom-select-width, auto);
  min-width: 180px;
  max-width: calc(100vw - 24px);
  max-height: var(--custom-select-max-height, min(360px, calc(100vh - 24px)));
  padding: 6px;
  overflow: hidden;
  border: 1px solid var(--border-2);
  border-radius: var(--r-card);
  background: var(--s3);
  color: var(--text);
  box-shadow: var(--shadow-menu);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.35;
  transform-origin: center top;
}

.custom-select-menu.custom-select-menu-open,
.custom-select-menu.is-open {
  display: block;
  animation: custom-select-in var(--dur-fast) var(--ease-out) both;
}

.custom-select-menu.is-up {
  transform-origin: center bottom;
}

.custom-select-list {
  max-height: var(--custom-select-max-height, min(346px, calc(100vh - 38px)));
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--border-2) transparent;
  scrollbar-width: thin;
}

.custom-select-list::-webkit-scrollbar {
  width: 8px;
}

.custom-select-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--border-2);
  background-clip: padding-box;
}

.custom-select-option {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 9px 38px 9px 11px;
  border-radius: calc(var(--r) - 2px);
  color: var(--text-2);
  cursor: pointer;
  outline: none;
  overflow-wrap: anywhere;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.custom-select-option:hover,
.custom-select-option.is-active,
.custom-select-option[aria-current="true"] {
  background: var(--s2);
  color: var(--text);
}

.custom-select-option.is-selected,
.custom-select-option[aria-selected="true"] {
  background: var(--pink-soft);
  color: var(--pink);
  font-weight: 600;
}

.custom-select-option.is-selected::after,
.custom-select-option[aria-selected="true"]::after {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 10px;
  height: 5px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  content: "";
  transform: translateY(-65%) rotate(-45deg);
}

.custom-select-option.is-disabled,
.custom-select-option[aria-disabled="true"] {
  background: transparent;
  color: var(--text-3);
  cursor: not-allowed;
  opacity: 0.58;
}

.custom-select-group + .custom-select-group,
.custom-select-option + .custom-select-group {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
}

.custom-select-group-label {
  display: block;
  padding: 7px 11px 5px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.custom-select-empty {
  padding: 12px;
  color: var(--text-3);
  text-align: center;
}

.custom-select-backdrop {
  position: fixed;
  z-index: 999;
  display: none;
  inset: 0;
  background: var(--overlay);
}

.custom-select-backdrop.is-open {
  display: block;
  animation: mh-fade var(--dur-fast) ease both;
}

.privacy-page .custom-select {
  margin-top: 6px;
}

@keyframes custom-select-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 620px) {
  .custom-select-menu.custom-select-menu-open,
  .custom-select-menu.is-open {
    top: auto !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    min-width: 0;
    max-width: none;
    max-height: min(72dvh, 620px);
    padding: 10px 8px max(10px, env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    animation-name: mh-sheet-up;
    transform-origin: center bottom;
  }

  .custom-select-menu.custom-select-menu-open::before,
  .custom-select-menu.is-open::before {
    display: block;
    width: 38px;
    height: 4px;
    margin: 0 auto 8px;
    border-radius: 4px;
    background: var(--border-2);
    content: "";
  }

  .custom-select-list {
    max-height: min(calc(72dvh - 38px), 582px);
  }

  .custom-select-option {
    min-height: 48px;
    padding-block: 11px;
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .custom-select-menu.custom-select-menu-open,
  .custom-select-menu.is-open {
    animation: none;
  }
}

@media (forced-colors: active) {
  .custom-select-trigger,
  .custom-select-menu {
    border: 1px solid ButtonText;
  }

  .custom-select-trigger:focus-visible,
  .custom-select.is-open .custom-select-trigger,
  .custom-select-option.is-active {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }

  .custom-select-option[aria-selected="true"] {
    background: Highlight;
    color: HighlightText;
  }
}
