: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;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --tab-h: calc(52px + var(--safe-bot));
  --nav-h: calc(44px + var(--safe-top));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
#locked[hidden], #app[hidden], [hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); height: 100%; }
html { height: 100%; height: -webkit-fill-available; }
body {
  min-height: 100%;
  min-height: -webkit-fill-available;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3 { font-weight: 600; margin: 0; }
a { color: var(--blue); text-decoration: none; }

.locked {
  position: fixed; inset: 0; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
}
.locked-mark {
  width: 56px; height: 56px; border-radius: 16px;
  background: #1c1c1e;
  position: relative;
}
.locked-mark::after {
  content: "";
  position: absolute; inset: 18px 20px 16px;
  border: 2px solid #fff; border-radius: 4px 4px 6px 6px;
  box-shadow: 0 -7px 0 -2px #fff;
  clip-path: inset(-12px 0 0 0);
}
.locked-title { margin: 0; font-size: 17px; font-weight: 600; color: var(--secondary); letter-spacing: -0.01em; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; }

.error-banner {
  position: relative; z-index: 5;
  padding: 8px var(--gutter);
  padding-top: calc(8px + var(--safe-top));
  background: #1c1c1e; color: var(--red);
  font-size: 13px; text-align: center;
}
.error-banner[hidden] { display: none; }
#app.error-on .navbar { padding-top: 8px; }

.screen {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tab-h) + 16px);
  overscroll-behavior: contain;
}
.screen-push { padding-bottom: calc(24px + var(--safe-bot)); }

.navbar {
  position: sticky; top: 0; z-index: 4;
  display: flex; align-items: center; gap: 4px;
  min-height: 44px;
  padding: var(--safe-top) 8px 0;
  background: rgba(0,0,0,0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.navbar h1 { flex: 1; text-align: center; font-size: 17px; font-weight: 600; pointer-events: none; }
.nav-title {
  flex: 1; text-align: left; font-size: 17px; font-weight: 600;
  min-height: 44px; padding: 0 6px;
  display: flex; align-items: center; gap: 4px;
}
.nav-title .chev { color: var(--tertiary); font-weight: 400; }
.nav-avatar, .nav-icon, .back-btn {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  position: relative; flex-shrink: 0; color: var(--text);
}
.nav-avatar span {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--card2); display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.bell-dot {
  position: absolute; top: 10px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
}
.nav-mid { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.nav-mid h1 { flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.nav-spacer { width: 44px; flex-shrink: 0; }
.back-btn { font-size: 32px; line-height: 1; font-weight: 300; color: var(--blue); }

.home-balance-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--gutter) 0;
}
.odometer {
  overflow: hidden;
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 72px; font-weight: 700; letter-spacing: -0.04em;
  line-height: 1; font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline;
}
.odometer .digit-col {
  display: inline-block; height: 1em; overflow: hidden; position: relative;
  width: 0.62em;
}
.odometer .digit-col .stack {
  display: flex; flex-direction: column; align-items: center;
}
.odometer .sym { width: auto; margin-right: 2px; }
.odometer .odo-dot { width: 0.28em; background: none; border-radius: 0; height: 1em; }
.home-meta {
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--gutter) 4px;
}
.today-pct { font-size: 17px; font-weight: 600; }
.today-pct.up { color: var(--green); }
.today-pct.down { color: var(--red); }

.pill {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 5px 8px; border-radius: 999px;
  display: inline-flex; align-items: center; height: 22px;
}
.pill-paper { background: rgba(255, 159, 10, 0.18); color: var(--orange); }
.pill-mult { background: rgba(0, 211, 90, 0.16); color: var(--green); }
.pill-stop { background: rgba(255, 69, 58, 0.16); color: var(--red); }
.pill-trail { background: rgba(0, 211, 90, 0.16); color: var(--green); }
.pill-shield { background: var(--card2); color: var(--cyan); }

.chart-wrap { position: relative; height: 180px; margin: 8px 0 0; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-empty {
  position: absolute; left: 0; right: 0; bottom: 28px;
  text-align: center; color: var(--tertiary); font-size: 13px; pointer-events: none;
}

.range-switch {
  display: flex; justify-content: space-between;
  padding: 8px var(--gutter) 4px;
}
.range-switch button {
  min-width: 44px; min-height: 44px;
  font-size: 13px; font-weight: 600; color: var(--secondary);
  border-radius: 8px;
}
.range-switch button.on { color: var(--green); }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px var(--gutter) 8px;
}
.section-head h2 { font-size: 20px; letter-spacing: -0.02em; }
.see-all { min-height: 44px; color: var(--secondary); font-size: 15px; padding: 0 4px; }

.agent-carousel {
  display: flex; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 0 var(--gutter) 8px;
  -webkit-overflow-scrolling: touch;
  scroll-padding-left: var(--gutter);
}
.agent-carousel::-webkit-scrollbar { display: none; }
.agent-card {
  flex: 0 0 calc(100vw - 32px);
  width: calc(100vw - 32px);
  aspect-ratio: 504 / 470;
  background: var(--card);
  border-radius: calc(42 * (100vw - 32px) / 504);
  padding: 20px 18px 16px;
  scroll-snap-align: start;
  display: flex; flex-direction: column; min-height: 0;
  text-align: left;
}
.agent-card .ac-top { display: flex; justify-content: space-between; align-items: baseline; }
.agent-card .ac-name { font-size: 15px; font-weight: 600; text-transform: capitalize; }
.agent-card .ac-stat { font-size: 13px; color: var(--secondary); }
.agent-card .ac-body { flex: 1; margin-top: 10px; min-height: 0; overflow: hidden; }
.agent-card .feed { display: flex; flex-direction: column; gap: 6px; }
.agent-card .feed-row { font-size: 13px; display: flex; gap: 8px; justify-content: space-between; }
.agent-card .killed { color: var(--tertiary); text-decoration: line-through; text-decoration-color: var(--red); }
.agent-card .kill-reason { color: var(--red); text-decoration: none; flex-shrink: 0; }
.agent-card .passed { color: var(--cyan); }
.agent-card .empty { color: var(--tertiary); font-size: 15px; padding-top: 12px; }
.layers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.layer-strip {
  height: 8px; border-radius: 4px; background: var(--card2);
}
.layer-strip.on-ok { background: var(--green); }
.layer-strip.on-no { background: var(--red); }
.ac-foot { margin-top: 8px; font-size: 13px; color: var(--secondary); display: flex; justify-content: space-between; }
.score-wrap { display: flex; align-items: center; gap: 16px; height: 100%; }
.score-wrap canvas { width: 120px; height: 120px; }
.score-label { font-size: 15px; color: var(--secondary); }
.exec-bar { height: 6px; border-radius: 3px; background: var(--card2); overflow: hidden; margin-top: 10px; }
.exec-bar > i { display: block; height: 100%; background: var(--green); width: 0; }
.pills-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.activity-list { padding: 0 var(--gutter); }
.act-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px 0;
  border-bottom: 0.5px solid var(--sep);
  width: 100%; text-align: left;
}
.act-row .act-main { flex: 1; min-width: 0; }
.act-row .act-title { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-row .act-sub { font-size: 13px; color: var(--secondary); margin-top: 2px; }
.act-row .act-val { font-size: 16px; font-weight: 600; text-align: right; flex-shrink: 0; }
.act-row .act-val.up { color: var(--green); }
.act-row .act-val.down { color: var(--red); }
.empty-note { color: var(--tertiary); font-size: 15px; padding: 32px 0; text-align: center; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-around;
  height: var(--tab-h);
  padding-bottom: var(--safe-bot);
  background: rgba(20, 20, 22, 0.96);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 0.5px solid var(--sep);
}
.tabbar 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;
}
.tabbar button.on { color: var(--text); }
body.push-open .tabbar { display: none; }
body.push-open .screen-tab { display: none !important; }

.agents-list { padding: 8px var(--gutter) 24px; display: flex; flex-direction: column; gap: 12px; }
.agent-full {
  background: var(--card); border-radius: 20px; padding: 16px;
}
.agent-full .af-top { display: flex; align-items: center; gap: 10px; }
.agent-full .af-name { font-size: 18px; font-weight: 600; text-transform: capitalize; flex: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.dot.paused, .dot.idle { background: var(--tertiary); }
.dot.error { background: var(--red); }
.af-count { font-size: 13px; color: var(--secondary); }
.switch {
  width: 51px; height: 31px; border-radius: 16px;
  background: var(--card2); position: relative; flex-shrink: 0;
  min-width: 51px; min-height: 31px;
}
.switch.on { background: var(--green); }
.switch i {
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%; background: #fff;
  transition: transform 0.2s ease;
}
.switch.on i { transform: translateX(20px); }
.switch.locked { opacity: 0.45; }
.af-decisions { margin-top: 12px; display: flex; flex-direction: column; }
.dec-row {
  display: flex; gap: 8px; padding: 8px 0; min-height: 44px; align-items: flex-start;
  border-top: 0.5px solid var(--sep); text-align: left; width: 100%;
}
.dec-time { width: 52px; color: var(--tertiary); font-size: 12px; flex-shrink: 0; }
.dec-main { flex: 1; min-width: 0; }
.dec-coin { font-size: 14px; font-weight: 500; }
.dec-reason { font-size: 12px; color: var(--secondary); }
.af-settings {
  margin-top: 8px; width: 100%; min-height: 44px;
  color: var(--blue); font-size: 15px; text-align: left;
}

.account-body { padding: 8px 0 32px; }
.group { background: var(--card); margin: 0 var(--gutter) 24px; border-radius: 14px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 16px;
  border-bottom: 0.5px solid var(--sep); width: 100%; text-align: left;
}
.row:last-child { border-bottom: 0; }
.row .label { flex: 1; font-size: 16px; }
.row .value { color: var(--secondary); font-size: 16px; }
.row .chev { color: var(--tertiary); font-size: 20px; }
.seg {
  display: flex; background: var(--card2); border-radius: 8px; padding: 2px;
}
.seg button {
  min-width: 64px; min-height: 28px; padding: 4px 12px;
  border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--secondary);
}
.seg button.on { background: var(--card); color: var(--text); }
.hint { margin: -16px var(--gutter) 24px; font-size: 12px; color: var(--tertiary); padding: 0 4px; }
.settings-block { margin: 0 var(--gutter) 24px; }
.settings-block h3 { font-size: 13px; color: var(--secondary); font-weight: 400; margin: 0 4px 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 12px);
  transform: translateX(-50%);
  background: var(--card2); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; z-index: 20; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.toast.show { opacity: 1; }
body.push-open .toast { bottom: calc(24px + var(--safe-bot)); }

.coin-body, .auditor-body { padding: 0 var(--gutter) 32px; }
.coin-sub { color: var(--secondary); font-size: 13px; display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.coin-price {
  font-family: "SF Pro Display", -apple-system, sans-serif;
  font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;
}
.coin-chg { margin: 6px 0 12px; font-size: 15px; font-weight: 600; }
.coin-chg.up { color: var(--green); }
.coin-chg.down { color: var(--red); }
.candle-wrap { height: 220px; margin: 4px -var(--gutter) 0; margin-left: -4px; margin-right: -4px; }
.candle-wrap canvas { width: 100%; height: 100%; display: block; }
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px;
  padding: 16px 0; border-top: 0.5px solid var(--sep); border-bottom: 0.5px solid var(--sep);
  margin-top: 8px;
}
.stat .k { font-size: 12px; color: var(--secondary); }
.stat .v { font-size: 16px; font-weight: 600; margin-top: 2px; }
.pos-card, .exit-card {
  background: var(--card); border-radius: 14px; padding: 14px 16px; margin-top: 14px;
}
.pos-card h3, .exit-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.exit-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 15px; }
.exit-row span:first-child { color: var(--secondary); }

.fomo-btn {
  display: flex; align-items: center; justify-content: center;
  margin-top: 20px; min-height: 52px; border-radius: 14px;
  background: var(--blue); color: #fff !important; font-size: 17px; font-weight: 600;
  width: 100%;
}
.fomo-btn[hidden] { display: none; }

.disc-stack { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 0 8px; position: relative; }
.disc {
  width: 72%; height: 18px; border-radius: 40px;
  background: var(--card2); position: relative;
}
.disc.ok { background: var(--green); }
.disc.no { background: var(--red); }
.disc .mark {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 700; color: #000;
}
.beam {
  position: absolute; left: 14%; right: 14%; height: 3px;
  background: var(--cyan); border-radius: 2px; opacity: 0; pointer-events: none;
}
.audit-rows { margin-top: 8px; }
.audit-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 0.5px solid var(--sep); font-size: 15px;
}
.audit-row .an { color: var(--secondary); }
.audit-row .av { font-weight: 500; text-align: right; }
.audit-verdict { margin-top: 16px; }
.audit-verdict h2 { font-size: 20px; }
.audit-verdict p { color: var(--secondary); margin: 6px 0 0; }
.toggle-row { margin-top: 16px; }

.search-input {
  flex: 1; min-height: 36px; margin-right: 8px;
  background: var(--card); color: #fff; border: 0; border-radius: 10px;
  padding: 8px 12px; font-size: 16px; outline: none;
}
.search-results { padding: 0 var(--gutter) 24px; }

.skel {
  background: var(--card); border-radius: 8px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; opacity: 0.7; }
  .odometer .stack { transition: none !important; }
  .beam { display: none; }
}

.confirm-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
}
.confirm-sheet {
  width: 100%; max-width: 390px;
  background: var(--card); border-radius: 14px 14px 0 0;
  padding: 20px 16px calc(16px + var(--safe-bot));
}
.confirm-sheet p { margin: 0 0 16px; font-size: 15px; text-align: center; }
.confirm-sheet button { width: 100%; min-height: 48px; font-size: 17px; }
.confirm-sheet .danger { color: var(--red); font-weight: 600; }
.confirm-sheet .sep { height: 0.5px; background: var(--sep); margin: 4px 0; }

.group a.row { color: inherit; }

.coin-reason {
  margin-top: 18px;
  font-size: 15px;
  color: var(--secondary);
  text-align: center;
  line-height: 1.4;
}
.fomo-view {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  min-height: 44px;
  width: 100%;
  color: var(--secondary);
  font-size: 15px;
  font-weight: 500;
  background: none;
}
.fomo-view[hidden] { display: none; }
