/* Ur Abode form-control library (docs/DESIGN_SYSTEM.md, "Form controls"): no control uses the browser's own look.
   Layer 1 (this file, no JavaScript needed): every native control is restyled with appearance: none and the design tokens.
   Layer 2 (static/js/controls.js): dropdown panels, calendars, chips, steppers, drop zones, tooltips and inline validation are built on top;
   the native element stays in the DOM, visually hidden, as the single source of truth, so forms submit and reset exactly as before.
   Only transform and opacity animate. Control borders meet 3:1 (--ctl-line); text meets AA. */

:root { --ctl-line: #85857B; --ctl-line-hover: #5A5A52; color-scheme: light; }
[data-bs-theme="dark"] { --ctl-line: #6F756A; --ctl-line-hover: #9BA194; color-scheme: dark; }
@media (pointer: coarse) { :root { --control-h: 2.75rem; --control-h-sm: 2.75rem; } }  /* touch targets of at least 44 px */

/* ---------- Page-wide details ---------- */
a, button, label, input, select, textarea, summary, [role="button"] { -webkit-tap-highlight-color: transparent; }
input, textarea, select, button { font-family: inherit; }
input, textarea { caret-color: var(--action); }
::placeholder { color: var(--text-3); opacity: 1; }
dialog::backdrop { background: var(--scrim); }
.table-responsive, .ua-table-wrap { position: relative; }  /* a visually-hidden label inside a scrolling table must not stretch the page */
.ua-native { position: absolute !important; width: 1px !important; height: 1px !important; min-width: 0 !important; max-width: 1px !important; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); opacity: 0; pointer-events: none; white-space: nowrap; }

/* ---------- Scrollbars (thin, rounded, in theme colours; Firefox through scrollbar-*, Chromium and Safari through ::-webkit-scrollbar) ---------- */
html { scrollbar-gutter: stable; }
* { scrollbar-width: thin; scrollbar-color: var(--ctl-line) transparent; }
*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--ctl-line); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; min-height: 2.5rem; min-width: 2.5rem; }
*::-webkit-scrollbar-thumb:hover { background: var(--ctl-line-hover); background-clip: content-box; }
*::-webkit-scrollbar-thumb:active { background: var(--action); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }
.ua-scroll-hidden { scrollbar-width: none; }  /* only for horizontal carousels; they stay scrollable by touch and keyboard */
.ua-scroll-hidden::-webkit-scrollbar { display: none; }
.ua-sidebar, .ua-pop, .modal-body, .ua-table-wrap, pre, textarea, .ua-palette-list { overscroll-behavior: contain; }
.ua-sidebar { scrollbar-width: thin; }

/* ---------- Text inputs, textareas, numbers, search, password, file, autofill ---------- */
.form-control, .form-select { border-color: var(--ctl-line); }
/* base.css's `background:` shorthand on :disabled resets the arrow's repeat and size, which drew a row of arrows */
.form-select, .form-select:disabled { background-repeat: no-repeat; background-position: right .75rem center; background-size: 1rem; }
.form-select:disabled { background-color: var(--surface-2); }
.form-control:hover:not(:focus):not(:disabled), .form-select:hover:not(:focus):not(:disabled) { border-color: var(--ctl-line-hover); }
.form-control:read-only:not(select):not([type="file"]) { background: var(--surface-2); }
.form-control:disabled, .form-select:disabled, .form-control[readonly] { cursor: not-allowed; opacity: 1; }
.form-control.is-valid, .form-select.is-valid { border-color: var(--success); }
textarea { resize: none; }
textarea.form-control { min-height: 6rem; line-height: 1.5; scrollbar-gutter: auto; }
textarea.form-control[data-ua-autogrow] { overflow-y: hidden; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; display: none; }
input::-ms-reveal, input::-ms-clear { display: none; }
input::-webkit-credentials-auto-fill-button, input::-webkit-contacts-auto-fill-button { visibility: hidden; display: none !important; pointer-events: none; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, textarea:-webkit-autofill, select:-webkit-autofill {
  -webkit-text-fill-color: var(--text); caret-color: var(--text); -webkit-box-shadow: 0 0 0 1000px var(--surface) inset; transition: background-color 9999s ease-in-out 0s; }
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"], input[type="week"] { -webkit-appearance: none; appearance: none; min-width: 0; }
input[type="date"]::-webkit-calendar-picker-indicator, input[type="time"]::-webkit-calendar-picker-indicator, input[type="datetime-local"]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
input[type="file"]::file-selector-button { margin-right: var(--s-3); padding: .3rem .8rem; border: 1px solid var(--ctl-line); border-radius: var(--r-1); background: var(--surface-2); color: var(--text); font: inherit; font-size: var(--fs-14); cursor: pointer; }
input[type="file"].form-control { height: auto; padding: var(--s-2) var(--s-3); line-height: 1.8; }

.ua-input-wrap { position: relative; display: block; width: 100%; }
.ua-input-wrap > .form-control { padding-right: 2.5rem; }
.ua-input-btn { position: absolute; top: 50%; right: .35rem; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: var(--r-1); background: transparent; color: var(--text-3); cursor: pointer; }
.ua-input-btn:hover { color: var(--text); background: var(--surface-2); }
.ua-input-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ua-input-btn[hidden] { display: none; }
.ua-input-btn .ua-i { width: 1.05rem; height: 1.05rem; }
@media (pointer: coarse) { .ua-input-btn { width: 2.75rem; height: 2.75rem; right: 0; } }
.ua-counter { display: block; margin-top: var(--s-1); font-size: var(--fs-12); color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.ua-counter.is-near { color: var(--warning); }
.ua-counter.is-over { color: var(--danger); }

/* ---------- Checkboxes, radios, switches (custom drawn; they work without JavaScript) ---------- */
.form-check { display: flex; align-items: flex-start; gap: var(--s-3); padding-left: 0; min-height: 1.5rem; }
.form-check .form-check-input { float: none; margin: .125rem 0 0; flex: none; }
.form-check-label { cursor: pointer; padding-block: .0625rem; color: var(--text); }
@media (pointer: coarse) { .form-check { min-height: 2.75rem; align-items: center; } .form-check .form-check-input { margin-top: 0; } }
.form-check-input { -webkit-appearance: none; appearance: none; width: 1.25rem; height: 1.25rem; border: 1.5px solid var(--ctl-line); background-color: var(--surface); background-repeat: no-repeat; background-position: center; background-size: 0.875rem; box-shadow: none; cursor: pointer; vertical-align: middle; }
.form-check-input[type="checkbox"] { border-radius: 5px; }
.form-check-input[type="radio"] { border-radius: 50%; }
.form-check-input:hover:not(:disabled) { border-color: var(--ctl-line-hover); }
.form-check-input:checked, .form-check-input[type="checkbox"]:indeterminate { background-color: var(--action); border-color: var(--action); }  /* an unchecked radio group is :indeterminate too, so it is not matched here */
.form-check-input[type="checkbox"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E"); }
.form-check-input[type="checkbox"]:indeterminate { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' d='M4 8h8'/%3E%3C/svg%3E"); }
.form-check-input[type="radio"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='3' fill='%23fff'/%3E%3C/svg%3E"); background-size: 1rem; }
[data-bs-theme="dark"] .form-check-input[type="checkbox"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2314200F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E"); }
[data-bs-theme="dark"] .form-check-input[type="checkbox"]:indeterminate { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2314200F' stroke-width='2' stroke-linecap='round' d='M4 8h8'/%3E%3C/svg%3E"); }
[data-bs-theme="dark"] .form-check-input[type="radio"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='3' fill='%2314200F'/%3E%3C/svg%3E"); }
.form-check-input:focus { box-shadow: none; }
.form-check-input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.form-check-input:disabled { background-color: var(--surface-3); border-color: var(--line-strong); cursor: not-allowed; opacity: .7; }
.form-check-input:disabled ~ .form-check-label { color: var(--text-3); cursor: not-allowed; }
.form-check-input.is-invalid { border-color: var(--danger); }
.form-check-input.is-invalid ~ .form-check-label { color: var(--danger); }
.form-switch { padding-left: 0; }
.form-switch .form-check-input { width: 2.5rem; height: 1.5rem; border-radius: 999px; border-width: 1.5px; background-color: var(--surface-3); background-position: .2rem center; background-size: 1.05rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%2385857B'/%3E%3C/svg%3E"); transition: background-position var(--dur-2, .16s) var(--ease-out, ease), background-color var(--dur-2, .16s); }
[data-bs-theme="dark"] .form-switch .form-check-input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%239BA194'/%3E%3C/svg%3E"); }
.form-switch .form-check-input:checked { background-position: calc(100% - .2rem) center; background-color: var(--action); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%23fff'/%3E%3C/svg%3E"); background-size: 1.05rem; }
[data-bs-theme="dark"] .form-switch .form-check-input:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%2314200F'/%3E%3C/svg%3E"); }

/* Choice lists, radio cards and segmented controls (Django's RadioSelect / CheckboxSelectMultiple render these through the widget templates) */
.ua-choices { display: flex; flex-direction: column; gap: var(--s-1); }
.ua-choices--inline { flex-direction: row; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.ua-choice { display: flex; align-items: flex-start; gap: var(--s-3); margin: 0; min-height: 1.75rem; cursor: pointer; color: var(--text); font-size: var(--fs-15); }
@media (pointer: coarse) { .ua-choice { min-height: 2.75rem; align-items: center; } }
.ua-choice > .form-check-input { margin-top: .2rem; }
.ua-choice > input:disabled ~ span { color: var(--text-3); cursor: not-allowed; }
.ua-choices--cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: var(--s-3); }
.ua-choices--cards .ua-choice { position: relative; display: block; padding: 0; min-height: 0; }
.ua-choices--cards .ua-choice > input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.ua-choices--cards .ua-choice > span { display: flex; flex-direction: column; gap: .15rem; height: 100%; padding: var(--s-4); border: 1.5px solid var(--ctl-line); border-radius: var(--r-2); background: var(--surface); transition: border-color var(--dur-2, .14s), box-shadow var(--dur-2, .14s); }
.ua-choices--cards .ua-choice:hover > span { border-color: var(--ctl-line-hover); }
.ua-choices--cards .ua-choice > input:checked + span { border-color: var(--action); box-shadow: 0 0 0 1px var(--action) inset; background: var(--action-soft); }
.ua-choices--cards .ua-choice > input:focus-visible + span { box-shadow: var(--focus-ring); }
.ua-choices--cards .ua-choice > input:disabled + span { opacity: .55; cursor: not-allowed; }
.ua-choices--cards .ua-choice > span > small { color: var(--text-2); font-size: var(--fs-13); }
.ua-choices--segmented { max-width: 100%; display: inline-flex; flex-direction: row; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--r-2); }
.ua-choices--segmented .ua-choice { position: relative; display: block; flex: 1 1 auto; min-height: 0; }
.ua-choices--segmented .ua-choice > input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.ua-choices--segmented .ua-choice > span { white-space: nowrap; justify-content: center; width: 100%; display: inline-flex; align-items: center; height: 2rem; padding: 0 var(--s-4); border-radius: calc(var(--r-2) - 3px); color: var(--text-2); font-size: var(--fs-14); font-weight: 500; }
@media (pointer: coarse) { .ua-choices--segmented .ua-choice > span { height: 2.5rem; } }
.ua-choices--segmented .ua-choice > input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--sh-sm); }
.ua-choices--segmented .ua-choice > input:focus-visible + span { box-shadow: var(--focus-ring); }
.btn-check + .ua-seg, .btn-check + .btn { cursor: pointer; }

/* ---------- Range sliders ---------- */
.form-range, input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 1.75rem; padding: 0; background: transparent; cursor: pointer; --ua-fill: 0%; }
@media (pointer: coarse) { .form-range, input[type="range"] { height: 2.75rem; } }
input[type="range"]:focus { outline: none; }
input[type="range"]::-webkit-slider-runnable-track { height: .375rem; border-radius: 999px; background: linear-gradient(to right, var(--action) var(--ua-fill), var(--surface-3) var(--ua-fill)); border: 1px solid var(--line-strong); }
input[type="range"]::-moz-range-track { height: .375rem; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong); }
input[type="range"]::-moz-range-progress { height: .375rem; border-radius: 999px; background: var(--action); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 1.375rem; height: 1.375rem; margin-top: calc(-.6875rem + .1875rem); border-radius: 50%; background: var(--surface); border: 2px solid var(--action); box-shadow: var(--sh-sm); transition: transform var(--dur-2, .14s); }
input[type="range"]::-moz-range-thumb { width: 1.125rem; height: 1.125rem; border-radius: 50%; background: var(--surface); border: 2px solid var(--action); box-shadow: var(--sh-sm); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: var(--focus-ring); }
input[type="range"]:disabled { opacity: .5; cursor: not-allowed; }
.ua-range-row { display: flex; align-items: center; gap: var(--s-3); }
.ua-range-out { min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); font-size: var(--fs-14); }

/* ---------- Native <progress> and <meter> ---------- */
progress, meter { -webkit-appearance: none; appearance: none; width: 100%; height: .5rem; border: 0; border-radius: 999px; background: var(--surface-3); overflow: hidden; vertical-align: middle; }
progress::-webkit-progress-bar, meter::-webkit-meter-bar { background: var(--surface-3); border-radius: 999px; border: 0; height: .5rem; }
progress::-webkit-progress-value { background: var(--action); border-radius: 999px; transition: width var(--dur-3, .2s) var(--ease-out, ease); }
progress::-moz-progress-bar { background: var(--action); border-radius: 999px; }
meter::-webkit-meter-optimum-value { background: var(--success); border-radius: 999px; }
meter::-webkit-meter-suboptimum-value { background: var(--warning); border-radius: 999px; }
meter::-webkit-meter-even-less-good-value { background: var(--danger); border-radius: 999px; }
meter::-moz-meter-bar { background: var(--action); border-radius: 999px; }
progress:indeterminate { background: linear-gradient(90deg, var(--surface-3) 0 30%, var(--action) 30% 60%, var(--surface-3) 60%) 0 0 / 200% 100%; animation: ua-indeterminate 1.2s linear infinite; }
progress:indeterminate::-webkit-progress-value { background: transparent; }
@keyframes ua-indeterminate { to { background-position: -200% 0; } }

/* ---------- <details> and <summary> ---------- */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker, details > summary::marker { display: none; content: ""; }
details:not([class*="pa-"]) > summary:not(.btn)::after { content: ""; display: inline-block; width: .9rem; height: .9rem; margin-left: .45rem; vertical-align: -.15rem; background: currentColor; opacity: .6; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' d='m4 6 4 4 4-4'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' d='m4 6 4 4 4-4'/%3E%3C/svg%3E") center / contain no-repeat; transition: transform var(--dur-2, .16s); }
details[open]:not([class*="pa-"]) > summary:not(.btn)::after { transform: rotate(180deg); }
details > summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-1); }

/* ---------- Field messages (inline validation, replacing the browser's popups) ---------- */
.ua-field-error, .invalid-feedback { display: flex; align-items: flex-start; gap: var(--s-2); margin-top: var(--s-1); color: var(--danger); font-size: var(--fs-13); font-weight: 500; line-height: 1.4; }
.ua-field-error[hidden] { display: none; }
.ua-field-error .ua-i { flex: none; width: 1rem; height: 1rem; margin-top: .1rem; }
.ua-field-ok { color: var(--success); font-size: var(--fs-13); margin-top: var(--s-1); }
.ua-summary-error { padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4); border: 1px solid var(--danger-line); border-radius: var(--r-2); background: var(--danger-bg); color: var(--danger); font-size: var(--fs-14); }

/* ---------- Custom tooltip (replaces native title tooltips) ---------- */
.ua-tooltip { position: fixed; z-index: 2000; max-width: min(20rem, 80vw); padding: .35rem .6rem; border-radius: var(--r-1); background: var(--text); color: var(--bg); font-size: var(--fs-12); line-height: 1.4; box-shadow: var(--sh-md); pointer-events: none; opacity: 0; transform: translateY(2px); transition: opacity .12s, transform .12s; }
.ua-tooltip.is-on { opacity: 1; transform: none; }

/* ---------- Popover panels (dropdown lists, calendar, time) and the phone bottom sheet ---------- */
.ua-pop { position: fixed; z-index: 1085; display: flex; flex-direction: column; min-width: 8rem; max-height: 20rem; background: var(--surface); color: var(--text); border-radius: var(--r-2); box-shadow: var(--sh-lg); opacity: 0; transform: translateY(-4px); transition: opacity .12s ease, transform .12s ease; }
.ua-pop.is-above { transform: translateY(4px); }
.ua-pop.is-open { opacity: 1; transform: none; }
.ua-pop-backdrop { position: fixed; inset: 0; z-index: 1084; background: var(--scrim); opacity: 0; transition: opacity .16s; }
.ua-pop-backdrop.is-open { opacity: 1; }
.ua-pop-handle { display: none; flex: none; width: 2.5rem; height: .3rem; margin: .6rem auto .2rem; border-radius: 999px; background: var(--line-strong); }
@media (max-width: 575.98px) {
  .ua-pop.is-sheet { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100% !important; max-width: none; max-height: min(70vh, 32rem) !important; border-radius: var(--r-3) var(--r-3) 0 0; transform: translateY(100%); transition: transform .2s ease, opacity .12s ease; padding-bottom: env(safe-area-inset-bottom); }
  .ua-pop.is-sheet.is-open { transform: none; }
  .ua-pop.is-sheet .ua-pop-handle { display: block; }
}
.ua-pop-search { position: relative; flex: none; padding: var(--s-2); }
.ua-pop-search .form-control { height: 2.25rem; padding-left: 2.1rem; }
.ua-pop-search .ua-i { position: absolute; left: 1.3rem; top: 50%; transform: translateY(-50%); width: 1rem; height: 1rem; color: var(--text-3); pointer-events: none; }
@media (pointer: coarse) { .ua-pop-search .form-control { height: 2.75rem; } }
.ua-optlist { flex: 1 1 auto; min-height: 0; margin: 0; padding: var(--s-1); overflow-y: auto; list-style: none; outline: none; }
.ua-opt { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 2.25rem; padding: .35rem var(--s-3); border-radius: var(--r-1); color: var(--text); font-size: var(--fs-15); cursor: pointer; user-select: none; }
@media (pointer: coarse) { .ua-opt { min-height: 2.75rem; } }
.ua-opt.is-active { background: var(--surface-2); }
.ua-opt[aria-selected="true"] { font-weight: 600; color: var(--action); }
.ua-opt[aria-selected="true"]::after { content: ""; flex: none; width: 1rem; height: 1rem; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E") center / contain no-repeat; }
.ua-opt[aria-disabled="true"] { color: var(--text-3); cursor: not-allowed; }
.ua-opt-group { padding: var(--s-2) var(--s-3) var(--s-1); font-size: var(--fs-12); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.ua-opt-empty { padding: var(--s-4) var(--s-3); text-align: center; color: var(--text-3); font-size: var(--fs-14); }

/* ---------- The dropdown (custom <select>) ---------- */
.ua-select { position: relative; display: block; width: 100%; min-width: 0; }
.input-group > .ua-select { flex: 1 1 auto; width: 1%; }
.ua-select-btn { display: flex; align-items: center; gap: var(--s-2); width: 100%; text-align: left; cursor: pointer; padding-right: 2.5rem; }
.ua-select-btn.form-select { padding-right: 2.5rem; }
.ua-select-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ua-select-btn.is-placeholder .ua-select-value { color: var(--text-3); }
.ua-select-btn[aria-expanded="true"] { border-color: var(--action); box-shadow: 0 0 0 3px color-mix(in srgb, var(--action) 22%, transparent); }
.ua-select-btn:disabled { cursor: not-allowed; }
.ua-select.is-invalid .ua-select-btn { border-color: var(--danger); }
.ua-select-clear { position: absolute; top: 50%; right: 2.1rem; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); cursor: pointer; }
.ua-select-clear:hover { color: var(--text); background: var(--surface-2); }
.ua-select-clear:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ua-select-clear .ua-i { width: .9rem; height: .9rem; }
.ua-select.is-loading .ua-select-btn { cursor: progress; }
.ua-select.is-loading .ua-select-btn::after, .ua-spinner::after { content: ""; position: absolute; right: .85rem; top: calc(50% - .5rem); width: 1rem; height: 1rem; border: 2px solid var(--line-strong); border-top-color: var(--action); border-radius: 50%; animation: ua-spin .7s linear infinite; }
@keyframes ua-spin { to { transform: rotate(360deg); } }
/* Multi-select: the chosen options are chips inside the control */
.ua-select--multi .ua-select-btn { height: auto; min-height: var(--control-h); padding-block: .3rem; align-items: center; }
.ua-chips { display: flex; flex-wrap: wrap; gap: .3rem; flex: 1 1 auto; min-width: 0; }
.ua-chip-tag { display: inline-flex; align-items: center; gap: .25rem; max-width: 100%; padding: .1rem .2rem .1rem .6rem; border-radius: 999px; background: var(--action-soft); color: var(--action); font-size: var(--fs-13); font-weight: 500; }
.ua-chip-tag > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ua-chip-x { display: inline-flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.ua-chip-x:hover { background: color-mix(in srgb, var(--action) 16%, transparent); }
.ua-chip-x:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ua-chip-x .ua-i { width: .8rem; height: .8rem; }
.ua-opt-check { flex: none; width: 1.125rem; height: 1.125rem; border: 1.5px solid var(--ctl-line); border-radius: 4px; }
.ua-pop[data-multi] .ua-opt[aria-selected="true"]::after { display: none; }
.ua-pop[data-multi] .ua-opt[aria-selected="true"] .ua-opt-check { background: var(--action) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E") center / .8rem no-repeat; border-color: var(--action); }
[data-bs-theme="dark"] .ua-pop[data-multi] .ua-opt[aria-selected="true"] .ua-opt-check { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2314200F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E"); }
.ua-opt-lead { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.ua-pop-foot { flex: none; display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-2); }

/* ---------- Number steppers ---------- */
.ua-stepper { display: flex; align-items: stretch; width: 100%; }
.ua-stepper > .form-control { flex: 1 1 auto; min-width: 0; text-align: center; border-radius: 0; font-variant-numeric: tabular-nums; }
.ua-step { flex: none; display: inline-flex; align-items: center; justify-content: center; width: var(--control-h); height: var(--control-h); padding: 0; border: 1px solid var(--ctl-line); background: var(--surface-2); color: var(--text); cursor: pointer; }
.ua-step:first-child { border-radius: var(--r-1) 0 0 var(--r-1); border-right: 0; }
.ua-step:last-child { border-radius: 0 var(--r-1) var(--r-1) 0; border-left: 0; }
.ua-step:hover:not(:disabled) { background: var(--surface-3); }
.ua-step:focus-visible { outline: none; box-shadow: var(--focus-ring); position: relative; z-index: 1; }
.ua-step:disabled { color: var(--text-3); cursor: not-allowed; }
.ua-step .ua-i { width: 1rem; height: 1rem; }

/* ---------- Date and time pickers ---------- */
.ua-date { position: relative; display: block; width: 100%; }
.ua-date > .form-control { padding-right: 2.75rem; }
.ua-cal { width: 19rem; max-width: 100%; padding: var(--s-3); }
.ua-cal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-2); }
.ua-cal-title { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; height: 2.25rem; padding: 0 var(--s-3); border: 0; border-radius: var(--r-1); background: transparent; color: var(--text); font-weight: 600; font-size: var(--fs-15); cursor: pointer; }
.ua-cal-title:hover { background: var(--surface-2); }
.ua-cal-nav { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 0; border-radius: var(--r-1); background: transparent; color: var(--text-2); cursor: pointer; }
.ua-cal-nav:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.ua-cal-nav:disabled { opacity: .35; cursor: not-allowed; }
.ua-cal button:focus-visible, .ua-cal-title:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ua-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.ua-cal-dow { padding: .3rem 0; font-size: var(--fs-12); font-weight: 600; color: var(--text-3); }
.ua-cal-day, .ua-cal-cell { display: inline-flex; align-items: center; justify-content: center; aspect-ratio: 1; min-height: 2.25rem; padding: 0; border: 1px solid transparent; border-radius: var(--r-1); background: transparent; color: var(--text); font-size: var(--fs-14); font-variant-numeric: tabular-nums; cursor: pointer; }
@media (pointer: coarse) { .ua-cal-day, .ua-cal-cell { min-height: 2.75rem; } }
.ua-cal-day:hover:not(:disabled), .ua-cal-cell:hover:not(:disabled) { background: var(--surface-2); }
.ua-cal-day.is-out { color: var(--text-3); }
.ua-cal-day.is-today { border-color: var(--ctl-line); font-weight: 700; }
.ua-cal-day[aria-selected="true"], .ua-cal-cell[aria-selected="true"] { background: var(--action); color: var(--action-fg); border-color: var(--action); font-weight: 700; }
.ua-cal-day:disabled, .ua-cal-cell:disabled { color: var(--text-3); opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.ua-cal-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; max-height: 14rem; overflow-y: auto; }
.ua-cal-months .ua-cal-cell { aspect-ratio: auto; min-height: 2.5rem; }
.ua-cal-foot { display: flex; justify-content: space-between; gap: var(--s-2); margin-top: var(--s-2); padding-top: var(--s-2); }
.ua-cal-foot .btn { height: 2rem; padding-inline: var(--s-3); font-size: var(--fs-13); }
.ua-time { display: flex; gap: var(--s-2); padding: var(--s-2) 0 0; }
.ua-time-col { flex: 1 1 0; display: flex; flex-direction: column; gap: 2px; max-height: 10rem; overflow-y: auto; padding: 2px; border-radius: var(--r-1); }
.ua-time-col .ua-cal-cell { aspect-ratio: auto; min-height: 2rem; }
@media (pointer: coarse) { .ua-time-col .ua-cal-cell { min-height: 2.75rem; } }
.ua-time-pop { width: 14rem; padding: var(--s-3); }
.ua-time-label { margin: 0 0 var(--s-1); font-size: var(--fs-12); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }

/* ---------- File drop zone ---------- */
.ua-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-6) var(--s-4); border: 1.5px dashed var(--ctl-line); border-radius: var(--r-2); background: var(--surface); color: var(--text-2); text-align: center; cursor: pointer; transition: border-color var(--dur-2, .14s), background-color var(--dur-2, .14s); }
.ua-drop:hover, .ua-drop.is-over { border-color: var(--action); background: var(--action-soft); }
.ua-drop:focus-within { box-shadow: var(--focus-ring); }
.ua-drop .ua-i { width: 1.6rem; height: 1.6rem; color: var(--text-3); }
.ua-drop-title { color: var(--text); font-weight: 600; font-size: var(--fs-15); }
.ua-drop-hint { font-size: var(--fs-13); color: var(--text-3); }
.ua-drop.is-disabled { opacity: .55; cursor: not-allowed; }
.ua-drop.is-invalid { border-color: var(--danger); }
.ua-files { margin: var(--s-3) 0 0; padding: 0; list-style: none; display: grid; gap: var(--s-2); }
.ua-files li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r-1); background: var(--surface); font-size: var(--fs-14); }
.ua-files .ua-file-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ua-files .ua-file-size { flex: none; color: var(--text-3); font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
.ua-file-x { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); cursor: pointer; }
.ua-file-x:hover { color: var(--danger); background: var(--danger-bg); }
.ua-file-x:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ua-drop-progress { width: 100%; max-width: 16rem; }

/* ---------- Datalist suggestions use the same panel as the dropdown ---------- */
input[list]::-webkit-calendar-picker-indicator { display: none !important; }

/* ---------- Motion, forced colours, no-JavaScript ---------- */
@media (prefers-reduced-motion: reduce) {
  .ua-pop, .ua-pop-backdrop, .ua-tooltip, .ua-drop, .form-switch .form-check-input, .ua-choices--cards .ua-choice > span, progress:indeterminate { transition: none; animation: none; }
  .ua-select.is-loading .ua-select-btn::after { animation-duration: 1.6s; }
}
@media (forced-colors: active) {
  .form-check-input, input[type="range"], progress, meter { -webkit-appearance: auto; appearance: auto; forced-color-adjust: auto; }
  .form-control, .form-select, .ua-select-btn, .ua-pop, .ua-drop, .ua-step, .ua-cal-day, .ua-choices--cards .ua-choice > span { border: 1px solid CanvasText; }
  .ua-opt.is-active, .ua-cal-day:focus-visible { outline: 2px solid Highlight; }
  .ua-opt[aria-selected="true"], .ua-cal-day[aria-selected="true"], .ua-choices--segmented .ua-choice > input:checked + span, .ua-choices--cards .ua-choice > input:checked + span { outline: 2px solid Highlight; background: Canvas; color: CanvasText; forced-color-adjust: none; }
  .ua-opt[aria-selected="true"]::after { background: Highlight; }
  .ua-native { clip: auto; }
}
html:not(.ua-js) .ua-choices--segmented .ua-choice > input:checked + span { background: var(--surface); }
