/* Piplix form components (shared: member site, Trading Lab, admin).
 * Source design: Brilliant-style system - neutral surfaces, ink selection, semantic
 * green/red/amber validation. Focus ring + caret + required "*" use brand orange, matching the
 * site-wide input focus in px-system.css (3D CTA buttons live in px-actions.css).
 *
 * Two parts:
 *  1. @layer piplix-forms   restyles LEGACY controls (.form-control, .tl-input, ...) - shape and
 *     focus only, so each page keeps its own sizes and Trading Lab keeps its dark/light theme.
 *  2. New components        .px-field/.px-label/.px-input (extended), .px-choice, .px-opt,
 *     .px-seg, .px-switch, .px-alert, .px-chipsel (js/px-chipselect.js).
 * Colours come from --f-* which default to --px-* and map to --tl-* inside the Trading Lab.
 */

:root {
  --f-bg: var(--px-surface-0, #fff);
  --f-bg-subtle: var(--px-surface-50, #F8FAFC);
  --f-pill: var(--px-surface-100, #F1F5F9);
  --f-line: var(--px-ink-300, #CBD5E1);
  --f-line-soft: var(--px-surface-200, #E2E8F0);
  --f-line-hover: var(--px-ink-400, #94A3B8);
  --f-ink: var(--px-ink-900, #0F172A);
  --f-ink-2: var(--px-ink-700, #262C30);
  --f-muted: var(--px-ink-500, #64748B);
  --f-placeholder: var(--px-ink-400, #94A3B8);
  --f-focus: var(--px-ink-700, #334155);          /* focus = one darker border, no glow (also set in px-system.css) */
  --f-ring: transparent;
  --f-on-ink: #fff;
  --f-ok: var(--px-success, #4EC363);
  --f-ok-text: #187A33;
  --f-ok-tint: var(--px-success-subtle, #E6F6EE);
  --f-err: var(--px-error, #E3473F);
  --f-err-text: #B91C1C;
  --f-err-tint: var(--px-error-subtle, #FDECEC);
  --f-warn: #F59E0B;
  --f-warn-text: #B45309;
  --f-warn-tint: #FFFBEB;
  --f-radius: var(--px-radius-md, 12px);
  --f-fs: var(--px-fs-sm, 15px);
  --f-fs-sm: var(--px-fs-xs, 13px);
  --f-caret: var(--px-orange, #FF7400);
  --f-accent: var(--px-orange, #FF7400);            /* ticks, selected borders, switches */
  --f-accent-ink: var(--px-orange-ink, #B84F00);    /* text on the soft tint */
  --f-accent-soft: var(--px-orange-soft, #FFF1E6);
  --f-accent-line: var(--px-orange-line, #FFD3B0);
}
.tl-workspace, .tl-theme, .tl-page {
  --f-bg: var(--tl-input-bg); --f-bg-subtle: var(--tl-surface-2); --f-pill: var(--tl-surface-3);
  --f-line: var(--tl-border); --f-line-soft: var(--tl-border); --f-line-hover: var(--tl-border-strong);
  --f-ink: var(--tl-ink-hi); --f-ink-2: var(--tl-ink); --f-muted: var(--tl-ink-lo);
  --f-placeholder: var(--tl-ink-dis);
  --f-on-ink: var(--tl-ink-inverse, #000); --f-focus: var(--tl-ink);
  --f-fs: var(--tl-fs-body, 14px); --f-fs-sm: 12px;
}
/* full Trading Lab pages (journal, trades, analytics...) read like the rest of the site; only the terminal stays compact */
.tl-page:not(.tl-workspace) { --f-fs: var(--px-fs-sm, 15px); --f-fs-sm: var(--px-fs-xs, 13px); }
@layer piplix-forms {
  .tl-page:not(.tl-workspace) :is(input.tl-input, select.tl-input, select.tl-select):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]) { min-height: 44px !important; }
}

/* ---------------------------------------------------------------------------
 * 1. Legacy controls: one border, radius, caret and focus ring everywhere.
 * ------------------------------------------------------------------------- */
@layer piplix-forms {
  :is(.form-control, .form-select, .tl-input, .tl-select, .pxch-select, .custom-select-base, .community-category-select, .pxstr-input, .pxstr__select, .px-bt-input, .px-bt__code, .fxh-control, .settings-section-select, .comment-input, .px-tovr__sort, .px-tst__search, .pj-search, input.px-dp-input, .px-input) {
    border-width: 1.5px !important;
    border-style: solid !important;
    border-color: var(--f-line) !important;
    border-radius: var(--f-radius) !important;
    caret-color: var(--f-caret);
    font-family: inherit;
    transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
  }
  :is(.form-control, .form-select, .tl-input, .tl-select, .pxch-select, .custom-select-base, .community-category-select, .pxstr-input, .pxstr__select, .px-bt-input, .px-bt__code, .fxh-control, .settings-section-select, .comment-input, .px-tovr__sort, .px-tst__search, .pj-search, input.px-dp-input, .px-input):hover:not(:focus):not(:disabled):not([aria-invalid="true"]) {
    border-color: var(--f-line-hover) !important;
  }
  :is(.form-control, .form-select, .tl-input, .tl-select, .pxch-select, .custom-select-base, .community-category-select, .pxstr-input, .pxstr__select, .px-bt-input, .px-bt__code, .fxh-control, .settings-section-select, .comment-input, .px-tovr__sort, .px-tst__search, .pj-search, input.px-dp-input, .px-input):focus,
  :is(.form-control, .form-select, .tl-input, .tl-select, .pxch-select, .custom-select-base, .community-category-select, .pxstr-input, .pxstr__select, .px-bt-input, .px-bt__code, .fxh-control, .settings-section-select, .comment-input, .px-tovr__sort, .px-tst__search, .pj-search, input.px-dp-input, .px-input):focus-visible {
    border-color: var(--f-focus) !important;
    box-shadow: 0 0 0 3px var(--f-ring) !important;
    outline: 0 !important;
  }
  :is(.form-control, .form-select, .tl-input, .tl-select, .pxch-select, .px-input)[aria-invalid="true"],
  :is(.form-control, .form-select, .tl-input, .tl-select, .pxch-select, .px-input).is-invalid {
    border-color: var(--f-err) !important;
  }
  :is(.form-control, .form-select, .tl-input, .tl-select, .pxch-select, .px-input):disabled {
    cursor: not-allowed;
    opacity: .7;
  }
  /* Bootstrap-style textareas and multiline fields keep their height; only the corners match. */
  textarea:is(.form-control, .tl-input, .px-input) { border-radius: var(--f-radius) !important; }
}

/* ---------------------------------------------------------------------------
 * 1b. Calculator / tool pages (.px-tool-page): Bootstrap fields + the page-local custom select
 *     (.cs-wrapper > .cs-trigger / .cs-dropdown / .cs-option) brought to the reference spec:
 *     44px fields, 15px text, 13px labels, 12px corners, neutral menu with a check mark.
 * ------------------------------------------------------------------------- */
@layer piplix-forms {
  .px-tool-page :is(.form-control, .form-select, .cs-trigger, .input-group-text) {
    min-height: 44px !important;
    padding: .5rem .875rem !important;
    font-size: var(--f-fs) !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
    color: var(--f-ink) !important;
    border-radius: var(--f-radius) !important;
  }
  .px-tool-page .input-group-text { min-width: 44px; justify-content: center; background: var(--f-pill) !important; color: var(--f-muted) !important; border: 1.5px solid var(--f-line) !important; }
  .px-tool-page .form-label, .px-tool-page .pill-label { font-size: var(--f-fs-sm) !important; font-weight: 600 !important; line-height: 1.4 !important; margin-bottom: 6px !important; color: var(--f-ink) !important; }
  .px-tool-page :is(.form-text, .small-hint) { font-size: var(--f-fs-sm) !important; line-height: 1.4 !important; color: var(--f-muted) !important; }
  /* joined input groups: flat inner corners */
  .px-tool-page .input-group > :not(:last-child):not(.dropdown-toggle) { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
  .px-tool-page .input-group > :not(:first-child) { border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; margin-left: -1.5px; }

  .px-tool-page .cs-trigger { background: var(--f-bg) !important; border: 1.5px solid var(--f-line) !important; transition: border-color .14s, box-shadow .14s; }
  .px-tool-page .cs-trigger:hover { border-color: var(--f-line-hover) !important; background: var(--f-bg) !important; }
  .px-tool-page .cs-wrapper.open .cs-trigger { border-color: var(--f-focus) !important; box-shadow: 0 0 0 3px var(--f-ring) !important; }
  .px-tool-page .cs-trigger::after {
    content: "\e071" !important; font-family: "lucide" !important; font-size: 17px; line-height: 1;
    width: auto !important; height: auto !important; border: 0 !important; color: var(--f-muted);
    transform: none !important; transition: transform .18s;
  }
  .px-tool-page .cs-wrapper.open .cs-trigger::after { transform: rotate(180deg) !important; color: var(--f-ink); }

  .px-tool-page .cs-dropdown { top: calc(100% + 6px) !important; padding: 0 !important; border-radius: var(--f-radius) !important; overflow: visible !important; }
  .px-tool-page .cs-wrapper.open .cs-dropdown-inner {
    background: var(--f-bg); border: 1.5px solid var(--f-line-soft); border-radius: var(--f-radius);
    padding: 6px !important; max-height: 260px; box-shadow: 0 12px 28px -6px rgba(15, 23, 42, .12), 0 4px 10px -3px rgba(15, 23, 42, .05);
  }
  .px-tool-page .cs-option {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 12px !important; border-radius: 8px; font-size: 14px !important; font-weight: 500; color: var(--f-ink);
  }
  .px-tool-page .cs-option:hover, .px-tool-page .cs-option.focused { background: var(--f-pill) !important; }
  .px-tool-page .cs-option.active, .px-tool-page .cs-option.cs-active { background: var(--f-pill) !important; font-weight: 600; }
  .px-tool-page .cs-option.active::after, .px-tool-page .cs-option.cs-active::after { content: "\e070"; font-family: "lucide"; font-size: 15px; line-height: 1; }
}
@media (max-width: 767px) {   /* 16px keeps iOS from zooming into focused fields */
  @layer piplix-forms { .px-tool-page :is(.form-control, .form-select, .cs-trigger) { font-size: 16px !important; } }
}

/* ---------------------------------------------------------------------------
 * 1b-2. One size for Bootstrap fields on the member site (the contact form mixed 20px "-lg" and 16px
 *       fields). Small variants and file pickers keep their own size; the admin keeps admin-system.css.
 * ------------------------------------------------------------------------- */
@layer piplix-forms {
  body:not(#page-top) :is(.form-control, .form-select):not(.form-control-sm):not(.form-select-sm):not(textarea):not([type="file"]):not([type="color"]) {
    min-height: 44px !important;
    font-size: var(--f-fs-field, var(--f-fs)) !important;
    line-height: 1.35 !important;
  }
  body:not(#page-top) textarea.form-control:not(.form-control-sm) { font-size: var(--f-fs-field, var(--f-fs)) !important; line-height: 1.45 !important; }
}
@media (max-width: 767px) {   /* one phone size for Trading Lab pages too (the mobile scale file made them 14 / 14.5 / 15) */
  @layer piplix-forms { .tl-page:not(.tl-workspace) :is(input.tl-input, select.tl-input, select.tl-select, textarea.tl-input, input.px-dp-input, input.pj-search, input.px-tst__search) { font-size: 16px !important; } }
}
@media (max-width: 767px) { body:not(#page-top) { --f-fs-field: 16px; } }   /* 16px keeps iOS from zooming into focused fields */

@layer piplix-forms {
  /* date fields match the dropdowns beside them on every page */
  input.px-dp-input { min-height: 44px !important; font-size: var(--f-fs) !important; }
  .pmd-search { min-height: 44px; border: 1.5px solid var(--f-line) !important; border-radius: var(--f-radius) !important; }
  .px-select > button { min-height: 44px !important; max-height: 44px; box-sizing: border-box; border-width: 1.5px !important; border-color: var(--f-line) !important; border-radius: var(--f-radius) !important; font-size: var(--f-fs) !important; }
  .px-select > button:hover { border-color: var(--f-line-hover) !important; }
  .px-select > button[aria-expanded="true"] { border-color: var(--f-focus) !important; box-shadow: 0 0 0 3px var(--f-ring) !important; }
  .px-select-menu { border: 1.5px solid var(--f-line-soft) !important; border-radius: var(--f-radius) !important; padding: 6px !important; background: var(--f-bg) !important; box-shadow: 0 12px 28px -6px rgba(15,23,42,.12), 0 4px 10px -3px rgba(15,23,42,.05) !important; z-index: 10060 !important; }
  .px-select-menu > button { display: flex !important; align-items: center; justify-content: space-between; gap: 10px; min-height: 0 !important; padding: 9px 12px !important; border-radius: 8px !important; font-size: var(--f-fs) !important; font-weight: 500 !important; color: var(--f-ink) !important; background: transparent !important; text-align: left; }
  .px-select-menu > button:hover, .px-select-menu > button:focus { background: var(--f-pill) !important; box-shadow: none !important; }
  .px-select-menu > button[aria-selected="true"] { background: var(--f-pill) !important; font-weight: 600 !important; }
  .px-select-menu > button[aria-selected="true"]::after { content: "\e070"; font-family: "lucide"; font-size: 15px; line-height: 1; color: var(--f-accent); }
}

/* ---------------------------------------------------------------------------
 * 1c. Fields that carry no class at all (blog search, markets tools, week-ahead filters, contact,
 *     journal, reflection notes...). Border, corners and caret only: padding and size stay with the
 *     page, so icon-in-field and inline layouts keep working. Trading terminal, Lix chat, setup popup
 *     and chart UI have their own compact controls and are left alone.
 * ------------------------------------------------------------------------- */
@layer piplix-forms {
  :is(#px-main, main, .container, .container-fluid)
  :is(input:not([class]):not([type]), input:not([class])[type="text"], input:not([class])[type="search"], input:not([class])[type="email"],
      input:not([class])[type="number"], input:not([class])[type="password"], input:not([class])[type="tel"], input:not([class])[type="url"],
      select:not([class]), textarea:not([class])):not(:is(.tl-terminal, .tl-workspace, .tl-setup, .px-lix, .px-dp, .px-chipsel, .tl-chrome-menu, .tl-settings, .pmd-search, .px-tst-trades__search, .px-input-wrap, [class*="search"], [class*="-wrap"], [class*="__field"], [class*="chart"]) *) {
    border: 1.5px solid var(--f-line) !important;
    border-radius: var(--f-radius) !important;
    font-size: var(--f-fs) !important;
    caret-color: var(--f-caret);
    transition: border-color .14s ease, box-shadow .14s ease;
  }
  :is(#px-main, main, .container, .container-fluid)
  :is(input:not([class]), select:not([class]), textarea:not([class])):not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):hover:not(:focus):not(:disabled):not(:is(.tl-terminal, .tl-workspace, .tl-setup, .px-lix, .tl-chrome-menu, .tl-settings) *) {
    border-color: var(--f-line-hover) !important;
  }
}

@media (max-width: 767px) {   /* unclassed text fields: 16px so iOS does not zoom in on focus */
  @layer piplix-forms {
    .pmd-search input, .px-tst-trades__search input { font-size: 16px !important; }
    :is(#px-main, main, .container, .container-fluid)
    :is(input:not([class]):not([type]), input:not([class])[type="text"], input:not([class])[type="search"], input:not([class])[type="email"],
        input:not([class])[type="number"], input:not([class])[type="password"], input:not([class])[type="tel"], input:not([class])[type="url"],
        select:not([class]), textarea:not([class])):not(:is(.tl-terminal, .tl-workspace, .tl-setup, .px-lix, .px-dp, .px-chipsel, .tl-chrome-menu, .tl-settings, .pmd-search, .px-tst-trades__search, .px-input-wrap, [class*="search"], [class*="-wrap"], [class*="__field"], [class*="chart"]) *) { font-size: 16px !important; }
  }
}

/* Bordered wrappers (search pills, icon fields): the wrapper takes the darker border, the field inside stays quiet. */
@layer piplix-forms {
  :is(label, div, span, form):has(> :is(input, select, textarea):focus-visible):is([class*="search"], [class*="input"], [class*="field"], [class*="wrap"]) {
    border-color: var(--f-focus) !important; outline: 0 !important; box-shadow: none !important;
  }
  :is(label, div, span, form):is([class*="search"], [class*="input"], [class*="field"], [class*="wrap"]):focus-within { outline: 0 !important; }
  :is(label, div, span):has(> :is(input, select, textarea):focus-visible) > :is(input, select, textarea):focus-visible { border-color: transparent !important; box-shadow: none !important; }
}

/* native checkboxes, radios and sliders everywhere: brand tick colour (the custom boxes above use the same one) */
input[type="checkbox"], input[type="radio"], input[type="range"], progress { accent-color: var(--f-accent); }

/* styled dropdown (js/product-select.mjs): the real <select> stays in the form, invisible */
.px-select { position: relative; }
.px-select > select.px-select__native { position: absolute !important; inset: auto 0 0 0; width: 1px !important; height: 1px !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important; }
:is(label, .tl-setup__field, .tl-setup__section, .px-field, .tl-field, .form-group, .mb-3, .col, [class*="col-"]) > .px-select { display: flex; width: 100%; }
.px-select > button { text-align: left; }

/* ---------------------------------------------------------------------------
 * 2. Field wrapper, label, helper
 * ------------------------------------------------------------------------- */
.px-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.px-label {
  display: inline-flex; align-items: center; gap: 3px; margin: 0;
  font-size: var(--f-fs-sm); font-weight: 600; color: var(--f-ink);
}
.px-req { color: var(--f-caret); font-weight: 600; }          /* required asterisk */
.px-field__help {
  margin: 0; display: flex; align-items: center; gap: 5px;
  font-size: var(--f-fs-sm); line-height: 1.4; color: var(--f-muted);
}
.px-field__help.is-valid { color: var(--f-ok-text); font-weight: 500; }
.px-field__help.is-invalid, .px-field__error { color: var(--f-err-text); font-weight: 500; }
.px-field__help.is-warning { color: var(--f-warn-text); font-weight: 500; }

/* ---------------------------------------------------------------------------
 * 3. .px-input (extends px-base): sizes, states, icon, textarea
 * ------------------------------------------------------------------------- */
.px-input {
  min-height: 44px; padding: 0 14px; font-size: var(--f-fs); font-weight: 500;
  color: var(--f-ink); background-color: var(--f-bg); caret-color: var(--f-caret);
}
.px-input::placeholder { color: var(--f-placeholder); font-weight: 400; }
.px-input--sm { min-height: 38px; padding: 0 12px; font-size: var(--f-fs-sm); border-radius: 10px !important; }
.px-input--lg { min-height: 52px; padding: 0 16px; }
textarea.px-input { min-height: 96px; padding: 12px 14px; line-height: 1.45; resize: vertical; }

.px-input[data-state="valid"]   { border-color: var(--f-ok) !important;   background-color: var(--f-ok-tint); }
.px-input[data-state="invalid"] { border-color: var(--f-err) !important;  background-color: var(--f-err-tint); }
.px-input[data-state="warning"] { border-color: var(--f-warn) !important; background-color: var(--f-warn-tint); }
.px-input[data-state="valid"]:focus   { box-shadow: 0 0 0 3px rgba(78, 195, 99, .18) !important; }
.px-input[data-state="invalid"]:focus { box-shadow: 0 0 0 3px rgba(227, 71, 63, .16) !important; }
.px-input[data-state="warning"]:focus { box-shadow: 0 0 0 3px rgba(245, 158, 11, .18) !important; }
.px-input[readonly] { background-color: var(--f-pill); cursor: default; }
.px-input:disabled { background-color: var(--f-pill); color: var(--f-placeholder); }

/* leading Lucide icon: <div class="px-input-wrap"><i class="lu lu-search"></i><input class="px-input"></div> */
.px-input-wrap { position: relative; display: block; width: 100%; }
.px-input-wrap > .lu { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 17px; color: var(--f-muted); pointer-events: none; }
.px-input-wrap > .px-input { padding-left: 40px; }

/* ---------------------------------------------------------------------------
 * 4. Choice cards (radio / checkbox):
 *    <label class="px-choice"><input type="radio" name="x"><span class="px-choice__mark"></span>
 *      <span class="px-choice__body"><strong>Title</strong><small>Hint</small></span></label>
 * ------------------------------------------------------------------------- */
.px-choice {
  position: relative; display: flex; align-items: flex-start; gap: 12px; margin: 0;
  padding: 13px 15px; cursor: pointer; user-select: none;
  background: var(--f-bg); border: 1.5px solid var(--f-line); border-radius: var(--f-radius);
  color: var(--f-ink); transition: border-color .14s, background-color .14s, box-shadow .14s;
}
.px-choice:hover { border-color: var(--f-line-hover); background: var(--f-bg-subtle); }
.px-choice > input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.px-choice__mark {
  flex: none; width: 19px; height: 19px; margin-top: 2px; box-sizing: border-box;
  border: 1.75px solid var(--f-line-hover); border-radius: 50%; background: var(--f-bg);
  display: inline-flex; align-items: center; justify-content: center; transition: all .14s;
}
.px-choice > input[type="checkbox"] + .px-choice__mark { border-radius: 6px; }
.px-choice > input:checked + .px-choice__mark { border-color: var(--f-ink); }
.px-choice > input[type="radio"]:checked + .px-choice__mark { border-width: 5.5px; }
.px-choice > input[type="checkbox"]:checked + .px-choice__mark { background: var(--f-bg); border-color: var(--f-accent); }
.px-choice > input[type="checkbox"]:checked + .px-choice__mark::after { content: "\e070"; font-family: "lucide"; font-size: 13px; line-height: 1; color: var(--f-accent); }
.px-choice:has(> input:checked) { border-color: var(--f-ink); background: var(--f-bg-subtle); box-shadow: 0 0 0 1px var(--f-ink); }
.px-choice > input:focus-visible + .px-choice__mark { outline: 2px solid var(--f-focus); outline-offset: 2px; }
.px-choice > input:disabled ~ * { opacity: .5; }
.px-choice__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--f-fs); }
.px-choice__body strong { font-weight: 600; }
.px-choice__body small { font-size: var(--f-fs-sm); color: var(--f-muted); }

/* ---------------------------------------------------------------------------
 * 5. Option pills (presets, timeframes): works on <label><input type=radio>… or <button aria-pressed>
 * ------------------------------------------------------------------------- */
.px-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.px-opt {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; height: 42px; padding: 0 14px; margin: 0; cursor: pointer;
  background: var(--f-bg); color: var(--f-ink); border: 1.5px solid var(--f-line); border-radius: 11px;
  font-family: inherit; font-weight: 600; font-size: var(--f-fs-sm); line-height: 1; transition: all .14s;
}
.px-opt > input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.px-opt:hover { border-color: var(--f-line-hover); background: var(--f-bg-subtle); }
.px-opt:has(> input:checked), .px-opt[aria-pressed="true"], .px-opt.is-selected {
  background: var(--f-ink); border-color: var(--f-ink); color: var(--f-on-ink);
}
.px-opt:has(> input:focus-visible) { outline: 2px solid var(--f-focus); outline-offset: 2px; }
.px-opt.px-opt--mono { font-family: var(--px-font-mono, ui-monospace, monospace); }

/* ---------------------------------------------------------------------------
 * 6. Segmented control: <div class="px-seg" role="group"><button class="is-active">…
 * ------------------------------------------------------------------------- */
.px-seg { display: inline-flex; align-items: center; gap: 2px; padding: 4px; background: var(--f-pill); border-radius: 9999px; }
.px-seg > :is(button, label) {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 14px; border: 0; border-radius: 9999px;
  background: transparent; color: var(--f-muted); font-family: inherit; font-weight: 500; font-size: var(--f-fs-sm); line-height: 1.2; cursor: pointer; transition: all .15s;
}
.px-seg > :is(button, label):hover { color: var(--f-ink); }
.px-seg > .is-active, .px-seg > [aria-pressed="true"], .px-seg > label:has(> input:checked) {
  background: var(--f-bg); color: var(--f-ink); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .14);
}
.px-seg > label > input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------------------
 * 7. Switch: <label class="px-switch"><input type="checkbox" role="switch"><span class="px-switch__track"></span></label>
 * ------------------------------------------------------------------------- */
.px-switch { position: relative; display: inline-flex; flex: none; margin: 0; cursor: pointer; }
.px-switch > input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.px-switch__track { width: 46px; height: 26px; padding: 3px; box-sizing: border-box; border-radius: 9999px; background: var(--f-line-soft); display: inline-flex; align-items: center; transition: background-color .18s; }
.px-switch__track::after { content: ""; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .22); transition: transform .18s cubic-bezier(.34, 1.56, .64, 1); }
.px-switch > input:checked + .px-switch__track { background: var(--f-accent); }
.px-switch > input:checked + .px-switch__track::after { transform: translateX(20px); }
.px-switch > input:focus-visible + .px-switch__track { outline: 2px solid var(--f-focus); outline-offset: 2px; }
.px-switch > input:disabled + .px-switch__track { opacity: .5; }

/* ---------------------------------------------------------------------------
 * 8. Alert / error banner: <div class="px-alert px-alert--error" role="alert"><i class="lu lu-circle-alert"></i><div>…
 * ------------------------------------------------------------------------- */
.px-alert { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border: 1.5px solid var(--f-line); border-radius: var(--f-radius); background: var(--f-bg-subtle); color: var(--f-ink); font-size: var(--f-fs); line-height: 1.45; }
.px-alert > .lu { flex: none; font-size: 18px; margin-top: 1px; }
.px-alert--error { border-color: var(--f-err); background: var(--f-err-tint); color: var(--f-err-text); }
.px-alert--warning { border-color: var(--f-warn); background: var(--f-warn-tint); color: var(--f-warn-text); }
.px-alert--success { border-color: var(--f-ok); background: var(--f-ok-tint); color: var(--f-ok-text); }

/* ---------------------------------------------------------------------------
 * 9. Searchable chip select (js/px-chipselect.js enhances <select multiple data-px-chips>)
 * ------------------------------------------------------------------------- */
.px-chipsel { position: relative; width: 100%; }
.px-chipsel__trigger {
  width: 100%; min-height: 44px; padding: 6px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--f-bg); color: var(--f-ink); border: 1.5px solid var(--f-line); border-radius: var(--f-radius);
  font-family: inherit; font-weight: 500; font-size: var(--f-fs); line-height: 1.3; text-align: left; cursor: pointer; transition: border-color .14s, box-shadow .14s;
}
.px-chipsel__trigger:hover { border-color: var(--f-line-hover); }
.px-chipsel[data-open="true"] .px-chipsel__trigger, .px-chipsel__trigger:focus-visible { border-color: var(--f-focus); box-shadow: 0 0 0 3px var(--f-ring); outline: 0; }
.px-chipsel__list { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.px-chipsel__ph { color: var(--f-placeholder); font-weight: 400; }
.px-chipsel__chev { flex: none; font-size: 17px; color: var(--f-muted); transition: transform .18s; }
.px-chipsel[data-open="true"] .px-chipsel__chev { transform: rotate(180deg); color: var(--f-ink); }
.px-chip-tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 9999px;
  background: var(--f-pill); border: 1px solid var(--f-line-soft); color: var(--f-ink);
  font: 600 var(--f-fs-sm)/1.2 var(--px-font-mono, ui-monospace, monospace);
}
.px-chip-tag button { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--f-muted); cursor: pointer; font-size: 12px; }
.px-chip-tag button:hover { background: var(--f-line-soft); color: var(--f-ink); }
.px-chipsel__count { flex: none; padding: 3px 8px; border-radius: 9999px; background: var(--f-pill); color: var(--f-muted); font-family: inherit; font-weight: 600; font-size: var(--f-fs-sm); line-height: 1; }

.px-chipsel__panel {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; display: none; flex-direction: column; overflow: hidden;
  background: var(--f-bg); border: 1.5px solid var(--f-line-soft); border-radius: 14px;
  box-shadow: 0 14px 32px -6px rgba(15, 23, 42, .14), 0 4px 12px -3px rgba(15, 23, 42, .06);
}
.px-chipsel[data-open="true"] .px-chipsel__panel { display: flex; }
.px-chipsel__search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--f-line-soft); color: var(--f-muted); }
.px-chipsel__search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--f-ink); caret-color: var(--f-caret); font-family: inherit; font-weight: 400; font-size: var(--f-fs); line-height: 1.3; }
.px-chipsel__tabs { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; border-bottom: 1px solid var(--f-line-soft); background: var(--f-bg-subtle); scrollbar-width: none; }
.px-chipsel__tabs::-webkit-scrollbar { display: none; }
.px-chipsel__tabs button { flex: none; padding: 4px 11px; border: 0; border-radius: 9999px; background: var(--f-pill); color: var(--f-muted); font-family: inherit; font-weight: 600; font-size: var(--f-fs-sm); line-height: 1.2; cursor: pointer; white-space: nowrap; }
.px-chipsel__tabs button.is-active { background: var(--f-ink); color: var(--f-on-ink); }
.px-chipsel__opts { max-height: 230px; overflow-y: auto; padding: 6px; }
.px-chipsel__grp { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--f-muted); }
.px-chipsel__opt { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--f-ink); font-family: inherit; font-weight: 500; font-size: var(--f-fs); line-height: 1.3; text-align: left; cursor: pointer; }
.px-chipsel__opt:hover, .px-chipsel__opt:focus-visible { background: var(--f-pill); outline: 0; }
.px-chipsel__opt.is-selected { background: var(--f-pill); font-weight: 600; }
.px-chipsel__opt .lu { font-size: 15px; visibility: hidden; color: var(--f-accent); }
.px-chipsel__opt.is-selected .lu { visibility: visible; }
.px-chipsel__empty { padding: 16px; text-align: center; font-size: var(--f-fs-sm); color: var(--f-muted); }
.px-chipsel__foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-top: 1px solid var(--f-line-soft); background: var(--f-bg-subtle); font-size: var(--f-fs-sm); color: var(--f-muted); }
.px-chipsel__foot button { border: 0; background: transparent; color: var(--f-ink-2); font-family: inherit; font-weight: 600; font-size: var(--f-fs-sm); line-height: 1; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.px-chipsel__foot button:hover { background: var(--f-pill); }

/* Long dropdowns (e.g. 88 markets): filter box pinned to the top of the menu. */
.px-select-menu > button[hidden] { display: none !important; }
.px-select-menu__search { position: sticky; top: 0; z-index: 1; display: block; box-sizing: border-box; width: calc(100% - 16px); margin: 8px; padding: 10px 12px; font: inherit; font-size: 16px; border: 1.5px solid #dfe7ee; border-radius: 12px; background: #fff; color: inherit; }
