/* ewatch: a trading-desk view of Extended positions (public; each visitor's watchlist stays in their browser).
   Rules (from ~/design-dos-and-donts.md): one loud number (PnL), one filled button (the next step),
   green/red only for direction and gain/loss, amber only for "behind", every color a token with a
   light value. Numbers are IBM Plex Mono, right-aligned; panels are flat with hairline edges. */

@font-face { font-family: "Plex Sans"; src: url("/static/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/static/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/static/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/static/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/static/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/static/fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0a0e13;
  --panel: #0f151c;
  --panel-2: #141b24;
  --hover: #18212c;
  --line: #1a232e;
  --border: #222d3a;
  --field: #3a4859;

  --fg: #d5dde6;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b4;
  --dim: #7b899a;

  --accent: #5ab4ff;          /* interactive: links, focus, selected */
  --accent-soft: rgba(90, 180, 255, 0.12);
  --accent-line: rgba(90, 180, 255, 0.4);
  --pop: #5ab4ff;             /* the one filled button */
  --pop-ink: #04121f;

  --gain: #34d27f;            /* long / profit */
  --gain-soft: rgba(52, 210, 127, 0.12);
  --loss: #ff5f6d;            /* short / loss */
  --loss-soft: rgba(255, 95, 109, 0.12);
  --warn: #e5a33b;
  --warn-line: rgba(229, 163, 59, 0.4);

  --font-sans: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --ease-out: cubic-bezier(0.2, 0.9, 0.3, 1);

  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem; --sp-5: 1.5rem; --sp-6: 2rem;
  --r: 3px;
  --top-h: 3.5rem;
  --z-sticky: 50; --z-toast: 1000;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #eef1f4;
    --panel: #ffffff;
    --panel-2: #f5f7f9;
    --hover: #edf1f5;
    --line: #e4e9ee;
    --border: #d3dae2;
    --field: #8593a3;
    --fg: #1a2330;
    --text-primary: #0a111c;
    --text-secondary: #485666;
    --dim: #5b6979;
    --accent: #1460cc;
    --accent-soft: rgba(20, 96, 204, 0.08);
    --accent-line: rgba(20, 96, 204, 0.35);
    --pop: #1460cc;
    --pop-ink: #ffffff;
    --gain: #0d8048;
    --gain-soft: rgba(13, 128, 72, 0.1);
    --loss: #c8243a;
    --loss-soft: rgba(200, 36, 58, 0.08);
    --warn: #8a5508;
    --warn-line: rgba(138, 85, 8, 0.35);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top-h) + 1rem); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; text-wrap: pretty; }
a { color: var(--accent); text-underline-offset: 2px; }
code { font-family: var(--font-mono); font-size: 0.85em; }
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em; flex-shrink: 0; }
.num, td.r, th.r { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.muted { color: var(--dim); }
.est { color: var(--dim); }

.skip-link { position: absolute; left: var(--sp-3); top: -3rem; z-index: var(--z-toast); background: var(--pop); color: var(--pop-ink); padding: var(--sp-2) var(--sp-3); border-radius: var(--r); font-weight: 600; }
.skip-link:focus { top: var(--sp-2); }
:is(a, button, input, select, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- top bar: brand, wallets, sync ----------------------------------- */
.topbar { position: sticky; top: 0; z-index: var(--z-sticky); background: var(--panel); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1480px; margin: 0 auto; padding: 0 var(--sp-5); min-height: var(--top-h); display: flex; align-items: stretch; gap: var(--sp-5); }
.brand { display: flex; align-items: center; gap: var(--sp-2); font-family: var(--font-mono); font-weight: 600; font-size: 0.95rem; color: var(--text-primary); letter-spacing: 0.02em; }
.brand .mark { color: var(--accent); width: 1.15em; height: 1.15em; }
.wallet-nav { flex: 1; min-width: 0; display: flex; }
.wallets { display: flex; align-items: stretch; gap: 0; }
.wallet-tab {
  font: inherit; cursor: pointer; color: var(--text-secondary); background: none; border: 0;
  border-bottom: 2px solid transparent; padding: 0 var(--sp-4); min-height: 44px; min-width: 7rem;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 1px; text-align: left;
  transition: color 0.15s var(--ease-out), border-color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
.wallet-tab.skeleton { margin: var(--sp-3) var(--sp-1); }
.wallet-tab:hover { color: var(--fg); background: var(--hover); }
.wallet-tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); }
.wallet-tab .name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.wallet-tab .sub { font-family: var(--font-mono); font-size: 0.72rem; color: var(--dim); white-space: nowrap; }

.sync { align-self: center; display: inline-flex; align-items: center; gap: var(--sp-2); font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.sync.live .dot { background: var(--gain); box-shadow: 0 0 0 3px var(--gain-soft); }
.sync.behind { color: var(--warn); }
.sync.behind .dot { background: var(--warn); }
.sync.down { color: var(--loss); }
.sync.down .dot { background: var(--loss); }

/* ---- layout ---------------------------------------------------------- */
main { max-width: 1480px; margin: 0 auto; padding: var(--sp-4) var(--sp-5) var(--sp-6); display: grid; gap: var(--sp-4); }
#view { display: grid; gap: var(--sp-4); min-width: 0; }
.desk { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: var(--sp-4); align-items: start; }
.desk > * { min-width: 0; }
.pair { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--sp-4); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); min-width: 0; }
.panel-head {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-4); min-height: 2.75rem; border-bottom: 1px solid var(--border); background: var(--panel-2);
}
.panel-head h2, .panel-head h3 { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-primary); }
.panel-head .meta { font-family: var(--font-mono); font-size: 0.75rem; color: var(--dim); }
.panel-head .right { margin-left: auto; display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.panel-note { padding: var(--sp-2) var(--sp-4) 0; font-size: 0.78rem; color: var(--dim); }

/* ---- summary strip: the loud number, then the account in one row ---- */
.strip { display: grid; grid-template-columns: minmax(16rem, 1.6fr) repeat(5, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); }
.strip .cell { padding: var(--sp-4); border-left: 1px solid var(--line); min-width: 0; }
.strip .cell:first-child { border-left: 0; }
.strip .k { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.strip .v { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 500; color: var(--text-primary); margin-top: var(--sp-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .s { font-size: 0.76rem; color: var(--text-secondary); margin-top: 2px; }
.strip .lead .loud { font-family: var(--font-mono); font-size: clamp(2rem, 4.2vw, 2.75rem); font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; color: var(--text-primary); margin-top: var(--sp-1); }
.strip .lead .loud.gain { color: var(--gain); }
.strip .lead .loud.loss { color: var(--loss); }
.split { display: flex; height: 4px; margin-top: var(--sp-2); border-radius: 2px; overflow: hidden; background: var(--hover); }
.split i { display: block; height: 100%; }
.split .l { background: var(--gain); }
.split .s { background: var(--loss); margin-left: auto; }

.who { display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: center; font-size: 0.78rem; color: var(--dim); padding: 0 var(--sp-1); }
.who code { color: var(--text-secondary); }

/* ---- controls -------------------------------------------------------- */
.btn {
  font: inherit; font-size: 0.82rem; font-weight: 500; cursor: pointer; border-radius: var(--r);
  min-height: 2.25rem; padding: 0 var(--sp-4); border: 1px solid var(--field); background: transparent; color: var(--fg);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); white-space: nowrap; text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
}
.btn:hover { background: var(--hover); border-color: var(--accent-line); }
.btn:active { transform: translateY(1px); }
.btn.pop { background: var(--pop); border-color: var(--pop); color: var(--pop-ink); font-weight: 600; }
.btn.pop:hover { opacity: 0.9; background: var(--pop); }
.btn.quiet { border-color: var(--border); color: var(--text-secondary); }
.btn.quiet:hover { color: var(--fg); }
.btn.small { font-size: 0.76rem; min-height: 1.9rem; padding: 0 var(--sp-3); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn .time { font-weight: 400; opacity: 0.75; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.seg button {
  font: inherit; font-family: var(--font-mono); font-size: 0.75rem; cursor: pointer; border: 0; border-left: 1px solid var(--border);
  background: transparent; color: var(--text-secondary); min-height: 1.9rem; padding: 0 var(--sp-3);
  transition: background 0.12s var(--ease-out), color 0.12s;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--fg); background: var(--hover); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

select {
  font: inherit; font-size: 0.8rem; color: var(--fg); background: var(--panel); border: 1px solid var(--field);
  border-radius: var(--r); min-height: 1.9rem; padding: 0 var(--sp-3);
}
label.check { display: inline-flex; gap: var(--sp-2); align-items: center; font-size: 0.8rem; color: var(--text-secondary); cursor: pointer; min-height: 1.9rem; }
label.check input { accent-color: var(--accent); width: 0.95rem; height: 0.95rem; }

/* ---- next step ------------------------------------------------------- */
.next-step {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  border: 1px solid var(--accent-line); border-radius: var(--r);
  background: var(--accent-soft); padding: var(--sp-3) var(--sp-4);
}
.next-step > .icon { color: var(--accent); width: 1.2rem; height: 1.2rem; }
.next-step .copy { flex: 1; min-width: 220px; }
.next-step .copy strong { color: var(--text-primary); font-weight: 600; }
.next-step .copy p { color: var(--text-secondary); font-size: 0.8rem; margin-top: 1px; }
.next-step.offline { border-color: var(--warn-line); border-left-color: var(--warn); background: transparent; }
.next-step.offline > .icon { color: var(--warn); }

/* ---- tables ---------------------------------------------------------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.82rem; }
thead th {
  position: sticky; top: var(--top-h); z-index: 2; background: var(--panel-2);
  text-align: left; font-weight: 500; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim);
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); white-space: nowrap; font-family: var(--font-sans);
}
thead th button { font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; min-height: 1.5rem; }
thead th button:hover { color: var(--fg); }
thead th[aria-sort] button { color: var(--accent); }
thead th .arrow { font-size: 0.72rem; }
tbody td { padding: 0.45rem var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
th:first-child, td:first-child { padding-left: var(--sp-4); }
th:last-child, td:last-child { padding-right: var(--sp-4); }
th.r, td.r { text-align: right; }
td .mkt { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); }
td:first-child { white-space: normal; min-width: 7rem; }
td .tag { display: inline-block; font-size: 0.72rem; color: var(--dim); border: 1px dashed var(--border); border-radius: var(--r); padding: 0 5px; margin-left: 6px; }
.side { display: inline-block; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 2px; }
.side.long { color: var(--gain); background: var(--gain-soft); }
.side.short { color: var(--loss); background: var(--loss-soft); }

/* diverging exposure bar: longs grow right of the centre line, shorts left */
.dbar { position: relative; display: inline-block; width: 84px; height: 8px; vertical-align: middle; }
.dbar::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--field); }
.dbar i { position: absolute; top: 1px; bottom: 1px; border-radius: 1px; }
.dbar i.l { left: 50%; background: var(--gain); }
.dbar i.s { right: 50%; background: var(--loss); }
.share { display: inline-flex; align-items: center; gap: var(--sp-2); justify-content: flex-end; }

.table-foot { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--line); color: var(--dim); font-size: 0.76rem; min-height: 2.5rem; }
.table-foot .btn { margin-left: auto; }

details.closed-list > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); min-height: 2.75rem; color: var(--text-secondary); font-size: 0.8rem; border-top: 1px solid var(--border); }
details.closed-list > summary::-webkit-details-marker { display: none; }
details.closed-list > summary::before { content: "▸"; font-size: 0.7rem; color: var(--dim); transition: transform 0.15s var(--ease-out); }
details.closed-list[open] > summary::before { transform: rotate(90deg); }
details.closed-list > summary:hover { background: var(--hover); }
details.closed-list thead th { top: var(--top-h); }

/* below 600px a row becomes a card */
@media (max-width: 600px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); }
  table.stack td { border: 0; padding: 2px 0; text-align: right; display: flex; justify-content: space-between; gap: var(--sp-3); white-space: normal; }
  table.stack td::before { content: attr(data-label); color: var(--dim); font-size: 0.76rem; font-family: var(--font-sans); letter-spacing: 0; text-align: left; white-space: nowrap; flex-shrink: 0; }
  table.stack td:first-child::before { content: none; }
  table.stack td:first-child { font-size: 0.95rem; margin-bottom: var(--sp-1); justify-content: flex-start; }
  table.stack tr:hover td { background: none; }
}

/* ---- alert tape ------------------------------------------------------ */
.al-controls { display: grid; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.al-controls .row { display: flex; gap: var(--sp-2) var(--sp-3); align-items: center; flex-wrap: wrap; justify-content: space-between; }
.al-controls .row > span { color: var(--text-secondary); font-size: 0.78rem; }
.al-controls .consequence { color: var(--dim); font-size: 0.76rem; }
.tape { max-height: 720px; overflow-y: auto; overscroll-behavior: contain; }
.tick {
  display: grid; grid-template-columns: 3.6rem minmax(0, 1fr); gap: 2px var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line);
}
.tick:hover { background: var(--hover); }
.tick.quiet { opacity: 0.65; }
.tick .t { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-secondary); line-height: 1.35; }
.tick .t small { display: block; color: var(--dim); font-size: 0.72rem; }
.tick .what { font-size: 0.82rem; color: var(--fg); }
.tick .what strong { color: var(--text-primary); font-weight: 600; }
.tick .act { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; padding: 0 5px; border-radius: 2px; margin-right: 6px; border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
.tick .act.long { color: var(--gain); border-color: transparent; background: var(--gain-soft); }
.tick .act.short { color: var(--loss); border-color: transparent; background: var(--loss-soft); }
.tick .detail { font-family: var(--font-mono); font-size: 0.74rem; color: var(--dim); margin-top: 2px; }
.tape-end { padding: var(--sp-3) var(--sp-4); color: var(--dim); font-size: 0.76rem; }

/* ---- charts ---------------------------------------------------------- */
.chart-box { min-height: 300px; padding: var(--sp-2) var(--sp-2) 0; }

/* ---- empty, loading, error ------------------------------------------ */
.empty { display: grid; justify-items: start; gap: var(--sp-2); padding: var(--sp-5) var(--sp-4); }
.empty .icon { width: 1.5rem; height: 1.5rem; color: var(--dim); }
.empty strong { color: var(--text-primary); font-weight: 600; }
.empty p { color: var(--text-secondary); font-size: 0.84rem; max-width: 62ch; }
.empty .btn { margin-top: var(--sp-1); }

.skeleton { position: relative; overflow: hidden; background: var(--hover); border-radius: var(--r); color: transparent !important; }

.sk-line { position: relative; overflow: hidden; height: 0.8rem; border-radius: 2px; background: var(--hover); }

.widget-error { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; padding: var(--sp-4); font-size: 0.84rem; }
.widget-error .icon { color: var(--loss); }
.widget-error .ref { color: var(--dim); font-size: 0.74rem; font-family: var(--font-mono); }

/* ---- toast ----------------------------------------------------------- */
.toast-stack { position: fixed; bottom: var(--sp-4); right: var(--sp-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-2); max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-3) var(--sp-4); font-size: 0.82rem; display: flex; align-items: flex-start; gap: var(--sp-2); box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.5); }
.toast .icon { color: var(--dim); margin-top: 0.15em; }
.toast.ok { border-left-color: var(--gain); }
.toast.ok .icon { color: var(--gain); }
.toast.err { border-left-color: var(--loss); }
.toast.err .icon { color: var(--loss); }
.toast .dismiss { margin-left: auto; background: none; border: none; color: var(--dim); cursor: pointer; padding: 0 0 0 var(--sp-2); min-width: 24px; min-height: 24px; }

.spinner { width: 0.9em; height: 0.9em; border-radius: 50%; display: inline-block; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.6s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- responsive ------------------------------------------------------ */
@media (max-width: 1440px) {
  .desk { grid-template-columns: minmax(0, 1fr); }
  .tape { max-height: 460px; }
}
@media (max-width: 1180px) {
  .strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .strip .lead { grid-column: 1 / -1; border-bottom: 1px solid var(--line); }
  .strip .cell:nth-child(2), .strip .cell:nth-child(5) { border-left: 0; }
  .strip .cell:nth-child(n+5) { border-top: 1px solid var(--line); }
}
@media (max-width: 860px) { .pair { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  :root { --top-h: 6.25rem; }
  .topbar-inner { flex-wrap: wrap; padding: 0 var(--sp-4); gap: 0 var(--sp-4); }
  .brand, .sync { min-height: 2.75rem; }
  .sync { margin-left: auto; }
  .wallet-nav { order: 3; flex-basis: calc(100% + 2 * var(--sp-4)); border-top: 1px solid var(--line); margin: 0 calc(-1 * var(--sp-4)); }
  .wallets { flex: 1; }
  .wallet-tab { flex: 1; min-width: 0; padding: 0 var(--sp-3); min-height: 3.4rem; }
  .wallet-tab .name { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  main { padding: var(--sp-3) var(--sp-4) var(--sp-6); gap: var(--sp-3); }
  #view { gap: var(--sp-3); }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip .cell { padding: var(--sp-3); }
  .strip .cell:nth-child(n) { border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
  .strip .cell:nth-child(2n) { border-left: 0; }
  .strip .lead { border-top: 0 !important; border-left: 0 !important; border-bottom: 0; }
  .toast-stack { left: var(--sp-4); right: var(--sp-4); max-width: none; }
}
@media (pointer: coarse) {
  .btn, .btn.small, .seg button, select, label.check, thead th button { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton, .sk-line { animation: none; }
  .btn, .wallet-tab, .seg button { transition: none; }
  .spinner { animation-duration: 1.4s; }
}
@media (max-width: 720px) { .strip .cell:last-child { grid-column: 1 / -1; border-left: 0; } }
@media (max-width: 720px) {
  .wallets { min-width: 0; }
  .wallet-tab { overflow: hidden; padding: 0 var(--sp-2) 0 var(--sp-3); }
  .wallet-tab .sub { overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-size: 0.72rem; }
}

/* ==== public additions ==================================================== */
html { scrollbar-color: var(--field) var(--bg); }
body { caret-color: var(--accent); }
::selection { background: var(--accent-line); color: var(--text-primary); }
code { font-family: var(--font-mono); font-size: 0.86em; }
.skeleton, .sk-line { animation: breathe 1.6s ease-in-out infinite alternate; }
@keyframes breathe { from { opacity: 1; } to { opacity: 0.45; } }
.sk-note { padding: var(--sp-3) var(--sp-4); font-size: 0.8rem; color: var(--dim); max-width: 75ch; }

/* wallet tabs: Overview first, then the visitor's watchlist */
.wallet-tab { text-decoration: none; }
.wallet-tab.add { min-width: 0; color: var(--dim); flex-direction: row; align-items: center; gap: 6px; }
.wallet-tab.add:hover { color: var(--fg); }
.wallets { overflow-x: auto; scrollbar-width: none; }
.wallets::-webkit-scrollbar { display: none; }

/* watch toggle */
.watch {
  font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r);
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary); min-height: 2.25rem; padding: 0 var(--sp-3);
  font-size: 0.82rem; font-weight: 500; transition: color 0.15s var(--ease-out), border-color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
.watch:hover { color: var(--fg); border-color: var(--accent-line); }
.watch[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.watch[aria-pressed="true"] .icon { fill: currentColor; }
.watch.mini { min-height: 1.9rem; min-width: 1.9rem; padding: 0; justify-content: center; border-color: transparent; }
.watch.mini[aria-pressed="true"] { background: transparent; border-color: transparent; }

/* forms */
input[type="text"] {
  font: inherit; font-size: 0.86rem; color: var(--fg); background: var(--bg); border: 1px solid var(--field);
  border-radius: var(--r); min-height: 2.25rem; padding: 0 var(--sp-3);
}
input[type="text"]::placeholder { color: var(--dim); }
input[type="text"]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.open-form { display: grid; gap: 6px; padding: var(--sp-3) var(--sp-4); }
.open-form label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.open-form .row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.open-form input { flex: 1; min-width: 14rem; }
.open-form .err { font-size: 0.8rem; color: var(--loss); }
.open-form .help { font-size: 0.76rem; color: var(--dim); max-width: 75ch; }

.who .actions { margin-left: auto; display: flex; gap: var(--sp-2); align-items: center; }
.hero-row { display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.copy-btn { font: inherit; font-size: 0.78rem; background: none; border: 0; color: var(--dim); cursor: pointer; padding: 2px 4px; display: inline-flex; align-items: center; border-radius: var(--r); }
.copy-btn:hover { color: var(--fg); background: var(--hover); }
.pill { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--text-secondary); }
.pill.healthy { color: var(--gain); background: rgba(52, 210, 127, 0.12); }
.pill.liquidatable, .pill.deleveragable { color: var(--loss); background: rgba(255, 95, 109, 0.12); }
.fuse { display: inline-block; width: 56px; height: 5px; border-radius: 3px; background: var(--hover); overflow: hidden; vertical-align: middle; }
.fuse i { display: block; height: 100%; border-radius: 3px; background: var(--text-secondary); }
.fuse.hot i { background: var(--loss); }
.fuse.warm i { background: var(--warn); }
.warn { color: var(--warn); }
tbody tr.clickable { cursor: pointer; }
td a.mkt, td a.acct { color: var(--text-primary); text-decoration: none; font-family: var(--font-mono); font-weight: 600; }
td a.acct:hover { color: var(--accent); text-decoration: underline; }
.tick .who-line { font-size: 0.76rem; color: var(--text-secondary); }
.tick .who-line a { color: inherit; }
.toast { align-items: center; }
.toast .undo { margin-left: auto; font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; cursor: pointer; padding: var(--sp-1) var(--sp-2); min-height: 2rem; }
.toast .undo + .dismiss { margin-left: 0; }
footer { max-width: 1480px; margin: 0 auto; padding: var(--sp-4) var(--sp-5) var(--sp-6); color: var(--dim); font-size: 0.78rem; display: flex; gap: var(--sp-4); flex-wrap: wrap; justify-content: space-between; border-top: 1px solid var(--line); }
footer span { max-width: 75ch; }
.next-step .copy p, .table-foot > span { max-width: 75ch; }
@media (max-width: 720px) {
  .wallet-tab.add span { display: none; }
  footer { padding: var(--sp-4); }
  .who .actions { margin-left: 0; }
}
@media (pointer: coarse) { .watch, .watch.mini { min-height: 44px; min-width: 44px; } }
.strip.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .strip.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } .strip.four .cell:nth-child(n) { border-left: 1px solid var(--line); border-top: 0; grid-column: auto; } .strip.four .cell:nth-child(2n+1) { border-left: 0; } .strip.four .cell:nth-child(n+3) { border-top: 1px solid var(--line); } }
