/* =============================================================================
   Aegis components: the shared parts every page is built from, on tokens.css (--ag-*) only.
   Direction (REBRAND.md): a dark, quiet, precise tool. Near-black canvas, grey panels, 1px lines; one blue
   accent for the primary action, selection and live data; Geist for text and figures, Geist Mono for small
   uppercase labels; 4px grid; 120 to 160ms ease, no bounce, no glow.
   1. base  2. layout  3. controls (.ui-*)  4. feedback (.ui-*)  5. tool parts (.ag-*)
   The .ui-* class names are kept from the earlier kit (pages and scripts use them); .ag-* are new.
   ========================================================================== */

/* ---------- 1. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scrollbar-gutter: stable; background: var(--ag-canvas);
  scrollbar-color: var(--ag-line-strong) transparent; }
body { margin: 0; background: var(--ag-canvas); color: var(--ag-text); font: var(--ag-t-body); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden; }
button, input, select, textarea { margin: 0; font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, h4 { letter-spacing: var(--ag-track-heading); }
h1 { letter-spacing: var(--ag-track-h1); }
code, kbd, samp, pre, .sc-mono { font-family: var(--ag-mono); text-transform: none; }
::placeholder { color: var(--ag-text-4); opacity: 1; }
::selection { background: var(--ag-blue-select-bg); color: var(--ag-text); }
button:not(:disabled) { cursor: pointer; }
button:focus:not(:focus-visible) { outline: 0; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: var(--ag-focus); outline-offset: var(--ag-focus-offset); }
/* Scrollbars: thin, a grey thumb on no track. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ag-line-strong); border: 3px solid transparent; border-radius: 10px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--ag-text-off); }
::-webkit-scrollbar-corner { background: transparent; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }

/* ---------- 2. Layout ---------- */
/* Header: the bar itself (the app shell in app.css places what goes in it). */
.ui-header { position: sticky; top: 0; z-index: var(--ag-z-header); display: flex; align-items: center; justify-content: space-between; min-height: var(--ag-header-h); padding: 0 var(--ag-page-pad); }
.ui-header::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--ag-canvas); border-bottom: 1px solid transparent; transition: border-color var(--ag-dur) var(--ag-ease); }
.ui-header__row { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: var(--ag-s-3); }
.ui-header__left, .ui-header__right, .ui-header__nav { display: flex; align-items: center; }
.ui-header__left { gap: var(--ag-s-2); flex-shrink: 0; min-width: 0; }
.ui-header__right { gap: var(--ag-s-3); justify-content: end; flex-shrink: 0; }
.ui-nav-item { display: flex; gap: 8px; align-items: center; color: var(--ag-text-2); font: var(--ag-t-body-m); text-decoration: none; white-space: nowrap; transition: color var(--ag-dur) var(--ag-ease); }
.ui-nav-item:hover, .ui-nav-item.is-active { color: var(--ag-text); }

/* Page container: content width with the page padding on each side. */
.ui-page { width: 100%; max-width: calc(var(--ag-page-w) + 2 * var(--ag-page-pad)); margin: 0 auto; padding: 0 var(--ag-page-pad); }

/* Panel / card: grey on the canvas with a hairline. */
.ui-card { background: var(--ag-panel); border: 1px solid var(--ag-line); border-radius: var(--ag-r-panel); padding: var(--ag-panel-pad); }
.ui-card--soft { border-radius: var(--ag-r-panel); }
.ui-card--subtle { background: var(--ag-raised); }
.ui-card__title { font: var(--ag-t-body-m); margin: 0 0 var(--ag-s-3); }

/* Table: mono header labels, 15px cells, hairline rows, figures right-aligned. Bleeds 16px each side so
   the text lines up with the panel's content. */
.ui-table { width: calc(100% + 32px); margin: 0 -16px; border-collapse: collapse; font: var(--ag-t-body); font-variant-numeric: tabular-nums; }
.ui-table th { height: 36px; padding: 8px 16px; text-align: left; vertical-align: middle; font: var(--ag-t-label); letter-spacing: var(--ag-track-label); text-transform: uppercase; color: var(--ag-text-3); border-bottom: 1px solid var(--ag-line-faint); white-space: nowrap; }
.ui-table td { padding: 12px 16px; vertical-align: top; font: var(--ag-t-body); color: var(--ag-text); border-bottom: 1px solid var(--ag-line-faint); overflow-wrap: break-word; }
.ui-table tbody tr:last-child td { border-bottom: 0; }
.ui-table td.middle { vertical-align: middle; }
.ui-table--dense td { padding: 4px; }
.ui-table tbody tr { cursor: pointer; transition: background-color var(--ag-dur-fast) var(--ag-ease); }
.ui-table tbody tr:hover td { background: var(--ag-raised); }
.ui-table tbody tr:hover td:first-child { border-radius: var(--ag-r-row) 0 0 var(--ag-r-row); }
.ui-table tbody tr:hover td:last-child { border-radius: 0 var(--ag-r-row) var(--ag-r-row) 0; }
.ui-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Overlay backdrop and scroll lock */
.ui-backdrop { position: fixed; inset: 0; z-index: var(--ag-z-modal); background-color: var(--ag-scrim); overscroll-behavior: contain; }
html.ui-scroll-lock { overscroll-behavior: none; scrollbar-gutter: stable; }
html.ui-scroll-lock body { overflow: hidden !important; overscroll-behavior: none; }

/* Data display helpers */
.ui-pos { color: var(--ag-green); }
.ui-neg { color: var(--ag-red); }
.ui-rank-delta { display: inline-block; padding: 2px 6px; border-radius: var(--ag-r-chip); font: var(--ag-t-small-m); white-space: nowrap; }
.ui-rank-delta.up { color: var(--ag-green); background: var(--ag-green-bg); }
.ui-rank-delta.down { color: var(--ag-red); background: var(--ag-red-bg); }
.ui-metric__label { display: flex; align-items: center; gap: 4px; font: var(--ag-t-label); letter-spacing: var(--ag-track-label); text-transform: uppercase; color: var(--ag-text-3); }
.ui-metric__value { font: var(--ag-t-figure); margin-top: var(--ag-s-2); }
.ui-address { font: var(--ag-t-code); color: var(--ag-text-2); }

/* ---------- 3. Controls ----------
   Heights: xs 28 · s 32 · m 36 · l and xl 48. Hover fades in 140ms; disabled = raised fill, dim text.
   Focus ring (base): 2px blue, 2px offset, keyboard only. */

/* Button */
.ui-btn { display: flex; justify-content: center; align-items: center; gap: 8px; width: auto; height: var(--ag-h-m); padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--ag-r-button); outline: none; cursor: pointer; user-select: none; text-decoration: none;
  font: var(--ag-t-body-m); background: var(--ag-blue); color: var(--ag-on-accent);
  transition: background-color var(--ag-dur) var(--ag-ease), border-color var(--ag-dur) var(--ag-ease), color var(--ag-dur) var(--ag-ease); }
.ui-btn:hover, .ui-btn:focus { text-decoration: none; }
.ui-btn:focus-visible { outline: var(--ag-focus); outline-offset: var(--ag-focus-offset); }
.ui-btn .sc-i { flex: none; }
.ui-btn.xs { height: var(--ag-h-xs); padding: 0 10px; font: var(--ag-t-small-m); }
.ui-btn.s  { height: var(--ag-h-s); padding: 0 12px; font: var(--ag-t-small-m); }
.ui-btn.m  { height: var(--ag-h-m); padding: 0 14px; font: var(--ag-t-body-m); }
.ui-btn.l  { height: var(--ag-h-cta); padding: 0 20px; font: var(--ag-t-body-m); border-radius: var(--ag-r-button-l); }
.ui-btn.xl { height: var(--ag-h-cta); padding: 0 24px; font: var(--ag-t-large-m); border-radius: var(--ag-r-cta); min-width: 148px; }
.ui-btn.full { width: 100%; } .ui-btn.contents { width: fit-content; }
.ui-btn.xs .sc-i, .ui-btn.s .sc-i { width: 16px; height: 16px; }
/* primary: the one blue action (the "constant white" variants from the earlier kit are the same now) */
.ui-btn.primary, .ui-btn.primary-constant-white { background: var(--ag-blue); color: var(--ag-on-accent); }
.ui-btn.primary:hover:not([disabled]), .ui-btn.primary-constant-white:hover:not([disabled]) { background: var(--ag-blue-hover); }
.ui-btn.primary:active:not([disabled]), .ui-btn.primary-constant-white:active:not([disabled]) { background: var(--ag-blue-press); }
/* secondary: grey */
.ui-btn.secondary, .ui-btn.secondary-constant-white, .ui-btn.inverted, .ui-btn.primary-constant-black, .ui-btn.secondary-inverted { background: var(--ag-overlay); color: var(--ag-text); }
.ui-btn:is(.secondary, .secondary-constant-white, .inverted, .primary-constant-black, .secondary-inverted):hover:not([disabled]) { background: var(--ag-overlay-hover); }
/* outline: a line, no fill */
.ui-btn.outline, .ui-btn.secondary-constant-black { background: transparent; border-color: var(--ag-line-strong); color: var(--ag-text); }
.ui-btn:is(.outline, .secondary-constant-black):hover:not([disabled]) { background: var(--ag-raised); }
/* ghost: text only */
.ui-btn.ghost { background: transparent; color: var(--ag-text-2); }
.ui-btn.ghost:hover:not([disabled]) { background: var(--ag-raised); color: var(--ag-text); }
/* danger */
.ui-btn.danger { background: var(--ag-red-strong); color: var(--ag-on-accent); }
.ui-btn.danger:hover:not([disabled]) { background: var(--ag-danger-hover); }
/* disabled: raised fill; a form CTA (xl, full) keeps its words readable, since it says what is missing */
.ui-btn[disabled], .ui-btn[aria-disabled="true"] { cursor: default; background: var(--ag-raised); border-color: transparent; color: var(--ag-text-off); }
.ui-btn:is(.xl, .full)[disabled] { color: var(--ag-text-4); }
a.ui-btn[disabled] { pointer-events: none; }

/* Icon button: square-rounded, icon 16 (s) or 24 */
.ui-icon-btn { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; border-radius: var(--ag-r-button); }
.ui-icon-btn > .ui-icon-btn__icon { display: flex; align-items: center; justify-content: center; border-radius: var(--ag-r-button); padding: var(--ui-icon-button-padding, 6px);
  background: var(--ag-overlay); color: var(--ag-text); transition: background-color var(--ag-dur) var(--ag-ease), color var(--ag-dur) var(--ag-ease); }
.ui-icon-btn.s > .ui-icon-btn__icon { padding: var(--ui-icon-button-padding, 4px); }
.ui-icon-btn.s > .ui-icon-btn__icon .sc-i { width: 16px; height: 16px; }
.ui-icon-btn.l > .ui-icon-btn__icon { padding: var(--ui-icon-button-padding, 10px); }
.ui-icon-btn.xl > .ui-icon-btn__icon { padding: var(--ui-icon-button-padding, 12px); }
.ui-icon-btn:hover:not([disabled]) > .ui-icon-btn__icon { background: var(--ag-overlay-hover); }
.ui-icon-btn.primary-inverted > .ui-icon-btn__icon { background: var(--ag-blue); color: var(--ag-on-accent); }
.ui-icon-btn.primary-inverted:hover:not([disabled]) > .ui-icon-btn__icon { background: var(--ag-blue-hover); }
.ui-icon-btn.secondary > .ui-icon-btn__icon, .ui-icon-btn.secondary-constant-white > .ui-icon-btn__icon { background: var(--ag-overlay); color: var(--ag-text); }
.ui-icon-btn:is(.ghost-secondary, .ghost-constant-white) > .ui-icon-btn__icon { background: transparent; color: var(--ag-text-3); }
.ui-icon-btn:is(.ghost-secondary, .ghost-constant-white):hover:not([disabled]) > .ui-icon-btn__icon { background: var(--ag-raised); color: var(--ag-text); }
.ui-icon-btn.raw > .ui-icon-btn__icon { background: transparent; padding: 0 !important; color: inherit; }
.ui-icon-btn.raw:hover:not([disabled]) > .ui-icon-btn__icon { background: transparent; color: var(--ag-text); }
.ui-icon-btn[disabled] { cursor: default; }
.ui-icon-btn[disabled] > .ui-icon-btn__icon { background: var(--ag-raised); color: var(--ag-text-off); }
.ui-icon-btn:focus-visible { outline: var(--ag-focus); outline-offset: var(--ag-focus-offset); }
.ui-icon { display: inline-block; width: 24px; height: 24px; flex: none; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.ui-icon.s { width: 16px; height: 16px; } .ui-icon.xs { width: 8px; height: 8px; } .ui-icon.l { width: 32px; height: 32px; } .ui-icon.xl { width: 40px; height: 40px; }

/* Text field: raised fill, 1px line, radius 12, 48px; the line turns blue on focus. Hooks: --input-*. */
.ui-input { display: flex; width: 100%; align-items: center; min-height: var(--input-min-height, var(--ag-h-cta)); padding: var(--input-padding, 11px 16px);
  background: var(--input-background, var(--ag-raised)); border: 1px solid var(--input-border, var(--ag-line)); border-radius: var(--input-radius, var(--ag-r-field)); color: var(--ag-text);
  transition: border-color var(--ag-dur) var(--ag-ease), background-color var(--ag-dur) var(--ag-ease); }
.ui-input:focus-within { border-color: var(--ag-blue); }
.ui-input > input { flex: 1; min-width: 0; border: none; background: none; color: var(--ag-text); outline: none; padding: 0 8px 0 0;
  font: var(--input-font, var(--ag-t-body)); height: var(--input-height, 24px); line-height: 1; overflow: hidden; text-overflow: ellipsis; }
.ui-input > input::placeholder { color: var(--ag-text-4); }
.ui-input > .sc-i:first-child, .ui-input > .ui-icon:first-child { color: var(--ag-text-3); margin-right: 8px; }
.ui-input .ui-input__paste { color: var(--ag-blue-text); font: var(--ag-t-small-m); border: none; background: none; cursor: pointer; padding: 0; }
.ui-input.pill-s { --input-padding: 11px 14px; --input-min-height: 44px; --input-height: 20px; }
.ui-input.pill-m { --input-padding: 11px 16px; --input-height: 24px; }
.ui-input-error { display: inline-flex; align-items: flex-start; gap: 4px; width: 100%; color: var(--ag-red); font: var(--ag-t-caption); }

/* Big amount field (swap form block): a sunken well inside a panel */
.ui-amount-block { background: var(--ag-sunken); border: 1px solid var(--ag-line-faint); border-radius: var(--ag-r-field); padding: var(--ag-s-4); display: grid; gap: var(--ag-s-2); }
.ui-amount-block__label { font: var(--ag-t-label); letter-spacing: var(--ag-track-label); text-transform: uppercase; color: var(--ag-text-3); }
.ui-amount-block__row { display: flex; align-items: center; justify-content: space-between; gap: var(--ag-s-4); }
.ui-amount-block__amount { font: var(--ag-t-figure); font-variant-numeric: tabular-nums; }
.ui-amount-block__amount small { font: inherit; color: var(--ag-text-3); margin-left: 12px; }
.ui-amount-block__fiat { font: var(--ag-t-small); color: var(--ag-text-3); }
.ui-amount-stack { display: grid; gap: 2px; position: relative; }
.ui-amount-stack__swap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

/* Filter / suggestion chips: pill, 13px; selected is grey-filled */
.ui-pill-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ui-pill { display: inline-flex; align-items: center; gap: 6px; height: var(--ag-h-s); padding: 0 12px; border: 1px solid var(--ag-line); border-radius: var(--ag-r-pill); white-space: nowrap;
  background: transparent; color: var(--ag-text-2); font: var(--ag-t-small-m); cursor: pointer;
  transition: background-color var(--ag-dur) var(--ag-ease), color var(--ag-dur) var(--ag-ease), border-color var(--ag-dur) var(--ag-ease); }
.ui-pill.s { height: var(--ag-h-xs); padding: 0 10px; font: var(--ag-t-caption); font-weight: var(--ag-w-medium); }
.ui-pill.l { height: var(--ag-h-m); padding: 0 14px; }
.ui-pill:hover:not([disabled]):not(.is-selected) { background: var(--ag-raised); color: var(--ag-text); }
.ui-pill.is-selected { background: var(--ag-overlay); border-color: transparent; color: var(--ag-text); }
.ui-pill[disabled] { color: var(--ag-text-off); cursor: not-allowed; }
.ui-pill__count { min-width: 1ch; text-align: center; color: var(--ag-text-3); font-variant-numeric: tabular-nums; }

/* Dropdown: compact trigger + floating menu */
.ui-dropdown { position: relative; display: inline-block; }
.ui-dropdown__trigger { display: flex; align-items: center; gap: 4px; height: var(--ag-h-s); padding: 0 8px 0 12px; background: var(--ag-raised); border: 1px solid var(--ag-line); border-radius: var(--ag-r-button);
  font: var(--ag-t-small-m); color: var(--ag-text); white-space: nowrap; cursor: pointer; transition: background-color var(--ag-dur) var(--ag-ease); }
.ui-dropdown__trigger:hover:not(:disabled) { background: var(--ag-overlay); }
.ui-dropdown__trigger:disabled { color: var(--ag-text-off); cursor: not-allowed; }
.ui-dropdown__label { color: var(--ag-text-3); }
.ui-dropdown__chevron { color: var(--ag-text-3); transition: transform var(--ag-dur) var(--ag-ease); } .ui-dropdown.is-open .ui-dropdown__chevron { transform: rotate(180deg); }
.ui-dropdown__menu, .ui-menu-panel { position: absolute; top: calc(100% + 6px); right: 0; min-width: 160px; max-height: 320px; overflow: auto; z-index: var(--ag-z-popover); padding: 4px;
  background: var(--ag-overlay); border: 1px solid var(--ag-line-strong); border-radius: var(--ag-r-field); box-shadow: var(--ag-shadow-float); scrollbar-width: thin; }
.ui-menu-panel { position: static; display: grid; }
.ui-dropdown__menu.left { right: auto; left: 0; }
.ui-dropdown__item, .ui-menu-panel a, .ui-menu-panel button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--ag-h-s); padding: 6px 10px; border: 0; border-radius: var(--ag-r-button);
  background: none; color: var(--ag-text-2); font: var(--ag-t-small); text-align: left; text-decoration: none; cursor: pointer; transition: background-color var(--ag-dur-fast) var(--ag-ease), color var(--ag-dur-fast) var(--ag-ease); }
.ui-dropdown__item:hover, .ui-dropdown__item.is-active, .ui-menu-panel a:hover, .ui-menu-panel button:hover { background: var(--ag-overlay-hover); color: var(--ag-text); }
.ui-dropdown__item[disabled] { color: var(--ag-text-off); cursor: not-allowed; }
@media (max-width: 600px) { .ui-dropdown__menu { max-width: calc(100vw - 32px); max-height: 50vh; } }

/* Listbox */
.ui-listbox { padding: 4px; display: block; }
.ui-option { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: var(--ag-h-m); padding: 6px 12px; border: 0; border-radius: var(--ag-r-button);
  background: transparent; color: var(--ag-text-2); font: var(--ag-t-body); cursor: pointer; }
.ui-option:hover, .ui-option[aria-selected="true"] { background: var(--ag-raised); color: var(--ag-text); }

/* Checkbox */
.ui-checkbox { position: relative; width: 20px; height: 20px; flex: none; border: 1px solid var(--ag-line-strong); border-radius: var(--ag-r-chip); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; background: var(--ag-sunken); color: var(--ag-on-accent); padding: 0;
  transition: background-color var(--ag-dur) var(--ag-ease), border-color var(--ag-dur) var(--ag-ease); }
.ui-checkbox[aria-checked="true"], .ui-checkbox[aria-checked="mixed"] { background: var(--ag-blue); border-color: var(--ag-blue); }
.ui-checkbox > .ui-icon, .ui-checkbox > .sc-i { width: 14px; height: 14px; visibility: hidden; }
.ui-checkbox[aria-checked="true"] > :is(.ui-icon, .sc-i), .ui-checkbox[aria-checked="mixed"] > :is(.ui-icon, .sc-i) { visibility: visible; }
.ui-checkbox:not([disabled]):hover { border-color: var(--ag-text-4); }
.ui-checkbox[disabled] { opacity: .5; cursor: not-allowed; }

/* Switch: m 44×26 · s 36×22 · xs 24×24 box with a 22×12 track. Off = grey track, on = blue. */
.ui-switch { position: relative; border-radius: var(--ag-r-pill); display: inline-block; flex: none; user-select: none; padding: 3px; margin: 0; cursor: pointer;
  width: 44px; height: 26px; background: var(--ag-line-strong); vertical-align: middle; transition: background-color var(--ag-dur) var(--ag-ease); }
.ui-switch > input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.ui-switch > .ui-switch__knob { display: block; position: relative; width: 20px; height: 20px; background: var(--ag-text); border-radius: 50%; transition: transform var(--ag-dur) var(--ag-ease-out); }
.ui-switch:has(input:checked) { background: var(--ag-blue); }
.ui-switch:has(input:checked) > .ui-switch__knob { transform: translate(18px); }
.ui-switch:has(input:checked):not(:has(input:disabled)):hover { background: var(--ag-blue-hover); }
.ui-switch:has(input:not(:checked)):not(:has(input:disabled)):hover { background: var(--ag-text-off); }
.ui-switch:has(input:focus-visible) { outline: var(--ag-focus); outline-offset: var(--ag-focus-offset); }
.ui-switch.s { width: 36px; height: 22px; } .ui-switch.s > .ui-switch__knob { width: 16px; height: 16px; }
.ui-switch.s:has(input:checked) > .ui-switch__knob { transform: translate(14px); }
.ui-switch.xs { width: 24px; height: 24px; padding: 0; background: transparent !important; }
.ui-switch.xs::before { content: ""; position: absolute; top: 6px; left: 1px; width: 22px; height: 12px; border-radius: var(--ag-r-pill); background: var(--ag-line-strong); }
.ui-switch.xs > .ui-switch__knob { position: absolute; top: 7px; left: 2px; width: 10px; height: 10px; }
.ui-switch.xs:has(input:checked)::before { background: var(--ag-blue); }
.ui-switch.xs:has(input:checked) > .ui-switch__knob { transform: translate(10px); }
.ui-switch:has(input:disabled) { cursor: default; background: var(--ag-raised); }
.ui-switch:has(input:disabled) > .ui-switch__knob { background: var(--ag-text-off); }
.ui-switch.xs:has(input:disabled)::before { background: var(--ag-raised); }

/* Segmented control: sunken track, 1px line, radius 10, 3px inset; the selected item is grey with a
   stronger line, radius 8. Sizes (outer height): s 32 · m (default) 36 · l 48. */
.ui-segmented { --seg-h: 28px; display: inline-grid; grid-auto-columns: max-content; grid-auto-flow: column; gap: var(--ui-segmented-gap, 2px); padding: 3px;
  background: var(--ag-sunken); border: 1px solid var(--ag-line); border-radius: var(--ag-r-seg); font: var(--ag-t-small-m); color: var(--ag-text-3); }
.ui-segmented.fill { display: grid; grid-auto-columns: 1fr; }
.ui-segmented__item { display: inline-flex; align-items: center; justify-content: center; height: var(--seg-h); padding: 0 14px; border: 1px solid transparent; border-radius: var(--ag-r-seg-item);
  background: none; font: inherit; color: inherit; text-align: center; white-space: nowrap; cursor: pointer; outline: none;
  transition: background-color var(--ag-dur) var(--ag-ease), color var(--ag-dur) var(--ag-ease), border-color var(--ag-dur) var(--ag-ease); }
.ui-segmented.s { --seg-h: 24px; } .ui-segmented.s .ui-segmented__item { padding: 0 10px; min-width: 40px; }
.ui-segmented.m .ui-segmented__item, .ui-segmented.sm .ui-segmented__item { min-width: 50px; }
.ui-segmented.sm .ui-segmented__item { padding: 0 16px; }
.ui-segmented.l { --seg-h: 40px; font: var(--ag-t-body-m); } .ui-segmented.l .ui-segmented__item { padding: 0 20px; }
.ui-segmented__item.is-selected, .ui-segmented__item[aria-pressed="true"], .ui-segmented__item[aria-checked="true"], .ui-segmented__item[aria-selected="true"] {
  cursor: default; background: var(--ag-overlay); border-color: var(--ag-line-strong); color: var(--ag-text); }
.ui-segmented__item:not(.is-selected):not([disabled]):hover { color: var(--ag-text-2); }
.ui-segmented__item[disabled] { cursor: not-allowed; color: var(--ag-text-off); }
.ui-segmented__item.is-selected[disabled] { background: var(--ag-raised); border-color: var(--ag-line); color: var(--ag-text-3); }
.ui-segmented__item:focus-visible { outline: var(--ag-focus); outline-offset: 0; }

/* Tabs: grey-filled (default) or text tabs; underline tabs (.ui-tab-group) */
.ui-tabs { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; overflow: auto hidden; scrollbar-width: none; }
.ui-tab { height: var(--ag-h-m); padding: 0 12px; border: 0; border-radius: var(--ag-r-button); background: transparent; color: var(--ag-text-3); font: var(--ag-t-small-m); white-space: nowrap; cursor: pointer;
  transition: background-color var(--ag-dur) var(--ag-ease), color var(--ag-dur) var(--ag-ease); }
.ui-tabs.s .ui-tab { height: var(--ag-h-xs); padding: 0 10px; }
.ui-tab:hover:not([disabled]) { color: var(--ag-text-2); }
.ui-tab[aria-selected="true"] { background: var(--ag-overlay); color: var(--ag-text); }
.ui-tabs.text { gap: 16px; }
.ui-tabs.text .ui-tab { padding: 0; height: auto; border-radius: 0; background: transparent; }
.ui-tabs.text .ui-tab[aria-selected="true"] { color: var(--ag-text); }
.ui-tab-group { display: flex; gap: 20px; border-bottom: 1px solid var(--ag-line-faint); }
.ui-tab-group > button, .ui-tab-group > a { position: relative; background: none; border: none; padding: 14px 0 12px; font: var(--ag-t-small-m); color: var(--ag-text-3); text-decoration: none; cursor: pointer;
  transition: color var(--ag-dur) var(--ag-ease); }
.ui-tab-group > :hover { color: var(--ag-text-2); }
.ui-tab-group > .is-active, .ui-tab-group > [aria-selected="true"] { color: var(--ag-text); }
.ui-tab-group > .is-active::after, .ui-tab-group > [aria-selected="true"]::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 1px; background: var(--ag-text); }

/* Sort header */
.ui-sort { display: inline-flex; align-items: center; gap: 4px; min-width: 0; margin: 0; padding: 0; border: none; background: none; font: inherit; color: inherit; text-transform: inherit; white-space: nowrap; cursor: pointer; user-select: none; }
.ui-sort .sc-i, .ui-sort .ui-icon { width: 12px; height: 12px; opacity: 0; transition: opacity var(--ag-dur) var(--ag-ease), transform var(--ag-dur) var(--ag-ease); }
.ui-sort:hover :is(.sc-i, .ui-icon) { opacity: .5; }
.ui-sort.is-active { color: var(--ag-text); } .ui-sort.is-active :is(.sc-i, .ui-icon) { opacity: 1; }
.ui-sort.is-asc :is(.sc-i, .ui-icon) { transform: rotate(180deg); }

/* Pagination */
.ui-pagination { display: flex; align-items: center; justify-content: center; gap: 8px; font: var(--ag-t-small); color: var(--ag-text-3); white-space: nowrap; }

/* ---------- 4. Feedback ---------- */

/* Badge / status chip: radius 6, 12px, tinted by meaning */
.ui-badge { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: var(--ui-badge-radius, var(--ag-r-chip)); white-space: nowrap;
  font: 500 var(--ag-fs-caption)/var(--ag-lh-caption) var(--ag-font); color: var(--ag-blue-select-text); background: var(--ag-blue-select-bg); }
.ui-badge.m { height: 24px; padding: 0 8px; font: var(--ag-t-small-m); }
.ui-badge.success { color: var(--ag-green); background: var(--ag-green-bg); }
.ui-badge.warning { color: var(--ag-yellow); background: var(--ag-yellow-bg); }
.ui-badge.danger, .ui-badge.danger-secondary { color: var(--ag-red); background: var(--ag-red-bg); }
.ui-badge.neutral { color: var(--ag-text-2); background: var(--ag-raised); box-shadow: inset 0 0 0 1px var(--ag-line); }

/* Tag (link chip) */
.ui-tag { display: inline-flex; align-items: center; gap: 6px; height: var(--ag-h-s); padding: 0 12px; border-radius: var(--ag-r-chip); background: var(--ag-raised); color: var(--ag-text);
  font: var(--ag-t-small-m); text-decoration: none; cursor: pointer; transition: background-color var(--ag-dur) var(--ag-ease); }
.ui-tag:hover { background: var(--ag-overlay); }
.ui-tag__count { color: var(--ag-text-3); }
.ui-tag.small { height: 22px; padding: 0 6px; color: var(--ag-text-3); font: var(--ag-t-caption); }

/* Tooltip / popover */
.ui-tooltip { display: inline-block; max-width: var(--ui-tooltip-width, 280px); padding: 6px 10px; border: 1px solid var(--ag-line-strong); border-radius: var(--ag-r-button);
  background: var(--ag-overlay); color: var(--ag-text); font: var(--ag-t-caption); box-shadow: var(--ag-shadow-float); }
.ui-tooltip.rich { padding: 12px 14px; border-radius: var(--ag-r-field); font: var(--ag-t-small); }

/* Dialog: a panel over a dim scrim; title left, a round close button in the corner, actions full width.
   Phones: a bottom sheet. */
.ui-dialog-backdrop { position: fixed; inset: 0; z-index: var(--ag-z-modal); background: var(--ag-scrim); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--ag-dur-slow) var(--ag-ease); }
.ui-dialog-backdrop.is-open { opacity: 1; }
.ui-dialog { position: relative; display: flex; flex-direction: column; align-items: stretch; text-align: left; width: min(480px, 100%); padding: 24px;
  background: var(--ag-panel); border: 1px solid var(--ag-line); border-radius: var(--ag-r-modal); box-shadow: var(--ag-shadow-float); }
.ui-dialog__close, .ui-dialog__back { position: absolute; top: 16px; z-index: 2; }
.ui-dialog__close { right: 16px; }
.ui-dialog__back { left: 16px; }
.ui-dialog__close .ui-icon-btn > .ui-icon-btn__icon, .ui-dialog__back .ui-icon-btn > .ui-icon-btn__icon { width: 28px; height: 28px; padding: 0; border-radius: 50%; background: var(--ag-overlay); color: var(--ag-text-2); }
.ui-dialog__close .ui-icon-btn:hover:not([disabled]) > .ui-icon-btn__icon, .ui-dialog__back .ui-icon-btn:hover:not([disabled]) > .ui-icon-btn__icon { background: var(--ag-overlay-hover); color: var(--ag-text); }
.ui-dialog__close .ui-icon-btn, .ui-dialog__back .ui-icon-btn { border-radius: 50%; }
.ui-dialog__close .sc-i, .ui-dialog__back .sc-i { width: 16px; height: 16px; }
.ui-dialog__title { font: var(--ag-t-h4); letter-spacing: var(--ag-track-heading); margin: 0 0 var(--ag-s-2); padding-right: 40px; text-wrap: balance; }
.ui-dialog__text { font: var(--ag-t-body); color: var(--ag-text-2); margin: 0 0 var(--ag-s-5); }
.ui-dialog__actions { display: flex; gap: var(--ag-s-2); width: 100%; }
.ui-dialog__actions > .ui-btn { flex: 1 1 0; min-width: 0; }
@media (max-width: 600px) {
  .ui-dialog-backdrop { align-items: flex-end; }
  .ui-dialog { width: 100%; padding: 20px 16px; border-bottom: 0; border-radius: var(--ag-r-modal) var(--ag-r-modal) 0 0; }
  .ui-dialog__close { top: 14px; right: 12px; } .ui-dialog__back { top: 14px; left: 12px; }
}
.ui-dialog__timer { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--ag-line-strong); transform-origin: left; animation: ui-timer var(--ui-timer, 10s) linear forwards; }
@keyframes ui-timer { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Toast: a small floating panel; a coloured dot says what kind it is; a 2px bar runs out in 10s. */
.ui-toast { display: block; flex-shrink: 0; position: relative; overflow: hidden; max-width: 396px; padding: 12px 16px 14px 16px; cursor: pointer;
  background: var(--ag-overlay); border: 1px solid var(--ag-line-strong); border-radius: var(--ag-r-field); box-shadow: var(--ag-shadow-float); color: var(--ag-text); }
.ui-toast__row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.ui-toast__title { font: var(--ag-t-small-m); }
.ui-toast__sub { font: var(--ag-t-caption); color: var(--ag-text-3); }
.ui-toast__expire { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--ag-line-strong); transform-origin: left; animation: ui-toast-expire 10s linear forwards; }
@keyframes ui-toast-expire { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.ui-toast-stack { display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; max-width: 396px; }

/* Status message (notice): a quiet box; caution, error and success are tinted */
.ui-status { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--ag-raised); border: 1px solid var(--ag-line); border-radius: var(--ag-r-field); color: var(--ag-text); font: var(--ag-t-small); }
.ui-status > .sc-i, .ui-status > .ui-icon { flex: none; width: 16px; height: 16px; margin-top: 1px; color: var(--ag-text-3); }
.ui-status__title { margin-bottom: 4px; font: var(--ag-t-small-m); }
.ui-status__text { font: var(--ag-t-small); color: var(--ag-text-2); }
.ui-status__text b, .ui-status__text strong { color: var(--ag-text); font-weight: var(--ag-w-medium); }
.ui-status.info-static { background: var(--ag-raised); }
.ui-status.destructive { background: var(--ag-yellow-bg); border-color: color-mix(in srgb, var(--ag-yellow) 20%, transparent); }
.ui-status.destructive > :is(.sc-i, .ui-icon) { color: var(--ag-yellow); }
.ui-status.error { background: var(--ag-red-bg); border-color: color-mix(in srgb, var(--ag-red) 22%, transparent); }
.ui-status.error > :is(.sc-i, .ui-icon) { color: var(--ag-red); }
.ui-status:is(.positive, .success) { background: var(--ag-green-bg); border-color: color-mix(in srgb, var(--ag-green) 20%, transparent); }
.ui-status:is(.positive, .success) > :is(.sc-i, .ui-icon) { color: var(--ag-green); }

/* Empty state: a mono label and one quiet sentence */
.ui-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--ag-s-2); }
.ui-empty__art { width: 40px; height: 40px; color: var(--ag-text-3); }
.ui-empty__title { margin-top: var(--ag-s-2); font: var(--ag-t-label); letter-spacing: var(--ag-track-label); text-transform: uppercase; color: var(--ag-text); }
.ui-empty__sub { font: var(--ag-t-small); color: var(--ag-text-2); }
.ui-empty > .ui-btn { margin-top: var(--ag-s-4); }

/* Spinner */
.ui-spinner { --size: 20px; --thickness: 2px; --color: var(--ag-blue); --track-color: var(--ag-line); width: var(--size); height: var(--size); display: inline-block; }
.ui-spinner svg { width: 100%; height: 100%; animation: ui-spin var(--duration, .8s) linear infinite; }
.ui-spinner circle { fill: none; stroke-width: var(--thickness); }
.ui-spinner .track { stroke: var(--track-color); } .ui-spinner .arc { stroke: var(--color); stroke-dasharray: 60 40; stroke-linecap: round; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ui-spinner svg { animation-duration: 3s !important; animation-iteration-count: infinite !important; } }

/* Skeleton: apply to the real element while it loads, so nothing jumps */
.ui-shimmer { display: inline-block; position: relative; overflow: hidden; pointer-events: none; user-select: none; color: transparent !important;
  background: var(--ag-raised); border-radius: var(--ui-shimmer-radius, var(--ag-r-chip)); animation: ag-pulse 1.6s var(--ag-ease) infinite; }
.ui-shimmer > * { visibility: hidden; }

/* Media */
.ui-token-icon { position: relative; display: inline-flex; width: 1em; height: 1em; font-size: 32px; flex: none; }
.ui-token-icon > img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ui-token-icon__stub { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; background: var(--ag-overlay); color: var(--ag-text-2); font: 500 .4em/1 var(--ag-font); }
.ui-token-icon__chain { position: absolute; left: -2px; bottom: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--ag-canvas); display: grid; place-items: center; }
.ui-token-icon__chain > img { width: 14px; height: 14px; border-radius: 50%; }
.ui-avatar { display: inline-flex; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: var(--ag-raised); flex: none; }
.ui-avatar > img, .ui-avatar > canvas { width: 100%; height: 100%; image-rendering: pixelated; }

/* ---------- 5. Tool parts (.ag-*): the vocabulary of the tool pages (REBRAND.md) ----------
   Pages build from these first and add page-specific rules in their own stylesheet. */

/* Mono label: 11px, 500, UPPERCASE, wide tracking ("LOCK", "EST. APR", "ON 25 DEC 26"). */
.ag-label { margin: 0; font: var(--ag-t-label); letter-spacing: var(--ag-track-label); text-transform: uppercase; color: var(--ag-text-3); }
.ag-label--strong { color: var(--ag-text); }
/* Mono message (error / empty states): 13px uppercase */
.ag-message { margin: 0; font: 500 var(--ag-fs-small)/var(--ag-lh-small) var(--ag-mono); letter-spacing: var(--ag-track-label); text-transform: uppercase; color: var(--ag-text); }
/* BETA-style flag: mono 10px, 1px strong line, radius 3 */
.ag-flag { display: inline-flex; align-items: center; height: 15px; padding: 0 4px; border: 1px solid var(--ag-line-strong); border-radius: var(--ag-r-flag);
  font: 500 10px/1 var(--ag-mono); letter-spacing: var(--ag-track-label); text-transform: uppercase; color: var(--ag-text-3); white-space: nowrap; vertical-align: middle; }
/* Figures */
.ag-num { font-variant-numeric: tabular-nums; }
.ag-figure { font: var(--ag-t-figure); letter-spacing: var(--ag-track-h1); font-variant-numeric: tabular-nums; color: var(--ag-text); }
.ag-figure.is-empty, .ag-figure:has(input:placeholder-shown) { color: var(--ag-text-3); }
.ag-figure input { width: 100%; min-width: 0; padding: 0; border: 0; background: none; outline: none; font: inherit; letter-spacing: inherit; color: inherit; }
.ag-fiat { font: var(--ag-t-small); color: var(--ag-text-3); font-variant-numeric: tabular-nums; }
.ag-muted { color: var(--ag-text-2); }
.ag-faint { color: var(--ag-text-3); }
/* Text link: blue text */
.ag-link { color: var(--ag-blue-text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--ag-blue-text) 35%, transparent); text-underline-offset: 3px;
  transition: text-decoration-color var(--ag-dur) var(--ag-ease), color var(--ag-dur) var(--ag-ease); }
.ag-link:hover { text-decoration-color: currentColor; }

/* Page header: title (25 to 30px), lead, actions */
.ag-title { margin: 0; font: var(--ag-t-h2); letter-spacing: var(--ag-track-h1); color: var(--ag-text); text-wrap: balance; }
.ag-lead { margin: 0; max-width: 640px; font: var(--ag-t-body); color: var(--ag-text-2); text-wrap: pretty; }
@media (max-width: 600px) { .ag-title { font: var(--ag-t-h3); } }

/* Panel: --ag-panel, 1px line, radius 14; an optional head row with a mono label left and mono meta right */
.ag-panel { background: var(--ag-panel); border: 1px solid var(--ag-line); border-radius: var(--ag-r-panel); padding: var(--ag-panel-pad); }
.ag-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--ag-s-3); margin-bottom: var(--ag-s-3); }
.ag-panel__head > .ag-label:last-child:not(:first-child) { text-align: right; }

/* Action card (swap / send style): centred, 440px, radius 20, padding 20, no visible border */
.ag-card { width: min(100%, var(--ag-card-w)); margin: 0 auto; background: var(--ag-panel); border: 1px solid var(--ag-line-faint); border-radius: var(--ag-r-card); padding: var(--ag-panel-pad); }

/* Amount input well: sunken, radius 12; mono label, 40px figure, fiat under it, token pill right */
.ag-well { display: grid; gap: 6px; padding: 14px 16px 16px; background: var(--ag-sunken); border: 1px solid var(--ag-line); border-radius: var(--ag-r-field); }
.ag-well__row { display: flex; align-items: center; justify-content: space-between; gap: var(--ag-s-3); }

/* Inset field (as "SEND TO"): sunken, 1px line, radius 12; mono label inside; 15px input */
.ag-inset { display: grid; gap: 6px; padding: 12px 16px; background: var(--ag-sunken); border: 1px solid var(--ag-line); border-radius: var(--ag-r-field); transition: border-color var(--ag-dur) var(--ag-ease); }
.ag-inset:focus-within { border-color: var(--ag-blue); }
.ag-inset :is(input, textarea, select) { width: 100%; min-width: 0; padding: 0; border: 0; background: none; outline: none; font: var(--ag-t-body); color: var(--ag-text); }
.ag-inset textarea { resize: vertical; }

/* Search field (picker): 48px, radius 12, strong line, icon left */
.ag-search { display: flex; align-items: center; gap: 10px; height: var(--ag-h-cta); padding: 0 14px; border: 1px solid var(--ag-line-strong); border-radius: var(--ag-r-field); background: transparent; color: var(--ag-text-3);
  transition: border-color var(--ag-dur) var(--ag-ease); }
.ag-search:focus-within { border-color: var(--ag-blue); }
.ag-search input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; outline: none; font: var(--ag-t-body); color: var(--ag-text); }
.ag-search input::-webkit-search-cancel-button { display: none; }

/* Quick-pick chips (25% / 50% / Max): 1px line, radius 6, 13px */
.ag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-chip { display: inline-flex; align-items: center; justify-content: center; height: var(--ag-h-xs); padding: 0 10px; border: 1px solid var(--ag-line); border-radius: var(--ag-r-chip);
  background: transparent; color: var(--ag-text-3); font: var(--ag-t-small); white-space: nowrap; cursor: pointer;
  transition: color var(--ag-dur) var(--ag-ease), border-color var(--ag-dur) var(--ag-ease), background-color var(--ag-dur) var(--ag-ease); }
.ag-chip:hover:not(:disabled) { color: var(--ag-text-2); border-color: var(--ag-line-strong); }
.ag-chip:is([aria-pressed="true"], .is-selected) { color: var(--ag-text); border-color: var(--ag-line-strong); background: var(--ag-raised); }
.ag-chip:disabled { color: var(--ag-text-off); cursor: default; }
/* Status chip ("44.3% apr"): tinted */
.ag-tint { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: var(--ag-r-chip); font: var(--ag-t-small-m); font-variant-numeric: tabular-nums; background: var(--ag-raised); color: var(--ag-text-2); }
.ag-tint.is-up { background: var(--ag-green-bg); color: var(--ag-green); }
.ag-tint.is-down { background: var(--ag-red-bg); color: var(--ag-red); }
.ag-tint.is-warn { background: var(--ag-yellow-bg); color: var(--ag-yellow); }
.ag-tint.is-info { background: var(--ag-blue-select-bg); color: var(--ag-blue-select-text); }

/* Token pill: 1px strong line, radius 16, 24px icon, chevron; empty = blue "Select token" */
.ag-pill { display: inline-flex; align-items: center; gap: 8px; height: var(--ag-h-m); padding: 0 10px 0 6px; border: 1px solid var(--ag-line-strong); border-radius: 18px; background: transparent;
  color: var(--ag-text); font: var(--ag-t-body-m); white-space: nowrap; cursor: pointer; transition: background-color var(--ag-dur) var(--ag-ease); }
.ag-pill:hover { background: var(--ag-raised); }
.ag-pill img, .ag-pill .ui-token-icon { width: 24px; height: 24px; font-size: 24px; border-radius: 50%; flex: none; }
.ag-pill .sc-i { width: 16px; height: 16px; color: var(--ag-text-3); }
.ag-pill--empty { padding: 0 10px 0 14px; border-color: transparent; background: var(--ag-blue); color: var(--ag-on-accent); }
.ag-pill--empty:hover { background: var(--ag-blue-hover); }
.ag-pill--empty .sc-i { color: currentColor; }

/* Square switch button (between SELL and BUY): 32px, radius 8, strong line, raised */
.ag-switch { display: inline-grid; place-items: center; width: var(--ag-h-s); height: var(--ag-h-s); padding: 0; border: 1px solid var(--ag-line-strong); border-radius: var(--ag-r-button);
  background: var(--ag-raised); color: var(--ag-text-2); cursor: pointer; transition: color var(--ag-dur) var(--ag-ease), background-color var(--ag-dur) var(--ag-ease); }
.ag-switch:hover { color: var(--ag-text); background: var(--ag-overlay); }
.ag-switch .sc-i { width: 16px; height: 16px; }

/* Dividers: hairline, or dashed for scenario separators and chart guides */
.ag-divider { height: 0; margin: 0; border: 0; border-top: 1px solid var(--ag-line-faint); }
.ag-divider--line { border-top-color: var(--ag-line); }
.ag-divider--dashed { border-top: 1px dashed var(--ag-line-strong); }

/* Selectable list (strikes, tokens, routes): 42px rows, figure left at 17px, meta right at 13px;
   the selected row is white with a 1px light outline, radius 10. */
.ag-list { display: grid; margin: 0; padding: 0; list-style: none; }
.ag-row { display: flex; align-items: center; justify-content: space-between; gap: var(--ag-s-3); width: 100%; min-height: var(--ag-h-row); padding: 0 12px; margin: 0;
  border: 1px solid transparent; border-radius: var(--ag-r-row); background: transparent; color: var(--ag-text-3); font: var(--ag-t-large-m); font-variant-numeric: tabular-nums; text-align: left; text-decoration: none; cursor: pointer;
  transition: color var(--ag-dur) var(--ag-ease), border-color var(--ag-dur) var(--ag-ease), background-color var(--ag-dur) var(--ag-ease); }
.ag-row:hover { color: var(--ag-text-2); }
.ag-row:is([aria-selected="true"], [aria-current]:not([aria-current="false"]), [aria-pressed="true"], .is-selected) { color: var(--ag-text); border-color: var(--ag-line-heavy); }
.ag-row__meta { font: var(--ag-t-small); color: var(--ag-text-3); white-space: nowrap; }
.ag-row:is([aria-selected="true"], .is-selected) .ag-row__meta { color: var(--ag-text-2); }
/* Index row (Learn topics, picker rows): 56px, title 15px, note 13px, chevron right */
.ag-row--index { min-height: var(--ag-h-row-l); padding: 8px 12px; font: var(--ag-t-body-m); color: var(--ag-text); border-radius: var(--ag-r-field); }
.ag-row--index:hover { background: var(--ag-raised); color: var(--ag-text); }
.ag-row__main { display: grid; gap: 2px; min-width: 0; }
.ag-row__note { font: var(--ag-t-small); color: var(--ag-text-3); }
.ag-row > .sc-i:last-child { flex: none; width: 16px; height: 16px; color: var(--ag-text-4); }
.ag-list--lined > * + * { border-top: 1px solid var(--ag-line-faint); }

/* Facts / scenario rows (like "ON 25 DEC 26 / Above $1,670 / Below $1,670"): a mono head over a hairline,
   rows split by dashed lines; each row a small label, a 15 to 17px value and an optional mono tag right. */
.ag-facts { display: grid; margin: 0; }
.ag-facts__head { padding: 0 0 10px; border-bottom: 1px solid var(--ag-line); }
.ag-facts > div, .ag-fact { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 4px 12px; padding: 12px 0; }
.ag-facts > div + div, .ag-fact + .ag-fact { border-top: 1px dashed var(--ag-line-strong); }
.ag-facts dt, .ag-fact__k { font: var(--ag-t-caption); color: var(--ag-text-2); }
.ag-facts dd, .ag-fact__v { grid-column: 1; margin: 0; font: var(--ag-t-body-m); color: var(--ag-text); font-variant-numeric: tabular-nums; }
.ag-facts .ag-label, .ag-fact .ag-label { grid-column: 2; grid-row: 1; justify-self: end; }
/* Meta row (quiet row of mono-labelled items, as under the options chart) */
.ag-meta { display: flex; flex-wrap: wrap; gap: var(--ag-s-3) var(--ag-s-8); margin: 0; padding: 0; list-style: none; }
.ag-meta > * { display: grid; gap: 4px; min-width: 0; }
.ag-meta dd { margin: 0; font: var(--ag-t-body-m); color: var(--ag-text); }

/* Empty, error and loading states: mono message, one quiet sentence, then (optionally) a full-width button */
.ag-state { display: grid; justify-items: center; align-content: center; gap: 6px; padding: 40px 20px; text-align: center; }
.ag-state__text { margin: 0; max-width: 360px; font: var(--ag-t-small); color: var(--ag-text-2); }
.ag-state > .ui-btn, .ag-state > .ag-actions { margin-top: var(--ag-s-5); }
.ag-state > .ui-btn.full { width: 100%; }
.ag-loading { display: inline-flex; align-items: center; gap: 8px; font: var(--ag-t-small); color: var(--ag-text-3); }
.ag-loading::before { content: ""; width: 14px; height: 4px; flex: none;
  background: radial-gradient(circle, currentColor 1.5px, transparent 2px) 0 50% / 5px 4px repeat-x; animation: ag-pulse 1.2s var(--ag-ease) infinite; }
/* Skeleton block */
.ag-skel { display: block; height: 12px; margin: 4px 0; border-radius: var(--ag-r-chip); background: var(--ag-raised); animation: ag-pulse 1.6s var(--ag-ease) infinite; }
@keyframes ag-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .ag-skel, .ag-loading::before, .ui-shimmer { animation: none; } }

/* Actions row */
.ag-actions { display: flex; flex-wrap: wrap; gap: var(--ag-s-2); }

/* Reading column (Learn, Security, research): 720px, 17/28 body in secondary grey, headings white,
   a mono label above each h2, code in Geist Mono on a raised chip. */
.ag-read { max-width: var(--ag-read-w); font: var(--ag-t-read); color: var(--ag-text-2); }
.ag-read :is(h2, h3, h4) { color: var(--ag-text); }
.ag-read h2 { margin: var(--ag-s-12) 0 var(--ag-s-3); font: var(--ag-t-h3); }
.ag-read h3 { margin: var(--ag-s-8) 0 var(--ag-s-2); font: var(--ag-t-h4); }
.ag-read p, .ag-read ul, .ag-read ol { margin: 0 0 var(--ag-s-4); }
.ag-read :is(strong, b) { color: var(--ag-text); font-weight: var(--ag-w-medium); }
.ag-read a:not([class]) { color: var(--ag-blue-text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--ag-blue-text) 35%, transparent); text-underline-offset: 3px; }
.ag-read a:not([class]):hover { text-decoration-color: currentColor; }
.ag-read :not(pre) > code { padding: 1px 5px; border-radius: 4px; background: var(--ag-raised); color: var(--ag-text); font-size: .86em; }
.ag-read pre { margin: 0 0 var(--ag-s-4); padding: 14px 16px; overflow-x: auto; background: var(--ag-sunken); border: 1px solid var(--ag-line); border-radius: var(--ag-r-field); font: var(--ag-t-code); color: var(--ag-text); }
@media (max-width: 600px) { .ag-read { font: var(--ag-t-body); } .ag-read h2 { font: var(--ag-t-h4); margin-top: var(--ag-s-10); } }
