:root {
  --bg: #050607;
  --panel: #0c0f12;
  --panel-2: #12161b;
  --line: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.1);
  --text: #eef1f4;
  --muted: #8a94a1;
  --dim: #535c67;
  --green: #2fd88c;
  --green-dim: rgba(47, 216, 140, 0.1);
  --red: #ff6166;
  --red-dim: rgba(255, 97, 102, 0.1);
  --amber: #f2b45a;
  --amber-dim: rgba(242, 180, 90, 0.1);
  --blue: #6aaeff;
  --radius: 16px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 14px/1.45 Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(76px + var(--safe-b));
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ── Шапка ── */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: rgba(5, 6, 7, 0.82);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.14em; font-size: 13px; }
.logo {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 4px var(--green-dim), 0 0 18px rgba(47, 216, 140, 0.55);
}
.live {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line-2);
  font: 600 11px var(--mono); letter-spacing: 0.06em; color: var(--muted);
}
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.live.ok { color: var(--green); border-color: rgba(47, 216, 140, 0.25); }
.live.ok i { background: var(--green); animation: pulse 2s infinite; }
.live.warn { color: var(--amber); }
.live.warn i { background: var(--amber); }
.live.bad { color: var(--red); }
.live.bad i { background: var(--red); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47, 216, 140, 0.5); } 70%, 100% { box-shadow: 0 0 0 6px rgba(47, 216, 140, 0); } }

.demo, .locked {
  margin: 14px 18px 0; padding: 12px 14px; border-radius: 12px;
  background: var(--amber-dim); color: var(--amber); font-size: 13px;
}
.locked { background: var(--red-dim); color: var(--red); font-size: 14px; padding: 18px; }

main { padding: 14px 18px; }
h3 { margin: 26px 4px 10px; font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; }
.hint { color: var(--muted); font-size: 13px; margin: 14px 4px; }
.empty { text-align: center; color: var(--dim); padding: 56px 16px; font-size: 13px; line-height: 1.6; }

/* ── Язык ── */
.top-right { display: flex; align-items: center; gap: 8px; }
.lang { display: inline-flex; padding: 2px; border-radius: 999px; border: 1px solid var(--line-2); }
.lang button { padding: 3px 8px; border-radius: 999px; font: 600 10px var(--mono); letter-spacing: 0.06em; color: var(--dim); }
.lang button.on { background: var(--text); color: var(--bg); }
.lang.big button { padding: 6px 14px; font-size: 12px; }

/* ── Сегменты и фильтры кабала ── */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.seg button { padding: 8px 0; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--muted); transition: background 0.15s, color 0.15s; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.filters-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  margin: 0 0 10px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  font-size: 12px; color: var(--muted); text-align: left;
}
.filters-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filters-btn svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.filters-btn.open { border-color: rgba(47, 216, 140, 0.35); color: var(--text); }
#cabalFilters { margin-bottom: 10px; }
.ext-key .ca { margin-top: 8px; font-size: 11px; color: var(--green); border-color: rgba(47, 216, 140, 0.35); }
.hint.small { font-size: 11px; color: var(--dim); margin: 2px 4px 10px; }
.card.cabal .t-count b { font-size: 18px; }
.card.cabal .t-count em { font-style: normal; font-size: 11px; color: var(--muted); font-family: Inter, sans-serif; margin-left: 2px; }

/* ── Поиск и фильтры ── */
.search input {
  width: 100%; padding: 12px 15px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); outline: none;
  transition: border-color 0.15s;
}
.search input::placeholder { color: var(--dim); }
.search input:focus { border-color: rgba(47, 216, 140, 0.45); }
.chips { display: flex; gap: 6px; margin: 12px 0 14px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 500;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }

/* ── Карточки токенов ── */
.list { display: flex; flex-direction: column; gap: 8px; }
.card {
  position: relative;
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px 12px;
  padding: 14px 10px 14px 16px; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 60%), var(--panel);
  border: 1px solid var(--line);
  text-align: left; width: 100%; cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.card:active { transform: scale(0.99); }
.card.hot { border-color: rgba(47, 216, 140, 0.28); }
.card.hot::before {
  content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 2px; border-radius: 2px;
  background: var(--green); box-shadow: 0 0 10px rgba(47, 216, 140, 0.6);
}
.card .x {
  grid-column: 3; grid-row: 1 / span 2; align-self: start;
  width: 28px; height: 28px; margin: -6px -2px 0 0; border-radius: 9px;
  color: var(--dim); font-size: 12px; line-height: 28px; text-align: center;
}
.card .x:hover, .card .x:active { color: var(--text); background: var(--panel-2); }
.t-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.t-sym { font-weight: 650; font-size: 15px; white-space: nowrap; letter-spacing: 0.01em; }
.t-name { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.t-meta { grid-column: 1; display: flex; gap: 8px; align-items: center; font-size: 12px; min-width: 0; }
.t-meta .badge { flex: none; }
.t-meta .m { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--panel-2); font-size: 11px; font-weight: 500; color: var(--muted);
}
.badge.green { color: var(--green); background: var(--green-dim); }
.badge.red { color: var(--red); background: var(--red-dim); }
.badge.amber { color: var(--amber); background: var(--amber-dim); }
.badge.blue { color: var(--blue); background: rgba(106, 174, 255, 0.1); }
.t-count { grid-row: 1 / span 2; grid-column: 2; text-align: right; align-self: center; }
.t-count b { display: block; font: 600 22px/1 var(--mono); color: var(--text); letter-spacing: -0.02em; }
.card.hot .t-count b { color: var(--green); }
.t-count small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.dots { display: flex; gap: 3px; justify-content: flex-end; margin-top: 6px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--line-2); }
.dots i.on { background: var(--green); }

.undo {
  position: fixed; left: 18px; right: 18px; bottom: calc(82px + var(--safe-b)); z-index: 8;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: 14px; background: #171c22; border: 1px solid var(--line-2);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55); font-size: 13px;
}
.undo button { color: var(--green); font-weight: 600; }

/* ── Настройки ── */
.group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row > span { display: flex; flex-direction: column; min-width: 0; }
.row b { font-weight: 500; }
.row small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.switch { cursor: pointer; }
.switch input { display: none; }
.switch i {
  flex: none; position: relative; width: 42px; height: 25px; border-radius: 999px;
  background: var(--line-2); transition: background 0.2s;
}
.switch i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%;
  background: #c9d0d8; transition: transform 0.2s;
}
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(17px); background: #fff; }
.stepper { flex: none; display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 11px; }
.stepper button { width: 34px; height: 32px; font-size: 17px; color: var(--muted); }
.stepper button:active { color: var(--text); }
.stepper output { min-width: 46px; text-align: center; font: 600 13px var(--mono); }
.saved { text-align: center; color: var(--green); font-size: 12px; }

/* ── Статус ── */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.stat b { display: block; font: 600 20px/1.2 var(--mono); overflow-wrap: anywhere; letter-spacing: -0.01em; }
.stat small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.stat small.sub { color: var(--dim); font-size: 11px; margin-top: 1px; }
.stat.wide { grid-column: 1 / -1; }
.stat.sm b { font: 500 13px/1.4 Inter, sans-serif; letter-spacing: 0; }
.stat.err b { color: var(--red); font: 500 13px/1.4 Inter, sans-serif; }
.lp-row { gap: 10px; }
.lp { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; }
.lp b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.n { font: 600 13px var(--mono); color: var(--muted); }
.user-actions, .row > span.user-actions { display: flex; flex-direction: row; gap: 6px; flex-wrap: wrap; }
.user-actions:empty { display: none; }
.user-row { flex-direction: column; align-items: stretch; gap: 10px; }
.btn-s { white-space: nowrap; }
.user-row b { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.compose textarea {
  display: block; width: 100%; padding: 13px 16px; resize: vertical; min-height: 84px;
  background: transparent; border: 0; outline: none; color: var(--text); font: inherit;
}
.compose textarea::placeholder { color: var(--dim); }
.compose-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.compose-bar small { color: var(--muted); font-size: 12px; }
.btn-s { padding: 6px 11px; border-radius: 9px; border: 1px solid var(--line-2); font-size: 12px; color: var(--muted); }
.btn-s.green { color: var(--green); border-color: rgba(47, 216, 140, 0.3); }
.btn-s.red { color: var(--red); border-color: rgba(255, 97, 102, 0.3); }

/* ── Нижние вкладки ── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 8px 6px calc(8px + var(--safe-b));
  background: rgba(7, 8, 10, 0.86);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0; font-size: 10px; font-weight: 500; letter-spacing: 0.02em; color: var(--dim); transition: color 0.15s; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--text); }
.tab.on svg { stroke: var(--green); }

/* ── Шторка токена ── */
.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(2px); }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto;
  background: var(--panel); border-top: 1px solid var(--line-2); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(20px + var(--safe-b));
  animation: up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 0 auto 16px; }
.sheet h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: 0.01em; }
.sheet .sub { color: var(--muted); margin: 4px 0 16px; font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.kpi b { display: block; font: 600 19px/1.15 var(--mono); letter-spacing: -0.01em; }
.kpi small { color: var(--muted); font-size: 11px; }
.kpi.g b { color: var(--green); }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  padding: 13px; border-radius: 14px; border: 1px solid var(--line-2); font-weight: 600; font-size: 14px;
}
.btn.primary { background: var(--green); color: #03140b; border: 0; font-size: 15px; box-shadow: 0 6px 22px rgba(47, 216, 140, 0.22); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 500; }
.btn.danger { color: var(--red); border-color: rgba(255, 97, 102, 0.25); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 10px; }
.actions .btn { font-weight: 500; color: var(--muted); }
.ca {
  display: block; width: 100%;
  padding: 11px 12px; border-radius: 12px; border: 1px dashed var(--line-2);
  font: 11px var(--mono); color: var(--dim); text-align: center; overflow-wrap: anywhere;
}
.ca.done { color: var(--green); border-color: rgba(47, 216, 140, 0.35); font-family: Inter, sans-serif; font-size: 12px; }
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.tl:last-child { border-bottom: 0; }
.tl > span:nth-child(2) { display: flex; flex-direction: column; }
.tl small { color: var(--dim); font-size: 11px; }
.tl .i { font: 600 12px var(--mono); color: var(--dim); }
.tl .v { font: 600 12px var(--mono); color: var(--muted); }
.tl.dev .i { color: var(--green); }
.tl.bundle .v { color: var(--blue); }
.tl.linked .v { color: var(--amber); }
.block-row { margin-top: 18px; }
.block-row.inline { margin-top: 0; }
.block-row.inline .btn { height: 100%; }

@media (min-width: 640px) {
  main { max-width: 640px; margin: 0 auto; }
  .sheet-body { max-width: 640px; margin: 0 auto; }
}
