:root {
  --ground: #f3f6f5;
  --surface: #ffffff;
  --sunk: #eaf0ee;
  --ink: #142320;
  --ink-2: #4c5f5a;
  --line: #d6e0dd;
  --accent: #0f8a74;
  --accent-ink: #ffffff;
  --good: #11804a;
  --bad: #c2362f;
  --warn: #a8670b;
  --radius: 10px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0c1311; --surface: #121c19; --sunk: #0f1715; --ink: #e2ece9; --ink-2: #93a7a1; --line: #23332f;
    --accent: #5fdcc0; --accent-ink: #062019; --good: #4fd18b; --bad: #ff7a70; --warn: #f0b65a;
  }
}
:root[data-theme="dark"] {
  --ground: #0c1311; --surface: #121c19; --sunk: #0f1715; --ink: #e2ece9; --ink-2: #93a7a1; --line: #23332f;
  --accent: #5fdcc0; --accent-ink: #062019; --good: #4fd18b; --bad: #ff7a70; --warn: #f0b65a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font: 14px/1.45 var(--sans); }
h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }
h1 { font-size: 17px; letter-spacing: 0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); margin-top: 6px; }
a { color: var(--accent); }
.muted, .hint, .note, .sub { color: var(--ink-2); }
.hint { font-size: 12px; }
.note { font-size: 12px; margin: 0; }
.n, .mono, .v, td.n, .log, .addr { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.bar { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; gap: 10px; align-items: center; }
.mark { width: 22px; height: 22px; border-radius: 6px; background: conic-gradient(from 210deg, var(--accent), transparent 70%, var(--accent)); border: 1px solid var(--accent); }
.sub { margin: 0; font-size: 12px; }
.state { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 200px; }
.phase { color: var(--ink-2); font-size: 13px; }
.pill { font: 500 12px var(--mono); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); text-transform: uppercase; letter-spacing: 0.06em; }
.pill.running { color: var(--good); border-color: currentColor; }
.pill.stopping { color: var(--warn); border-color: currentColor; }
.pill.stopped { color: var(--ink-2); }
.controls { display: flex; gap: 8px; }

button { font: 500 13px var(--sans); padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--bad); }
button.danger:hover:not(:disabled) { border-color: var(--bad); }
button:disabled { opacity: 0.45; cursor: default; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.stats > div { background: var(--surface); padding: 12px 20px; display: grid; gap: 2px; }
.k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.v { font-size: 20px; font-weight: 500; }
.h { font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; padding: 16px 20px 40px; align-items: start; }
.col { display: grid; gap: 16px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.end .note { margin-right: auto; }

.live.empty { color: var(--ink-2); }
.live .title { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.live .sym { font: 600 20px var(--sans); }
.live .facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px 16px; margin-top: 10px; }
.live .facts div { display: grid; }
.steps { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.steps span { font: 11px var(--mono); padding: 2px 7px; border-radius: 4px; background: var(--sunk); color: var(--ink-2); }
.steps span.on { background: var(--accent); color: var(--accent-ink); }
.steps span.done { color: var(--ink); }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.n, td.n { text-align: right; }
tr.failed td { color: var(--ink-2); }
.tag { font: 11px var(--mono); padding: 1px 6px; border-radius: 4px; background: var(--sunk); }

.settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; }
.settings .group { grid-column: 1 / -1; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-top: 6px; padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.settings label { display: grid; gap: 3px; font-size: 12px; min-width: 0; }
.settings .lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings .q { font-style: normal; display: inline-block; width: 13px; height: 13px; line-height: 13px; text-align: center; border-radius: 50%; border: 1px solid var(--line); font-size: 9px; color: var(--ink-2); vertical-align: 1px; cursor: help; }
.settings input, .settings select { padding: 5px 8px; font-size: 13px; }
label { display: grid; gap: 3px; font-size: 12px; color: var(--ink-2); min-width: 0; }
label small { font-size: 11px; line-height: 1.3; }
input, select, textarea { font: 13px var(--sans); color: var(--ink); background: var(--sunk); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; width: 100%; min-width: 0; }
.settings input { font-family: var(--mono); }
textarea { resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.add { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
details.bulk { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 8px; }
details.bulk[open] { gap: 8px; }
summary { cursor: pointer; font-size: 13px; }

.queue, .wallets { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.queue li, .wallets li { display: flex; gap: 10px; align-items: center; padding: 5px 8px; background: var(--sunk); border-radius: 6px; font-size: 13px; }
.queue li .grow, .wallets li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue img { width: 26px; height: 26px; border-radius: 5px; object-fit: cover; background: var(--line); }
.queue button { padding: 2px 8px; font-size: 12px; }
.treasury { display: grid; gap: 4px; padding: 10px; background: var(--sunk); border-radius: 8px; }
.addr { font-size: 12px; overflow-wrap: anywhere; }

.log { margin: 0; max-height: 280px; overflow: auto; font-size: 12px; line-height: 1.5; background: var(--sunk); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
#rehearsal ul { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 3px; font-size: 13px; }
#rehearsal .ok::before { content: "ok"; color: var(--good); font: 11px var(--mono); margin-right: 8px; }
#rehearsal .bad::before { content: "fail"; color: var(--bad); font: 11px var(--mono); margin-right: 8px; }
#rehearsal .sum { font-weight: 500; margin-top: 6px; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 18px; width: min(360px, 92vw); }
dialog form { display: grid; gap: 10px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; padding: 12px 16px 32px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar { padding: 12px 16px; }
}
@media (max-width: 520px) {
  .settings, .two, .three { grid-template-columns: 1fr; }
  .controls { width: 100%; }
  .controls button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
label.inline { display: flex; align-items: center; gap: 8px; }
label.inline input { width: 3.5em; }
tr.coin { cursor: pointer; }
tr.coin:hover td { background: var(--sunk); }
.caret { display: inline-block; width: 1em; color: var(--ink-2); }
tr.detail > td { white-space: normal; background: var(--sunk); padding: 10px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; }
.chips span { display: grid; gap: 1px; }
.chips i { font-style: normal; font-size: 11px; color: var(--ink-2); }
.chips b { font: 500 13px var(--mono); font-variant-numeric: tabular-nums; }
table.coin-tx { font-size: 12px; }
table.coin-tx td, table.coin-tx th { padding: 3px 6px; white-space: normal; overflow-wrap: anywhere; }
table.coin-tx tr.our td { font-weight: 500; }
.live .chips, .live table.coin-tx { margin-top: 8px; }

/* History: ten coins a page, one open at a time, small rows, and never a sideways scroll. Sized by the card, not the window. */
.coins-wrap, .tx-wrap { container-type: inline-size; }
/* the trade list lives in a fixed window: it scrolls, the header stays, and a coin with a hundred rows takes no more room than one with ten */
.tx-wrap { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.tx-wrap table.coin-tx { margin-top: 0; }
.tx-wrap table.coin-tx thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
details.plumbing .tx-wrap { max-height: 240px; }
details.holders > summary { color: var(--ink); }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 8px; }
.pager[hidden] { display: none; }
.pager-btns { display: flex; gap: 4px; }
.pager button { padding: 3px 9px; font-size: 12px; }
table.coins { font-size: 12px; }
table.coins th { white-space: normal; padding: 3px 5px; font-size: 10px; vertical-align: bottom; }
table.coins td { padding: 3px 5px; white-space: normal; }
table.coins td.t-time, table.coins td.n { white-space: nowrap; }
table.coins td.t-exit { overflow-wrap: anywhere; min-width: 90px; }
tr.detail > td { padding: 6px 8px; }
.chips { gap: 3px 14px; margin-bottom: 5px; }
.chips i { font-size: 10px; }
.chips b { font-size: 11.5px; }
table.coin-tx { font-size: 11px; }
table.coin-tx th { font-size: 9.5px; }
table.coin-tx td, table.coin-tx th { padding: 1px 4px; }
table.coin-tx td.n { white-space: nowrap; }
@container (max-width: 760px) {
  table.coins, table.coins tbody { display: block; }
  table.coins thead { display: none; }
  /* two lines per coin: when, what and profit, then the numbers */
  table.coins tr.coin { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 9px; padding: 4px 2px; border-bottom: 1px solid var(--line); }
  table.coins tr.coin::after { content: ""; flex-basis: 100%; height: 0; order: 0; }
  table.coins tr.coin td { display: block; padding: 0; border: 0; order: 1; font-size: 11px; color: var(--ink-2); white-space: nowrap; background: none; }
  table.coins tr.coin:hover { background: var(--sunk); }
  table.coins td[data-l]::before { content: attr(data-l) " "; font-size: 10px; }
  table.coins tr.coin td.t-time { order: -3; font-size: 11px; }
  table.coins tr.coin td.t-coin { order: -2; font-size: 13px; font-weight: 600; }
  table.coins tr.coin td.t-profit { order: -1; margin-left: auto; font-size: 13px; font-weight: 600; color: inherit; }
  table.coins tr.coin td.t-profit.pos { color: var(--good); }
  table.coins tr.coin td.t-profit.neg { color: var(--bad); }
  table.coins tr.coin td.t-time::before, table.coins tr.coin td.t-coin::before, table.coins tr.coin td.t-profit::before { content: none; }
  table.coins tr.coin td.t-exit { order: 2; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
  table.coins tr.detail { display: block; }
  table.coins tr.detail > td { display: block; }
}
@container (max-width: 640px) {
  table.coin-tx, table.coin-tx tbody { display: block; }
  table.coin-tx thead { display: none; }
  /* two lines per transaction: where and what, then the timing */
  table.coin-tx tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; padding: 2px 0; border-bottom: 1px solid var(--line); }
  table.coin-tx tr::after { content: ""; flex-basis: 100%; height: 0; order: 0; }
  /* each cell keeps its own width: overflow-wrap:anywhere (set for the wide table) let flex shrink a cell to one letter per line */
  table.coin-tx td { display: block; padding: 0; border: 0; order: 1; font-size: 10.5px; color: var(--ink-2); white-space: nowrap; overflow-wrap: normal; flex: 0 0 auto; min-width: 0; }
  table.coin-tx td[data-l="First relay"] { white-space: normal; }
  table.coin-tx td[data-l]::before { content: attr(data-l) " "; font-size: 9.5px; font-weight: 400; }
  table.coin-tx td[data-l="After launch"] { order: -4; font-size: 11.5px; color: inherit; }
  table.coin-tx td[data-l="Who"] { order: -3; font-size: 11.5px; color: inherit; }
  table.coin-tx td[data-l="What"] { order: -2; font-size: 11.5px; color: inherit; white-space: normal; flex: 1 1 auto; min-width: 12ch; }
  table.coin-tx td[data-l="HYPE"] { order: -1; margin-left: auto; font-size: 11.5px; color: inherit; }
  table.coin-tx td[data-l="After launch"]::before, table.coin-tx td[data-l="Who"]::before, table.coin-tx td[data-l="What"]::before, table.coin-tx td[data-l="HYPE"]::before { content: none; }
}
.fleet { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.fleet li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: var(--sunk); border-radius: 6px; }
.fleet .grow { flex: 1; min-width: 0; }
.fleet small { display: block; }
.live hr.sep { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
/* strangers' trades stand out: buys green, sells red */
table.coin-tx tr.obuy td { color: var(--good); }
table.coin-tx tr.osell td { color: var(--bad); }
table.coin-tx tr.obuy td[data-l="What"], table.coin-tx tr.osell td[data-l="What"] { font-weight: 600; }
/* housekeeping transactions fold away under one line */
details.plumbing { margin-top: 8px; }
details.plumbing > summary { cursor: pointer; font-size: 12px; color: var(--ink-2); padding: 4px 0; }
details.plumbing[open] > summary { margin-bottom: 4px; }

/* settings: number fields carry +/- buttons that nudge by the field's step; the rarely changed knobs fold under Advanced */
.settings .num { display: flex; align-items: stretch; }
.settings .num input { flex: 1 1 auto; min-width: 0; border-radius: 0; text-align: center; }
.settings .num button { flex: 0 0 26px; font: 500 14px var(--mono); line-height: 1; color: var(--ink-2); background: var(--sunk); border: 1px solid var(--line); cursor: pointer; padding: 0; }
.settings .num button:first-child { border-radius: 6px 0 0 6px; border-right: 0; }
.settings .num button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.settings .num button:hover { color: var(--ink); background: var(--surface); }
.settings details.advanced { grid-column: 1 / -1; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.settings details.advanced > summary { cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.settings details.advanced > .inner { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; margin-top: 8px; }
.head .ghost.small { margin-left: auto; font-size: 12px; padding: 4px 10px; }
@media (max-width: 1100px) { .settings, .settings details.advanced > .inner { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .settings, .settings details.advanced > .inner { grid-template-columns: 1fr; } }

.controls .agent-toggle, .agent-toggle { display: inline-flex; flex: 0 0 auto; flex-direction: row; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); cursor: pointer; white-space: nowrap; width: auto; }
.controls .agent-toggle input, .agent-toggle input { display: inline-block; width: 15px; height: 15px; flex: 0 0 15px; margin: 0; accent-color: var(--accent); }

/* one coin on several chains */
.fl-rows { display: grid; gap: 6px; }
.fl-row { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(90px, 1fr) minmax(0, 1.4fr); gap: 8px; align-items: center; }
.fl-pick { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; white-space: nowrap; }
.fl-pick input { width: auto; accent-color: var(--accent); }
.fl-custom { display: grid; gap: 8px; }
.fl-custom[hidden] { display: none; }
/* the multi-chain card folds, closed by default; the summary is the card's head */
#fleet-fold > summary { cursor: pointer; list-style: none; }
#fleet-fold > summary::-webkit-details-marker { display: none; }
#fleet-fold > summary h2::before { content: "\25B8"; display: inline-block; width: 1em; color: var(--ink-2); }
#fleet-fold[open] > summary h2::before { content: "\25BE"; }
#fleet-fold[open] > summary { margin-bottom: 10px; }
/* the treasury Send row, right under the treasury */
.send-row { display: grid; gap: 6px; margin: 8px 0 4px; }
#wd-to { font-family: var(--mono); }

/* the coin, where it launches, and the queue: one card */
.fl-coin { border-top: 0; padding-top: 0; }
.fl-queue { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.fl-queue .head h3 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
