/* grep.fi — terminal UI */
:root {
  --bg: #0A0A0A;
  --panel: #0E100F;
  --panel-2: #131614;
  --line: #1E2420;
  --line-2: #2A322D;
  --text: #E5E5E5;
  --muted: #8C8C8C;
  --dim: #5E655F;
  --green: #00FF88;
  --green-dim: rgba(0, 255, 136, .12);
  --red: #FF4D6A;
  --red-dim: rgba(255, 77, 106, .12);
  --amber: #FFB020;
  --cyan: #4DD8FF;
  --font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ticker-h: 28px;
  --top-h: 60px;
  --status-h: 26px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--text); }
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--green); color: var(--bg); }

/* thin dark scrollbars (the default light ones looked off on desktop) */
* { scrollbar-width: thin; scrollbar-color: #2A322D transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #2A322D; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #3c4740; background-clip: padding-box; }
*::-webkit-scrollbar-corner { background: transparent; }

/* CRT overlay */
body.crt::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

@keyframes blink { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }
.blink { animation: blink 1.1s steps(1) infinite; }

/* ---------- ticker ---------- */
.ticker {
  height: var(--ticker-h);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  white-space: nowrap;
  background: #070807;
}
.ticker-track {
  display: inline-flex;
  gap: 28px;
  padding-left: 28px;
  line-height: var(--ticker-h);
  animation: scroll 60s linear infinite;
  font-size: 12px;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes scroll { to { transform: translateX(-50%); } }
.tk-sym { color: var(--muted); margin-right: 6px; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--green); flex-shrink: 0; }
.brand:hover { color: var(--green); }
.brand-icon { width: 30px; height: 30px; }
.brand-word { color: var(--text); font-weight: 800; font-size: 20px; letter-spacing: -1px; display: flex; align-items: baseline; }
.brand-dot { display: inline-block; width: 6px; height: 6px; background: var(--green); margin: 0 2px; box-shadow: 0 0 8px var(--green); }

.cmd {
  flex: 1;
  min-width: 0;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  background: var(--panel);
  border: 1px solid var(--line-2);
}
.cmd:focus-within { border-color: var(--green); box-shadow: 0 0 0 1px var(--green-dim); }
.cmd-prompt { color: var(--green); white-space: nowrap; }
.cmd input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; }
.cmd input::placeholder { color: var(--dim); }
.cmd-kbd { font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); padding: 0 6px; }

.chain-badge {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-2);
  padding: 0 10px; height: 36px;
  white-space: nowrap;
}
.chain-dot { width: 8px; height: 8px; background: var(--green); box-shadow: 0 0 8px var(--green); }
.chain-id { color: var(--muted); font-size: 11px; border-left: 1px solid var(--line-2); padding-left: 8px; }
.chains { display: flex; gap: 4px; }
.chip {
  background: none;
  border: 1px solid var(--line-2);
  color: var(--muted);
  padding: 6px 10px;
  min-height: 32px;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.active { color: var(--bg); background: var(--green); border-color: var(--green); font-weight: 700; }

.btn {
  background: var(--green);
  color: var(--bg);
  border: 1px solid var(--green);
  padding: 8px 14px;
  min-height: 36px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); box-shadow: 0 0 12px var(--green-dim); }
.btn-outline { background: none; color: var(--green); }
.btn-outline:hover { background: var(--green-dim); }
.btn-sm { padding: 4px 10px; min-height: 28px; font-size: 12px; }
.btn-red { background: var(--red); border-color: var(--red); color: var(--bg); }
.btn-ghost { background: none; border-color: var(--line-2); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

/* ---------- shell ---------- */
.shell {
  height: calc(100vh - var(--ticker-h) - var(--top-h) - var(--status-h));
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 340px;
}
@supports (height: 100dvh) {
  .shell { height: calc(100dvh - var(--ticker-h) - var(--top-h) - var(--status-h)); }
}
.m-show { display: none; }

.sidebar {
  border-right: 1px solid var(--line);
  padding: 14px 0;
  display: flex;
  flex-direction: column;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--muted);
  border-left: 2px solid transparent;
}
.sidebar a:hover { color: var(--text); background: var(--panel); }
.sidebar a.active { color: var(--green); border-left-color: var(--green); background: var(--green-dim); }
.nav-caret { opacity: 0; width: 8px; margin-right: -4px; }
.nav-ico { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar a.active .nav-ico { filter: drop-shadow(0 0 6px rgba(0, 255, 136, .6)); }
.sidebar a.active .nav-caret, .sidebar a:hover .nav-caret { opacity: 1; }
.sidebar .short { display: none; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--line); }

.mini-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.daemon-pill { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); }
.daemon-pill .dot { width: 8px; height: 8px; background: var(--dim); }
.daemon-pill.on { color: var(--green); }
.daemon-pill.on .dot { background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 1.1s steps(1) infinite; }

/* ---------- main ---------- */
.main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.view-head { padding: 16px 18px 6px; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.view-title { margin: 0; font-size: 18px; font-weight: 800; }
.view-title::before { content: "~/"; color: var(--green); }
.view-sub { margin: 0; color: var(--muted); font-size: 12px; }

.toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 18px 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.toolbar .sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; }
.toolbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.field {
  background: var(--panel);
  border: 1px solid var(--line-2);
  padding: 5px 8px;
  min-height: 32px;
  width: 84px;
  outline: 0;
}
.field:focus { border-color: var(--green); }
select.field { width: auto; }

.table-wrap { flex: 1; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  text-align: right;
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text); }
thead th.sorted { color: var(--green); }
th:first-child, td:first-child { text-align: left; }
th.left, td.left { text-align: left; }
tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
tbody tr { cursor: pointer; transition: background .3s; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.flash-up { background: var(--green-dim); }
tbody tr.flash-down { background: var(--red-dim); }
td.sticky, th.sticky { position: sticky; left: 0; background: var(--bg); z-index: 1; }
thead th.sticky { z-index: 3; }
tbody tr:hover td.sticky { background: var(--panel-2); }

.tok { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 12px;
  color: var(--bg);
  background: var(--av, var(--green));
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar.has-img { background: #141714; box-shadow: inset 0 0 0 1px var(--line-2); }
.tok-name { font-weight: 700; }
.tok-sub { color: var(--muted); font-size: 11px; display: flex; gap: 8px; align-items: center; }
.copy { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 0; font-size: 11px; }
.copy:hover { color: var(--green); }

.up { color: var(--green); }
.down { color: var(--red); }
.muted { color: var(--muted); }
.amber { color: var(--amber); }
.cyan { color: var(--cyan); }
.tag { display: inline-block; font-size: 10px; padding: 1px 5px; border: 1px solid currentColor; margin-left: 6px; vertical-align: middle; }

.score { display: inline-flex; align-items: center; gap: 8px; }
.score-bar { width: 52px; height: 6px; background: var(--line-2); position: relative; }
.score-bar i { position: absolute; inset: 0 auto 0 0; background: var(--green); }
.score.mid .score-bar i { background: var(--amber); }
.score.low .score-bar i { background: var(--red); }

.buy-btn {
  background: none;
  border: 1px solid var(--green);
  color: var(--green);
  padding: 4px 10px;
  min-height: 30px;
  cursor: pointer;
  font-weight: 700;
}
.buy-btn:hover { background: var(--green); color: var(--bg); }

.empty { padding: 40px 18px; color: var(--muted); }

/* new pairs columns */
.lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; height: 100%; }
.lane { border-right: 1px solid var(--line); overflow: auto; }
.lane:last-child { border-right: 0; }
.lane-head { position: sticky; top: 0; background: var(--bg); padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; z-index: 1; }
.lane-head b { font-weight: 700; }
.card {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}
.card:hover { background: var(--panel-2); }
.card.fresh { animation: fresh 1.2s ease-out; }
@keyframes fresh { from { background: var(--green-dim); } to { background: transparent; } }
.card-meta { color: var(--muted); font-size: 11px; display: flex; gap: 10px; flex-wrap: wrap; }
.progress { height: 4px; background: var(--line-2); margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--green); }

/* ---------- agent console ---------- */
.console {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #080908;
}
.console-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--green); }
.console-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.stat-big { font-size: 16px; font-weight: 700; margin-top: 2px; }
.console-strategy { display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.console-strategy select { background: var(--panel); border: 1px solid var(--line-2); padding: 6px 8px; min-height: 34px; }
.log { flex: 1; overflow: auto; padding: 10px 14px; font-size: 12px; line-height: 1.6; }
.log-line { white-space: pre-wrap; word-break: break-word; }
.log-line .ts { color: var(--dim); }
.log-line .lv-scan { color: var(--cyan); }
.log-line .lv-match { color: var(--amber); }
.log-line .lv-exec { color: var(--green); }
.log-line .lv-exit { color: var(--text); }
.log-line .lv-warn { color: var(--red); }
.agent-log {
  flex: none;
  height: 46vh;
  min-height: 240px;
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  background: #080908;
  overscroll-behavior: contain;
}
.log-head { display: flex; align-items: center; justify-content: space-between; padding-right: 18px; }
.log-jump { min-height: 28px; padding: 2px 10px; color: var(--green); border-color: var(--green); }
.log-cursor::after { content: "█"; color: var(--green); animation: blink 1.1s steps(1) infinite; }

/* agent view */
.agent-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.agent-grid > div { background: var(--bg); padding: 14px 18px; }
.agent-grid .stat-big { font-size: 22px; }
.section-title { padding: 14px 18px 8px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.mini-sub { font-size: 11px; margin-top: 2px; }
.gas-grid .stat-big { font-size: 16px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 90; }
.modal {
  position: fixed; z-index: 95; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); overflow: auto;
  background: var(--bg); border: 1px solid var(--green); box-shadow: 0 20px 60px rgba(0,0,0,.7);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); }
.modal-head b { font-size: 15px; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.qr { background: #fff; padding: 10px; width: 200px; height: 200px; margin: 0 auto; }
.qr svg { width: 100%; height: 100%; display: block; }
.dep-addr { font-size: 13px; text-align: center; word-break: break-all; padding: 8px; border: 1px dashed var(--line-2); }
.warn-box { border: 1px solid var(--amber); color: var(--text); background: rgba(255,176,32,.07); padding: 10px 12px; font-size: 12px; line-height: 1.5; }
.f-label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.f-input { background: var(--panel); border: 1px solid var(--line-2); padding: 10px; min-height: 42px; color: var(--text); font: inherit; font-size: 14px; outline: 0; width: 100%; }
.f-input:focus { border-color: var(--green); }
.f-hint { font-size: 12px; min-height: 16px; margin-top: -6px; }
.amount .chip { min-height: 30px; margin-right: 4px; }
.review-amt { font-size: 26px; font-weight: 800; text-align: center; padding: 6px 0; }
.review-amt span { color: var(--muted); font-size: 16px; }
.addr-wrap { word-break: break-all; text-align: right; max-width: 70%; font-size: 12px; }
.row-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.row-btns .btn { min-height: 44px; }
.pf-actions { display: flex; gap: 8px; margin-left: auto; }
.pf-actions .btn { min-height: 40px; }
.row-acts { white-space: nowrap; }
.send-btn { border-color: var(--cyan); color: var(--cyan); }
.send-btn:hover { background: var(--cyan); color: var(--bg); }
.pf-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pf-id { display: flex; gap: 12px; align-items: center; min-width: 0; }
.pf-id .w-ico, .pf-id .w-ico svg { width: 26px; height: 26px; }
.pf-who { font-weight: 800; font-size: 15px; word-break: break-all; }
.pf-addr { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); word-break: break-all; }
.pf-total { text-align: right; }
.pf-total-v { font-size: 28px; font-weight: 800; color: var(--green); }
.pf-share { display: inline-block; width: 46px; height: 5px; background: var(--line-2); vertical-align: middle; margin-right: 6px; }
.pf-share i { display: block; height: 100%; background: var(--cyan); }
.pf-dust { margin: 10px 18px 24px; color: var(--muted); }
.pf-dust summary { cursor: pointer; padding: 8px 0; }
.pf-empty { padding: 60px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pf-empty-title { font-size: 18px; font-weight: 800; }
.agent-note { padding: 10px 18px 0; margin: 0; font-size: 12px; }
.signal { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 18px 8px; padding: 10px 12px; border: 1px solid var(--line-2); background: var(--panel); }
.signal.buy { border-left: 3px solid var(--green); }
.signal.sell { border-left: 3px solid var(--red); }
.signal.done { opacity: .7; }
.signal-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12px; }
.signal-main .muted { word-break: break-word; }
.signal-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.ascii { color: var(--green); padding: 4px 18px 14px; margin: 0; font-size: 12px; line-height: 1.25; overflow: auto; }

/* ---------- status bar ---------- */
.statusbar {
  height: var(--status-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 0 0 0;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.sb-mode { background: var(--green); color: var(--bg); font-weight: 800; padding: 0 10px; height: 100%; display: flex; align-items: center; }
.sb-btn { background: none; border: 0; border-left: 1px solid var(--line); color: var(--muted); padding: 0 12px; height: 100%; cursor: pointer; }
.sb-btn:hover { color: var(--green); }
.sb-right { margin-left: auto; }
.sb-feed { border-left: 0; padding: 0; color: var(--amber); }
.sb-feed.live { color: var(--green); }
.live-tag { color: var(--green); border-color: var(--green); }
.demo-tag { color: var(--amber); border-color: var(--amber); }
.embed-box { border: 1px solid var(--line); height: 360px; }
.embed-box iframe { width: 100%; height: 100%; border: 0; display: block; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.btn.connected { background: none; color: var(--green); }
#connectBtn { display: inline-flex; align-items: center; gap: 8px; }
.btn.wallet-on { background: var(--green-dim); border-color: var(--green); color: var(--text); font-weight: 500; }
.btn.wallet-on:hover { background: rgba(0, 255, 136, .2); }
.btn.busy { opacity: .8; cursor: progress; }
.w-spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.w-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); flex-shrink: 0; }
.w-ico { width: 16px; height: 16px; display: inline-grid; place-items: center; color: var(--text); flex-shrink: 0; }
.w-ico svg { width: 16px; height: 16px; }
.w-addr { font-weight: 700; color: var(--green); }
.w-bal { color: var(--muted); border-left: 1px solid var(--line-2); padding-left: 8px; }
.w-caret { color: var(--muted); font-size: 10px; }
.w-warn { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); color: var(--red); font-weight: 800; }
.wallet-menu {
  position: fixed; z-index: 80; width: 290px; max-width: calc(100vw - 16px);
  background: var(--panel); border: 1px solid var(--green); box-shadow: 0 16px 40px rgba(0,0,0,.6);
  display: flex; flex-direction: column; padding: 6px;
}
.wallet-menu > button, .wallet-menu > a {
  text-align: left; background: none; border: 0; color: var(--text); padding: 10px 10px; min-height: 40px; cursor: pointer; font: inherit; display: block;
}
.wallet-menu > button:hover, .wallet-menu > a:hover { background: var(--panel-2); color: var(--green); }
.wm-head { display: flex; gap: 10px; align-items: center; padding: 8px 10px; }
.wm-head .w-ico, .wm-head .w-ico svg { width: 22px; height: 22px; }
.wm-who { font-weight: 700; word-break: break-all; }
.wm-addr { font-size: 11px; color: var(--muted); padding: 0 10px 8px; word-break: break-all; border-bottom: 1px solid var(--line); }
.wm-bal { display: flex; justify-content: space-between; padding: 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.wallet-menu .wm-out { color: var(--red); border-top: 1px solid var(--line); margin-top: 4px; }
.btn.connected.btn-red { color: var(--bg); background: var(--red); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: wait; }
.quote-box { border: 1px dashed var(--line-2); padding: 10px; display: flex; flex-direction: column; gap: 4px; min-height: 42px; font-size: 12px; }
.quote-box .toggle-row { color: var(--muted); }
.quote-box b { color: var(--text); }
.slips { display: flex; gap: 4px; }
.slips .chip { min-height: 28px; padding: 2px 8px; }
.trade-status { min-height: 18px; font-size: 12px; color: var(--amber); word-break: break-word; }
.fine { margin: 0; font-size: 11px; color: var(--dim); line-height: 1.5; }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--green);
  z-index: 50;
  overflow: auto;
  box-shadow: -20px 0 60px rgba(0,0,0,.6);
}
.drawer-inner { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 16px; }
.drawer-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 -18px; padding: 10px 18px;
  background: rgba(10, 10, 10, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.back-btn {
  background: none; border: 1px solid var(--green); color: var(--green);
  min-height: 40px; padding: 6px 14px; font-weight: 700; cursor: pointer;
}
.back-btn:hover { background: var(--green); color: var(--bg); }
.drawer-bar-title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.drawer-open { overscroll-behavior: none; }
.drawer-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-price { font-size: 26px; font-weight: 800; }
.close-btn { background: none; border: 1px solid var(--line-2); color: var(--muted); width: 36px; height: 36px; cursor: pointer; }
.close-btn:hover { color: var(--text); border-color: var(--text); }
.tf { display: flex; gap: 4px; }
.chart-box { border: 1px solid var(--line); background: #070807; }
.chart-box canvas { display: block; width: 100%; height: 320px; cursor: crosshair; touch-action: pan-y; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.chart-head .tf { flex-wrap: wrap; }
.chart-head .chip { min-height: 30px; padding: 4px 9px; }
.chart-src { font-size: 11px; }
.ohlc { display: flex; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; gap: 10px; font-size: 11px; color: var(--muted); min-height: 16px; font-variant-numeric: tabular-nums; }
.ohlc b { font-weight: 500; }
.chart-modes { display: flex; gap: 4px; }
.chart-modes .chip { min-height: 30px; padding: 3px 10px; }
.lwc-box { position: relative; border: 1px solid var(--line); height: 380px; background: #070807; }
.lwc { position: absolute; inset: 0; }
.lwc-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; pointer-events: none; text-align: center; padding: 20px; }
.tv-box { border: 1px solid var(--line); height: 460px; background: #070807; }
.tv-box iframe { width: 100%; height: 100%; border: 0; display: block; }
.chart-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: -8px; font-size: 10px; }
.chart-hint { font-size: 10px; }
.chart-why { font-size: 11px; color: var(--amber); margin-top: -8px; word-break: break-word; }
.chart-why:empty { display: none; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.stat-grid > div { background: var(--bg); padding: 10px 12px; }
.stat-grid .v { font-weight: 700; margin-top: 2px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.check { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line-2); padding: 4px 0; }
.trade { border: 1px solid var(--line); }
.trade-tabs { display: grid; grid-template-columns: 1fr 1fr; }
.trade-tabs button { background: var(--panel); border: 0; border-bottom: 1px solid var(--line); padding: 10px; min-height: 40px; cursor: pointer; color: var(--muted); font-weight: 700; }
.trade-tabs button.active.buy { color: var(--bg); background: var(--green); }
.trade-tabs button.active.sell { color: var(--bg); background: var(--red); }
.trade-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.presets button { background: var(--panel); border: 1px solid var(--line-2); padding: 8px 0; min-height: 36px; cursor: pointer; }
.presets button:hover, .presets button.active { border-color: var(--green); color: var(--green); }
.amount { display: flex; align-items: center; border: 1px solid var(--line-2); background: var(--panel); }
.amount input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 10px; font-size: 16px; }
.amount span { padding: 0 12px; color: var(--muted); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); }
.switch { appearance: none; width: 40px; height: 22px; background: var(--line-2); position: relative; cursor: pointer; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: var(--muted); transition: transform .15s; }
.switch:checked { background: var(--green-dim); outline: 1px solid var(--green); }
.switch:checked::after { transform: translateX(18px); background: var(--green); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 48px;
  transform: translate(-50%, 20px);
  background: var(--panel);
  border: 1px solid var(--green);
  color: var(--text);
  padding: 10px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 60;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

:focus-visible { outline: 1px solid var(--green); outline-offset: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 1500px) {
  .shell { grid-template-columns: 172px minmax(0, 1fr) 300px; }
  thead th, tbody td { padding: 9px 9px; }
  .score-bar { width: 40px; }
  .toolbar .field { width: 64px; }
}
@media (max-width: 1400px) {
  .opt2 { display: none; }
}
@media (max-width: 400px) {
  .cmd-prompt { display: none; }
  .hide-xs { display: none; }
}
@media (max-width: 1600px) {
  .opt { display: none; }
}
@media (max-width: 1180px) {
  .shell { grid-template-columns: 170px minmax(0, 1fr); }
  .opt2 { display: table-cell; }
  .console { display: none; }
  .agent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .chains, .chain-badge { display: none; }
  .lanes { grid-template-columns: 1fr; height: auto; }
  .lane { border-right: 0; overflow: visible; }
}
@media (max-width: 720px) {
  :root { --top-h: 56px; }
  body { font-size: 12px; }
  .topbar { gap: 10px; padding: 0 10px; }
  .brand-word { display: none; }
  .cmd-kbd { display: none; }
  #connectBtn { padding: 6px 8px; font-size: 11px; min-height: 34px; }
  .cmd { height: 36px; padding: 0 8px; }
  .shell { grid-template-columns: 1fr; height: calc(100vh - var(--ticker-h) - var(--top-h) - 62px - env(safe-area-inset-bottom)); }
  @supports (height: 100dvh) {
    .shell { height: calc(100dvh - var(--ticker-h) - var(--top-h) - 62px - env(safe-area-inset-bottom)); }
  }
  .m-hide { display: none !important; }
  .m-show { display: inline; }
  .score-bar { display: none; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar > * { flex-shrink: 0; }
  .field, .cmd input, .console-strategy select, .amount input { font-size: 16px; }
  .field { width: 72px; min-height: 36px; }
  thead th, tbody td { padding: 9px 8px; }
  .buy-btn { padding: 4px 8px; min-height: 36px; }
  .tok { gap: 8px; }
  .tok-sub { font-size: 10px; }
  td.sticky .tok > div { min-width: 0; max-width: 104px; }
  td.sticky .avatar { width: 24px !important; height: 24px !important; font-size: 10px; }
  .tok { gap: 6px; }
  td.sticky .tok-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
  .avatar { width: 28px !important; height: 28px !important; font-size: 11px; }
  .ascii { font-size: 10px; }
  .agent-log { margin: 0 12px 12px; height: 42vh; }
  .signal { margin: 0 12px 8px; flex-direction: column; align-items: stretch; }
  .signal-actions .btn { flex: 1; }
  .agent-note { padding: 8px 12px 0; }
  .agent-grid > div { padding: 10px 12px; }
  .agent-grid .stat-big { font-size: 15px; }
  .pf-head { padding: 12px; }
  .pf-total { text-align: left; }
  .pf-actions { margin-left: 0; width: 100%; }
  .pf-actions .btn { flex: 1; }
  .pf-total-v { font-size: 22px; }
  .pf-addr span { font-size: 10px; }
  .chart-box canvas { height: 300px; }
  .tv-box { height: 420px; }
  .lwc-box { height: 320px; }
  .ohlc { gap: 8px; font-size: 10px; }
  .chart-head .chip { min-height: 30px; padding: 3px 7px; font-size: 11px; }
  .view-sub { width: 100%; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: 62px;
    flex-direction: row;
    padding: 0;
    border-right: 0;
    border-top: 1px solid var(--line);
    background: var(--bg);
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(62px + env(safe-area-inset-bottom));
  }
  .sidebar a { flex: 1; min-width: 0; flex-direction: column; justify-content: center; gap: 4px; text-align: center; padding: 0; border-left: 0; border-top: 2px solid transparent; font-size: 10px; }
  .nav-ico { width: 20px; height: 20px; }
  .sidebar a.active { border-top-color: var(--green); }
  .nav-caret, .sidebar-foot, .sidebar .full { display: none; }
  .sidebar .short { display: inline; }
  .statusbar { display: none; }
  .view-head { padding: 12px 12px 4px; }
  .toolbar { padding: 6px 12px 10px; }
  .agent-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .checks { grid-template-columns: 1fr; }
  .toast { bottom: 72px; }
}
