:root {
  --bg: #000;
  --text: #fff;
  --secondary: rgba(235, 235, 245, 0.6);
  --tertiary: rgba(235, 235, 245, 0.3);
  --sep: rgba(84, 84, 88, 0.55);
  --card: #1c1c1e;
  --card2: #2c2c2e;
  --green: #00d35a;
  --red: #ff453a;
  --orange: #ff9f0a;
  --cyan: #64d2ff;
  --blue: #0a84ff;
  --yellow: #ffd60a;
  --pink: #ff6b9a;
  --gutter: 16px;
  --nav-h: calc(52px + env(safe-area-inset-top, 0px));
  --tab-h: calc(50px + env(safe-area-inset-bottom, 0px));
  --text-font: "SF Pro Text", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  --display-font: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono-font: "SF Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--text-font);
  font-size: 15px;
  line-height: 1.3;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; }
.num, .odo, .price, .pct, .value, .stat-val, .big-price {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.display { font-family: var(--display-font); }
.mono, .pill { font-family: var(--mono-font); }

#app {
  min-height: 100dvh;
  background: var(--bg);
}
#error-bar {
  position: fixed;
  left: 0; right: 0;
  top: var(--nav-h);
  z-index: 55;
  background: #3a0a0a;
  color: var(--red);
  font-size: 12px;
  line-height: 1.3;
  padding: 8px var(--gutter);
  min-height: 28px;
}
#error-bar[hidden] { display: none; }
#app.has-error .view.on,
#app.has-error .view.sheet:not([hidden]) { padding-top: calc(var(--nav-h) + 36px); }

.view {
  display: none;
  padding: var(--nav-h) 0 calc(var(--tab-h) + 16px);
  min-height: 100dvh;
}
.view.on { display: block; }
.view.sheet {
  position: fixed;
  inset: 0 0 var(--tab-h) 0;
  z-index: 45;
  background: var(--bg);
  overflow: auto;
  display: block;
  padding-bottom: 16px;
}
.view.sheet .nav { z-index: 46; }
.view.sheet[hidden] { display: none; }

.nav {
  position: fixed;
  left: 0; right: 0; top: 0;
  z-index: 35;
  height: var(--nav-h);
  padding: env(safe-area-inset-top, 0px) var(--gutter) 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  background: rgba(0,0,0,0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.nav-title {
  font-family: var(--display-font);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.nav-title .chev { color: var(--tertiary); font-weight: 500; }
.icon-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
  position: relative;
  flex: 0 0 44px;
}
.icon-btn svg { width: 22px; height: 22px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--card2);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.bell-dot {
  position: absolute; top: 10px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  display: none;
}
.bell-dot.on { display: block; }

.gutter { padding-left: var(--gutter); padding-right: var(--gutter); }
.section-h {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px var(--gutter) 10px;
  font-size: 20px;
  font-family: var(--display-font);
  font-weight: 650;
  letter-spacing: -0.02em;
}
.section-h .link {
  font-size: 15px;
  font-weight: 500;
  color: var(--blue);
  min-height: 44px;
  display: inline-flex; align-items: center;
}
.muted { color: var(--secondary); }
.dim { color: var(--tertiary); }

/* balance */
.balance-wrap { padding: 12px var(--gutter) 4px; }
.balance-row { display: flex; align-items: flex-start; gap: 10px; }
.odo {
  font-family: var(--display-font);
  font-weight: 700;
  font-size: 72px;
  line-height: 0.95;
  letter-spacing: -0.04em;
  display: flex; align-items: flex-start;
}
.odo-col { height: 0.95em; overflow: hidden; display: inline-block; }
.odo-strip { display: flex; flex-direction: column; transition: transform 600ms ease-out; }
.odo-strip span { height: 0.95em; line-height: 0.95em; }
.paper-pill {
  margin-top: 10px;
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: 11px;
  background: var(--orange);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
body.mode-live .paper-pill, .mode-live .paper-pill { display: none !important; }
.today-row {
  display: flex; align-items: center; gap: 8px;
  padding: 2px var(--gutter) 10px;
  font-variant-numeric: tabular-nums;
}
.today-row .pct { font-size: 17px; font-weight: 600; }
.up { color: var(--green); }
.down { color: var(--red); }
.mult-pill {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: 11px;
  background: rgba(0, 211, 90, 0.16);
  color: var(--green);
  font-weight: 650;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.chart-box { position: relative; height: 220px; margin: 0 var(--gutter); }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.chart-empty {
  position: absolute; left: 0; right: 0; bottom: 28px;
  text-align: center;
  color: var(--secondary);
  font-size: 14px;
  pointer-events: none;
}
.ranges {
  display: flex;
  margin: 8px var(--gutter) 0;
  background: var(--card);
  border-radius: 9px;
  padding: 2px;
}
.ranges button {
  flex: 1;
  min-height: 32px;
  border-radius: 7px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ranges button.on { background: var(--card2); color: var(--text); }

/* agent carousel */
.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: 12px;
  padding: 0 var(--gutter) 8px;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.agent-card {
  flex: 0 0 calc(100vw - 32px);
  width: calc(100vw - 32px);
  aspect-ratio: 504 / 470;
  border-radius: calc(42 * (100vw - 32px) / 504);
  background: var(--card);
  scroll-snap-align: start;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.agent-card .ac-top { display: flex; justify-content: space-between; align-items: baseline; }
.agent-card h3 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.agent-card .ac-label { color: var(--secondary); font-size: 15px; margin-top: 4px; }
.agent-card .ac-body { flex: 1; margin-top: 16px; overflow: hidden; }
.layer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.layer-strip {
  height: 22px;
  border-radius: 6px;
  background: var(--card2);
  display: flex; align-items: center;
  padding: 0 8px;
  font-size: 11px;
  color: var(--secondary);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.layer-strip.ok { color: var(--green); }
.layer-strip.bad { color: var(--red); }
.feed-list { font-size: 13px; }
.feed-row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }
.feed-row.killed .nm { color: var(--tertiary); text-decoration: line-through; text-decoration-color: var(--red); }
.feed-row .why { color: var(--red); font-size: 12px; }
.feed-row.passed .go { color: var(--cyan); }
.exec-bar-wrap { margin-top: 16px; }
.exec-bar {
  height: 6px; border-radius: 3px; background: var(--card2); overflow: hidden;
}
.exec-bar > i { display: block; height: 100%; width: 0; background: var(--green); }
.exec-cap { margin-top: 8px; color: var(--secondary); font-size: 14px; }
.pills { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pill.stop { background: rgba(255, 69, 58, 0.16); color: var(--red); }
.pill.trail { background: rgba(0, 211, 90, 0.16); color: var(--green); }
.score-wrap { display: flex; align-items: center; gap: 16px; height: 100%; }
.score-wrap canvas { width: 120px; height: 120px; }

/* lists */
.row {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 8px var(--gutter);
  gap: 12px;
}
.row + .row, .list .row { border-top: 0.5px solid var(--sep); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-size: 16px; font-weight: 500; }
.row .sub { font-size: 13px; color: var(--secondary); margin-top: 2px; }
.row .value { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.empty {
  padding: 28px var(--gutter);
  color: var(--secondary);
  text-align: center;
}

/* agents tab */
.agent-full {
  margin: 10px var(--gutter);
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
}
.agent-full .hf { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.agent-full h3 { margin: 0; font-family: var(--display-font); font-size: 22px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 6px; }
.status-dot.off { background: var(--tertiary); }
.switch {
  min-width: 51px; height: 31px; border-radius: 16px;
  background: var(--card2);
  position: relative;
  flex: 0 0 51px;
  opacity: 0.9;
}
.switch i {
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff;
}
.switch.on { background: var(--green); }
.switch.on i { left: 22px; }
.switch.locked { opacity: 0.45; }
.hint { font-size: 12px; color: var(--tertiary); margin-top: 6px; }
.decisions { margin-top: 12px; }
.decisions .drow {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-top: 0.5px solid var(--sep);
  font-size: 13px;
}
.decisions .drow a { color: var(--blue); }
.set-link { color: var(--blue); font-size: 14px; min-height: 44px; display: inline-flex; align-items: center; }

/* auditor */
.discs { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0 4px; }
.disc {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--secondary);
  position: relative;
  z-index: 1;
}
.disc.ok { background: rgba(0,211,90,0.18); color: var(--green); }
.disc.bad { background: rgba(255,69,58,0.18); color: var(--red); }
.beam {
  position: absolute; left: 50%; width: 6px; margin-left: -3px;
  height: 28px; border-radius: 3px;
  background: var(--cyan);
  top: 0; z-index: 2;
  opacity: 0;
  pointer-events: none;
}
.audit-rows { margin-top: 8px; }
.audit-rows .row .title { font-size: 15px; }
.headline { padding: 10px var(--gutter) 4px; font-family: var(--display-font); font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.headline.bad { color: var(--red); }
.headline.ok { color: var(--green); }
.subhead { padding: 0 var(--gutter) 16px; color: var(--secondary); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.fomo-btn {
  display: flex; align-items: center; justify-content: center;
  margin: 16px var(--gutter) 8px;
  min-height: 50px;
  border-radius: 14px;
  background: var(--card2);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
}

/* coin */
.coin-meta { padding: 4px var(--gutter) 0; color: var(--secondary); font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shield {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: 11px;
  background: var(--card2);
  font-size: 12px; font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.big-price {
  font-family: var(--display-font);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.03em;
  padding: 8px var(--gutter) 0;
}
.since { padding: 0 var(--gutter) 8px; font-weight: 600; }
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 12px var(--gutter);
  background: var(--sep);
  border-radius: 14px;
  overflow: hidden;
}
.stat { background: var(--card); padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--secondary); }
.stat-val { font-size: 17px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card {
  margin: 10px var(--gutter);
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px;
}
.card h4 { margin: 0 0 8px; font-size: 15px; font-weight: 650; }

/* account */
.group { margin: 18px 0 8px; }
.group-title { padding: 0 var(--gutter) 6px; color: var(--secondary); font-size: 13px; font-weight: 500; }
.group .card, .settings-card {
  margin: 0 var(--gutter);
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
}
.set-row {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 0.5px solid var(--sep);
  min-height: 44px;
}
.set-row:first-child { border-top: 0; }
.set-row label { flex: 1; min-width: 120px; font-size: 15px; }
.set-row .exact { width: 88px; text-align: right; color: var(--secondary); font-variant-numeric: tabular-nums; font-family: var(--mono-font); font-size: 13px; }
.set-row input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
  pointer-events: none;
  opacity: 0.85;
}
.copied { color: var(--green); font-size: 13px; margin-left: 8px; }

/* tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 50;
  height: var(--tab-h);
  padding: 4px 8px env(safe-area-inset-bottom, 0px);
  display: flex;
  background: rgba(0,0,0,0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tabs button {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: 44px;
  color: var(--tertiary);
  font-size: 10px;
  font-weight: 500;
}
.tabs button svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--blue); }

/* loading skeletons */
.skel {
  background: var(--card);
  border-radius: 12px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.skel-balance { height: 72px; width: 70%; margin: 16px var(--gutter) 8px; border-radius: 10px; }
.skel-line { height: 16px; width: 30%; margin: 0 var(--gutter) 12px; }
.skel-chart { height: 220px; margin: 0 var(--gutter); border-radius: 16px; }
.skel-card { height: calc((100vw - 32px) * 470 / 504); margin: 0 var(--gutter); border-radius: calc(42 * (100vw - 32px) / 504); }

@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; opacity: 0.7; }
  .odo-strip { transition: none !important; }
  .beam { transition: none !important; }
}
