/* ==========================================================================
   Instrument — components (plain CSS)

   Load after tokens.css. Every rule reads tokens; nothing here has its own
   dark-mode selector, because the theme lives entirely in tokens.css.

   State is read from the attributes accessible markup already carries, so a
   headless library (or plain HTML) drives the look without extra classes:
     :disabled / [aria-disabled="true"]   unavailable
     [aria-busy="true"]                   working
     [aria-invalid="true"]                error
     [aria-selected="true"] / [aria-pressed="true"] / [aria-current]  chosen
     [aria-expanded="true"]               its menu is open

   Class names are short and unprefixed. To avoid collisions in a large app,
   find-and-replace a prefix (e.g. `.btn` → `.in-btn`) once.

   Each component's spec and reasons: components/<name>.md
   ========================================================================== */

/* ---- Shared -------------------------------------------------------------- */

/* Focus: a 3px ring at half strength plus a ring-coloured edge. An outline,
   not a box-shadow, so it never fights a component's depth shadow. */
:where(.btn, .input, .textarea, .select, .chip, .tab, .checkbox, .switch, .menu-item, .nav-item, .list-row):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 0;
}

.spinner {
  display: inline-block;
  width: var(--icon-md);
  height: var(--icon-md);
  flex-shrink: 0;
  border: 1.8px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
  animation: in-spin 0.8s linear infinite;
}

@keyframes in-spin { to { rotate: 360deg; } }
@keyframes in-pop-in {
  from { opacity: 0; scale: 0.95; }
}
@keyframes in-rise-in {
  from { opacity: 0; translate: 0 var(--rise-md); }
}
@keyframes in-pulse {
  50% { opacity: 0.5; }
}

/* ==========================================================================
   Button
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1-5);
  flex-shrink: 0;
  height: var(--control-md);
  padding: 0 var(--space-2-5);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--depth-raised-fill);
  font: var(--weight-medium) var(--text-sm) / 1 var(--font-sans);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  cursor: pointer;
  transition:
    background-color 150ms, color 150ms, box-shadow 150ms, translate 150ms,
    opacity 150ms;
}
.btn > svg { width: var(--icon-md); height: var(--icon-md); flex-shrink: 0; pointer-events: none; }
.btn:hover {
  background: color-mix(in oklch, var(--primary) 80%, transparent);
  box-shadow: var(--depth-raised-fill-hover);
}
/* Press: down a pixel, shadow gone — the gap to the surface closes. Not on
   menu triggers, where the menu opening is the feedback. */
.btn:active:not([aria-haspopup]) { translate: 0 1px; box-shadow: none; }
/* A raised control that doesn't respond is a lie: flat and faded. */
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  box-shadow: none;
  pointer-events: none;
}
/* Busy is not unavailable: full strength, just not clickable. Put a
   <span class="spinner"></span> before the label. */
.btn[aria-busy="true"] { opacity: 1; pointer-events: none; }
.btn[aria-invalid="true"] { border-color: var(--destructive); outline: 3px solid var(--invalid-ring); }

/* Variants */
.btn-outline {
  background: var(--control-bg);
  color: var(--foreground);
  border: var(--hairline) solid var(--control-border);
  box-shadow: var(--depth-raised);
}
.btn-outline:hover, .btn-outline[aria-expanded="true"] {
  background: var(--control-bg-hover);
  box-shadow: var(--depth-raised-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  box-shadow: var(--depth-raised);
}
.btn-secondary:hover {
  background: color-mix(in oklch, var(--secondary), var(--foreground) 5%);
  box-shadow: var(--depth-raised-hover);
}

/* Flat by design: a shadow under nothing looks like a rendering bug. */
.btn-ghost {
  background: transparent;
  color: var(--foreground);
  box-shadow: none;
}
.btn-ghost:hover, .btn-ghost[aria-expanded="true"] {
  background: var(--ghost-hover);
  box-shadow: none;
}

/* A tint, never a solid red block. */
.btn-destructive {
  background: var(--destructive-tint);
  color: var(--destructive);
  box-shadow: var(--depth-raised);
}
.btn-destructive:hover {
  background: var(--destructive-tint-hover);
  box-shadow: var(--depth-raised-hover);
}

.btn-link {
  height: auto;
  padding: 0;
  background: none;
  color: var(--primary-ink);
  box-shadow: none;
  text-underline-offset: 4px;
}
.btn-link:hover { background: none; box-shadow: none; text-decoration: underline; }

/* Sizes */
.btn-xs {
  height: var(--control-xs);
  padding: 0 var(--space-2);
  gap: var(--space-1);
  font-size: var(--text-xs);
  border-radius: min(var(--radius-md), 10px);
}
.btn-sm {
  height: var(--control-sm);
  padding: 0 var(--space-2-5);
  gap: var(--space-1);
  font-size: 0.8rem;
  border-radius: min(var(--radius-md), 12px);
}
.btn-lg { height: var(--control-lg); }
.btn-xs > svg { width: var(--icon-xs); height: var(--icon-xs); }
.btn-sm > svg { width: var(--icon-sm); height: var(--icon-sm); }
.btn-xs .spinner { width: var(--icon-xs); height: var(--icon-xs); }
.btn-sm .spinner { width: var(--icon-sm); height: var(--icon-sm); }
/* Square icon-only button. Always give it an aria-label. */
.btn-icon { width: var(--control-md); padding: 0; }
.btn-icon.btn-xs { width: var(--control-xs); }
.btn-icon.btn-sm { width: var(--control-sm); }
.btn-icon.btn-lg { width: var(--control-lg); }

/* ==========================================================================
   Form fields
   ========================================================================== */
.field { display: grid; align-content: start; gap: var(--space-2); }
.label {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  font: var(--weight-medium) var(--text-sm) / var(--leading-sm) var(--font-sans);
  color: var(--foreground);
}
.field-hint { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--muted-foreground); }
.field-error { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--destructive); }

.input, .textarea, .select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--input);
  border-radius: var(--radius-lg);
  background: var(--field-bg);
  color: var(--foreground);
  /* 16px on touch screens stops mobile browsers zooming in on focus. */
  font: var(--weight-regular) var(--text-base) / var(--leading-sm) var(--font-sans);
  transition: border-color 150ms, outline-color 150ms;
}
@media (min-width: 768px) {
  .input, .textarea, .select { font-size: var(--text-sm); }
}
.input { height: var(--control-md); padding: var(--space-1) var(--space-2-5); }
.textarea { min-height: 80px; padding: var(--space-1-5) var(--space-2-5); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { border-color: var(--ring); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--destructive);
  outline: 3px solid var(--invalid-ring);
}
.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--field-bg-disabled);
  opacity: 0.5;
  cursor: not-allowed;
}

/* Native <select>, or a headless select's trigger button. */
.select {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1-5);
  height: var(--control-md);
  padding: 0 var(--space-2) 0 var(--space-2-5);
  background-color: var(--background);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
}
select.select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5M7 9l5-5 5 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
}
.select > svg { width: var(--icon-md); height: var(--icon-md); color: var(--muted-foreground); }

/* Checkbox: native input restyled. */
.checkbox {
  appearance: none;
  display: inline-grid;
  place-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin: 0;
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  background: var(--background);
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms;
}
.checkbox::after {
  content: "";
  width: 9px;
  height: 5px;
  border: solid var(--primary-foreground);
  border-width: 0 0 1.8px 1.8px;
  rotate: -45deg;
  translate: 0 -1px;
  opacity: 0;
}
.checkbox:checked, .checkbox:indeterminate { background: var(--primary); border-color: var(--primary); }
.checkbox:checked::after { opacity: 1; }
.checkbox:indeterminate::after { width: 8px; height: 0; border-width: 0 0 1.8px 0; rotate: 0deg; translate: 0; opacity: 1; }
.checkbox:disabled { opacity: 0.5; cursor: not-allowed; }

/* Switch: <button role="switch" aria-checked> with an empty <span> thumb,
   or <input type="checkbox" role="switch">. */
.switch {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: var(--input);
  cursor: pointer;
  transition: background-color 150ms;
}
.switch::before {
  content: "";
  position: absolute;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
  transition: translate 200ms var(--ease-out-strong);
}
.switch:checked, .switch[aria-checked="true"] { background: var(--primary); }
.switch:checked::before, .switch[aria-checked="true"]::before { translate: 16px 0; }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==========================================================================
   Badge
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  width: fit-content;
  height: 20px;
  flex-shrink: 0;
  padding: 0 var(--space-2);
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--primary-foreground);
  font: var(--weight-medium) var(--text-xs) / 1 var(--font-sans);
  white-space: nowrap;
}
.badge > svg { width: var(--icon-xs); height: var(--icon-xs); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline { background: transparent; border-color: var(--border); color: var(--foreground); }
.badge-destructive { background: var(--destructive-tint); color: var(--destructive); }
/* Status: 15% tint fill, deep ink. tokens.css lifts the ink in dark. */
.badge-success { background: var(--status-success-fill); color: var(--status-success-ink); }
.badge-warning { background: var(--status-warning-fill); color: var(--status-warning-ink); }
.badge-danger  { background: var(--status-danger-fill);  color: var(--status-danger-ink); }
.badge-info    { background: var(--status-info-fill);    color: var(--status-info-ink); }
/* Pending, stopped, cancelled. A deliberate action is never red. */
.badge-neutral { background: var(--status-neutral-fill); border-color: var(--border); color: var(--status-neutral-ink); }
/* <span class="dot"></span> inside a badge; add .badge-live to pulse it. */
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-live .dot { animation: in-pulse 2s ease-in-out infinite; }

/* Counter bubble (unread counts, beside a nav item). */
.counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  min-width: 16px;
  margin-left: auto;
  padding: 0 var(--space-1);
  border-radius: var(--radius-full);
  background: var(--destructive);
  color: var(--destructive-foreground);
  font: var(--weight-medium) var(--text-2xs) / 1 var(--font-sans);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Filter chips
   ========================================================================== */
/* On small screens the row scrolls sideways instead of wrapping, and bleeds
   into the page gutter so the cut-off chip says "there's more". Set
   --gutter to the page's side padding. */
.chip-row {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  margin: 0 calc(var(--gutter, 16px) * -1);
  padding: var(--space-2) var(--gutter, 16px);
  overflow-x: auto;
  scrollbar-width: none;
}
@media (min-width: 640px) {
  .chip-row { margin: 0; padding: 0; min-height: var(--bar-filter); flex-wrap: wrap; overflow: visible; }
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted-foreground);
  font: var(--weight-medium) var(--text-xs) / var(--leading-xs) var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}
.chip:hover { background: color-mix(in oklch, var(--muted) 60%, transparent); color: var(--foreground); }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--muted); color: var(--foreground); }
/* "Add a filter" and other not-yet-a-filter chips. */
.chip-dashed { border-style: dashed; }

/* ==========================================================================
   Tabs
   ========================================================================== */
/* Segmented: a muted track, the active segment lifted onto the page colour.
   Markup: <div class="tabs" role="tablist"><button class="tab" role="tab"
   aria-selected="true">…</button>…</div> */
.tabs {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  height: var(--control-md);
  padding: 3px;
  border-radius: var(--radius-lg);
  background: var(--muted);
  color: var(--muted-foreground);
}
.tab {
  position: relative;
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: var(--space-1-5);
  height: calc(100% - 1px);
  padding: 2px var(--space-1-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: color-mix(in oklch, var(--foreground) 60%, transparent);
  font: var(--weight-medium) var(--text-sm) / 1 var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms, background-color 150ms, box-shadow 150ms;
}
.tab > svg { width: var(--icon-md); height: var(--icon-md); }
.tab:hover { color: var(--foreground); }
.tab[aria-selected="true"] {
  background: var(--segment-active-bg);
  border-color: var(--segment-active-border);
  color: var(--foreground);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.tab:disabled, .tab[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

/* Line: an underline under the active tab. With the optional indicator
   element (one bar that slides — see components/tabs.md), add .has-indicator
   to the list so the per-tab underline steps aside. */
.tabs-line { gap: var(--space-1); padding: 0; border-radius: 0; background: transparent; }
.tabs-line .tab { padding: 0 var(--space-1-5); }
.tabs-line .tab[aria-selected="true"] { background: transparent; border-color: transparent; box-shadow: none; }
.tabs-line:not(.has-indicator) .tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 2px;
  border-radius: var(--radius-full);
  background: var(--foreground);
}
.tabs-indicator {
  position: absolute;
  left: 0;
  bottom: -2px;
  width: var(--active-tab-width, 0);
  height: 2px;
  border-radius: var(--radius-full);
  background: var(--foreground);
  translate: var(--active-tab-left, 0) 0;
  transition: translate var(--duration-fast) var(--ease-out-strong), width var(--duration-fast) var(--ease-out-strong);
}
/* Panel: enters only (an exit would hold two panels on screen). Set
   data-direction="left|right" to arrive from the direction of travel. */
.tab-panel {
  transition: opacity var(--duration-fast) var(--ease-out-strong), translate var(--duration-fast) var(--ease-out-strong);
}
@starting-style {
  .tab-panel { opacity: 0; }
  .tab-panel[data-direction="left"] { translate: calc(var(--rise-md) * -1) 0; }
  .tab-panel[data-direction="right"] { translate: var(--rise-md) 0; }
}

/* ==========================================================================
   Card
   ========================================================================== */
.card {
  --card-spacing: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--card-spacing);
  padding: var(--card-spacing) 0;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}
.card-sm { --card-spacing: var(--space-3); }
.card:has(> .card-footer) { padding-bottom: 0; }
.card-header { display: grid; gap: var(--space-1); padding: 0 var(--card-spacing); }
.card-title { margin: 0; font-size: var(--text-base); font-weight: var(--weight-medium); line-height: var(--leading-snug); }
.card-sm .card-title { font-size: var(--text-sm); }
.card-description { margin: 0; color: var(--muted-foreground); }
.card-content { padding: 0 var(--card-spacing); }
.card-footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--card-spacing);
  border-top: 1px solid var(--border);
  background: color-mix(in oklch, var(--muted) 50%, transparent);
}

/* ==========================================================================
   Dialog — styles a native <dialog> (or any role="dialog" popup)
   ========================================================================== */
.dialog {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  width: calc(100% - 2rem);
  max-width: 320px;
  max-height: calc(100svh - 2rem);
  margin: auto;
  padding: var(--space-4);
  overflow-y: auto;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--depth-floating);
  font-size: var(--text-sm);
}
@media (min-width: 640px) { .dialog { max-width: 448px; } }
.dialog[open], .dialog[data-open] { display: grid; gap: var(--space-4); animation: in-pop-in var(--duration-instant) ease-out; }
/* Barely there: the dialog lifts; the page isn't punished. */
.dialog::backdrop, .dialog-overlay {
  background: rgb(0 0 0 / 0.1);
  backdrop-filter: blur(4px);
}
.dialog-header { display: grid; gap: var(--space-1-5); }
.dialog-title { margin: 0; font-size: var(--text-base); font-weight: var(--weight-medium); line-height: var(--leading-snug); }
.dialog-description { margin: 0; color: var(--muted-foreground); text-wrap: balance; }
/* Full-bleed muted strip. Stacked on phones with the primary action last,
   nearest the thumb; in a row, right-aligned, from sm up. */
.dialog-footer {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  margin: 0 calc(var(--space-4) * -1) calc(var(--space-4) * -1);
  padding: var(--space-4);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  background: color-mix(in oklch, var(--muted) 50%, transparent);
}
@media (min-width: 640px) { .dialog-footer { flex-direction: row; justify-content: flex-end; } }
.dialog-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: grid;
  place-items: center;
  width: var(--control-sm);
  height: var(--control-sm);
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}
.dialog-close:hover { background: var(--muted); color: var(--foreground); }
.dialog-close > svg { width: var(--icon-md); height: var(--icon-md); }

/* ==========================================================================
   Menu (dropdowns, select popups, context menus)
   ========================================================================== */
.menu {
  min-width: 128px;
  max-height: var(--available-height, 60vh);
  padding: var(--space-1);
  overflow-y: auto;
  border-radius: var(--radius-lg);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--depth-floating);
  transform-origin: var(--transform-origin, top);
  animation: in-pop-in var(--duration-instant) ease-out;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  width: 100%;
  padding: var(--space-1) var(--space-1-5);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  font: var(--weight-regular) var(--text-sm) / var(--leading-sm) var(--font-sans);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}
.menu-item > svg { width: var(--icon-md); height: var(--icon-md); flex-shrink: 0; }
.menu-item:hover, .menu-item:focus-visible, .menu-item[data-highlighted] {
  outline: none;
  background: var(--accent);
  color: var(--accent-foreground);
}
.menu-item[aria-current], .menu-item[aria-checked="true"] { background: var(--accent); }
.menu-item-destructive, .menu-item-destructive > svg { color: var(--destructive); }
.menu-item-destructive:hover, .menu-item-destructive:focus-visible, .menu-item-destructive[data-highlighted] {
  background: var(--destructive-tint);
  color: var(--destructive);
}
.menu-item[aria-disabled="true"], .menu-item:disabled { opacity: 0.5; pointer-events: none; }
.menu-item .shortcut { margin-left: auto; color: var(--muted-foreground); font-size: var(--text-xs); }
.menu-label { padding: var(--space-1) var(--space-1-5); color: var(--muted-foreground); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.menu-separator { height: 1px; margin: var(--space-1) calc(var(--space-1) * -1); border: 0; background: var(--border); }

/* ==========================================================================
   Tooltip — an inverted chip. Show with no delay.
   ========================================================================== */
.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  width: fit-content;
  max-width: 320px;
  padding: var(--space-1-5) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--foreground);
  color: var(--background);
  font: var(--weight-regular) var(--text-xs) / var(--leading-xs) var(--font-sans);
  animation: in-pop-in var(--duration-instant) ease-out;
}
/* Optional arrow: a rotated square in the same fill. Position it on the side
   facing the trigger (the headless library usually supplies the offsets). */
.tooltip-arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--foreground);
  rotate: 45deg;
}
.tooltip[data-side="top"] .tooltip-arrow, .tooltip:not([data-side]) .tooltip-arrow { bottom: -4px; left: calc(50% - 5px); }
.tooltip[data-side="bottom"] .tooltip-arrow { top: -4px; left: calc(50% - 5px); }

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  width: min(356px, calc(100vw - 2rem));
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--depth-floating);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  animation: in-rise-in var(--duration-fast) var(--ease-out-strong);
}
.toast > svg, .toast > .spinner { width: var(--icon-md); height: var(--icon-md); flex-shrink: 0; margin-top: 2px; }
.toast-title { margin: 0; font-weight: var(--weight-medium); }
.toast-description { margin: 0; color: var(--muted-foreground); }

/* ==========================================================================
   Banner — a full-width strip above the app for something the user must
   not mistake for part of the page (impersonation, outage, read-only).
   ========================================================================== */
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1-5) var(--space-3);
  border-bottom: 1px solid var(--banner-warning-border);
  background: var(--banner-warning-bg);
  color: var(--banner-warning-ink);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
}

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty {
  display: flex;
  min-height: 60vh;
  align-items: center;
  justify-content: center;
  padding: 48px var(--space-2);
}
.empty-inner { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); max-width: 384px; }
.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--muted);
  color: var(--muted-foreground);
}
.empty-icon > svg { width: 20px; height: 20px; }
.empty-title { margin: 0; font-size: var(--text-base); font-weight: var(--weight-medium); line-height: var(--leading-snug); }
.empty-description { margin: var(--space-1) 0 0; color: var(--muted-foreground); font-size: var(--text-sm); line-height: var(--leading-sm); }
.empty-action { margin-top: var(--space-2); }

/* ==========================================================================
   Loading
   ========================================================================== */
/* A single block (a number, an avatar): a gentle pulse. */
.skeleton {
  border-radius: var(--radius-md);
  background: var(--muted);
  animation: in-pulse 2s ease-in-out infinite;
}
/* Rows in a loading list: a faint band sweeps a muted base — reads as
   working, not blinking. */
.skeleton-shimmer {
  border-radius: var(--radius-md);
  background-color: color-mix(in oklch, var(--muted) 50%, transparent);
  background-image: linear-gradient(90deg, transparent 0%,
    color-mix(in oklch, var(--foreground) 4%, transparent) 50%, transparent 100%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: in-shimmer 1.6s ease-in-out infinite;
}
@keyframes in-shimmer {
  0% { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}
/* Status text while something is thinking ("Exploring the checkout…"). */
.thinking {
  background: linear-gradient(90deg,
    color-mix(in oklab, var(--muted-foreground) 45%, transparent) 0%,
    color-mix(in oklab, var(--muted-foreground) 90%, transparent) 50%,
    color-mix(in oklab, var(--muted-foreground) 45%, transparent) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: in-thinking 2.5s linear infinite;
}
@keyframes in-thinking {
  0% { background-position: 200% 0; }
  100% { background-position: 0% 0; }
}

/* ==========================================================================
   Stat
   ========================================================================== */
.stat-label { color: var(--muted-foreground); font-size: var(--text-sm); line-height: var(--leading-sm); }
.stat-value-row { display: flex; align-items: baseline; gap: var(--space-2); margin-top: var(--space-1); }
.stat-value { font-size: var(--text-2xl); font-weight: var(--weight-semibold); line-height: 2rem; font-variant-numeric: tabular-nums; }
.stat-hint { color: var(--muted-foreground); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Page header
   ========================================================================== */
.page-header { display: grid; gap: var(--space-2); margin-bottom: var(--space-8); }
.page-header-row { display: flex; flex-direction: column; gap: var(--space-4); }
@media (min-width: 640px) { .page-header-row { flex-direction: row; align-items: center; justify-content: space-between; } }
.page-eyebrow, .page-description { margin: 0; color: var(--muted-foreground); font-size: var(--text-sm); line-height: var(--leading-sm); }
.page-title { min-width: 0; margin: 0; font-size: var(--text-base); font-weight: var(--weight-medium); line-height: var(--leading-snug); }
.page-actions { display: flex; align-items: center; gap: var(--space-2); }

/* ==========================================================================
   Lists
   ========================================================================== */
/* The bar at the top of a pane: title left, actions right. The right inset
   is tighter because the actions are buttons with their own padding. */
.pane-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: var(--bar-pane);
  padding: 0 var(--space-1-5) 0 var(--space-3);
  border-bottom: 1px solid color-mix(in oklch, var(--border) 60%, transparent);
}
@media (min-width: 768px) { .pane-header { padding-left: var(--space-4); } }
.pane-title { min-width: 0; margin: 0; overflow: hidden; font-size: var(--text-sm); font-weight: var(--weight-medium); text-overflow: ellipsis; white-space: nowrap; }
.pane-actions { display: flex; flex-shrink: 0; align-items: center; gap: var(--space-1-5); }

/* A collapsible group. Markup: <section><button class="list-group-header"
   aria-expanded="true"><svg class="chevron">…</svg><span
   class="list-group-label">Today</span><span class="list-group-count">4</span>
   </button><ul class="list">…</ul></section> */
.list-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--muted);
  color: var(--muted-foreground);
  font: var(--weight-regular) var(--text-xs) / var(--leading-xs) var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms;
}
.list-group-header:hover { background: color-mix(in oklch, var(--muted) 80%, transparent); }
.list-group-header .chevron { width: var(--icon-sm); height: var(--icon-sm); flex-shrink: 0; transition: rotate 150ms; }
.list-group-header[aria-expanded="true"] .chevron { rotate: 90deg; }
.list-group-label { color: var(--foreground); font-size: var(--text-sm); }
.list-group-count { font-variant-numeric: tabular-nums; }
.list-group-end { margin-left: auto; }
.list { margin: 2px 0 0; padding: 0; list-style: none; }
.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  color: inherit;
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  text-decoration: none;
  transition: background-color 150ms;
}
:is(a, button).list-row, .list-row[role="button"], .list-row[role="option"], .list-row.is-interactive { cursor: pointer; }
:is(a, button).list-row:hover, .list-row[role="button"]:hover, .list-row[role="option"]:hover, .list-row.is-interactive:hover {
  background: color-mix(in oklch, var(--muted) 50%, transparent);
}
.list-row[aria-selected="true"], .list-row[aria-current] { background: color-mix(in oklch, var(--muted) 60%, transparent); }
.list-row-meta { margin-left: auto; color: var(--muted-foreground); font-size: var(--text-xs); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ==========================================================================
   Navigation
   ========================================================================== */
.nav { display: flex; flex-direction: column; padding: 0 var(--space-2) var(--space-4); }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  width: 100%;
  margin-bottom: 2px;
  padding: var(--space-1-5) var(--space-2);
  border: 0;
  border-radius: var(--radius-nav);
  background: transparent;
  color: var(--muted-foreground);
  font: var(--weight-regular) var(--text-sm) / var(--leading-sm) var(--font-sans);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nav-item > svg { width: var(--icon-sm); height: var(--icon-sm); flex-shrink: 0; }
.nav-item:hover, .nav-item[aria-current="page"] { background: var(--sidebar-accent); color: var(--foreground); }
.nav-group-label { margin: var(--space-4) 0 var(--space-1); padding: 0 var(--space-2); color: var(--muted-foreground); font-size: var(--text-xs); font-weight: var(--weight-medium); }

/* ==========================================================================
   App shell — see patterns/app-shell.md
   ========================================================================== */
.app-shell {
  display: flex;
  height: 100svh;
  overflow: hidden;
  background: var(--background);
  color: var(--foreground);
}
.app-sidebar { display: none; flex-direction: column; flex-shrink: 0; width: var(--sidebar-width); }
.app-sidebar-head { display: flex; align-items: center; gap: var(--space-2); height: var(--bar-app); padding: 0 var(--space-2); }
.app-main { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.app-mobile-bar { display: flex; flex-shrink: 0; align-items: center; gap: var(--space-2); height: var(--bar-app); padding: 0 var(--space-3); }
/* The only thing that scrolls. Both overflow axes set: setting one makes the
   other auto, and a few stray pixels would let the page pan sideways. */
.app-panel { flex: 1; min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; }
@media (min-width: 768px) {
  .app-shell { background: color-mix(in oklch, var(--muted) 40%, var(--background)); }
  .app-sidebar { display: flex; }
  .app-mobile-bar { display: none; }
  .app-main { padding: var(--space-3) var(--space-3) var(--space-3) 0; }
  .app-panel { border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--depth-panel); }
}
/* Key this on the SECTION that changed, not the full URL. */
.route-enter { animation: in-rise-in var(--duration-base) ease-out; }

/* Page content inside the panel. */
.page { width: 100%; margin: 0 auto; padding: var(--space-10) var(--space-4); }
@media (min-width: 768px) { .page { padding-inline: var(--space-6); } }
.page-narrow { max-width: 672px; }
.page-settings { max-width: 896px; }
@media (min-width: 768px) { .page-settings { padding-inline: var(--space-10); } }

/* ---- Separator, table, kbd ------------------------------------------------ */
.separator { height: 1px; margin: 0; border: 0; background: var(--border); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: var(--leading-sm); }
.table th { padding: var(--space-2) var(--space-4); color: var(--muted-foreground); font-weight: var(--weight-medium); text-align: left; white-space: nowrap; }
.table td { padding: var(--space-4); vertical-align: middle; white-space: nowrap; }
.table tr { border-bottom: 1px solid color-mix(in oklch, var(--border) 80%, transparent); }
.table tbody tr:last-child { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }
.kbd {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--muted-foreground);
  font: var(--weight-medium) var(--text-xs) / 1 var(--font-sans);
}

/* ---- Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .btn, .chip, .tab, .switch::before, .tabs-indicator, .tab-panel, .list-group-header .chevron { transition: none; }
  .dialog[open], .menu, .tooltip, .toast, .route-enter,
  .skeleton, .skeleton-shimmer, .thinking, .badge-live .dot { animation: none; }
}
