:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6c6c72;
  --faint: #a0a0a6;
  --line: #e6e6ea;
  --hover: #f1f1f3;
  --new: #f2f5f9;
  --up: #2e7a4e;
  --down: #b0463e;
  --warn: #8f6a12;
  --chip: #f0f0f2;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101012;
    --surface: #17171a;
    --text: #ececef;
    --muted: #9b9ba3;
    --faint: #66666e;
    --line: #2a2a2f;
    --hover: #1e1e22;
    --new: #1a1f29;
    --up: #74be8f;
    --down: #e0877f;
    --warn: #d2a54c;
    --chip: #222227;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #101012;
  --surface: #17171a;
  --text: #ececef;
  --muted: #9b9ba3;
  --faint: #66666e;
  --line: #2a2a2f;
  --hover: #1e1e22;
  --new: #1a1f29;
  --up: #74be8f;
  --down: #e0877f;
  --warn: #d2a54c;
  --chip: #222227;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.boot-error {
  position: fixed; left: 16px; right: 16px; top: 16px; z-index: 100; padding: 12px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font: 14px/1.5 var(--sans); text-align: center;
}

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

button { font: inherit; color: inherit; }

.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
.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: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.up { color: var(--up); }
.down { color: var(--down); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand {
  display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap;
  text-decoration: none; color: var(--text); border-radius: 8px; padding: 4px 6px; margin-left: -6px;
}
.brand:hover { background: var(--hover); }
.brand:focus-visible { outline: 2px solid color-mix(in srgb, var(--text) 30%, transparent); }
.mark { width: 22px; height: 22px; flex: none; display: block; }
.mark-bg { fill: var(--text); }
.mark-line { fill: none; stroke: var(--bg); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- landing: just a search box in the middle ---------- */
.landing {
  min-height: calc(100vh - 102px); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 16px;
}
.landing-credit { margin: 0; font-size: 13px; color: var(--muted); }
.landing-form {
  width: min(560px, 100%); display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 14px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.04);
}
.landing-form:focus-within { border-color: color-mix(in srgb, var(--text) 35%, var(--line)); }
.landing-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.landing-input {
  flex: 1; min-width: 0; height: 40px; border: 0; outline: 0; background: transparent; color: var(--text);
  font: 15px var(--mono);
}
.landing-form .btn { height: 40px; border-radius: 10px; }
body.is-landing .account-form,
body.is-landing #soundBtn,
body.is-landing #notifyBtn,
body.is-landing .audio-hint { display: none; }
body.is-landing .top-actions { margin-left: auto; }
body.is-landing .footer { display: none; }
@media (max-width: 520px) { body:not(.is-landing) .brand-name { display: none; } }
.account-form { display: flex; gap: 6px; flex: 1; min-width: 0; max-width: 420px; margin-left: auto; }
.account-input {
  flex: 1; min-width: 0; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text);
  font: 13px var(--mono);
}
.account-input:focus { outline: 2px solid color-mix(in srgb, var(--text) 25%, transparent); outline-offset: 0; }
.top-actions { display: flex; gap: 4px; }

.btn {
  height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--text);
  background: var(--text); color: var(--bg); cursor: pointer; white-space: nowrap;
}
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--hover); }
.btn-icon {
  width: 34px; padding: 0; display: inline-grid; place-items: center;
  background: transparent; color: var(--muted); border: 1px solid transparent;
}
.btn-icon:hover { background: var(--hover); color: var(--text); }
.btn-icon[aria-pressed="true"] { color: var(--text); }
.btn-icon svg { width: 18px; height: 18px; }
.link-btn { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

.audio-hint {
  max-width: 1440px; margin: 10px auto 0; padding: 8px 16px; font-size: 13px; color: var(--muted);
}

/* ---------- layout ---------- */
/* Every page: top traders | content, where content is the search page or a wallet
   (wallet + feed | following). Narrower screens fold the leaderboard into a block. */
.shell {
  max-width: 1440px; margin: 0 auto; padding: 16px;
  display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 0 20px; align-items: start;
}
.shell-main { min-width: 0; }
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0 20px; align-items: start;
  grid-template-areas: "account side" "feed side";
  grid-template-rows: auto 1fr;
}
.account-card { grid-area: account; }
.feed-col { grid-area: feed; min-width: 0; }
.side-col { grid-area: side; position: sticky; top: 70px; max-height: calc(100vh - 86px); overflow: auto; scrollbar-width: thin; }
.side-inner { display: grid; gap: 14px; }
.side-summary { display: none; }

@media (max-width: 1179px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* the search page: search first, the leaderboard under it */
  body.is-landing .shell-main { order: 1; }
  body.is-landing .lb-col { order: 2; margin: 0; }
  .landing { min-height: 0; padding: 48px 0 28px; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "account" "side" "feed"; grid-template-rows: auto; gap: 12px; }
  .side-col { position: static; max-height: none; overflow: visible; }
  .side-summary {
    display: block; cursor: pointer; list-style: none; padding: 10px 14px; border: 1px solid var(--line);
    border-radius: var(--radius); background: var(--surface); font-weight: 500; font-size: 13px;
  }
  .side-summary::-webkit-details-marker { display: none; }
  .side-summary::after { content: '▾'; float: right; color: var(--muted); }
  .side-wrap[open] .side-summary { margin-bottom: 12px; }
  .side-wrap[open] .side-summary::after { content: '▴'; }
  .feed-toolbar { margin-top: 0; }
}

/* ---------- account card ---------- */
.account-card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.account-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.account-id { font: 600 16px var(--mono); word-break: break-all; }
.account-balance { text-align: right; white-space: nowrap; }
.balance-near { font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }
.account-links { margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

.live { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.live.ok .live-dot { background: var(--up); animation: pulse 2s ease-in-out infinite; }
.live.err .live-dot { background: var(--down); }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .live.ok .live-dot { animation: none; } }

/* ---------- toolbar ---------- */
.feed-toolbar { margin: 14px 0 8px; display: grid; gap: 10px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; padding: 8px 10px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }
.tabs .count { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.toolbar-row { display: flex; gap: 8px; }
.search {
  flex: 1; min-width: 0; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit;
}

.new-banner { position: sticky; top: 62px; z-index: 5; display: flex; justify-content: center; margin: 4px 0; }
.new-banner button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.06); font-size: 13px;
}

/* ---------- feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.feed:empty { display: none; }
.day-sep {
  padding: 8px 16px; font-size: 12px; color: var(--muted); background: var(--bg);
  border-bottom: 1px solid var(--line); font-weight: 500; text-transform: none;
}
.day-sep:not(:first-child) { border-top: 1px solid var(--line); }

.post {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  transition: background-color 2.5s ease;
}
.post:last-child { border-bottom: 0; }
.post.is-new { background: var(--new); transition: none; }
.post-icon {
  width: 40px; height: 40px; border-radius: 50%; background: var(--chip); overflow: hidden;
  display: grid; place-items: center; color: var(--muted); font-size: 17px; flex: none;
}
.post-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 13px; color: var(--muted); }
.post-author { color: var(--text); font-weight: 600; }
.post-head time { font-variant-numeric: tabular-nums; }
.tag {
  margin-left: auto; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--chip); color: var(--muted);
  white-space: nowrap;
}
.tone-buy .tag-main { color: var(--up); }
.tone-sell .tag-main { color: var(--down); }
.tone-fail .tag-main, .tone-warn .tag-main { color: var(--warn); }
.post-title { font-size: 15px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.post-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tone-warn .post-title { color: var(--warn); }

.kv { margin: 8px 0 0; display: grid; gap: 3px; }
.kv-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv dd .v.mono { font-size: 12.5px; }
.kv dd .note { color: var(--muted); margin-left: 6px; }
.kv dd .live-mark {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  margin-right: 6px; vertical-align: 1px; animation: pulse 2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .kv dd .live-mark { animation: none; } }
.kv dd .links { margin-left: 8px; font-size: 12px; color: var(--muted); }
.kv dd .links a + a { margin-left: 8px; }
.kv dd.pre { white-space: pre-wrap; }
.copy-btn {
  border: 0; background: none; padding: 0 2px; margin-left: 4px; cursor: pointer; color: var(--faint);
  vertical-align: -2px; line-height: 1;
}
.copy-btn:hover { color: var(--text); }
.copy-btn svg { width: 13px; height: 13px; }

.more { margin-top: 6px; }
.more summary { cursor: pointer; color: var(--muted); font-size: 12px; list-style: none; display: inline-block; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '▸ '; }
.more[open] summary::before { content: '▾ '; }

@media (max-width: 520px) {
  .post { grid-template-columns: 32px minmax(0, 1fr); gap: 10px; padding: 12px; }
  .post-icon { width: 32px; height: 32px; font-size: 14px; }
  .kv-row { grid-template-columns: 1fr; gap: 0; }
  .kv-row + .kv-row { margin-top: 4px; }
  .tag { margin-left: 0; }
  .topbar-inner { flex-wrap: wrap; }
  .account-form { order: 3; max-width: none; flex-basis: 100%; }
}

.feed-footer { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px; }

/* ---------- summary tab ---------- */
body.view-summary .toolbar-row,
body.view-summary #newBanner,
body.view-summary #feed,
body.view-summary .feed-footer,
body.view-positions .toolbar-row,
body.view-positions #newBanner,
body.view-positions #feed,
body.view-positions .feed-footer,
body.view-orders .toolbar-row,
body.view-orders #newBanner,
body.view-orders #feed,
body.view-orders .feed-footer { display: none !important; }
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 16px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--chip); border-radius: 10px; justify-self: start; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.sum-hero { display: grid; gap: 2px; }
.sum-label { font-size: 13px; }
.sum-big { font-size: 30px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.sum-sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.sum-grid { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; }
.sum-grid > div { display: grid; gap: 1px; padding-top: 8px; border-top: 1px solid var(--line); }
.sum-grid dt { color: var(--muted); font-size: 12px; }
.sum-grid dd { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sum-grid dd small { color: var(--muted); font-size: 12px; margin-left: 4px; }
.sum-section { font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0 -6px; }
.sum-rows { display: grid; }
.sum-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.sum-row:first-child { border-top: 0; }
.sum-row .chip { font-size: 11px; padding: 0 7px; border-radius: 999px; background: var(--chip); color: var(--muted); margin-left: 6px; font-weight: 400; }
.sum-empty { padding: 8px 0; }
.sum-notes { display: grid; gap: 4px; }
@media (max-width: 520px) { .sum-grid { grid-template-columns: minmax(0, 1fr); } .sum-big { font-size: 26px; } }

/* ---------- side panels ---------- */
.panel-title { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.panel-note { margin: 10px 0 0; }

.pos { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); align-items: center; }
.pos:first-child { border-top: 0; padding-top: 0; }
.pos-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--chip); overflow: hidden; display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.pos-icon img { width: 100%; height: 100%; object-fit: cover; }
.pos-name { font-weight: 600; font-size: 13px; display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.pos-name .state { font-weight: 400; font-size: 11px; color: var(--muted); }
.pos-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pos-pnl { text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos-pnl .pct { display: block; font-weight: 400; font-size: 12px; }
.pos button { all: unset; cursor: pointer; }

.holding { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 13px; border-top: 1px solid var(--line); }
.holding:first-child { border-top: 0; padding-top: 0; }
.holding .h-val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.holding .h-val small { display: block; color: var(--muted); font-size: 11.5px; }
.holding .h-name { min-width: 0; overflow-wrap: anywhere; }

.stats { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- dialog / toast ---------- */
.dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.dialog-body { padding: 18px 20px; display: grid; gap: 12px; }
.dialog-title { margin: 0 0 4px; font-size: 16px; }
.field { display: grid; gap: 4px; font-size: 13px; }
.field.row { grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
.field select, .field input[type="number"] {
  height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
.dialog-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 9px; font-size: 13px;
  max-width: calc(100vw - 32px);
}

.footer {
  max-width: 1440px; margin: 0 auto; padding: 8px 16px 28px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px;
}
.credit { color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.credit a, .landing-credit a { color: var(--text); font-weight: 500; text-decoration: none; }
.credit a:hover, .landing-credit a:hover { text-decoration: underline; text-decoration-color: var(--faint); }
.footer .sources { flex: 1 1 320px; text-align: right; }
@media (max-width: 700px) { .footer { justify-content: center; text-align: center; } .footer .sources { text-align: center; } }
.top-credit { font-size: 12px; color: var(--muted); text-decoration: none; white-space: nowrap; padding: 4px 6px; border-radius: 8px; }
.top-credit:hover { color: var(--text); background: var(--hover); }
/* Header credit in the wallet view; the landing page and phones show it in the footer instead. */
body.is-landing .top-credit { display: none; }
@media (max-width: 900px) { .top-credit { display: none; } }

.group-list { list-style: none; margin: 8px 0 0 -52px; padding: 0; border-top: 1px solid var(--line); }
.group-list .post { padding-left: 0; padding-right: 0; }
.group-list .post:last-child { border-bottom: 0; }
@media (max-width: 520px) { .group-list { margin-left: -42px; } }

/* ---------- Check fomo: wallet connection, profile, follows ---------- */
.connect-top { height: 32px; padding: 0 12px; font-size: 13px; }
.profile-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px 0 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; max-width: 200px;
}
.profile-chip:hover { background: var(--hover); }
.profile-name { font: 500 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.is-landing .connect-top, body.is-landing .profile-chip { margin-left: auto; }
body.is-landing .top-actions { margin-left: 0; }

.avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--chip); color: var(--muted); flex: none;
  display: inline-grid; place-items: center; font-size: 10px; font-weight: 600; text-transform: uppercase; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.account-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.account-ident { min-width: 0; }
.account-name:empty { display: none; }
.account-side { display: grid; justify-items: end; gap: 8px; }
.account-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.follow-btn { height: 30px; padding: 0 14px; font-size: 13px; border-radius: 999px; }
.follow-btn.on { background: transparent; color: var(--text); border-color: var(--line); }
.follow-btn.on:hover { color: var(--down); border-color: currentColor; }
.you-badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--chip); color: var(--text); font-weight: 500; }

.pnl-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.pnl-tile {
  text-align: left; border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 8px 10px; cursor: pointer;
  display: grid; gap: 1px; min-width: 0;
}
.pnl-tile:hover { background: var(--hover); }
.pnl-tile .pt-label { font-size: 11.5px; color: var(--muted); }
.pnl-tile .pt-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pnl-tile .pt-sub { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel-head .panel-title { margin: 0; }
.seg-sm button { padding: 3px 9px; font-size: 12px; }
.follow-body { display: grid; gap: 0; }
.follow-empty { font-size: 13px; color: var(--muted); display: grid; gap: 10px; justify-items: start; }
.ff-item {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 9px; padding: 8px 0; border-top: 1px solid var(--line);
  transition: background-color 2.5s ease;
}
.ff-item:first-child { border-top: 0; padding-top: 0; }
.ff-item.is-new { background: var(--new); transition: none; }
.ff-head { display: flex; gap: 6px; align-items: baseline; font-size: 12px; color: var(--muted); min-width: 0; }
.ff-acc { all: unset; cursor: pointer; color: var(--text); font: 600 12px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.ff-acc:hover { text-decoration: underline; }
.ff-title { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.tone-buy .ff-title { color: var(--up); }
.tone-sell .ff-title { color: var(--down); }
.ff-sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.ff-tx { margin-left: auto; color: var(--faint); text-decoration: none; }
.fw-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); }
.fw-row:first-child { border-top: 0; padding-top: 0; }
.fw-name { all: unset; cursor: pointer; font: 600 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.fw-name:hover { text-decoration: underline; }
.fw-meta { font-size: 11.5px; color: var(--muted); }
.fw-actions { display: flex; gap: 4px; }
.mini-btn { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 7px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.mini-btn:hover { color: var(--text); background: var(--hover); }
.follow-foot { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* connect page */
.connect-wrap { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 16px; }
.connect-card {
  width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px;
  display: grid; gap: 12px; text-align: center;
}
.connect-title { margin: 0; font-size: 20px; }
.connect-card p { margin: 0; font-size: 14px; }
.connect-btn { height: 44px; font-size: 15px; border-radius: 12px; }
.connect-status:empty { display: none; }
.connect-or { margin-top: 6px; }
.connect-card .landing-form { width: 100%; }
.connect-back { text-decoration: none; }

@media (max-width: 520px) {
  .pnl-board { gap: 6px; }
  .pnl-tile { padding: 7px 8px; }
  .pnl-tile .pt-value { font-size: 13.5px; }
  .account-head { flex-wrap: wrap; }
  .account-side { justify-items: start; width: 100%; grid-template-columns: 1fr auto; align-items: center; }
  .profile-name { display: none; }
  .profile-chip { padding: 0 4px; }
}

/* ---------- Positions tab ---------- */
.positions-view { display: grid; gap: 12px; }
.po-head {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 16px;
}
.po-head > div { display: grid; gap: 1px; min-width: 0; }
.po-head dt { font-size: 12px; color: var(--muted); }
.po-head dd { margin: 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.po-head dd small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.pos-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 10px;
}
.pos-card.is-open { border-left-color: var(--up); }
.pos-card.is-closed { border-left-color: var(--down); }
.pc-head { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.pc-head .pos-icon { width: 32px; height: 32px; }
.pc-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.pc-sym { all: unset; cursor: pointer; font-weight: 650; font-size: 15px; }
.pc-sym:hover { text-decoration: underline; }
.pc-status { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 999px; }
.pc-status.open { color: var(--up); background: color-mix(in srgb, var(--up) 14%, transparent); }
.pc-status.closed { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }
.pc-total { text-align: right; font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pc-total .sub { display: block; font-size: 13px; font-weight: 500; }
.pc-grid { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.pc-grid > div { display: grid; gap: 1px; min-width: 0; }
.pc-grid dt { font-size: 12px; color: var(--muted); }
.pc-grid dd { margin: 0; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* USD amounts are primary information: same colour as the value, readable size */
.pc-grid dd .sub { display: block; font-size: 13px; font-weight: 500; }
.pc-entry { font-size: 11.5px; color: var(--muted); }
.pc-foot { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pos-empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--muted); font-size: 13px; }
@media (max-width: 700px) {
  .po-head, .pc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc-total { font-size: 15px; }
}

.po-sort { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.po-sort .seg button { font-variant-numeric: tabular-nums; }

/* ---------- leaderboard: top meme traders ---------- */
.lb-col { min-width: 0; position: sticky; top: 70px; }
.lb-summary { display: none; }
.lb-panel { padding: 14px 0 10px; display: flex; flex-direction: column; max-height: calc(100vh - 86px); min-height: 0; }
.lb-top {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title refresh" "controls controls";
  align-items: center; gap: 8px; padding: 0 12px 0 16px;
}
.lb-title { grid-area: title; margin: 0; }
.lb-refresh { grid-area: refresh; width: 30px; height: 30px; }
.lb-refresh svg { width: 16px; height: 16px; }
.lb-refresh:disabled { cursor: default; }
.lb-refresh.spinning svg { animation: lb-spin 0.9s linear infinite; }
@keyframes lb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .lb-refresh.spinning svg { animation: none; } }
.lb-controls { grid-area: controls; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lb-controls .seg button { font-variant-numeric: tabular-nums; }
.lb-progress { height: 2px; margin: 10px 16px 0; background: var(--line); border-radius: 2px; overflow: hidden; }
.lb-progress span { display: block; height: 100%; width: 0; background: var(--muted); transition: width 0.3s ease; }
.lb-status { padding: 8px 16px 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-status:empty { display: none; }
.lb-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1 1 auto; min-height: 0; scrollbar-width: thin; border-top: 1px solid var(--line); }
.lb-row {
  all: unset; box-sizing: border-box; width: 100%; cursor: pointer;
  display: grid; grid-template-columns: 22px 28px minmax(0, 1fr) auto; gap: 8px; align-items: center;
  padding: 7px 14px 7px 12px; border-bottom: 1px solid var(--line);
}
.lb-row:hover { background: var(--hover); }
.lb-row:focus-visible { outline: 2px solid color-mix(in srgb, var(--text) 30%, transparent); outline-offset: -2px; }
.lb-row.is-current { background: var(--new); }
.lb-row .avatar { width: 28px; height: 28px; }
.lb-rank { font-size: 12px; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.lb-rank.top { color: var(--text); font-weight: 600; }
.lb-main { display: grid; min-width: 0; }
.lb-acc { font: 600 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-meta { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lb-pnl { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb-empty { padding: 14px 16px; font-size: 13px; color: var(--muted); }
.lb-partial, .lb-note { margin: 8px 16px 0; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.lb-partial { color: var(--warn); }

/* Folding exists only on narrower screens: a wide screen always shows the column. */
@media (max-width: 1179px) {
  .lb-col { position: static; margin-bottom: 12px; }
  .lb-summary {
    display: block; width: 100%; text-align: left; cursor: pointer; padding: 10px 14px; border: 1px solid var(--line);
    border-radius: var(--radius); background: var(--surface); color: var(--text); font-weight: 500; font-size: 13px;
  }
  .lb-summary::after { content: '▴'; float: right; color: var(--muted); }
  .lb-wrap:not(.folded) .lb-summary { margin-bottom: 12px; }
  .lb-wrap.folded .lb-summary::after { content: '▾'; }
  .lb-wrap.folded .lb-panel { display: none; }
  .lb-panel { max-height: 560px; }
  /* the folded block's own header already says "Top traders" */
  .lb-top { grid-template-areas: "controls refresh"; }
  .lb-title { display: none; }
}

/* ---------- sign-in gate (opening a wallet needs a signed-in visitor) ---------- */
.gate { width: min(420px, calc(100vw - 32px)); }
.gate-body { position: relative; text-align: center; padding: 24px 22px 20px; }
.gate-body .dialog-title { font-size: 18px; margin: 0 24px; }
.gate-sub { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.gate-body .landing-form { width: 100%; }
.gate-close { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; font-size: 20px; line-height: 1; }
.gate-note { margin: 0; }

/* ---------- Orders tab: open limit orders on Rhea DCL ---------- */
.ord-card.is-buy { border-left-color: var(--up); }
.ord-card.is-sell { border-left-color: var(--down); }
.pc-status.buy { color: var(--up); background: color-mix(in srgb, var(--up) 14%, transparent); }
.pc-status.sell { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }
.ord-card .pc-total .sub { font-size: 12px; font-weight: 400; }
.orders-view .po-sort { justify-content: flex-start; }

/* ---------- system addresses (contracts, not people) ---------- */
.sys-note {
  margin: 12px 0 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5;
  background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
}
.sys-note strong { color: var(--warn); font-weight: 600; }
