/* Valquia components: shadcn/ui anatomy and states, server-rendered. Contract: docs/ui.md.
   Tokens come from app.css. Focus ring: 3px of --ring at 50% (sliders 4px). */

:root { --ring-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent); }

/* ================================================================== Button */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex-shrink: 0;
  height: 36px; padding: 0 16px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs);
  font-family: var(--sans); font-size: var(--text-base); font-weight: 600; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s, opacity .15s; }
.btn:hover { background: var(--muted); text-decoration: none; }
.btn:active { background: color-mix(in srgb, var(--muted) 80%, var(--foreground) 6%); }
.btn:focus-visible { outline: none; border-color: var(--ring); box-shadow: var(--ring-shadow); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; cursor: default; }
.btn svg { width: 16px; height: 16px; flex: none; pointer-events: none; }
.btn .kbd { font-weight: 600; }

.btn[data-variant="default"], .btn.primary { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.btn[data-variant="default"]:hover, .btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--background)); }
.btn[data-variant="default"]:active, .btn.primary:active { background: color-mix(in srgb, var(--primary) 80%, var(--background)); }
.btn[data-variant="secondary"] { background: var(--secondary); color: var(--secondary-foreground); border-color: transparent; box-shadow: none; }
.btn[data-variant="secondary"]:hover { background: color-mix(in srgb, var(--secondary) 80%, var(--foreground) 8%); }
.btn[data-variant="outline"]:hover { background: var(--muted); }
.btn[data-variant="ghost"] { background: transparent; border-color: transparent; box-shadow: none; }
.btn[data-variant="ghost"]:hover { background: var(--muted); }
.btn[data-variant="link"] { background: none; border-color: transparent; box-shadow: none; height: auto; padding: 0; font-weight: 600;
  text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 4px; }
.btn[data-variant="link"]:hover { text-decoration-color: currentColor; background: none; }
.btn[data-variant="destructive"] { background: var(--destructive); color: var(--destructive-foreground); border-color: transparent; }
.btn[data-variant="destructive"]:hover { background: color-mix(in srgb, var(--destructive) 88%, var(--background)); }
.btn[data-variant="destructive"]:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 45%, transparent); border-color: var(--destructive); }
.btn[data-variant="ghost"]:focus-visible, .btn[data-variant="link"]:focus-visible { border-color: transparent; }

.btn[data-size="sm"], .btn.small { height: 32px; padding: 0 12px; gap: 6px; font-size: var(--text-sm); }
.btn[data-size="lg"] { height: 40px; padding: 0 24px; font-size: var(--text-base); }
.btn[data-size="icon"] { width: 36px; padding: 0; }
.btn[data-size="icon-sm"] { width: 32px; height: 32px; padding: 0; }
.btn[data-variant="link"][data-size] { height: auto; padding: 0; width: auto; }
.btn[data-loading] svg.spin { animation: ui-spin 1s linear infinite; }

/* ================================================================== Badge */
.badge { display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: fit-content; flex-shrink: 0;
  padding: 3px 8px; border-radius: var(--radius-md); border: 1px solid transparent; overflow: hidden; vertical-align: middle;
  font-family: var(--sans); font-size: var(--text-xs); font-weight: 600; line-height: 1.2; white-space: nowrap;
  background: var(--primary); color: var(--primary-foreground); text-decoration: none; transition: background-color .15s, color .15s; }
.badge svg { width: 12px; height: 12px; flex: none; pointer-events: none; }
.badge[data-variant="secondary"] { background: var(--secondary); color: var(--secondary-foreground); }
.badge[data-variant="outline"] { background: transparent; color: var(--foreground); border-color: var(--border); }
.badge[data-variant="destructive"] { background: var(--destructive); color: var(--destructive-foreground); }
.badge[data-variant="success"] { background: var(--success); color: var(--success-foreground); }
.badge[data-variant="warning"] { background: var(--warning); color: var(--warning-foreground); }
a.badge:hover { filter: brightness(1.08); }
a.badge[data-variant="outline"]:hover { background: var(--muted); filter: none; }
.badge:focus-visible { outline: none; box-shadow: var(--ring-shadow); }
.badge .glyph { width: 9px; height: 9px; border-width: 1.5px; }
.badge.s-FIRED { color: var(--destructive); } .badge.s-PARTIAL { color: var(--warning); } .badge.s-NOT-FIRED { color: var(--success); }
.badge.s-UNRESOLVED { color: var(--muted-foreground); } .badge.s-PENDING { color: var(--muted-foreground); }
.badge.rating { letter-spacing: .02em; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

/* ================================================================== Card */
.card { display: flex; flex-direction: column; gap: var(--space-6); padding: var(--space-6) 0; min-width: 0;
  background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.card-header { display: grid; gap: 6px; padding: 0 var(--space-6); align-items: start; }
.card-header:has(.card-action) { grid-template-columns: 1fr auto; }
.card-action { grid-column: 2; grid-row: 1 / span 2; justify-self: end; }
.card-title { font-family: var(--sans); font-size: var(--text-md); font-weight: 600; line-height: 1.25; letter-spacing: 0; margin: 0; }
.card-description { color: var(--muted-foreground); font-size: var(--text-base); }
.card-content { padding: 0 var(--space-6); display: grid; gap: var(--space-4); min-width: 0; }
.card-footer { padding: 0 var(--space-6); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
@media (max-width: 720px) { .card { padding: var(--space-5) 0; gap: var(--space-5); } .card-header, .card-content, .card-footer { padding-inline: var(--space-4); } }

/* ================================================================== Separator */
.separator { border: 0; margin: 0; flex-shrink: 0; background: var(--border); height: 1px; width: 100%; }
.separator[data-orientation="vertical"] { display: inline-block; width: 1px; height: auto; min-height: 1em; align-self: stretch; }

/* ================================================================== Kbd */
.kbd { display: inline-flex; align-items: center; justify-content: center; gap: 2px; height: 20px; min-width: 20px; padding: 0 5px;
  border-radius: var(--radius-sm); background: var(--muted); color: var(--muted-foreground); border: 1px solid var(--border);
  font-family: var(--sans); font-size: var(--text-xs); font-weight: 600; line-height: 1; pointer-events: none; }

/* ================================================================== Tabs */
.tabs { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.tabs-list { display: inline-flex; align-items: center; width: fit-content; max-width: 100%; height: 36px; padding: 3px;
  border-radius: var(--radius-lg); background: var(--muted); color: var(--muted-foreground);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs-list::-webkit-scrollbar { display: none; }
.tabs-trigger { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: 1 0 auto; height: 100%;
  padding: 0 12px; border: 1px solid transparent; border-radius: var(--radius-md); background: transparent; color: var(--muted-foreground);
  font-family: var(--sans); font-size: var(--text-base); font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: color .15s, background-color .15s, box-shadow .15s; }
.tabs-trigger:hover { color: var(--foreground); }
.tabs-trigger[data-state="active"], .tabs-trigger[aria-selected="true"] { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-sm); }
.tabs-trigger:focus-visible { outline: none; box-shadow: var(--ring-shadow); border-color: var(--ring); }
.tabs-trigger:disabled { opacity: .5; pointer-events: none; }
.tabs-trigger svg { width: 16px; height: 16px; }
.tabs-trigger .badge { padding: 1px 6px; }
.tabs-trigger .dot { width: 6px; height: 6px; }
.tabs-content { min-width: 0; }
.tabs-content:focus-visible { outline: none; box-shadow: var(--ring-shadow); border-radius: var(--radius-md); }
.tabs-trigger[data-state="active"] { border-color: var(--raised-border); }

.tabs[data-variant="underline"] > .tabs-list { height: auto; padding: 0; gap: var(--space-5); border-radius: 0; background: none;
  width: 100%; border-bottom: 1px solid var(--border); }
.tabs[data-variant="underline"] > .tabs-list > .tabs-trigger { flex: none; height: 40px; padding: 0 2px; border: 0; border-radius: 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px; box-shadow: none; background: none; }
.tabs[data-variant="underline"] > .tabs-list > .tabs-trigger[data-state="active"] { border-bottom-color: var(--foreground); color: var(--foreground); }
.tabs[data-variant="underline"] > .tabs-list > .tabs-trigger:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ring) 60%, transparent); border-radius: var(--radius-sm); }

/* ================================================================== ToggleGroup */
.toggle-group { display: inline-flex; align-items: stretch; width: fit-content; max-width: 100%; border-radius: var(--radius-md);
  border: 1px solid var(--input); box-shadow: var(--shadow-xs); background: var(--background); overflow-x: auto; scrollbar-width: none; }
.toggle-group::-webkit-scrollbar { display: none; }
.toggle-item { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; min-width: 36px; height: 34px;
  padding: 0 12px; border: 0; border-left: 1px solid var(--input); background: transparent; color: var(--muted-foreground);
  font-family: var(--sans); font-size: var(--text-base); font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: color .15s, background-color .15s, box-shadow .15s; }
.toggle-item:first-child { border-left: 0; }
.toggle-item:hover { background: color-mix(in srgb, var(--muted) 60%, transparent); color: var(--foreground); }
.toggle-item[aria-pressed="true"], .toggle-item[data-state="on"] { background: var(--accent-surface); color: var(--foreground); }
.toggle-item:focus-visible { outline: none; position: relative; z-index: 1; box-shadow: inset 0 0 0 2px var(--ring); }
.toggle-item:disabled { opacity: .5; pointer-events: none; }
.toggle-item svg { width: 16px; height: 16px; }
.toggle-item .count { font-family: var(--mono); font-size: var(--text-xs); color: var(--muted-foreground); font-weight: 400; }
.toggle-group[data-size="sm"] .toggle-item { height: 30px; padding: 0 10px; font-size: var(--text-sm); min-width: 32px; }

/* ================================================================== Slider */
[data-slot="slider"] { position: relative; display: flex; align-items: center; width: 100%; height: 20px; touch-action: none;
  user-select: none; -webkit-user-select: none; cursor: pointer; }
[data-slot="slider"][data-has-labels] { margin-bottom: 18px; }
[data-slot="slider"][aria-disabled="true"] { opacity: .5; pointer-events: none; }
[data-slot="slider-track"] { position: relative; flex: 1; height: 6px; border-radius: 999px; background: var(--muted);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 70%, transparent); }
[data-slot="slider-range"] { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: color-mix(in srgb, var(--primary) 35%, transparent); }
[data-slot="slider-thumb"] { position: absolute; top: 50%; left: 0; z-index: 2; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; background: var(--background); border: 1px solid var(--primary); box-shadow: var(--shadow-sm);
  cursor: grab; outline: none; transition: box-shadow .15s, transform .1s; touch-action: none; }
[data-slot="slider-thumb"][data-emphasis] { background: var(--primary); z-index: 3; }
[data-slot="slider-thumb"]:hover { box-shadow: var(--shadow-sm), 0 0 0 4px color-mix(in srgb, var(--ring) 25%, transparent); }
[data-slot="slider-thumb"]:focus-visible { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ring) 50%, transparent); }
[data-slot="slider-thumb"][data-dragging] { transform: scale(1.1); cursor: grabbing; box-shadow: 0 0 0 4px color-mix(in srgb, var(--ring) 50%, transparent); z-index: 4; }
[data-slot="slider-thumb"]::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; }
.slider-thumb-label { position: absolute; top: 22px; left: 50%; transform: translateX(-50%); padding: 0 4px; border-radius: var(--radius-sm);
  background: var(--background); color: var(--muted-foreground); font-size: var(--text-xs); font-weight: 600; line-height: 16px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s; }
[data-slot="slider-thumb"]:hover .slider-thumb-label, [data-slot="slider-thumb"]:focus-visible .slider-thumb-label,
[data-slot="slider-thumb"][data-dragging] .slider-thumb-label { opacity: 1; }
.slider-ticks { position: absolute; left: 0; right: 0; top: 13px; height: 6px; pointer-events: none; }
.slider-tick { position: absolute; top: 0; width: 1px; height: 6px; margin-left: -.5px; background: var(--muted-foreground); pointer-events: auto; }
.slider-tick::before { content: ""; position: absolute; left: -5px; right: -5px; top: -4px; bottom: -4px; }
.slider-tick[data-kind="ghost"] { background: color-mix(in srgb, var(--foreground) 45%, transparent); top: -7px; height: 20px; width: 1px;
  background: repeating-linear-gradient(180deg, color-mix(in srgb, var(--foreground) 55%, transparent) 0 3px, transparent 3px 5px); }
.slider-tick[data-kind="price"] { background: var(--price); width: 2px; margin-left: -1px; top: -7px; height: 20px; }
.slider-tick-label { position: absolute; top: 9px; transform: translateX(-50%); font-size: var(--text-xs); line-height: 16px; color: var(--muted-foreground); white-space: nowrap; }
.slider-tick-label[data-kind="price"] { color: var(--price); font-weight: 600; }
.slider-tick-label[data-edge="start"] { transform: none; }
.slider-tick-label[data-edge="end"] { transform: translateX(-100%); }
.slider-tooltip { position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); z-index: 5; pointer-events: none;
  padding: 4px 8px; border-radius: var(--radius-md); background: var(--foreground); color: var(--background);
  font-family: var(--mono); font-size: var(--text-xs); line-height: 1.3; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) {
  [data-slot="slider"] { height: 44px; }
  [data-slot="slider-thumb"] { width: 20px; height: 20px; margin: -10px 0 0 -10px; }
  [data-slot="slider-thumb"]::before { inset: -12px; }
  [data-slot="slider"]:has(.slider-thumb-label) { margin-bottom: 14px; }
  .slider-thumb-label { opacity: 1; top: 26px; }
  .slider-ticks { top: 25px; }
}

/* ================================================================== Input, Textarea, Select, Checkbox, Label */
.input, .textarea, .select { display: block; width: 100%; min-width: 0; height: 36px; padding: 0 12px;
  border: 1px solid var(--input); border-radius: var(--radius-md); background: var(--background); color: var(--foreground);
  box-shadow: var(--shadow-xs); font-family: var(--sans); font-size: var(--text-base); line-height: 1.4; outline: none;
  transition: border-color .15s, box-shadow .15s; }
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); opacity: 1; }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { border-color: var(--ring); box-shadow: var(--ring-shadow); }
.input:disabled, .textarea:disabled, .select:disabled { opacity: .5; cursor: not-allowed; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--destructive);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 20%, transparent); }
.input[data-size="sm"], .select[data-size="sm"] { height: 32px; font-size: var(--text-sm); padding: 0 10px; }
.input.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--text-base); }
.input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.textarea { height: auto; min-height: 64px; padding: 8px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; width: auto; min-width: 8rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted-foreground) 50%), linear-gradient(135deg, var(--muted-foreground) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.select option { background: var(--popover); color: var(--popover-foreground); }
.input-group { display: flex; align-items: stretch; width: 100%; min-width: 0; border-radius: var(--radius-md); box-shadow: var(--shadow-xs); }
.input-group > .input { box-shadow: none; border-radius: 0; flex: 1; }
.input-group > .input:first-child { border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
.input-group > .input:last-child { border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }
.input-group > .input:focus-visible { position: relative; z-index: 1; }
.input-addon { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--input); background: var(--muted);
  color: var(--muted-foreground); font-size: var(--text-sm); white-space: nowrap; }
.input-addon:first-child { border-right: 0; border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-addon:last-child { border-left: 0; border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.label, label.label { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-base); font-weight: 600; line-height: 1.2; color: var(--foreground); user-select: none; }
.field { display: grid; gap: 8px; align-content: start; }
.field-description { color: var(--muted-foreground); font-size: var(--text-sm); }
.checkbox { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 16px; height: 16px; margin: 0;
  border: 1px solid var(--input); border-radius: var(--radius-sm); background: var(--background); box-shadow: var(--shadow-xs); cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s; vertical-align: middle; }
.checkbox:checked, .checkbox:indeterminate { background: var(--primary); border-color: var(--primary); }
.checkbox:checked::after { content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px;
  border: solid var(--primary-foreground); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.checkbox:indeterminate::after { content: ""; position: absolute; left: 3px; right: 3px; top: 6.5px; height: 2px; background: var(--primary-foreground); }
.checkbox:focus-visible { outline: none; border-color: var(--ring); box-shadow: var(--ring-shadow); }
.checkbox:disabled { opacity: .5; cursor: not-allowed; }

/* ================================================================== Popover, DropdownMenu, Tooltip (floating) */
.popover, .dropdown-menu { position: fixed; z-index: 60; top: 0; left: 0; outline: none;
  background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.popover { width: 18rem; max-width: calc(100vw - 16px); padding: var(--space-4); border-radius: var(--radius-md); display: grid; gap: var(--space-3); }
.popover[data-state="open"], .dropdown-menu[data-state="open"] { animation: ui-pop-in .12s ease-out; }
.popover[data-side="top"][data-state="open"], .dropdown-menu[data-side="top"][data-state="open"] { animation-name: ui-pop-in-up; }
.dropdown-menu { min-width: 12rem; max-width: calc(100vw - 16px); max-height: calc(100vh - 80px); overflow-y: auto; padding: 4px; border-radius: var(--radius-md); }
.dropdown-label { padding: 6px 8px; font-size: var(--text-sm); font-weight: 600; color: var(--muted-foreground); }
.dropdown-item { position: relative; display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 6px 8px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--popover-foreground); text-align: left; text-decoration: none;
  font-family: var(--sans); font-size: var(--text-base); line-height: 1.3; cursor: pointer; outline: none; user-select: none; }
.dropdown-item:hover, .dropdown-item:focus, .dropdown-item[data-highlighted] { background: var(--muted); text-decoration: none; }
.dropdown-item[aria-current="page"] { font-weight: 600; }
.dropdown-item[aria-disabled="true"], .dropdown-item:disabled { opacity: .5; pointer-events: none; }
.dropdown-item[data-variant="destructive"] { color: var(--destructive); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--muted-foreground); flex: none; }
.dropdown-shortcut { margin-left: auto; font-size: var(--text-xs); color: var(--muted-foreground); letter-spacing: .05em; }
.dropdown-separator { height: 1px; margin: 4px -4px; background: var(--border); }

.tooltip { position: fixed; z-index: 80; top: 0; left: 0; max-width: 18rem; padding: 6px 12px; border-radius: var(--radius-md);
  background: var(--foreground); color: var(--background); font-family: var(--sans); font-size: var(--text-xs); font-weight: 400; line-height: 1.4;
  pointer-events: none; text-wrap: pretty; animation: ui-fade-in .1s ease-out; }

/* ================================================================== Accordion, Collapsible */
.accordion { display: grid; }
.accordion-item { border-bottom: 1px solid var(--border); }
.accordion-trigger { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4) 0; cursor: pointer; list-style: none;
  font-size: var(--text-base); font-weight: 600; border-radius: var(--radius-md); outline: none; transition: color .15s; }
.accordion-trigger::-webkit-details-marker, .collapsible > summary::-webkit-details-marker { display: none; }
.accordion-trigger::after, .collapsible > summary::after { content: ""; flex: none; width: 16px; height: 16px; margin-left: auto;
  background: var(--muted-foreground); transition: transform .2s;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%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 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat; }
.accordion-trigger:hover { text-decoration: underline; text-underline-offset: 4px; }
.accordion-trigger:focus-visible, .collapsible > summary:focus-visible { box-shadow: var(--ring-shadow); }
details[open] > .accordion-trigger::after, .collapsible[open] > summary::after { transform: rotate(180deg); }
.accordion-trigger .badge, .accordion-trigger .muted { text-decoration: none; }
.accordion-trigger .muted { font-weight: 400; margin-left: auto; }
.accordion-trigger:has(.muted)::after { margin-left: var(--space-3); }   /* the note takes the auto margin; the chevron sits after it */
.accordion-content { padding: 0 0 var(--space-4); display: grid; gap: var(--space-3); min-width: 0; }
.collapsible > summary { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 12px; margin-left: -12px;
  border-radius: var(--radius-md); cursor: pointer; list-style: none; font-size: var(--text-sm); font-weight: 600; color: var(--foreground); outline: none; }
.collapsible > summary::after { margin-left: 0; }
.collapsible > summary:hover { background: var(--muted); }
.collapsible[open] > summary { margin-bottom: var(--space-2); }

/* ================================================================== Sheet, Dialog, overlay */
.ui-overlay { position: fixed; inset: 0; z-index: 70; background: var(--overlay); animation: ui-fade-in .15s ease-out; }
.ui-overlay[data-state="closed"] { animation: ui-fade-out .15s ease-in forwards; pointer-events: none; }
.sheet, .dialog { position: fixed; z-index: 71; display: flex; flex-direction: column; background: var(--background); color: var(--foreground);
  box-shadow: var(--shadow-lg); outline: none; }
.sheet { gap: var(--space-4); overflow: hidden; }
.sheet[data-side="right"], .sheet:not([data-side]) { top: 0; bottom: 0; right: 0; width: min(24rem, 85vw); border-left: 1px solid var(--border); animation: ui-in-right .25s ease-out; }
.sheet[data-side="left"] { top: 0; bottom: 0; left: 0; width: min(20rem, 85vw); border-right: 1px solid var(--border); animation: ui-in-left .25s ease-out; }
.sheet[data-side="bottom"] { left: 0; right: 0; bottom: 0; max-height: 85vh; border-top: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0; animation: ui-in-bottom .25s ease-out; padding-bottom: env(safe-area-inset-bottom); }
.sheet[data-side="right"][data-state="closed"], .sheet:not([data-side])[data-state="closed"] { animation: ui-out-right .2s ease-in forwards; }
.sheet[data-side="left"][data-state="closed"] { animation: ui-out-left .2s ease-in forwards; }
.sheet[data-side="bottom"][data-state="closed"] { animation: ui-out-bottom .2s ease-in forwards; }
.sheet-header, .dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.sheet-header { padding: var(--space-4) var(--space-4) 0; padding-top: max(var(--space-4), env(safe-area-inset-top)); }
.sheet-title, .dialog-title { margin: 0; font-family: var(--sans); font-size: var(--text-lg); font-weight: 600; line-height: 1.3; letter-spacing: 0; }
.sheet-description, .dialog-description { color: var(--muted-foreground); font-size: var(--text-base); }
.sheet-header > .btn, .dialog-header > .btn { margin: -6px -6px 0 0; }
.sheet-content { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--space-4) var(--space-4); display: grid; align-content: start; gap: var(--space-4); }
.sheet-footer, .dialog-footer { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
.sheet-footer { padding: 0 var(--space-4) var(--space-4); margin-top: auto; }
.dialog { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(32rem, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  gap: var(--space-4); padding: var(--space-6); border: 1px solid var(--border); border-radius: var(--radius-lg); animation: ui-dialog-in .15s ease-out; }
.dialog[data-state="closed"] { animation: ui-dialog-out .12s ease-in forwards; }
.dialog-header { display: grid; gap: 6px; }
.dialog-header:has(> .btn) { grid-template-columns: 1fr auto; }
@media (max-width: 720px) { .dialog-footer { flex-direction: column-reverse; } .dialog-footer > .btn { width: 100%; } }
html[data-ui-scroll-lock] { overflow: hidden; }

/* ================================================================== Command palette */
.dialog.command { top: 12vh; transform: translateX(-50%); padding: 0; gap: 0; width: min(36rem, calc(100vw - 24px)); overflow: hidden; max-height: 76vh; }
.dialog.command { animation-name: ui-command-in; }
.dialog.command[data-state="closed"] { animation-name: ui-command-out; }
.command-input-wrap { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px; border-bottom: 1px solid var(--border); margin: 0; }
.command-input-wrap > svg { width: 16px; height: 16px; color: var(--muted-foreground); flex: none; }
.command-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; color: var(--foreground);
  font-family: var(--sans); font-size: var(--text-base); }
.command-input::placeholder { color: var(--muted-foreground); }
.command-list { max-height: min(360px, 60vh); overflow-y: auto; padding: 4px; overscroll-behavior: contain; }
.command-group + .command-group { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.command-group-heading { padding: 6px 8px; font-size: var(--text-xs); font-weight: 600; color: var(--muted-foreground); }
.command-item { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 8px; border-radius: var(--radius-sm);
  color: var(--foreground); text-decoration: none; cursor: pointer; font-size: var(--text-base); user-select: none; }
.command-item[aria-selected="true"] { background: var(--muted); }
.command-item svg { width: 16px; height: 16px; color: var(--muted-foreground); flex: none; }
.command-item .command-meta { color: var(--muted-foreground); font-size: var(--text-sm); }
.command-item .badge { margin-left: auto; }
.command-empty { padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted-foreground); font-size: var(--text-base); }
.command-footer { display: flex; gap: var(--space-4); padding: 8px 12px; border-top: 1px solid var(--border); color: var(--muted-foreground); font-size: var(--text-xs); }
.command-footer span { display: inline-flex; align-items: center; gap: 4px; }

/* ================================================================== Table */
.table-wrap { position: relative; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; caption-side: bottom; font-family: var(--sans); font-size: var(--text-base); color: var(--foreground); }
.table caption { margin-top: var(--space-4); color: var(--muted-foreground); font-size: var(--text-sm); text-align: left; }
.table th { height: 40px; padding: 0 8px; text-align: left; vertical-align: middle; white-space: nowrap; border-bottom: 1px solid var(--border);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-foreground); }
.table td { padding: 8px; vertical-align: middle; border-bottom: 1px solid var(--border); color: var(--foreground); }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table[data-inset] th:first-child, .table[data-inset] td:first-child { padding-left: 8px; }
.table[data-inset] th:last-child, .table[data-inset] td:last-child { padding-right: 8px; }
.table tbody tr { transition: background-color .15s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--muted) 55%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-state="selected"] { background: var(--muted); }
.table .num, .table th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--text-sm); white-space: nowrap; }
.table th.num { font-family: var(--sans); font-size: var(--text-xs); }
.table td .muted, .table td.muted { color: var(--muted-foreground); }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: 0; }
.table[data-size="sm"] td { padding-top: 6px; padding-bottom: 6px; }
.table-sort { display: inline-flex; align-items: center; gap: 4px; height: 28px; margin: 0 -6px; padding: 0 6px; border: 0; border-radius: var(--radius-sm);
  background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.table-sort:hover { background: var(--muted); color: var(--foreground); }
.table-sort:focus-visible { outline: none; box-shadow: var(--ring-shadow); }
.table-sort svg { width: 14px; height: 14px; opacity: .6; }
th[aria-sort="ascending"] .table-sort, th[aria-sort="descending"] .table-sort { color: var(--foreground); }
th[aria-sort] .table-sort svg { opacity: 1; }
th.num .table-sort { flex-direction: row-reverse; margin: 0 -6px 0 auto; }

/* ================================================================== Alert */
.alert { position: relative; display: grid; grid-template-columns: 0 1fr; align-items: start; row-gap: 2px; width: 100%;
  padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); color: var(--card-foreground);
  font-size: var(--text-base); line-height: 1.5; }
.alert:has(> svg) { grid-template-columns: 16px 1fr; column-gap: 12px; }
.alert > svg { width: 16px; height: 16px; margin-top: 2px; color: currentColor; }
.alert-title { grid-column: 2; font-weight: 600; line-height: 1.4; min-height: 1em; }
.alert-description { grid-column: 2; color: var(--muted-foreground); display: grid; gap: 4px; }
.alert-description a { color: var(--foreground); }
.alert > .alert-actions { grid-column: 2; display: flex; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.alert[data-variant="warning"] { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, var(--border)); background: color-mix(in srgb, var(--warning) 7%, var(--card)); }
.alert[data-variant="destructive"] { color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 40%, var(--border)); background: color-mix(in srgb, var(--destructive) 6%, var(--card)); }
.alert[data-variant="warning"] .alert-description, .alert[data-variant="destructive"] .alert-description { color: color-mix(in srgb, currentColor 80%, var(--foreground)); }

/* ================================================================== Progress, Skeleton, Spinner */
.progress { position: relative; width: 100%; height: 8px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--primary) 18%, transparent); }
.progress-indicator { height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .3s ease; }
.progress[data-variant="warning"] .progress-indicator { background: var(--warning); }
.progress[data-variant="destructive"] .progress-indicator { background: var(--destructive); }
.skeleton { display: block; border-radius: var(--radius-md); background: var(--muted); animation: ui-pulse 2s cubic-bezier(.4, 0, .6, 1) infinite; }
.spin, svg.spin { animation: ui-spin 1s linear infinite; }
.icon { display: inline-block; vertical-align: middle; flex: none; }

/* ================================================================== Empty state */
.empty-state { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-10) var(--space-6); text-align: center;
  border: 1px dashed var(--border); border-radius: var(--radius-lg); color: var(--muted-foreground); }
.empty-state .empty-title { color: var(--foreground); font-size: var(--text-md); font-weight: 600; }

/* ================================================================== description list (label: value rows) */
.dl { display: grid; grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr); gap: 8px var(--space-6); margin: 0; font-size: var(--text-base); }
.dl dt { color: var(--muted-foreground); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .dl dd { margin-bottom: 8px; } }

/* ================================================================== Select + Combobox (shadcn Select, faceted filter) */
.select-trigger { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px 0 12px; max-width: 100%;
  border: 1px solid var(--input); border-radius: var(--radius-md); background: var(--background); color: var(--foreground);
  box-shadow: var(--shadow-xs); font: inherit; font-size: var(--text-base); white-space: nowrap; cursor: pointer; outline: none;
  transition: background-color .15s, border-color .15s, box-shadow .15s; }
.select-trigger:hover { background: var(--muted); }
.select-trigger:focus-visible { border-color: var(--ring); box-shadow: var(--ring-shadow); }
.select-trigger[data-size="sm"] { height: 32px; font-size: var(--text-sm); }
.select-trigger > svg { width: 14px; height: 14px; flex: none; color: var(--muted-foreground); }
.select-trigger .select-prefix { color: var(--muted-foreground); }
.select-trigger .select-value { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.select-trigger[data-variant="dashed"] { border-style: dashed; box-shadow: none; }
.select-trigger[data-variant="dashed"][data-state-filled="true"] { border-style: solid; }
.select-trigger .select-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
.select-trigger .badge { font-weight: 500; }
.select-content { position: fixed; z-index: 60; top: 0; left: 0; outline: none; min-width: 12rem; max-width: calc(100vw - 16px);
  padding: 4px; border-radius: var(--radius-md); background: var(--popover); color: var(--popover-foreground);
  border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.select-content[data-state="open"] { animation: ui-pop-in .12s ease-out; }
.select-content[data-side="top"][data-state="open"] { animation-name: ui-pop-in-up; }
.select-content [role="listbox"] { max-height: min(320px, 60vh); overflow-y: auto; overscroll-behavior: contain; }
.select-label { padding: 6px 8px 4px; font-size: var(--text-xs); font-weight: 600; color: var(--muted-foreground); }
.select-item { position: relative; display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 6px 30px 6px 8px;
  border-radius: var(--radius-sm); font-size: var(--text-base); line-height: 1.3; cursor: pointer; user-select: none; }
.select-item[data-highlighted] { background: var(--muted); }
.select-item[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.select-item-text { display: grid; gap: 1px; min-width: 0; }
.select-item-hint { color: var(--muted-foreground); font-size: var(--text-sm); }
.select-item .select-check { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: none; }
.select-item[aria-selected="true"] .select-check { display: inline-flex; }
.select-item .select-check svg { width: 16px; height: 16px; }
.select-item .select-count { margin-left: auto; font-family: var(--mono); font-size: var(--text-sm); color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
/* multiple: a checkbox on the left instead of the tick */
[data-multiple-list] .select-item { padding-right: 8px; }
[data-multiple-list] .select-item .select-check { position: static; transform: none; display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; flex: none; border: 1px solid var(--input); border-radius: var(--radius-sm); color: transparent; }
[data-multiple-list] .select-item[aria-selected="true"] .select-check { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
[data-multiple-list] .select-item .select-check svg { width: 12px; height: 12px; }
.select-search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px; margin: -4px -4px 4px; border-bottom: 1px solid var(--border); }
.select-search svg { width: 15px; height: 15px; color: var(--muted-foreground); flex: none; }
.select-search input:focus, .select-search input:focus-visible { outline: none; box-shadow: none; border: 0; }
.select-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; color: var(--foreground); font: inherit; font-size: var(--text-base); }
.select-empty { padding: 16px 8px; text-align: center; color: var(--muted-foreground); font-size: var(--text-sm); }
.select-footer { border-top: 1px solid var(--border); margin: 4px -4px -4px; padding: 4px; }
.select-footer button { width: 100%; justify-content: center; }
@media (pointer: coarse) {
  .select-trigger { min-height: 44px; font-size: 16px; }
  .select-item { min-height: 44px; }
  .select-search input { font-size: 16px; }
}

/* ================================================================== touch targets */
@media (pointer: coarse) {
  .btn, .btn.small, .btn[data-size="sm"], .btn[data-size="icon"], .btn[data-size="icon-sm"] { min-height: 44px; }
  .btn[data-size="icon"], .btn[data-size="icon-sm"] { min-width: 44px; }
  .btn[data-variant="link"] { min-height: 0; }
  .toggle-item, .toggle-group[data-size="sm"] .toggle-item { min-height: 42px; min-width: 44px; }
  .tabs-list { height: 44px; } .tabs[data-variant="underline"] > .tabs-list > .tabs-trigger { height: 44px; }
  .dropdown-item, .command-item { min-height: 44px; }
  .input, .select { min-height: 44px; font-size: 16px; }
  .textarea, .command-input { font-size: 16px; }
  .collapsible > summary, .table-sort { min-height: 44px; }
  .checkbox { width: 20px; height: 20px; } .checkbox:checked::after { left: 6px; top: 2.5px; width: 5px; height: 10px; }
}

/* ================================================================== motion */
@keyframes ui-spin { to { transform: rotate(360deg); } }
@keyframes ui-pulse { 50% { opacity: .5; } }
@keyframes ui-fade-in { from { opacity: 0; } }
@keyframes ui-fade-out { to { opacity: 0; } }
@keyframes ui-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.97); } }
@keyframes ui-pop-in-up { from { opacity: 0; transform: translateY(4px) scale(.97); } }
@keyframes ui-in-right { from { transform: translateX(100%); } }
@keyframes ui-out-right { to { transform: translateX(100%); } }
@keyframes ui-in-left { from { transform: translateX(-100%); } }
@keyframes ui-out-left { to { transform: translateX(-100%); } }
@keyframes ui-in-bottom { from { transform: translateY(100%); } }
@keyframes ui-out-bottom { to { transform: translateY(100%); } }
@keyframes ui-dialog-in { from { opacity: 0; transform: translate(-50%, -48%) scale(.96); } }
@keyframes ui-dialog-out { to { opacity: 0; transform: translate(-50%, -48%) scale(.96); } }
@keyframes ui-command-in { from { opacity: 0; transform: translateX(-50%) scale(.97); } }
@keyframes ui-command-out { to { opacity: 0; transform: translateX(-50%) scale(.97); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skeleton { animation: none; }
}
