:root {
  /* тёмная «терминальная» тема по умолчанию; в Telegram — цвета его темы */
  --bg: #0e1117;
  --bg2: #161b24;
  --card: #1a2030;
  --line: rgba(255, 255, 255, .07);
  --text: #e8ecf3;
  --hint: #8a93a6;
  --accent: #3d8bfd;
  --accent-text: #fff;
  --up: #16c784;
  --down: #ea3943;
  --gold: #f0b90b;
  --radius: 14px;
  --tabs-h: 62px;
}
:root[data-tg] {
  --bg: var(--tg-theme-bg-color, #0e1117);
  --bg2: var(--tg-theme-secondary-bg-color, #161b24);
  --card: color-mix(in srgb, var(--tg-theme-secondary-bg-color, #161b24) 70%, var(--tg-theme-bg-color, #0e1117));
  --text: var(--tg-theme-text-color, #e8ecf3);
  --hint: var(--tg-theme-hint-color, #8a93a6);
  --accent: var(--tg-theme-button-color, #3d8bfd);
  --accent-text: var(--tg-theme-button-text-color, #fff);
}
:root[data-light] { --line: rgba(0,0,0,.08); --card: var(--tg-theme-bg-color, #fff); --bg: var(--tg-theme-secondary-bg-color, #f1f3f7); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); overscroll-behavior-y: none; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 17px; }
.status { font-size: 12px; color: var(--hint); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--bg2); color: var(--hint); }
.badge.pro { background: linear-gradient(90deg, #f0b90b, #ff8a00); color: #1b1300; }
.badge.soon { background: rgba(138,147,166,.18); }
.badge.free { background: rgba(22,199,132,.15); color: var(--up); }

.view { padding: 12px 12px 20px; max-width: 760px; margin: 0 auto; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--bg2); border-top: 1px solid var(--line); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--hint); font-size: 11px; }
.tabs a i { font-style: normal; font-size: 20px; filter: grayscale(1) opacity(.7); }
.tabs a.on { color: var(--accent); }
.tabs a.on i { filter: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); font-weight: 600;
  display: flex; justify-content: space-between; align-items: center; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.muted { color: var(--hint); font-size: 13px; }
.small { font-size: 12px; }
.up { color: var(--up); } .down { color: var(--down); }
.mono { font-variant-numeric: tabular-nums; }
.hscroll { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px 12px; padding: 0 12px; }
.hscroll::-webkit-scrollbar { display: none; }

.tick { min-width: 118px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; }
.tick b { display: block; font-size: 13px; }
.tick .p { font-size: 16px; font-weight: 700; margin: 2px 0; }

.stat { background: var(--bg2); border-radius: 12px; padding: 10px; text-align: center; }
.stat .v { font-size: 20px; font-weight: 800; }
.stat .l { font-size: 11px; color: var(--hint); }
.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--bg2); margin: 6px 0; }
.bar .l { background: var(--down); } .bar .s { background: var(--up); }

.list { display: flex; flex-direction: column; }
.li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .t { flex: 1; min-width: 0; }
.li .t .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coinlink { font-weight: 700; cursor: pointer; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 11px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line);
  font-size: 13px; cursor: pointer; white-space: nowrap; user-select: none; }
.chip.on { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 11px 14px;
  background: var(--accent); color: var(--accent-text); font-weight: 600; cursor: pointer; }
.btn.sec { background: var(--bg2); color: var(--text); border: 1px solid var(--line); }
.btn.gold { background: linear-gradient(90deg, #f0b90b, #ff8a00); color: #1b1300; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
input, textarea, select { width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; outline: none; }
input:focus, textarea:focus { border-color: var(--accent); }

.seg { display: flex; background: var(--bg2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 6px; border-radius: 8px; font-size: 13px; color: var(--hint); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.2); }

#chart { height: 360px; margin: 0 -12px; }
.coinbar { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.coinbar .name { font-size: 22px; font-weight: 800; }
.coinbar .price { font-size: 20px; font-weight: 700; }
.search { position: relative; }
.dropdown { position: absolute; top: 100%; left: 0; right: 0; z-index: 4; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-top: 4px; max-height: 320px; overflow: auto; }
.dropdown div { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.info-blocks .ev { border-left: 3px solid var(--accent); padding: 6px 10px; margin: 6px 0; background: var(--bg2); border-radius: 0 10px 10px 0; }

.ev-card { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ev-card:last-child { border-bottom: 0; }
.ev-head { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--hint); margin-bottom: 4px; }
.ev-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ev-title { font-weight: 600; }
.ev-body { margin-top: 6px; font-size: 14px; white-space: pre-wrap; color: var(--text); }
.ev-coins { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

.cat { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.cat:last-child { border-bottom: 0; }
.cat .t { flex: 1; min-width: 0; }
.cat .t .n { font-weight: 600; }
.cat .t .d { font-size: 12px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw { position: relative; width: 46px; height: 28px; flex: none; }
.sw input { display: none; }
.sw span { position: absolute; inset: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 99px; transition: .2s; }
.sw span:after { content: ""; position: absolute; width: 22px; height: 22px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.sw input:checked + span { background: var(--up); border-color: var(--up); }
.sw input:checked + span:after { transform: translateX(18px); }
.sec-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.sec-head .cnt { font-size: 12px; color: var(--hint); }
.slot { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 2px solid transparent; cursor: pointer; font-size: 16px; background: var(--bg2); }
.slot.on { border-color: var(--accent); }
.slot.off { opacity: .35; }

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet.hidden { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .18s ease-out; max-width: 760px; margin: 0 auto; }
.sheet-body h2 { margin: 0 0 6px; font-size: 19px; }
.sheet-body .grip { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: -6px auto 12px; }
.fg { margin: 14px 0; }
.fg .lbl { font-size: 13px; color: var(--hint); margin-bottom: 6px; }
@keyframes up { from { transform: translateY(30px); opacity: .5 } to { transform: none; opacity: 1 } }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px); transform: translateX(-50%); background: #222a3a; color: #fff; padding: 10px 16px;
  border-radius: 12px; z-index: 30; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: 90vw; }
.toast.hidden { display: none; }
.loader { width: 28px; height: 28px; margin: 40px auto; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.empty { text-align: center; color: var(--hint); padding: 30px 10px; }
.gauge { position: relative; width: 100%; max-width: 120px; margin: 0 auto; }
.plan { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--bg2); border-radius: 12px; margin-bottom: 8px; }
.plan b { font-size: 16px; }
.refbox { display: flex; gap: 6px; }
.refbox input { font-size: 12px; }
table.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
table.stats td, table.stats th { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; }
table.stats td:first-child, table.stats th:first-child { text-align: left; }
table.stats th { color: var(--hint); font-weight: 500; font-size: 11px; }
.ai-text { white-space: pre-wrap; line-height: 1.5; }
