/* Dropdowns (select.js): the trigger that stands in for a <select>, and the panel that lists
   its options. Loaded last on each page that has a select, so its rules win over the page
   rules written for the bare control. Every color is a token of next.css (or of the
   workspace layers over it), so both themes repaint; the panel's shadow and the sheet's scrim
   are declared here for each theme. */
:root {
  --picker-radius: var(--r, 8px);
  --picker-panel-radius: 14px;
  --picker-row-radius: 8px;
  --picker-h: 36px;
  --picker-fs: 13px;
  --picker-ease: cubic-bezier(.2, .7, .2, 1);
  --picker-shadow: 0 1px 2px rgba(22, 18, 52, 0.06), 0 6px 14px -6px rgba(22, 18, 52, 0.12), 0 28px 56px -24px rgba(22, 18, 52, 0.34);
  --picker-scrim: rgba(8, 10, 19, 0.36);
  --picker-edge: rgba(22, 18, 52, 0.10);
}
[data-theme="dark"] {
  --picker-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 18px -8px rgba(0, 0, 0, 0.7), 0 30px 60px -20px rgba(0, 0, 0, 0.9);
  --picker-scrim: rgba(0, 0, 0, 0.58);
  --picker-edge: rgba(0, 0, 0, 0.45);
}
.workbench { --picker-radius: var(--pill, 999px); --picker-panel-radius: 16px; --picker-h: 32px; --picker-fs: 12.5px; }

/* ── The control in the page ── */
.picker-wrap { position: relative; display: inline-flex; vertical-align: middle; min-width: 0; max-width: 100%; }
.picker-wrap[hidden] { display: none !important; }
.picker-wrap > select.picker-native {
  position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; min-width: 0 !important; min-height: 0 !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important; appearance: none;
}
.picker-wrap > button.picker {
  display: inline-flex; flex: 1 1 auto; align-items: center; gap: 8px; min-width: 0; height: var(--picker-h); min-height: var(--picker-h); margin: 0; padding: 0 9px 0 12px;
  border: 1px solid var(--rule-strong); border-radius: var(--picker-radius); background: var(--surface); color: var(--ink);
  font: 500 var(--picker-fs)/1.2 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; text-align: left; white-space: nowrap;
  cursor: pointer; box-shadow: 0 1px 0 var(--rule-soft); -webkit-tap-highlight-color: transparent;
  transition: border-color .14s ease, box-shadow .16s ease, background-color .14s ease, transform .22s var(--bounce, var(--picker-ease));
}
.picker-wrap > button.picker:hover:not(:disabled) { border-color: color-mix(in srgb, var(--brand) 50%, var(--rule-strong)); background: color-mix(in srgb, var(--brand) 3%, var(--surface)); }
.picker-wrap > button.picker:active:not(:disabled) { transform: scale(.985); }
.picker-wrap > button.picker:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 24%, transparent); }
.picker-wrap > button.picker[aria-expanded="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.picker-wrap > button.picker:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.picker-wrap > button.picker[aria-invalid="true"] { border-color: var(--neg); }
.picker-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.picker-value.is-placeholder { color: var(--muted); }
.picker .picker-lead { flex: none; font: 600 11px/1 var(--mono); letter-spacing: .02em; color: var(--muted); }
.picker .picker-lead[hidden] { display: none; }
.picker-chevron { flex: none; width: 15px; height: 15px; margin-left: auto; color: var(--muted); transition: transform .2s var(--picker-ease), color .14s ease; }
.picker[aria-expanded="true"] .picker-chevron { transform: rotate(180deg); color: var(--brand); }

/* Sizes: compact for toolbars, field for forms (the full width of its cell), inline for a
   control set in a line of text. */
.picker-compact > button.picker { --picker-h: 28px; --picker-fs: 12px; gap: 6px; padding: 0 7px 0 11px; }
.picker-compact .picker-chevron { width: 13px; height: 13px; }
.picker-field { display: flex; width: 100%; }
.picker-inline > button.picker { height: auto; min-height: 0; padding: 2px 3px 2px 6px; gap: 3px; border-color: transparent; background: transparent; box-shadow: none; font-weight: 600; }
.picker-inline > button.picker:hover:not(:disabled) { border-color: transparent; background: var(--surface-hover); }

/* The page contexts that sized their select: the wrapper takes that size. */
.monitor-select .picker-wrap { --picker-h: 32px; }
.eq-select .picker-wrap, .catalog-tools .picker-wrap { --picker-h: 28px; --picker-fs: 12px; }
.eq-select .picker-wrap > button.picker, .catalog-tools .picker-wrap > button.picker { padding: 0 7px 0 11px; gap: 6px; }
.catalog-tools .picker-wrap, .catalog-filter .picker-wrap { max-width: 100%; }
.catalog-filter .picker-wrap { --picker-h: 38px; min-width: min(280px, 100%); }
.alert-field .picker-wrap, .tw-cols .picker-wrap, .tw-field .picker-wrap, .study-field .picker-wrap { display: flex; width: 100%; }
.alert-field .picker-wrap, .tw-view .picker-wrap, .study-field .picker-wrap { --picker-h: 32px; --picker-fs: 13px; }
.curve-head .eq-select .picker-wrap, .scr-sort .picker-wrap { flex: 1; min-width: 0; }
.tw-cond-rule .picker-wrap { flex: 1 1 120px; min-width: 0; }

/* ── The panel ── */
.picker-panel {
  position: fixed; inset: auto; top: var(--picker-y, auto); bottom: var(--picker-b, auto); left: var(--picker-x, 0);
  display: flex; flex-direction: column; box-sizing: border-box; width: max-content; min-width: var(--picker-min, 180px); max-width: var(--picker-max-w, calc(100vw - 16px)); max-height: var(--picker-room, 360px);
  margin: 0; padding: 0; overflow: hidden; z-index: 2147483000;
  border: 1px solid var(--rule); border-radius: var(--picker-panel-radius); background: var(--surface); color: var(--ink);
  font: 400 var(--picker-fs, 13px)/1.35 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; text-align: left;
  box-shadow: var(--picker-shadow); transform-origin: var(--picker-origin, top center);
  animation: picker-in .15s var(--picker-ease) both;
}
.picker-panel[data-side="above"] { --picker-shift: 4px; }
.picker-panel.is-leaving { animation: picker-out .11s ease-in both; }
@keyframes picker-in { from { opacity: 0; transform: translateY(var(--picker-shift, -4px)) scale(.97); } }
@keyframes picker-out { to { opacity: 0; transform: translateY(var(--picker-shift, -2px)) scale(.985); } }

.picker-search { position: relative; display: flex; flex: none; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-bottom: 1px solid var(--rule-soft); }
.picker-search-glyph { flex: none; width: 15px; height: 15px; color: var(--muted); }
.picker-panel .picker-search input.picker-input[type="text"] { flex: 1 1 auto; min-width: 0; height: 100%; margin: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 500 13px var(--sans); letter-spacing: 0; text-transform: none; box-shadow: none; border-radius: 0; }
.picker-search input.picker-input::placeholder { color: var(--muted); opacity: 1; font-weight: 400; }
.picker-count { flex: none; font: 500 11px/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.picker-scroll { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
.picker-list { display: grid; gap: 1px; padding: 5px; outline: 0; }
/* Scroll shadows: a soft edge at the top or bottom of the list while more rows sit past it. */
.picker-scroll::before, .picker-scroll::after {
  content: ""; position: sticky; z-index: 2; display: block; height: 14px; pointer-events: none; opacity: 0; transition: opacity .16s ease;
}
.picker-scroll::before { top: 0; margin-bottom: -14px; background: linear-gradient(var(--picker-edge), transparent); }
.picker-scroll::after { bottom: 0; margin-top: -14px; background: linear-gradient(transparent, var(--picker-edge)); }
.picker-panel.is-above .picker-scroll::before, .picker-panel.is-below .picker-scroll::after { opacity: 1; }

.picker-option {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 6px 8px 6px 10px; border-radius: var(--picker-row-radius);
  color: var(--ink); cursor: pointer; scroll-margin: 5px; -webkit-tap-highlight-color: transparent;
}
.picker-option[data-active] { background: var(--brand-wash); }
.picker-option[aria-disabled="true"] { opacity: .45; cursor: default; }
.picker-option[aria-disabled="true"][data-active] { background: transparent; }
.picker-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-option[aria-selected="true"] .picker-label { font-weight: 600; }
.picker-label mark { padding: 0; border-radius: 2px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); font-weight: 650; }
.picker-option .picker-lead { flex: none; min-width: 2.6ch; font: 600 11px/1 var(--mono); letter-spacing: .03em; color: var(--muted); }
.picker-meta { flex: none; margin-left: auto; padding-left: 14px; font: 500 11.5px/1 var(--mono); font-variant-numeric: tabular-nums slashed-zero; color: var(--muted); text-align: right; }
.picker-option[data-active] .picker-meta, .picker-option[data-active] .picker-lead { color: var(--ink-2); }
.picker-check { flex: none; width: 15px; height: 15px; margin-left: 2px; color: var(--brand); stroke-width: 2.2; opacity: 0; transform: scale(.6); transition: opacity .14s ease, transform .18s var(--picker-ease); }
.picker-meta + .picker-sr + .picker-check { margin-left: 0; }
.picker-option[aria-selected="true"] .picker-check { opacity: 1; transform: none; }
.picker-group { display: grid; gap: 1px; }
.picker-group + .picker-group { margin-top: 4px; }
.picker-group-label {
  position: sticky; top: 0; z-index: 1; margin: 0 -5px; padding: 8px 15px 5px; background: var(--surface);
  font: 600 11px/1.2 var(--sans); letter-spacing: var(--label, .1em); text-transform: uppercase; color: var(--muted);
}

.picker-empty { display: grid; justify-items: center; gap: 4px; padding: 22px 18px 24px; text-align: center; color: var(--muted); }
.picker-empty[hidden] { display: none; }
.picker-empty-glyph { width: 22px; height: 22px; margin-bottom: 4px; color: var(--rule-strong); }
.picker-empty p { margin: 0; max-width: 30ch; }
.picker-empty-text { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.picker-empty-hint { font-size: 12px; }

.picker-foot { display: flex; flex: none; gap: 14px; padding: 7px 12px; border-top: 1px solid var(--rule-soft); background: var(--surface-2); font: 500 11px/1 var(--sans); color: var(--muted); }
.picker-foot kbd { display: inline-grid; place-items: center; min-width: 17px; height: 17px; margin-right: 3px; padding: 0 4px; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); font: 500 11px/1 var(--mono); color: var(--ink-2); }
.picker-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── A narrow screen: a bottom sheet with 48px rows over a scrim ── */
.picker-panel.is-sheet {
  top: auto; bottom: var(--picker-lift, 0); left: 0; right: 0; width: auto; min-width: 0; max-width: none; max-height: var(--picker-room, 86dvh);
  border-width: 1px 0 0; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom, 0);
  --picker-fs: 15px; animation: picker-sheet-in .24s cubic-bezier(.2, .8, .2, 1) both;
}
.picker-panel.is-sheet.is-leaving { animation: picker-sheet-out .16s ease-in both; }
@keyframes picker-sheet-in { from { transform: translateY(100%); } }
@keyframes picker-sheet-out { to { transform: translateY(100%); } }
.picker-scrim { position: fixed; inset: 0; z-index: 2147482999; width: auto; height: auto; margin: 0; padding: 0; border: 0; background: var(--picker-scrim); animation: picker-fade .2s ease both; touch-action: none; }
.picker-scrim.is-leaving { animation: picker-fade .16s ease reverse both; }
@keyframes picker-fade { from { opacity: 0; } }
.picker-head { position: relative; display: flex; flex: none; align-items: center; gap: 8px; min-height: 56px; padding: 10px 6px 0 18px; touch-action: none; }
.picker-grab { position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--rule-strong); }
.picker-title { flex: 1 1 auto; min-width: 0; font: 600 15px/1.2 var(--sans); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.picker-close:hover { background: var(--surface-hover); color: var(--ink); }
.picker-close:focus-visible { outline: 2px solid var(--brand); outline-offset: -4px; }
.picker-close-glyph { width: 20px; height: 20px; }
.is-sheet .picker-search { height: 48px; margin: 0 12px 6px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface-2); }
.picker-panel.is-sheet .picker-search input.picker-input[type="text"] { font-size: 16px; }
.is-sheet .picker-list { padding: 4px 8px 10px; }
.is-sheet .picker-option { min-height: 48px; padding: 10px 12px; gap: 12px; border-radius: 12px; }
.is-sheet .picker-meta { font-size: 13px; }
.is-sheet .picker-check { width: 18px; height: 18px; }
.is-sheet .picker-group-label { margin: 0 -8px; padding: 12px 20px 6px; }

/* Touch screens and narrow windows: 44px targets. */
@media (pointer: coarse), (max-width: 480px) {
  .picker-wrap > button.picker { min-height: 44px; }
  .picker-option { min-height: 44px; }
}

/* ── The workspace's own menus share the panel: the chart bar's menus, the screener's filter
   menus and the search results take its radius, hairline, elevation and opening motion. ── */
.cb-menu:not([hidden]), .scr-facet[open] > .scr-menu, .search-results:not([hidden]) { box-shadow: var(--picker-shadow); animation: picker-in .15s var(--picker-ease) both; transform-origin: top left; }
.cb-menu, .scr-menu { border-color: var(--rule); border-radius: var(--picker-panel-radius); }
.scr-menu { padding: 5px; }
.scr-menu label { border-bottom: 0; border-radius: var(--picker-row-radius); }
.scr-menu label:hover { background: var(--brand-wash); }

@media (prefers-reduced-motion: reduce) {
  .picker-panel, .picker-panel.is-sheet, .picker-scrim, .cb-menu:not([hidden]), .scr-facet[open] > .scr-menu, .search-results:not([hidden]) { animation: none; }
  .picker-chevron, .picker-check, .picker-wrap > button.picker { transition: none; }
  .picker-wrap > button.picker:active:not(:disabled) { transform: none; }
}

/* ── Forced colors: system colors, a visible frame and a highlighted active row ── */
@media (forced-colors: active) {
  .picker-wrap > button.picker, .picker-panel { border: 1px solid CanvasText; }
  .picker-wrap > button.picker:focus-visible, .picker-wrap > button.picker[aria-expanded="true"] { outline: 2px solid Highlight; outline-offset: 2px; }
  .picker-option[data-active] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .picker-option[data-active] :is(.picker-meta, .picker-lead, .picker-check) { color: HighlightText; }
  .picker-option[aria-disabled="true"] { color: GrayText; opacity: 1; }
  /* A mark keeps the platform's MarkText ink unless it is named here, which vanishes on a dark Canvas. */
  .picker-label mark { background: transparent; color: CanvasText; text-decoration: underline; }
  .picker-option[data-active] .picker-label mark { color: HighlightText; }
  .picker-option[aria-disabled="true"] .picker-label mark { color: GrayText; }
  .picker-check, .picker-chevron, .picker[aria-expanded="true"] .picker-chevron, .picker-search-glyph { color: CanvasText; }
  .picker-scroll::before, .picker-scroll::after { display: none; }
}
