/* Custom select — progressive enhancement over native <select>.
   Studio Light tokens: tile #faf8f6, ink #2b222b, muted #7a6e77,
   border #e5ddd6, tint #f0dde3, link #a34460. */

.cs {
  position: relative;
  display: inline-block;
  width: 100%;
  /* Never let the enhanced control push past its container on small screens. */
  max-width: 100%;
  min-width: 0;
}

/* Native select is kept in the DOM (form value + a11y fallback) but hidden
   once enhanced. Before JS runs, the native select shows normally. */
.cs > select.cs-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.cs-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #e5ddd6;
  border-radius: 16px;
  background: #faf8f6;
  color: #2b222b;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.cs-trigger:hover:not(:disabled) { background: #fff; }
.cs-trigger:focus-visible,
.cs-trigger.cs-open {
  outline: none;
  border-color: #d9a7b6;
  box-shadow: 0 0 0 3px rgba(163, 68, 96, 0.18);
}
.cs-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.cs-trigger-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-trigger-label.cs-is-placeholder { color: #9c8f96; font-weight: 400; }

.cs-chevron {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: #7a6e77;
  transition: transform .18s ease;
  pointer-events: none;
}
.cs-trigger.cs-open .cs-chevron { transform: rotate(180deg); }

/* Menu is portaled to <body> and positioned fixed, so card overflow never clips it. */
.cs-menu {
  position: fixed;
  z-index: 1000;
  min-width: 160px;
  max-height: 288px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #e5ddd6;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 12px 32px -12px rgba(43, 34, 43, 0.28), 0 2px 8px -4px rgba(43, 34, 43, 0.16);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease;
}
.cs-menu.cs-menu-open { opacity: 1; transform: translateY(0); }

.cs-search {
  width: 100%;
  margin-bottom: 6px;
  padding: 7px 10px;
  border: 1px solid #e5ddd6;
  border-radius: 12px;
  background: #faf8f6;
  color: #2b222b;
  font-size: 13px;
  outline: none;
}
.cs-search:focus { border-color: #d9a7b6; box-shadow: 0 0 0 2px rgba(163, 68, 96, 0.14); }

.cs-optgroup-label {
  padding: 8px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9c8f96;
}

.cs-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 14px;
  color: #2b222b;
  cursor: pointer;
  user-select: none;
}
.cs-option:hover:not(.cs-option-disabled),
.cs-option.cs-active:not(.cs-option-disabled) { background: #f0ebe5; }
.cs-option.cs-selected { background: #f0dde3; color: #8e3a52; font-weight: 600; }
.cs-option.cs-selected.cs-active { background: #ecd2da; }
.cs-option-disabled { color: #b9afb4; cursor: not-allowed; }

.cs-option-check {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  color: #a34460;
  opacity: 0;
}
.cs-option.cs-selected .cs-option-check { opacity: 1; }

.cs-empty {
  padding: 10px;
  font-size: 13px;
  color: #9c8f96;
  text-align: center;
}

/* Dark-theme viewers (in case a dark surface is ever reintroduced). */
:root[data-theme="dark"] .cs-trigger {
  background: #241c25;
  border-color: #3a2f3b;
  color: #f2ecf1;
}
:root[data-theme="dark"] .cs-trigger:hover:not(:disabled) { background: #2b222b; }
:root[data-theme="dark"] .cs-menu {
  background: #241c25;
  border-color: #3a2f3b;
}
:root[data-theme="dark"] .cs-option { color: #f2ecf1; }
:root[data-theme="dark"] .cs-option:hover:not(.cs-option-disabled),
:root[data-theme="dark"] .cs-option.cs-active:not(.cs-option-disabled) { background: #322734; }
