/* =========================================================================
   TM Guitar — themed select (replaces the native dropdown UI)
   One trigger button per <select> + one shared popover listbox.
   ========================================================================= */

/* the real select stays in the DOM as the source of truth, visually removed */
select.ui-native {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  opacity: 0; pointer-events: none;
  clip-path: inset(50%);
  overflow: hidden;
}

/* ---------- trigger ---------- */
.ui-sel {
  position: relative;
  display: inline-flex; align-items: center;
  height: 36px; max-width: 100%;
  padding-block: 0;
  padding-inline: 12px 30px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 12.5px; font-weight: 600;
  text-align: start;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.ui-sel:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--line-2)); }
.ui-sel:focus-visible {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}
.ui-sel[disabled] { opacity: .55; cursor: default; }
.ui-sel-label {
  min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  line-height: 1.2;
}
.ui-sel-chev {
  position: absolute; inset-inline-end: 10px; top: 50%;
  width: 14px; height: 14px; margin-top: -7px;
  color: var(--ink-3); pointer-events: none;
  transition: transform .2s ease, color .2s ease;
}
.ui-sel[aria-expanded="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.ui-sel[aria-expanded="true"] .ui-sel-chev { transform: rotate(180deg); color: var(--ink-2); }

/* the wrapper's own chevron is redundant once a trigger is inside */
.field.has-ui-sel::after { display: none; }
.field .ui-sel { max-width: 210px; }
.field-sm .ui-sel { height: 34px; font-size: 12px; padding-inline: 8px 26px; border-radius: 8px; }
.field-sm .ui-sel-chev { inset-inline-end: 8px; width: 12px; height: 12px; margin-top: -6px; }
.appbar-tools .field .ui-sel { min-width: 0; }

/* tuner: big transparent preset trigger */
.tp-select .ui-sel {
  height: auto; width: 100%;
  padding: 2px 0 2px 22px;
  border: 0; background: transparent; border-radius: 6px;
  font-size: 16px; font-weight: 800; color: var(--ink);
}
.tp-select .ui-sel:hover { border: 0; }
.tp-select .ui-sel:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; box-shadow: none; }
.tp-select .ui-sel[aria-expanded="true"] { box-shadow: none; }
.tp-select .ui-sel-chev { inset-inline-end: 0; width: 16px; height: 16px; margin-top: -8px; }

/* tuner settings rows */
.ts-row .ui-sel { height: 34px; max-width: 56%; font-size: 12.5px; padding-inline: 10px 26px; background: var(--surface-2); border-width: 1.5px; }
.ts-row .ui-sel-chev { inset-inline-end: 9px; width: 13px; height: 13px; margin-top: -6.5px; }

/* ---------- popover ---------- */
.ui-menu {
  position: fixed; z-index: 300;
  padding: 6px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: 0 26px 60px -22px rgba(4, 12, 30, .55), 0 4px 14px -6px rgba(4, 12, 30, .18);
  max-height: min(58vh, 340px);
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  transform-origin: top center;
  animation: ui-menu-in .15s cubic-bezier(.2, .85, .3, 1);
}
html[data-theme="dark"] .ui-menu {
  background: color-mix(in srgb, var(--surface-2) 92%, #0b1424);
  box-shadow: 0 26px 60px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .04);
}
.ui-menu.up { transform-origin: bottom center; }
.ui-menu[hidden] { display: none; }
@keyframes ui-menu-in {
  from { opacity: 0; transform: translateY(-5px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.ui-group {
  padding: 9px 10px 4px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .02em;
  color: var(--ink-3);
}
.ui-opt {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  text-align: start; line-height: 1.45;
  transition: background .12s, color .12s;
}
.ui-opt-txt { min-width: 0; flex: 1 1 auto; }
.ui-opt .ui-tick {
  flex: none; width: 15px; height: 15px;
  color: var(--gold-ink); opacity: 0;
  transform: scale(.6); transition: opacity .15s, transform .18s cubic-bezier(.3, 1.5, .5, 1);
}
html[data-theme="dark"] .ui-opt .ui-tick { color: var(--gold); }
.ui-opt[aria-selected="true"] { color: var(--ink); font-weight: 800; background: var(--gold-soft); }
.ui-opt[aria-selected="true"] .ui-tick { opacity: 1; transform: none; }
.ui-opt.is-active { background: var(--surface-2); }
.ui-opt[aria-selected="true"].is-active { background: color-mix(in srgb, var(--gold-soft) 70%, var(--surface-2)); }
.ui-opt[aria-disabled="true"] { opacity: .45; }
.ui-opt:active { transform: scale(.99); }

/* a soft backdrop only on touch-sized screens, so a stray tap closes the menu */
.ui-scrim {
  position: fixed; inset: 0; z-index: 299;
  background: transparent; border: 0; padding: 0;
}
.ui-scrim[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .ui-menu { animation: none; }
  .ui-opt .ui-tick, .ui-sel-chev { transition: none; }
}
