:root {
  color-scheme: dark;
  --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;
  --purple: #bf5af2;
  --gutter: 16px;
  --tab-h: 49px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
  min-height: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
input, select {
  background: var(--card2);
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 44px;
}
.tabular, .num { font-variant-numeric: tabular-nums; }
.muted { color: var(--secondary); }
.tertiary { color: var(--tertiary); }
.green { color: var(--green); }
.red { color: var(--red); }
.orange { color: var(--orange); }

#error-banner {
  position: sticky; top: 0; z-index: 50;
  background: var(--red); color: #fff;
  padding: 10px var(--gutter);
  padding-top: calc(10px + env(safe-area-inset-top));
  font-size: 13px;
  line-height: 1.35;
}

#pair-screen {
  min-height: 100dvh;
  padding: 56px var(--gutter) 32px;
  padding-top: calc(56px + env(safe-area-inset-top));
}
#pair-screen h1 { font-size: 28px; font-weight: 600; margin: 0 0 12px; }
#pair-screen p { line-height: 1.45; }
#pair-form { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
#pair-form input {
  text-align: center;
  letter-spacing: 0.14em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 22px;
  text-transform: uppercase;
}
#pair-form button, .primary {
  min-height: 44px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  padding: 0 16px;
}

#app { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); }
#navbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 8px var(--gutter);
  padding-top: calc(8px + env(safe-area-inset-top));
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(16px);
}
.avatar {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 50%;
  background: var(--card2);
  display: grid; place-items: center;
  font-weight: 600; font-size: 14px;
}
.nav-title { flex: 1; text-align: left; font-size: 17px; font-weight: 600; min-height: 44px; }
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--text);
  position: relative;
}
#bell-dot {
  position: absolute; top: 10px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red);
}

#view { padding: 8px var(--gutter) 24px; }
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(22,22,22,0.86);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tab {
  flex: 1;
  min-height: 44px;
  color: var(--secondary);
  font-size: 10px;
  font-weight: 500;
}
.tab.on { color: var(--blue); }

.row { display: flex; align-items: center; gap: 8px; }
.space { justify-content: space-between; }
.balance {
  font-family: "SF Pro Display", -apple-system, system-ui, sans-serif;
  font-size: 66px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 8px 0 4px;
}
.balance .digit { display: inline-block; }
.meta-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: var(--card2);
}
.pill.paper { color: var(--orange); }
.pill.mult { color: var(--green); }
.pct.up { color: var(--green); }
.pct.down { color: var(--red); }

.ranges { display: flex; gap: 4px; margin: 4px 0 16px; }
.ranges button {
  min-height: 44px; min-width: 44px;
  padding: 0 10px;
  color: var(--secondary);
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ranges button.on { color: var(--text); }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 14px;
  margin: 0 0 16px;
}
.section-h {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 8px 0 10px;
  font-size: 20px; font-weight: 600;
}
.section-h a, .section-h button.link, .link {
  color: var(--blue); font-size: 15px; font-weight: 500; text-decoration: none;
}

.live-card { padding: 0; overflow: hidden; border-radius: 22px; }
.live-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  overflow: hidden;
}
.live-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.live-tag {
  position: absolute; left: 10px; top: 10px;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #fff;
  text-shadow: none;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #8e8e93; }
.dot.live { background: var(--red); }
.lane-tag {
  position: absolute; right: 10px; top: 10px;
  font-size: 12px; font-weight: 600;
}
.live-meta { padding: 12px 14px 14px; }
.checks { display: flex; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--secondary); }
.check.ok { color: var(--green); }
.check.no { color: var(--red); }
.check.na { color: var(--tertiary); }

.carousel {
  display: flex; gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--gutter)) 16px;
  padding: 0 var(--gutter);
}
.bot-mini {
  flex: 0 0 220px;
  scroll-snap-align: start;
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  min-height: 108px;
  text-align: left;
}
.bot-mini h3 { margin: 0 0 6px; font-size: 16px; text-transform: capitalize; }
.bot-mini .struck { color: var(--red); text-decoration: line-through; }

.activity-row, .decision {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 12px 0;
  min-height: 44px;
  border-bottom: 0.5px solid var(--sep);
  text-align: left;
  width: 100%;
  background: none;
  color: inherit;
}
.activity-row:last-child, .decision:last-child { border-bottom: 0; }
.activity-row .title, .decision .title { font-size: 16px; font-weight: 500; }
.activity-row .sub, .decision .sub { grid-column: 1; font-size: 13px; color: var(--secondary); }
.activity-row .val, .decision .val { grid-row: 1 / span 2; align-self: center; font-variant-numeric: tabular-nums; }

.bot-full {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.status-dot.off { background: #8e8e93; }
.status-dot.paused { background: var(--orange); }
.switch {
  width: 51px; height: 31px; border-radius: 16px;
  background: var(--card2);
  position: relative;
  min-width: 51px;
}
.switch.on { background: var(--green); }
.switch i {
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff;
  transition: transform 180ms ease;
}
.switch.on i { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) {
  .switch i { transition: none; }
  .skel { animation: none !important; }
}

.layers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 10px 0;
}
.layer {
  background: var(--card2);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}
.ring {
  width: 52px; height: 52px;
}

.audit-discs { display: flex; gap: 8px; justify-content: space-between; margin: 16px 0 20px; }
.disc {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--card2);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.disc.ok { background: var(--green); color: #000; }
.disc.no { background: var(--red); color: #fff; }
.beam { height: 3px; background: var(--cyan); border-radius: 2px; margin: -8px 0 16px; }

.coin-price {
  font-family: "SF Pro Display", -apple-system, system-ui, sans-serif;
  font-size: 44px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  margin: 8px 0;
}
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 12px 0; }
.stats div { background: var(--card); border-radius: 12px; padding: 10px; }
.stats span { display: block; font-size: 12px; color: var(--secondary); margin-bottom: 4px; }
.btn-row { display: flex; gap: 8px; margin-top: 16px; }
.btn-row button, .btn-row a {
  flex: 1; min-height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 600; text-decoration: none; color: #fff;
}
.btn-row .ghost { background: var(--card2); }
.btn-row .sell { background: var(--red); }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 12px var(--gutter) calc(20px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 8px 0 16px; font-size: 18px; }
.sheet .pcts { display: flex; gap: 8px; margin-bottom: 16px; }
.sheet .pcts button {
  flex: 1; min-height: 44px; border-radius: 12px; background: var(--card2); font-weight: 600;
}
.sheet .pcts button.on { background: var(--blue); }
#overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,0.5);
}

.search-box { margin-bottom: 12px; width: 100%; }
.search-hit { text-align: left; width: 100%; }

.setting { padding: 12px 0; border-bottom: 0.5px solid var(--sep); }
.setting .top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.setting label { font-size: 15px; }
.setting input[type="range"] { width: 100%; }
.setting .exact { width: 96px; min-height: 44px; padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.setting select { min-height: 44px; max-width: 160px; background: var(--card2); color: var(--text); border-radius: 10px; padding: 0 8px; }
.setting input[type="range"] { min-height: 44px; }
.range-hint { margin: 0; font-size: 12px; color: var(--tertiary); }
.settings-err {
  color: var(--red);
  background: rgba(255, 69, 58, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  margin: 8px 0 4px;
}
.group-title { margin: 22px 0 6px; font-size: 13px; color: var(--secondary); font-weight: 600; }

.mode-seg { display: flex; background: var(--card2); border-radius: 10px; padding: 2px; margin: 12px 0; }
.mode-seg button { flex: 1; min-height: 40px; border-radius: 8px; font-weight: 600; }
.mode-seg button.on { background: var(--card); }

.skel {
  background: var(--card);
  border-radius: 12px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.empty { color: var(--secondary); padding: 24px 0; font-size: 16px; }

.preview img { width: 100%; border-radius: 16px; }

[hidden] { display: none !important; }

.gate-card { padding: 14px 16px; }
.gate-h { font-weight: 650; margin-bottom: 8px; }
.gate-list { list-style: none; padding: 0; margin: 0 0 8px; }
.gate-list li { padding: 4px 0; font-size: 14px; }
.gate-list li.ok { color: var(--ok, #1a7f37); }
.gate-list li.miss { color: var(--secondary); }
