/* Likelihood design system: tokens, base type, primitives (buttons, segmented control, inputs, chips, tags),
   app chrome (header, nav, footer, modal, toasts) and skeletons. Screens live in launchpad.css.

   Type: the system stack (SF on Apple platforms), scale 34/28/22/17/15/13/11, tabular figures everywhere,
   600/700 headings and 400/500 body, -0.02em on large headings. Neutral greys, one accent, green = buy, red = sell.
   Spacing 4/8/12/16/24/32. Radii 10 (inputs, small), 16 (cards, buttons), 20 (panels, modal), pill for chips.
   Light palette on bare :root; dark from the OS unless the viewer picked light; an explicit dark pick wins too. */

:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', 'Segoe UI', Inter, Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', Inter, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  --t-xxl: 34px; --t-xl: 28px; --t-lg: 22px; --t-md: 17px; --t-base: 15px; --t-sm: 13px; --t-xs: 11px;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px;
  --r-sm: 10px; --r: 16px; --r-lg: 20px;
  --container: 1280px;
  --gutter: 20px;
  --header-h: 56px;
  --banner-h: 0px;
  --tabbar-h: 0px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.3, 0.64, 1);

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --surface-3: #e8e8ec;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --hairline: rgba(0, 0, 0, 0.1);
  --text: #1d1d1f;
  --text-2: #3f3f44;
  --muted: #65656b;
  --accent: #6a3df5;
  --accent-hover: #5b2ee6;
  --accent-ink: #5b2fe6;
  --accent-soft: rgba(106, 61, 245, 0.1);
  --on-accent: #ffffff;
  --sun: #ffd23f;
  --mark: rgba(255, 210, 63, 0.9);
  --pill-active: #ffffff;
  --yes: #15803d;
  --yes-bg: rgba(21, 128, 61, 0.1);
  --yes-bg-hover: rgba(21, 128, 61, 0.18);
  --buy: #15803d;
  --buy-hover: #166534;
  --no: #d92d20;
  --no-bg: rgba(217, 45, 32, 0.09);
  --no-bg-hover: rgba(217, 45, 32, 0.16);
  --sell: #d92d20;
  --sell-hover: #b42318;
  --warn: #9a5b00;
  --warn-bg: rgba(245, 165, 36, 0.16);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
  --card-border: rgba(0, 0, 0, 0.08);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  --lift: 0 12px 32px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.05);
  --thumb-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  --flash-up: rgba(21, 128, 61, 0.18);
  --flash-down: rgba(217, 45, 32, 0.16);
  --flash-chg: rgba(106, 61, 245, 0.14);
  --backdrop: rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0a0a0b;
    --surface: #151517;
    --surface-2: #1e1e21;
    --surface-3: #29292e;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);
    --hairline: rgba(255, 255, 255, 0.11);
    --text: #f5f5f7;
    --text-2: #c9c9ce;
    --muted: #9a9aa2;
    --accent: #7c5cff;
    --accent-hover: #8e71ff;
    --accent-ink: #b09bff;
    --accent-soft: rgba(142, 109, 255, 0.16);
    --on-accent: #ffffff;
    --mark: rgba(255, 210, 63, 0.4);
    --pill-active: #2c2c31;
    --yes: #4ade80;
    --yes-bg: rgba(74, 222, 128, 0.12);
    --yes-bg-hover: rgba(74, 222, 128, 0.2);
    --buy: #1f9e56;
    --buy-hover: #23b062;
    --no: #ff6b60;
    --no-bg: rgba(255, 107, 96, 0.12);
    --no-bg-hover: rgba(255, 107, 96, 0.2);
    --sell: #d93a30;
    --sell-hover: #e64a40;
    --warn: #fbbf24;
    --warn-bg: rgba(251, 191, 36, 0.14);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: none;
    --lift: 0 12px 32px rgba(0, 0, 0, 0.5);
    --thumb-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --flash-up: rgba(74, 222, 128, 0.2);
    --flash-down: rgba(255, 107, 96, 0.2);
    --flash-chg: rgba(142, 109, 255, 0.2);
    --backdrop: rgba(0, 0, 0, 0.65);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --surface: #151517;
  --surface-2: #1e1e21;
  --surface-3: #29292e;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --hairline: rgba(255, 255, 255, 0.11);
  --text: #f5f5f7;
  --text-2: #c9c9ce;
  --muted: #9a9aa2;
  --accent: #7c5cff;
  --accent-hover: #8e71ff;
  --accent-ink: #b09bff;
  --accent-soft: rgba(142, 109, 255, 0.16);
  --on-accent: #ffffff;
  --mark: rgba(255, 210, 63, 0.4);
  --pill-active: #2c2c31;
  --yes: #4ade80;
  --yes-bg: rgba(74, 222, 128, 0.12);
  --yes-bg-hover: rgba(74, 222, 128, 0.2);
  --buy: #1f9e56;
  --buy-hover: #23b062;
  --no: #ff6b60;
  --no-bg: rgba(255, 107, 96, 0.12);
  --no-bg-hover: rgba(255, 107, 96, 0.2);
  --sell: #d93a30;
  --sell-hover: #e64a40;
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-shadow: none;
  --lift: 0 12px 32px rgba(0, 0, 0, 0.5);
  --thumb-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --flash-up: rgba(74, 222, 128, 0.2);
  --flash-down: rgba(255, 107, 96, 0.2);
  --flash-chg: rgba(142, 109, 255, 0.2);
  --backdrop: rgba(0, 0, 0, 0.65);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; }
body {
  min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--t-base) / 1.47 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
}
/* sticky offsets account for the demo banner's real height */
body:has(.mode-banner:not(:empty)) { --banner-h: 27px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
p { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }
.pos { color: var(--yes); }
.neg { color: var(--no); }
.ic { flex: none; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
b { font-weight: 600; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
::selection { background: var(--accent-soft); }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.main { flex: 1; padding-block: var(--s4) var(--s8); }
.page-title { font-size: var(--t-xl); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); }
.section-head h2 { font-size: var(--t-md); }
.section-hint { color: var(--muted); font-size: var(--t-sm); }

/* page enter: a short fade + lift on each freshly routed screen */
.main > * { animation: page-in 0.16s var(--ease-out) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- surfaces ---------- */

.card { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--r); box-shadow: var(--card-shadow); padding: var(--s4); }
.note { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); font-size: var(--t-sm); line-height: 1.45; overflow-wrap: anywhere; }
.note .ic { margin-top: 2px; color: var(--muted); }
.note a { color: var(--accent-ink); font-weight: 600; }
.warn-inline { display: flex; gap: 6px; align-items: flex-start; color: var(--warn); font-size: var(--t-sm); line-height: 1.45; }
.banner { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r); border: 1px solid; margin-top: var(--s3); font-size: var(--t-sm); }
.banner > div { flex: 1; }
.banner-lost { background: var(--no-bg); border-color: var(--no); }

/* ---------- buttons: sm 32 / md 40 / lg 50 ---------- */

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 var(--s4); border-radius: 12px;
  font-weight: 600; font-size: var(--t-base); letter-spacing: -0.01em; white-space: nowrap; border: 1px solid transparent;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.12s var(--ease-out), opacity 0.15s, box-shadow 0.15s;
}
.btn-sm { height: 32px; padding: 0 var(--s3); font-size: var(--t-sm); border-radius: 9px; }
.btn-lg { height: 50px; padding: 0 var(--s6); font-size: 16px; font-weight: 700; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover:not(:disabled) { background: var(--surface-2); }
.btn-warn { background: var(--warn); color: #1b1300; }
.btn-yes { background: var(--buy); color: #fff; }
.btn-yes:hover:not(:disabled) { background: var(--buy-hover); }
.btn-no { background: var(--sell); color: #fff; }
.btn-no:hover:not(:disabled) { background: var(--sell-hover); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.is-loading { pointer-events: none; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; color: var(--muted); flex: none; transition: background-color 0.15s, color 0.15s, transform 0.12s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.link-btn { color: var(--accent-ink); font-weight: 600; font-size: var(--t-sm); }
.link-btn:hover { text-decoration: underline; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }

/* chips (filters, slippage, quick amounts) and tags */
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-weight: 600; font-size: var(--t-sm); white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.12s var(--ease-out);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.chip:active { transform: scale(0.96); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-sm { height: 30px; padding: 0 11px; font-size: var(--t-sm); }
.chip-input { padding-right: 8px; cursor: text; min-width: 0; }
.chip-input:active { transform: none; }
.chip-input input { width: 52px; font-size: var(--t-sm); background: transparent; border: 0; outline: 0; color: inherit; font: inherit; text-align: right; }
.chip-input input::placeholder { color: var(--muted); font-weight: 500; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: var(--t-xs); font-weight: 600; white-space: nowrap; letter-spacing: 0.01em; }
.tag-grad { background: var(--accent-soft); color: var(--accent-ink); }
.tag-uni { background: var(--yes-bg); color: var(--yes); }
.tag-new { background: var(--yes-bg); color: var(--yes); text-transform: uppercase; font-size: 10px; letter-spacing: 0.06em; font-weight: 700; }

/* segmented control (Buy / Sell): a thumb slides between the two halves */
.seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.seg::before { content: ''; position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 4.5px); border-radius: 999px; background: var(--pill-active); box-shadow: var(--thumb-shadow); transition: transform 0.22s var(--ease-out); }
.seg[data-side='sell']::before { transform: translateX(calc(100% + 3px)); }
.seg button { position: relative; z-index: 1; height: 38px; border-radius: 999px; font-family: var(--display); font-weight: 700; font-size: var(--t-base); color: var(--muted); transition: color 0.18s; }
.seg button:hover { color: var(--text); }
.seg button.active[data-side='buy'] { color: var(--buy); }
.seg button.active[data-side='sell'] { color: var(--sell); }
:root[data-theme='dark'] .seg button.active[data-side='buy'] { color: var(--yes); }
:root[data-theme='dark'] .seg button.active[data-side='sell'] { color: var(--no); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .seg button.active[data-side='buy'] { color: var(--yes); }
  :root:not([data-theme='light']) .seg button.active[data-side='sell'] { color: var(--no); }
}

/* ---------- inputs ---------- */

.input {
  display: flex; align-items: center; gap: var(--s2); height: 42px; padding: 0 var(--s3);
  border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.input:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent); }
.input input, .input textarea { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); padding: 0; }
.input input::placeholder, .input textarea::placeholder { color: var(--muted); }
.input .unit { flex: none; color: var(--muted); font-weight: 600; font-size: var(--t-sm); }
.input.area { height: auto; padding: var(--s2) var(--s3); }
.input.area textarea { resize: none; min-height: 56px; line-height: 1.45; }
.input.lg { height: 60px; padding: 0 var(--s4); font-size: clamp(22px, 5.5vw, 28px); font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; border-radius: 14px; }
.input.lg .unit { font-size: var(--t-base); font-weight: 600; }
.input.lg input::placeholder { color: var(--border-strong); }
.field { display: grid; gap: 5px; min-width: 0; }
.field-label { font-weight: 600; font-size: var(--t-sm); color: var(--text-2); display: flex; justify-content: space-between; gap: var(--s2); }
.field-label .muted { font-weight: 500; }
.field-hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.field.has-error .input { border-color: var(--no); }
.field-error { color: var(--no); font-size: 12px; }
.search { cursor: text; }
.search input::-webkit-search-cancel-button { display: none; }

/* ---------- header ---------- */

.header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px); border-bottom: 1px solid var(--hairline); }
.mode-banner { display: flex; align-items: center; justify-content: center; gap: 6px; height: 26px; padding: 0 var(--s4); background: var(--warn-bg); color: var(--text); font-size: 12px; border-bottom: 1px solid var(--border); }
.mode-banner:empty { display: none; }
.mode-banner .ic { color: var(--warn); }
.header-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s3); height: var(--header-h); }
.logo { display: inline-flex; align-items: center; gap: 8px; justify-self: start; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.03em; }
.logo-mark { transition: transform 0.5s var(--ease-out); }
.logo:hover .logo-mark { transform: rotate(180deg); }
.nav-pill { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.np-link { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 999px; color: var(--text-2); font-weight: 600; font-size: var(--t-sm); white-space: nowrap; transition: background-color 0.15s, color 0.15s, box-shadow 0.15s; }
.np-link:hover { color: var(--text); }
.np-link.active { background: var(--pill-active); color: var(--text); box-shadow: var(--thumb-shadow); }
.np-link.active .ic { color: var(--accent-ink); }
.header-actions { display: flex; align-items: center; justify-self: end; gap: var(--s2); min-width: 0; }
.wallet-pill { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: var(--t-sm); white-space: nowrap; transition: border-color 0.15s, background-color 0.15s; }
.wallet-pill:hover { border-color: var(--border-strong); background: var(--surface-2); }
.wallet-pill .mono { font-size: 12px; }
.wallet-pill .bal { color: var(--muted); font-weight: 500; border-radius: 6px; padding: 0 3px; }
.chain-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yes); flex: none; }
body.tx-pending .chain-dot { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.header-actions .btn { height: 40px; padding: 0 14px; border-radius: 999px; }
.header-actions .icon-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; }

/* mobile bottom bar */
.tabbar { display: none; }
#theme-btn-header { display: none; }
@media (min-width: 861px) { #theme-btn-header { display: inline-flex; } }

/* ---------- footer ---------- */

.footer { border-top: 1px solid var(--hairline); padding-block: var(--s4); font-size: var(--t-sm); color: var(--muted); }
.foot-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--s3) var(--s6); flex-wrap: wrap; }
.foot-links { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.foot-links a { color: var(--text-2); font-weight: 500; }
.foot-links a:hover { color: var(--text); }
.foot-links .icon-btn { width: 32px; height: 32px; }
.foot-legal { flex-basis: 100%; font-size: 12px; }

/* ---------- states, skeletons ---------- */

.state { grid-column: 1 / -1; display: grid; justify-items: center; gap: var(--s2); padding: var(--s8) var(--s4); text-align: center; }
.state h2 { font-size: var(--t-lg); }
.state code { font-family: var(--mono); font-size: var(--t-sm); }
.config-problems { display: inline-grid; gap: 2px; margin: 0 0 var(--s2); padding-left: 18px; text-align: left; }
.empty-row { grid-column: 1 / -1; display: grid; justify-items: center; gap: var(--s3); padding: var(--s8) var(--s4); border-radius: var(--r); border: 1px dashed var(--border-strong); color: var(--muted); text-align: center; }
.empty-row .empty-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.empty-row p { font-size: var(--t-base); color: var(--text-2); }
.sk { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%) 0 0 / 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-card { display: grid; grid-template-columns: 44px 1fr auto; gap: var(--s2) var(--s3); align-items: center; padding: var(--s4); min-height: 150px; align-content: start; }
.sk-card .block { width: 44px; height: 44px; border-radius: 50%; grid-row: 1 / span 2; }
.sk-card .line { height: 12px; }
.sk-card .w70 { width: 70%; }
.sk-card .w40 { width: 40%; }
.sk-card .cap { width: 56px; height: 14px; grid-row: 1 / span 2; }
.sk-card .bar { grid-column: 1 / -1; height: 6px; margin-top: var(--s3); }
.sk-card .foot { grid-column: 1 / -1; height: 10px; width: 55%; }
.sk-page { display: grid; gap: var(--s3); }
.sk-page .sk-head { display: flex; gap: var(--s3); align-items: center; }
.sk-page .sk-head .sk:first-child { width: 52px; height: 52px; border-radius: 50%; flex: none; }
.sk-page .sk-lines { display: grid; gap: 8px; flex: 1; }
.sk-page .sk-lines .sk { height: 14px; }
.sk-page .sk-lines .sk:first-child { width: 40%; height: 22px; }
.sk-page .sk-lines .sk:last-child { width: 60%; }
.sk-page .sk-cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s4); }
.sk-page .sk-cols .sk { height: 260px; border-radius: var(--r); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: -2px; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- coin art ---------- */
.tok { position: relative; display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; background: var(--surface-2); box-shadow: 0 0 0 1px var(--card-border); }
.tok svg, .tok img { width: 100%; height: 100%; display: block; object-fit: cover; }
.tok-md { width: 36px; height: 36px; }
.tok-lg { width: 44px; height: 44px; }
.tok-xl { width: 56px; height: 56px; }

/* ---------- live numbers: flashes on change ---------- */
.price-sub sub { font-size: 0.62em; vertical-align: -0.28em; margin: 0 0.04em; line-height: 0; }
.flash-up, .flash-down, .tick { border-radius: 6px; animation: flash-bg 1.1s ease-out; }
.flash-up { --flash: var(--flash-up); }
.flash-down { --flash: var(--flash-down); }
.tick { --flash: var(--flash-chg); }
@keyframes flash-bg { 0% { background-color: var(--flash); } 100% { background-color: transparent; } }
.live-dot { position: relative; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--yes); flex: none; }
.live-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--yes); opacity: 0; animation: ring 1.8s ease-out infinite; }
@keyframes ring { 0% { transform: scale(0.5); opacity: 0.8; } 100% { transform: scale(1.4); opacity: 0; } }

/* ---------- progress bar (curve -> Uniswap) ---------- */
.rbar { display: grid; gap: 5px; min-width: 0; }
.rbar-track { position: relative; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.rbar-track span { position: relative; display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.5s var(--ease-out); overflow: hidden; }
.rbar-track span::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.45) 50%, transparent 100%); transform: translateX(-100%); animation: sweep 2.4s ease-in-out infinite; }
@keyframes sweep { 60%, 100% { transform: translateX(100%); } }
.rbar-grad .rbar-track span { background: linear-gradient(90deg, var(--accent), var(--sun)); }
.rbar-grad .rbar-track span::after { animation: none; }
.rbar-label { display: flex; justify-content: space-between; gap: var(--s2); font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.rbar-label b { color: var(--text-2); }
.rbar-grad .rbar-label b { color: var(--accent-ink); }

/* ---------- modal ---------- */
body.modal-open { overflow: hidden; }
#modal-root { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: var(--s4); }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade-in 0.16s ease-out; }
@keyframes fade-in { from { opacity: 0; } }
.modal { position: relative; width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--s6); animation: modal-in 0.2s var(--ease-out); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-x { position: absolute; top: 12px; right: 12px; border-radius: 999px; }
#modal-root[data-locked='true'] .modal-x { visibility: hidden; }
.modal-title { font-size: var(--t-lg); margin: 0 32px var(--s3) 0; }
.modal-foot { margin-top: var(--s4); display: grid; gap: var(--s2); }
.pos-row { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--border); font-size: var(--t-sm); }
.pos-row > span:first-child { color: var(--muted); }
.review { display: flex; gap: var(--s3); align-items: center; padding: var(--s3); border-radius: var(--r); background: var(--surface-2); margin-bottom: var(--s3); font-size: var(--t-sm); }
.review b { font-size: var(--t-base); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.step { display: flex; gap: var(--s3); padding: var(--s2) var(--s2); border-radius: var(--r-sm); }
.step.busy { background: var(--accent-soft); }
.step-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none; background: var(--surface-3); font-size: var(--t-xs); font-weight: 700; color: var(--text-2); }
.step-mark.ok { background: var(--buy); color: #fff; animation: pop 0.3s var(--spring); }
.step-mark.bad { background: var(--sell); color: #fff; }
.step-mark.busy { background: var(--accent); color: #fff; }
.step-mark .spinner { width: 12px; height: 12px; }
@keyframes pop { from { transform: scale(0.6); } }
.step-text { flex: 1; min-width: 0; }
.step-title { font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.step-status { font-size: var(--t-sm); color: var(--accent-ink); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.step.done .step-status { color: var(--yes); }
.step.failed .step-status { color: var(--no); }
.step-error { color: var(--no); font-size: var(--t-sm); margin-top: 4px; line-height: 1.4; }
.step-error b { color: var(--text-2); font-weight: 500; }
.err-details { margin-top: 4px; font-size: 12px; }
.err-details summary { color: var(--muted); font-weight: 600; }
.err-details summary:hover { color: var(--text); }
.err-details code { display: block; margin-top: 4px; padding: var(--s2); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); font-family: var(--mono); font-size: var(--t-xs); overflow-wrap: anywhere; white-space: pre-wrap; }
.tx-link { color: var(--muted); }
.xlink { color: var(--text); display: inline-flex; align-items: center; gap: 3px; }
.xlink:hover { color: var(--accent-ink); }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: var(--s4); bottom: calc(var(--tabbar-h) + var(--s4) + env(safe-area-inset-bottom, 0px)); z-index: 150; display: flex; flex-direction: column; gap: var(--s2); max-width: min(360px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); border-left: 3px solid var(--accent); font-size: var(--t-sm); font-weight: 500; transition: opacity 0.3s, transform 0.3s; animation: toast-in 0.25s var(--ease-out); }
.toast.success { border-left-color: var(--yes); }
.toast.error { border-left-color: var(--no); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- responsive chrome ---------- */
@media (max-width: 860px) {
  .header-row { grid-template-columns: auto minmax(0, 1fr); gap: var(--s2); }
  .nav-pill { display: none; }
  :root { --tabbar-h: 56px; --gutter: 16px; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); padding: 4px var(--s2) env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--hairline); background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
  }
  .tab { display: grid; justify-items: center; align-content: center; gap: 2px; border-radius: var(--r-sm); color: var(--muted); font-size: var(--t-xs); font-weight: 600; min-height: 44px; }
  .tab.active { color: var(--text); }
  .tab.active .ic { color: var(--accent-ink); }
  body[data-screen='coin'].trade-bar-shown .tabbar { display: none; }
  /* touch: every tap target at least 40px */
  .chip, .chip-sm, .icon-btn.sm, .btn-sm, .seg button, .details summary, .launch-links summary, .err-details summary { min-height: 40px; }
  .chip-sm { min-width: 40px; }
  .icon-btn.sm { min-width: 40px; }
  .foot-links a, .xlink, .launch-links summary, .err-details summary { display: inline-flex; align-items: center; min-height: 40px; }
  .foot-links .icon-btn { width: 40px; height: 40px; }
  .logo { min-height: 40px; }
  .details-body p a, .launch-summary .field-hint a, .note a { padding-block: 13px; }
  .sk-page .sk-cols { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .logo { font-size: 18px; }
  .wallet-pill { padding-inline: 10px; }
  .wallet-pill .tag, .wallet-pill .bal { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
