:root {
  /* One stepped tonal ramp (night synoptic chart): every neutral comes from here. */
  --z0: #060d15;
  --bg: #0b1622;
  --bg-2: #0a1520;
  --panel: #0f1d2b;
  --panel-2: #132535;
  --panel-3: #1a2e40;
  --line: #182a3b;
  --line-2: #24394d;
  --dim: #7c93a7;
  --muted: #8ea2b3;
  --text: #e7eef4;
  /* Isobar blue: selection, focus, primary actions. */
  --accent: #8fc1ec;
  --accent-ink: #06121d;
  --accent-soft: rgba(143, 193, 236, 0.12);
  /* Reserved for the user's own bot: its positions, copies, P&L. Never used for anything else. */
  --bot: #b48cff;
  --bot-ink: #160a2c;
  --bot-soft: rgba(180, 140, 255, 0.13);
  --green: #3ccf8e;
  --green-soft: rgba(60, 207, 142, 0.13);
  --red: #f0605d;
  --red-soft: rgba(240, 96, 93, 0.13);
  --amber: #f2b84b;
  --amber-soft: rgba(242, 184, 75, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 14px 36px rgba(2, 8, 14, 0.55);
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --num: 'Archivo Narrow', 'Archivo', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  /* Four-step numeral scale */
  --n1: 12px;
  --n2: 14px;
  --n3: 21px;
  --n4: 40px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --header-h: 60px;
  --tabbar-h: 64px;
  color-scheme: dark;
  accent-color: var(--accent);
  scrollbar-color: var(--panel-3) var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; font-family: var(--num); letter-spacing: 0.005em; }
::selection { background: rgba(143, 193, 236, 0.3); color: var(--text); }
input, textarea { caret-color: var(--accent); }
a { text-underline-offset: 3px; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.pos { color: var(--green); }
.neg { color: var(--red); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------------------ header */
.header {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 20px 0;
  display: flex; align-items: center; gap: 18px;
  background-color: #0d1a27;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='60' viewBox='0 0 640 60'%3E%3Cg fill='none' stroke='%2321364a' stroke-width='1'%3E%3Cpath d='M-10 44C80 30 150 52 240 40s170-30 260-12 120 22 150 10'/%3E%3Cpath d='M-10 26C70 14 160 34 250 22s160-24 250-6 110 18 150 6'/%3E%3Cpath d='M-10 8C90 -4 170 16 260 4s150-14 240 2 100 12 150 2'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 640px 60px;
  border-bottom: 1px solid var(--line-2);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; margin-top: -2px; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav button {
  background: none; border: 0; padding: 8px 14px; border-radius: 10px;
  color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 8px;
}
.nav button svg { width: 16px; height: 16px; }
.nav button:hover { color: var(--text); background: var(--panel); }
.nav button.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.live {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px;
  border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600;
}
.live:hover { border-color: var(--line-2); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); position: relative; }
.live.on .dot { background: var(--green); }
.live.on .dot::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--green);
  opacity: 0; animation: ping 1.8s ease-out infinite;
}
.live.off .dot { background: var(--red); }
@keyframes ping { 0% { transform: scale(0.5); opacity: 0.8; } 100% { transform: scale(1.6); opacity: 0; } }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 17px; height: 17px; }

/* ------------------------------------------------------------ layout */
main { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.view { display: none; animation: fadein 0.25s ease; }
.view.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; letter-spacing: -0.025em; margin: 0; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 14.5px; margin: 0; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.card-head h2 .badge { font-weight: 600; }
.card-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ------------------------------------------------------------ KPI */
.kpis {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin-bottom: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.kpis .kpi.card { background: none; border: 0; border-radius: 0; box-shadow: inset -1px 0 var(--line); }
.kpis .kpi.card:last-child { box-shadow: none; }
.kpi { padding: 14px 18px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-family: var(--num); font-variant-numeric: tabular-nums; font-size: var(--n3); font-weight: 700; letter-spacing: 0; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ratio { height: 6px; border-radius: 99px; background: var(--red); overflow: hidden; margin-top: 10px; }
.ratio > span { display: block; height: 100%; background: var(--green); border-radius: 99px 0 0 99px; transition: width 0.5s ease; }

/* ------------------------------------------------------------ controls */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 0 18px 14px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; padding: 6px 11px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 0 0 1px var(--line-2); }
.field {
  display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 3px 10px; height: 38px; min-width: 0;
}
.field:focus-within { border-color: var(--accent); }
.field svg { width: 15px; height: 15px; color: var(--dim); flex: none; }
.field input, .field select { background: none; border: 0; outline: none; height: 100%; min-width: 0; width: 100%; font-size: 13px; }
.field select { padding-right: 4px; }
.field select option { background: var(--panel); }
.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); user-select: none; cursor: pointer; background: none; border: 0; padding: 4px 2px; }
.toggle .sw { width: 34px; height: 20px; border-radius: 99px; background: var(--panel-3); border: 1px solid var(--line-2); position: relative; transition: background 0.2s; }
.toggle .sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 0.2s, background 0.2s; }
.toggle[aria-pressed='true'] { color: var(--text); }
.toggle[aria-pressed='true'] .sw { background: var(--accent-soft); border-color: rgba(143, 193, 236, 0.5); }
.toggle[aria-pressed='true'] .sw::after { transform: translateX(14px); background: var(--accent); }
.btn {
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); padding: 8px 14px;
  border-radius: 10px; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { background: var(--panel-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.block { width: 100%; }
.btn svg { width: 15px; height: 15px; }

/* ------------------------------------------------------------ pills / badges */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; line-height: 1.3;
}
.pill.long { background: var(--green-soft); color: var(--green); }
.pill.short { background: var(--red-soft); color: var(--red); }
.pill.closeL { background: rgba(60, 207, 142, 0.06); color: #8fdcb8; box-shadow: inset 0 0 0 1px rgba(60, 207, 142, 0.22); }
.pill.closeS { background: rgba(240, 96, 93, 0.06); color: #f1a0ad; box-shadow: inset 0 0 0 1px rgba(240, 96, 93, 0.22); }
.pill.flip { background: var(--accent-soft); color: var(--accent); }
.badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 650; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.badge.rank { background: var(--accent-soft); color: var(--accent); }
.badge.hft { background: var(--amber-soft); color: var(--amber); }
.badge.new { background: var(--accent); color: var(--accent-ink); }
.coin {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.01em; background: none; border: 0; padding: 0;
}
.coin .ci {
  width: 28px; height: 26px; border-radius: 7px; display: grid; place-items: center; font: 700 11px/1 var(--num);
  color: var(--muted); background: var(--panel-3); box-shadow: inset 0 0 0 1px var(--line-2); flex: none; letter-spacing: 0.02em;
}
.coin:hover .cn { color: var(--accent); }
.trader-link { background: none; border: 0; padding: 0; color: var(--text); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; text-align: left; }
.trader-link:hover .tn { color: var(--accent); }
.tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ feed */
.feed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.feed { list-style: none; margin: 0; padding: 0; }
.trade {
  display: grid; grid-template-columns: 64px 128px minmax(110px, 1fr) minmax(120px, 1fr) minmax(140px, 1.3fr) 100px;
  align-items: center; gap: 14px; padding: 11px 18px; border-top: 1px solid var(--line); position: relative;
  transition: background 0.6s ease;
}

.trade:hover { background: rgba(255, 255, 255, 0.018); }
.trade.flash { background: rgba(143, 193, 236, 0.07); }
.trade .t-time { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.trade .t-size { font-family: var(--num); font-weight: 700; font-size: var(--n2); white-space: nowrap; }
.trade .t-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trade .t-pnl { text-align: right; font-weight: 650; white-space: nowrap; }
.trade .t-pnl small { display: block; font-weight: 500; color: var(--dim); font-size: 11px; }
.feed-head { display: grid; grid-template-columns: 64px 128px minmax(110px, 1fr) minmax(120px, 1fr) minmax(140px, 1.3fr) 100px; gap: 14px; padding: 8px 18px; color: var(--dim); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.feed-head span:last-child { text-align: right; }
.more { padding: 14px 18px 18px; display: flex; justify-content: center; }
.new-banner {
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top) + 10px); z-index: 5; display: none; margin: 0 auto -38px; width: max-content;
}
.new-banner.show { display: block; }
.new-banner button { box-shadow: var(--shadow); border-radius: 999px; }

/* side panels */
.side { display: grid; gap: 16px; position: sticky; top: calc(var(--header-h) + 20px); }
.mini-list { list-style: none; margin: 0; padding: 0 0 8px; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 9px 18px; border-top: 1px solid var(--line); }
.mini-list li > :last-child { margin-left: auto; text-align: right; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; color: var(--dim); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 8px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: transparent;
}
th.r, td.r { text-align: right; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--muted); }
th.sorted { color: var(--accent); }
td { padding: 11px 14px; border-top: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:first-child td { border-top: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: rgba(255, 255, 255, 0.02); }

.split { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--panel-3); min-width: 120px; gap: 2px; }
.split .l { background: var(--green); }
.split .s { background: var(--red); }
.split-cell { display: grid; gap: 6px; min-width: 150px; }
.split-meta { display: flex; justify-content: space-between; font-size: 12px; font-weight: 650; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.stack { display: grid; gap: 16px; }

/* ------------------------------------------------------------ sheet (trader / coin detail) */
.scrim { position: fixed; inset: 0; background: rgba(2, 4, 8, 0.6); backdrop-filter: blur(3px); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); z-index: 60; background: var(--bg-2);
  border-left: 1px solid var(--line-2); box-shadow: var(--shadow); transform: translateX(102%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column;
}
.sheet.show { transform: none; }
.sheet-head { display: flex; align-items: flex-start; gap: 14px; padding: calc(18px + env(safe-area-inset-top)) 22px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sheet-head .addr { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); flex-wrap: wrap; }
.sheet-body { overflow-y: auto; overflow-x: hidden; padding: 18px 22px calc(30px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; -webkit-overflow-scrolling: touch; }
.sheet .close { margin-left: auto; flex: none; }
.statgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.stat .label { color: var(--muted); font-size: 11.5px; font-weight: 550; }
.stat .value { font-family: var(--num); font-variant-numeric: tabular-nums; font-size: var(--n3); font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.links { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-link { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--text); }
.chip-link:hover { border-color: var(--accent); text-decoration: none; }
.chip-link svg { width: 13px; height: 13px; }
.compact .trade { grid-template-columns: 58px 118px minmax(90px, 1fr) minmax(110px, 1fr) 90px; padding: 10px 16px; }
.compact .trade .t-trader { display: none; }

/* ------------------------------------------------------------ empty / loading */
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; color: var(--dim); margin-bottom: 8px; }
.empty b { color: var(--text); display: block; margin-bottom: 4px; font-size: 14px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.progress { height: 4px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width 0.5s ease; }
.notice {
  display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px;
  background: var(--accent-soft); border: 1px solid rgba(143, 193, 236, 0.28); font-size: 13px;
}
.notice .progress { flex: 1; min-width: 80px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--panel-3); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 10px; z-index: 80; font-weight: 600;
  transition: all 0.25s; pointer-events: none; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.health { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.health .stat .value { font-size: var(--n2); }

/* ------------------------------------------------------------ mobile tab bar */
.tabbar { display: none; }

@media (max-width: 1100px) {
  .feed-grid { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:first-child { grid-column: span 2; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  body { font-size: 14px; }
  .header { padding-left: 16px; padding-right: 12px; gap: 10px; }
  .nav { display: none; }
  .brand small { display: none; }
  .live .txt-long { display: none; }
  main { padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 20px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis .kpi:first-child { grid-column: span 2; }
  .kpi .value { font-size: var(--n3); }
  .side { grid-template-columns: minmax(0, 1fr); }
  .notice { flex-wrap: wrap; gap: 6px 12px; }
  .split-cell { min-width: 120px; }
  .trade .t-coin .coin .badge { display: none; }
  .notice .progress { flex-basis: 100%; }
  .toolbar { padding: 0 14px 12px; gap: 8px; }
  .toolbar .field { flex: 1 1 140px; }
  .card-head { padding: 14px 14px 10px; }
  .feed-head { display: none; }
  .trade, .compact .trade {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'coin pnl' 'size time' 'trader trader';
    gap: 4px 10px; padding: 12px 14px;
  }
  .trade .t-coin { grid-area: coin; display: flex; align-items: center; gap: 8px; min-width: 0; }
  .trade .t-time { grid-area: time; text-align: right; }
  .trade .t-sizebox { grid-area: size; display: flex; gap: 8px; align-items: baseline; min-width: 0; }
  .trade .t-trader { grid-area: trader; font-size: 12.5px; }
  .compact .trade .t-trader { display: none; }
  .trade .t-pnl { grid-area: pnl; }
  .trade .t-dir { display: none; }
  .trade .t-coin .pill { display: inline-flex; }
  td, th { padding: 10px 7px; }
  td:first-child, th:first-child { padding-left: 14px; }
  td:last-child, th:last-child { padding-right: 14px; }
  .cell-sub { white-space: normal; }
  #traders-body .tn { max-width: 118px; }
  .sheet-head .addr .mono { font-size: 11px; word-break: break-all; }
  .sheet-head h2 { font-size: 16px; }
  .split-cell { min-width: 96px !important; }
  .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet { width: 100%; top: auto; height: calc(100% - 24px - env(safe-area-inset-top)); border-left: 0; border-top: 1px solid var(--line-2); border-radius: 18px 18px 0 0; transform: translateY(102%); }
  .sheet-head { padding: 16px 16px 14px; }
  .sheet-head::before { content: ''; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; border-radius: 99px; background: var(--line-2); transform: translateX(-50%); }
  .sheet-body { padding: 14px 16px calc(30px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(8, 11, 16, 0.9); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar button { background: none; border: 0; color: var(--dim); display: grid; place-items: center; align-content: center; gap: 4px; font-size: 11px; font-weight: 650; }
  .tabbar button svg { width: 22px; height: 22px; }
  .tabbar button.active { color: var(--accent); }
  .health { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none !important; }
}
@media (min-width: 761px) { .t-coin .pill { display: none; } .show-sm { display: none !important; } }


.trade .t-sizebox { display: flex; flex-direction: column; min-width: 0; }
.trade .t-coin { min-width: 0; }
@media (max-width: 760px) { .trade .t-sizebox { flex-direction: row; } }

.view .stack > .card, .feed-grid > * { min-width: 0; }
.show-all { padding: 10px 18px 16px; display: flex; justify-content: center; }

/* ------------------------------------------------------------ charts */
.chart-coins { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chart-coins::-webkit-scrollbar { display: none; }
.coin-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 12px; flex: none;
  background: var(--panel); border: 1px solid var(--line); font-weight: 650; font-size: 13px; color: var(--text);
}
.coin-chip .ci { width: 26px; height: 24px; border-radius: 7px; display: grid; place-items: center; font: 700 11px/1 var(--num); color: var(--muted); background: var(--panel-3); }
.coin-chip small { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.coin-chip:hover { border-color: var(--line-2); }
.coin-chip.active { border-color: var(--accent); background: var(--accent-soft); }
.chart-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.chart-card { min-width: 0; overflow: hidden; }
.chart-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px 6px; }
.chart-search { width: 170px; }
.chart-legend { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding: 8px 16px 4px; min-height: 30px; font-size: 12.5px; color: var(--muted); }
.chart-legend .lg-coin { font-size: 16px; font-weight: 750; color: var(--text); letter-spacing: -0.02em; }
.chart-legend .lg-px { font-size: var(--n3); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-legend b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; height: 520px; padding: 0 4px; }
#chart { position: absolute; inset: 0 4px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; background: rgba(2, 4, 8, 0.6); }
.chart-key { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 16px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.chart-key i { display: inline-block; }
.k-buy { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid var(--green); }
.k-sell { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid var(--red); }
.k-line { width: 16px; height: 0; border-top: 2px dashed currentColor; }
.mini-feed li { gap: 10px; }
.mini-feed .mf-main { min-width: 0; flex: 1; }
.mini-feed .mf-top { display: flex; align-items: center; gap: 8px; }
.mini-feed .mf-sub { color: var(--muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-feed .mf-right { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.mini-feed .mf-right .dim { font-size: 12px; }
.pos-split { display: grid; gap: 10px; }
.pos-split .row { display: flex; justify-content: space-between; font-size: 13px; }
.pos-split .row span:first-child { color: var(--muted); }
@media (max-width: 1100px) { .chart-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .tabbar { grid-template-columns: repeat(4, 1fr); }
  .chart-wrap { height: 380px; }
  .chart-toolbar { padding: 12px 12px 4px; gap: 8px; }
  .chart-search { width: 100%; flex: 1 1 100%; }
  .chart-legend { padding: 8px 12px 2px; }
  .chart-key { padding: 10px 12px 12px; gap: 6px 12px; }
}
.chart-empty[hidden] { display: none; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ copy bot */
.big-toggle { width: 64px; height: 36px; border-radius: 99px; background: var(--panel-3); border: 1px solid var(--line-2); position: relative; padding: 0; flex: none; transition: background 0.2s; }
.big-toggle .sw { position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: var(--muted); transition: transform 0.2s, background 0.2s; }
.big-toggle[aria-pressed='true'] { background: var(--bot-soft); border-color: var(--bot); }
.big-toggle[aria-pressed='true'] .sw { transform: translateX(28px); background: var(--bot); }
.bot-state { font-size: 16px; font-weight: 750; letter-spacing: -0.02em; }
.badge.paper { background: var(--panel-3); color: var(--muted); }
.badge.testnet { background: var(--amber-soft); color: var(--amber); }
.badge.mainnet { background: var(--red-soft); color: var(--red); }
.btn.danger { background: var(--red-soft); color: var(--red); border-color: rgba(240, 96, 93, 0.4); }
.btn.danger:hover { background: rgba(240, 96, 93, 0.22); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.bot-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.form-body { padding: 0 18px 18px; display: grid; gap: 14px; }
.fld { display: grid; gap: 6px; min-width: 0; }
.fld > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.fld small { font-size: 11.5px; line-height: 1.4; }
.fld .field b { font-weight: 600; }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sig-action { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.sig-copied { background: var(--bot-soft); color: var(--bot); }
.sig-skipped { background: var(--panel-3); color: var(--muted); }
.sig-failed { background: var(--red-soft); color: var(--red); }
.confirm-box { display: grid; gap: 14px; }
.confirm-box .btns { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .tabbar { grid-template-columns: repeat(5, 1fr); }
  .tabbar button { font-size: 11px; }
}

/* ------------------------------------------------------------ copy markers + bot dashboard */
.badge.copied { background: var(--bot-soft); color: var(--bot); gap: 4px; }
.badge.copied svg { width: 11px; height: 11px; }
.trade.is-copied { background: rgba(180, 140, 255, 0.05); }
.bot-pill { color: var(--bot); border-color: rgba(180, 140, 255, 0.4); }
.bot-pill svg { width: 14px; height: 14px; }
.equity-wrap { position: relative; height: 240px; margin: 0 8px 12px; }
#equity-chart { position: absolute; inset: 0; }
.ex-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 18px 12px; }
.ex-stats .stat { padding: 10px 12px; }
.ex-stats .stat .value { font-size: var(--n2); }
.ex-orders { list-style: none; margin: 0; padding: 0 0 8px; }
.ex-orders li { display: flex; align-items: center; gap: 10px; padding: 8px 18px; border-top: 1px solid var(--line); font-size: 13px; }
.ex-orders li > :last-child { margin-left: auto; }
.copy-feed { list-style: none; margin: 0; padding: 0 0 6px; }
.copy-item { display: grid; grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr) 104px; gap: 12px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.copy-item.flash { background: var(--bot-soft); }
.copy-item .ci-arrow { color: var(--dim); display: grid; place-items: center; }
.copy-item .ci-arrow svg { width: 16px; height: 16px; }
.copy-item.copied .ci-arrow { color: var(--bot); }
.copy-item .ci-time { display: grid; justify-items: end; gap: 2px; font-size: var(--n1); color: var(--muted); text-align: right; }
.copy-item .ci-time b { color: var(--text); font-weight: 600; }
.ours { color: var(--bot); }
.copy-item .ci-side { min-width: 0; }
.copy-item .ci-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copy-item .ci-sub { color: var(--muted); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-item .ci-sub .trader-link { font-size: 12px; }
.copy-item.skipped .ci-ours { opacity: 0.75; }
.lat { display: inline-flex; gap: 6px; font-size: 11.5px; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }
.lat b { color: var(--text); font-weight: 650; }
@media (max-width: 760px) {
  .copy-item { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 12px 14px; }
  .copy-item .ci-side:first-child { grid-column: 1 / -1; }
  .copy-item .ci-arrow { display: none; }
  .copy-item .ci-time { grid-auto-flow: column; gap: 10px; }
  .bot-pill span { display: none; }
  .bot-pill { padding: 6px 9px; }
  .ex-stats { padding: 0 14px 12px; }
}

.sig-followed { background: var(--accent-soft); color: var(--accent); }


/* ------------------------------------------------------------ copy bot: barograph desk */
.bot-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.bot-main, .bot-rail { min-width: 0; }
.baro { overflow: hidden; }
.baro-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px 0; flex-wrap: wrap; }
.baro-id { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.baro-id h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }
.baro-controls { display: flex; align-items: center; gap: 16px; }
.baro-reading { display: flex; align-items: baseline; gap: 6px 18px; padding: 14px 20px 0; flex-wrap: wrap; }
.baro-pnl { font-size: var(--n4); font-weight: 700; line-height: 1; color: var(--text); }
.baro-pnl.pos { color: var(--green); }
.baro-pnl.neg { color: var(--red); }
.baro-sub { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 13px; }
.baro-sub b { color: var(--text); font-family: var(--num); font-weight: 600; }
.baro .equity-wrap {
  height: 228px; margin: 14px 0 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.baro .equity-wrap #equity-chart { inset: 0 0 0 0; }
.baro-key { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 20px; font-size: 12px; color: var(--muted); }
.baro-key span { display: inline-flex; align-items: center; gap: 7px; }
.k-long { width: 13px; height: 6.5px; border-radius: 999px 999px 0 0; background: var(--green); }
.k-short { width: 0; height: 0; border-left: 6.5px solid transparent; border-right: 6.5px solid transparent; border-top: 10px solid var(--red); }
.k-trace { width: 18px; height: 2px; background: var(--bot); border-radius: 999px; }
.bot-kpis { margin: 0; border: 0; border-radius: 0; border-top: 1px solid var(--line); background: none; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.bot-meta { display: flex; flex-wrap: wrap; gap: 10px 28px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.bot-meta .m { display: grid; gap: 2px; min-width: 0; }
.bot-meta .m span { color: var(--muted); font-size: 11.5px; font-weight: 550; }
.bot-meta .m b { font-size: var(--n2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.bot-desc { font-size: 12.5px; line-height: 1.55; margin: 0 4px; }
.pressure { list-style: none; margin: 0; padding: 0 0 6px; }
.pressure li { display: grid; grid-template-columns: 32px minmax(0, 1fr) 84px; gap: 12px; align-items: center; padding: 9px 18px; border-top: 1px solid var(--line); cursor: pointer; transition: background 0.18s var(--ease); }
.pressure li:hover { background: var(--panel-2); }
.pressure .cell-name { display: flex; justify-content: space-between; font-weight: 650; font-size: 13px; margin-bottom: 5px; }
.pressure .cell-name small { color: var(--muted); font-weight: 500; font-family: var(--num); }
.pressure .r { text-align: right; font-family: var(--num); font-size: var(--n1); color: var(--muted); }
.hl { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 700 var(--n2)/1 var(--num); border: 2px solid currentColor; }
.hl.H { color: var(--green); }
.hl.L { color: var(--red); }
.hl.E { color: var(--dim); border-style: dashed; }
.hl.sm { width: 22px; height: 22px; font-size: 12px; border-width: 1.5px; }
@media (max-width: 1180px) { .bot-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .baro-head { padding: 14px 14px 0; }
  .baro-controls { width: 100%; flex-wrap: wrap; gap: 12px; }
  .baro-controls .bot-switch { flex: 1 1 100%; }
  .baro-controls .btn.danger { flex: 1 1 100%; }
  .baro-reading { padding: 12px 14px 0; }
  .baro .equity-wrap { height: 210px; }
  .baro-key, .bot-meta { padding-left: 14px; padding-right: 14px; }
  .bot-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bot-kpis .kpi.card { box-shadow: inset -1px -1px var(--line); }
}

.bot-switch { display: flex; align-items: center; gap: 12px; }

/* ------------------------------------------------------------ motion: state, arrival, the pen */
.view.active { animation: fadein 0.18s var(--ease); }
@keyframes fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.trade.flash, .copy-item.flash { animation: arrive 0.42s var(--ease); }
.copy-item.flash { background: var(--bot-soft); transition: background 1.2s var(--ease); }
@keyframes arrive { from { opacity: 0.2; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.ticked { animation: tick 0.7s var(--ease); }
@keyframes tick { 0% { color: var(--text); } 100% { } }
.btn, .seg button, .nav button, .tabbar button, .icon-btn, .chip-link, .coin-chip, tbody tr.click td { transition: background 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease); }
.btn:active, .seg button:active { transform: translateY(1px); }
.big-toggle .sw { transition: transform 0.22s var(--ease), background 0.22s var(--ease); }

/* Reduced motion: keep colour and state feedback, drop spatial movement. */
@media (prefers-reduced-motion: reduce) {
  @keyframes fadein { from { opacity: 0.4; } to { opacity: 1; } }
  @keyframes arrive { from { opacity: 0.4; } to { opacity: 1; } }
  .sheet { transition-duration: 0.01ms; }
  .live.on .dot::after,   .btn:active, .seg button:active { transform: none; }
  @keyframes glyph-drop { from { opacity: 0; } to { opacity: 1; } }
  .pen-ink.inking { animation: none; }
}

/* barograph overlay: front glyphs and the pen */
.baro-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 2; }
.glyph.long { fill: var(--green); }
.glyph.short { fill: var(--red); }
.glyph { stroke: var(--panel); stroke-width: 1.5; paint-order: stroke; transform-box: fill-box; }
.glyph.drop { animation: glyph-drop 0.5s var(--ease) both; }
@keyframes glyph-drop { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
.pen-ink { fill: none; stroke: var(--bot); stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 0; }
.pen-ink.inking { animation: pen-ink 0.22s var(--ease) both; }
@keyframes pen-ink { from { stroke-dashoffset: 0.45; } to { stroke-dashoffset: 0; } }
.pen-head { fill: var(--bot); stroke: var(--panel); stroke-width: 2; }
/* skipped signals recede so copies lead the feed */
.copy-item.quiet { grid-template-columns: 64px minmax(0, 1fr) 104px; padding: 7px 18px; color: var(--dim); font-size: 12.5px; }
.copy-item.quiet .q-coin { font-family: var(--num); font-weight: 700; color: var(--muted); }
.copy-item.quiet span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-item.quiet .num { text-align: right; font-size: var(--n1); }

.bot-kpis .kpi.card:first-child { grid-column: auto; }
@media (max-width: 760px) {
  .copy-item.quiet { grid-template-columns: 44px minmax(0, 1fr) auto; padding: 8px 14px; }
}
.nav button, .live, .bot-pill { white-space: nowrap; }
@media (max-width: 1060px) and (min-width: 761px) {
  .brand small { display: none; }
  .nav { margin-left: 0; }
  .header { gap: 12px; }
  .nav button { padding: 8px 9px; }
  .nav button svg { display: none; }
  .bot-pill span, .live .txt-long { display: none; }
}

.copy-item.quiet.run { cursor: pointer; }
.copy-item.quiet.run:hover { background: var(--panel-2); }
.copy-item.quiet.run[aria-expanded='true'] { color: var(--muted); }

/* KPI detail lines wrap instead of truncating real figures */
.bot-kpis .kpi .foot { white-space: normal; overflow: visible; }
