/* Arbot Mini App. Tokens come from specs/007-telegram-miniapp/design (dark) with a light twin; Telegram's own theme
   colours override a few of them at run time (app.js sets --tg-* variables through the CSSOM). No inline styles. */
:root {
  --bg: #0E1217; --card: #161C23; --line: #232C36; --text: #EEF2F5; --text2: #B9C4CE; --muted: #9AA7B4;
  --muted2: #8693A0; --accent: #5AA9FF; --on-accent: #0B1520; --link: #7DB8FF; --pos: #3FD08A; --pos-t: #6FE0A6;
  --pos-bg: #12261C; --neg: #FF8A7A; --neg-t: #FF9A8C; --neg-bg: #2A1713; --warn: #F5B84B; --warn-bg: #2B2210;
  --chip: #1E2630; --seg-on: #2A3542; --tab-line: #1E2630; --accent-bg: #16263A; --accent-line: #2B4566;
  --shadow: 0 -8px 30px rgba(0, 0, 0, .45); --overlay: rgba(4, 7, 10, .62);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #FFFFFF; --card: #F3F5F7; --line: #E1E6EB; --text: #12161B; --text2: #3C4752; --muted: #5C6975;
  --muted2: #66737F; --accent: #1F6FD0; --on-accent: #FFFFFF; --link: #1F6FD0; --pos: #138A56; --pos-t: #0E7A4A;
  --pos-bg: #E3F5EC; --neg: #C8372D; --neg-t: #B3261E; --neg-bg: #FBE9E7; --warn: #8F5600; --warn-bg: #FFF3DC;
  --chip: #E9EDF1; --seg-on: #FFFFFF; --tab-line: #E1E6EB; --accent-bg: #E6F0FC; --accent-line: #B7D2F3;
  --shadow: 0 -8px 30px rgba(20, 30, 40, .18); --overlay: rgba(20, 30, 40, .4); color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px;
  line-height: 1.4; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
button { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
.n { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 16px 16px 20px; min-width: 0; }
.screen.has-tabs { padding-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.mt-auto { margin-top: auto; }
.muted { color: var(--muted); } .small { font-size: 13px; line-height: 18px; } .tiny { font-size: 11px; }
.bold { font-weight: 700; } .semi { font-weight: 600; }
.center { text-align: center; }

/* signs: never colour alone (the arrow and the sign carry the meaning too) */
.pos { color: var(--pos); } .neg { color: var(--neg); } .long { color: var(--pos-t); } .short { color: var(--neg-t); }

/* step dots */
.dots { display: flex; gap: 6px; justify-content: center; padding-top: 4px; }
.dots i { width: 8px; height: 4px; border-radius: 2px; background: var(--seg-on); }
.dots i.on { width: 22px; background: var(--accent); }
h1.title { font-size: 28px; line-height: 34px; font-weight: 800; letter-spacing: -.4px; }
h1.hero { font-size: 34px; line-height: 40px; font-weight: 800; letter-spacing: -.5px; }
.lead { font-size: 17px; line-height: 24px; color: var(--text2); }
h2.h { font-size: 17px; font-weight: 700; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }

/* buttons: 52px, the MainButton look */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 0 16px;
  border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 16px;
  cursor: pointer; text-align: center; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--link); min-height: 44px; }
.btn.danger { background: var(--neg); color: #1B0A07; }
.btn.real { background: var(--warn); color: #1F1400; }
.btn.small { min-height: 44px; font-size: 14px; width: auto; padding: 0 14px; }
.btns { display: flex; gap: 10px; } .btns > * { flex: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; min-width: 0; }
.card.note { border-radius: 14px; padding: 14px 16px; font-size: 14px; line-height: 20px; color: var(--text2); }
.card.warn { background: var(--warn-bg); border-color: var(--warn); }
.card.bad { background: var(--neg-bg); border-color: var(--neg); }
.card.good { background: var(--pos-bg); border-color: var(--pos); }

/* segmented account switch */
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 38px; border: 0; background: none; border-radius: 9px; color: var(--muted);
  font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--text); }
.seg.fill button { min-height: 44px; }

.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; font-size: 13px;
  font-weight: 600; background: var(--chip); color: var(--text2); }
.pill i { width: 8px; height: 8px; border-radius: 4px; background: currentColor; }
.pill.on { background: var(--pos-bg); color: var(--pos-t); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--neg-bg); color: var(--neg-t); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  background: var(--chip); color: var(--text2); }
.badge.real { background: var(--warn-bg); color: var(--warn); } .badge.demo { background: var(--accent-bg); color: var(--link); }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent); color: var(--link); }
.reason { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--chip); color: var(--text2); }

/* equity */
.big { font-size: 38px; line-height: 44px; font-weight: 800; letter-spacing: -.8px; }
.huge { font-size: 36px; line-height: 42px; font-weight: 800; letter-spacing: -1px; }
.spark { display: block; width: 100%; height: 56px; margin-top: 12px; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 8px; }
.kv > div > b { display: block; font-size: 15px; } .kv .label { font-size: 11px; }
.kv.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* position rows and cards */
.pos-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer; min-height: 56px; }
.pos-row:last-child { border-bottom: 0; }
.coin { flex: none; width: 36px; height: 36px; border-radius: 18px; background: var(--chip); display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700; }
.right { text-align: right; }
.bar { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); width: 0; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live i { width: 7px; height: 7px; border-radius: 4px; background: var(--muted2); }
.live.on i { background: var(--pos); }

/* tab bar */
.tabs { position: sticky; bottom: 0; display: flex; border-top: 1px solid var(--tab-line); background: var(--bg); padding: 4px 8px 10px;
  max-width: 480px; width: 100%; margin: 0 auto; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 48px; padding: 6px 0; border: 0;
  background: none; font-size: 11px; font-weight: 600; color: var(--muted2); cursor: pointer; }
.tab[aria-current="page"] { color: var(--accent); }
.tab svg { width: 22px; height: 22px; }

/* history bars */
.bars { display: flex; align-items: stretch; gap: 3px; height: 120px; }
.bars .col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.bars .up, .bars .dn { flex: 1; display: flex; }
.bars .up { align-items: flex-end; } .bars .dn { align-items: flex-start; }
.bars .up i, .bars .dn i { display: block; width: 100%; min-height: 2px; border-radius: 2px; }
.bars .up i { background: var(--pos); } .bars .dn i { background: var(--neg); }
.trade { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.trade:last-child { border-bottom: 0; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font: inherit; font-size: 16px; }
input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--accent); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px; background: var(--card);
  border: 1px solid var(--line); cursor: pointer; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--accent); margin: 0; }
.cards-pick { display: flex; flex-direction: column; gap: 10px; }
.pick { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 16px; background: var(--card);
  border: 1px solid var(--line); cursor: pointer; min-height: 88px; }
.pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-bg); }
.pick.real[aria-pressed="true"] { border-color: var(--warn); background: var(--warn-bg); }
.keybox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 17px; word-break: break-all;
  background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 10px; white-space: pre-wrap; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step .num { flex: none; width: 28px; height: 28px; border-radius: 14px; background: var(--chip); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 14px; }
.step .num.done { background: var(--pos-bg); color: var(--pos-t); }

/* check list */
.cl { display: flex; flex-direction: column; gap: 12px; }
.cl .item { display: flex; gap: 12px; align-items: flex-start; }
.cl .mark { flex: none; width: 24px; height: 24px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--chip); font-size: 14px; font-weight: 800; }
.cl .ok .mark { background: var(--pos-bg); color: var(--pos-t); } .cl .fail .mark { background: var(--neg-bg); color: var(--neg-t); }
.cl .pending .mark { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .cl .pending .mark, .skel { animation: none; } }

/* lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; border-bottom: 1px solid var(--line); width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer; }
.li:last-child { border-bottom: 0; }
.li.static { cursor: default; }
.toggle { appearance: none; width: 50px; height: 30px; border-radius: 15px; background: var(--chip); position: relative; cursor: pointer;
  border: 1px solid var(--line); flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 11px; background: var(--muted); transition: left .15s; }
.toggle:checked { background: var(--accent); border-color: var(--accent); } .toggle:checked::after { left: 23px; background: var(--on-accent); }

/* sheets and toasts */
.overlay { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 14px 16px 22px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--line); }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--seg-on); align-self: center; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); max-width: 92vw; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; z-index: 30; }
.toast.err { background: var(--neg); color: #1B0A07; }

/* states */
.skel { height: 18px; border-radius: 8px; background: var(--card); animation: pulse 1.4s infinite; }
.skel.tall { height: 110px; border-radius: 16px; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 17px; margin-bottom: 4px; }
.icon-tile { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-bg); border: 1px solid var(--accent-line);
  display: flex; align-items: center; justify-content: center; color: var(--accent); }
.feat { display: flex; gap: 14px; align-items: flex-start; }
.feat .ico { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--card); display: flex; align-items: center; justify-content: center; }
.hide { display: none !important; }
