/* spread Mini App — значения из spread-miniapp-design/DESIGN.md и screens/*.dc.html. Тема только тёмная. */
:root {
  --page: #0a0a0a; --surface: #161616; --surface-2: #1d1d1d; --line: #272727;
  --ink: #f2f2f2; --muted: #757575; --ok: #4ade80; --danger: #f87171; --warn: #fbbf24;
  --tile-empty: #2a2a2a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--page); }
body {
  color: var(--ink); font-family: 'Roboto Mono', ui-monospace, monospace; font-size: 14px;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; }
button:disabled { opacity: .4; cursor: default; }
a { color: var(--ink); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ok { color: var(--ok); } .danger { color: var(--danger); } .warn { color: var(--warn); }

#app {
  max-width: 480px; min-width: 320px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
  padding: 18px 14px 28px;
}

/* ---------- шапка ---------- */
.hdr { display: flex; align-items: center; justify-content: space-between; height: 44px; gap: 10px; }
.wordmark { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.hdr-title { font-size: 18px; font-weight: 700; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 999px; background: var(--surface); color: var(--muted);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); flex: none;
}
.icon-btn.alt { background: var(--surface-2); color: var(--ink); }
.icon-btn.on { color: var(--ink); }

/* ---------- вкладки ---------- */
.tabs { display: flex; gap: 8px; }
.tab {
  height: 40px; padding: 0 20px; border-radius: 999px; background: var(--surface); color: var(--muted);
  font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; box-shadow: var(--shadow);
  transition: transform .15s, color .15s;
}
.tab.active { color: var(--ink); transform: scale(1.06); }

/* ---------- карточки и панели ---------- */
.card { background: var(--surface); border-radius: 28px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.big { border-radius: 32px; padding: 20px 16px; gap: 16px; }
.card.tight { gap: 10px; }
.panel { background: var(--surface-2); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.panel.rows { padding: 6px 16px; gap: 0; }
.panel.list { gap: 10px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.kv.tight { padding: 4px 0; }
.kv > :first-child { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv > :last-child { font-variant-numeric: tabular-nums; text-align: right; flex: none; }
.empty { font-size: 13px; color: var(--muted); line-height: 1.6; }
.note-text { font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
h1 { margin: 0; font-size: 18px; font-weight: 600; }
.section { display: flex; flex-direction: column; gap: 8px; }

/* ---------- кнопки ---------- */
.btn {
  height: 40px; padding: 0 16px; border-radius: 999px; background: var(--surface-2); color: var(--ink);
  font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--ink); color: var(--page); }
.btn.cta { height: 56px; width: 100%; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; }
.btn.danger-text { background: transparent; color: var(--danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.on-surface { background: var(--surface); }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pill {
  height: 28px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.pill.on-surface { background: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 32px; padding: 0 12px 0 6px; border-radius: 999px; background: var(--surface); color: var(--ink);
  font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
}
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button {
  height: 32px; padding: 0 12px; border-radius: 999px; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600;
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg.on-surface button.active { background: var(--surface-2); }

/* ---------- поля ---------- */
.input {
  height: 40px; border-radius: 12px; border: 0; padding: 0 16px; background: var(--surface-2); color: var(--ink);
  font-size: 14px; outline: none; width: 100%; min-width: 0;
}
.input.on-panel { background: var(--surface); padding: 0 14px; font-size: 13px; }
.input::placeholder, textarea::placeholder { color: var(--muted); }
.big-input {
  background: transparent; border: 0; outline: none; color: var(--ink); font-size: 30px; font-weight: 600;
  padding: 0; letter-spacing: -0.5px; width: 100%; text-transform: uppercase;
}
.big-input::placeholder { color: #3a3a3a; text-transform: none; }
textarea.note-input {
  height: 52px; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 13px; resize: none;
  outline: none; width: 100%; line-height: 1.6;
}
.counter { font-size: 11px; color: var(--muted); text-align: right; }
.row-input { display: flex; gap: 8px; }

/* ---------- плитки логотипов (правило ChainIcon) ---------- */
.tile { display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex: none; }
.tile img { display: block; }
.tile .ini { font-weight: 600; color: var(--ink); line-height: 1; }
.route { display: flex; flex: none; }
.route .tile + .tile { margin-left: -6px; }

/* ---------- вотчлист ---------- */
.live { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); display: inline-block; }
.live.stale i { background: var(--muted); }
.wl { display: flex; flex-direction: column; }
.wl-row {
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 12px; border-radius: 16px;
  color: var(--ink); background: transparent; text-align: left; width: 100%;
}
.wl-row.hot { background: var(--surface-2); }
.wl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wl-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-spread { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; flex: none; }
.nolegs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.nolegs .label { margin-right: 2px; }

/* ---------- карточка токена ---------- */
.spread-big { font-size: 46px; font-weight: 600; letter-spacing: -2px; line-height: 1; font-variant-numeric: tabular-nums; }
.spread-line { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.spread-cap { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.6; }
.bs { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding-top: 2px; }
.bs-panel {
  height: 80px; border-radius: 20px; background: var(--surface-2); padding: 16px 14px; display: flex;
  align-items: center; gap: 12px; min-width: 0;
}
.bs-panel.sell { flex-direction: row-reverse; text-align: right; }
.bs-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bs-text .label { line-height: 1; }
.bs-name { font-size: 16px; font-weight: 600; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bs-chev {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.8); width: 28px; height: 28px;
  border-radius: 12px; background: var(--surface-2); color: var(--muted); box-shadow: 0 0 0 4px var(--surface);
  display: flex; align-items: center; justify-content: center;
}
.leg-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; width: 100%; background: transparent; text-align: left; }
.leg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.leg-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg-sub.wrap { white-space: normal; }
.leg-price { font-size: 14px; font-variant-numeric: tabular-nums; flex: none; text-align: right; }
.leg-off { opacity: .45; }
.divider { height: 1px; background: var(--line); margin: 6px 0; }
.warn-text { font-size: 12px; color: var(--warn); line-height: 1.5; }
.err-text { font-size: 12px; color: var(--danger); line-height: 1.5; }

/* ---------- группа настроек ---------- */
.group { border: 1px solid var(--line); border-radius: 16px; }
.group > * + * { border-top: 1px solid var(--line); }
.grow {
  display: flex; align-items: center; gap: 16px; padding: 16px; width: 100%; background: transparent;
  text-align: left; color: var(--ink);
}
.grow.compact { padding: 14px 16px; gap: 12px; }
.grow.block { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 16px; }
.gtext { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gtitle { font-size: 14px; font-weight: 600; }
.gnote { font-size: 12px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.stepper button { width: 32px; height: 32px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 16px; }
.stepper span { min-width: 48px; text-align: center; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sw {
  appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 12px; background: var(--line);
  position: relative; margin: 0; cursor: pointer; flex: none; transition: background .15s;
}
.sw::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: left .15s, background .15s;
}
.sw:checked { background: var(--ink); }
.sw:checked::after { left: 19px; background: var(--page); }
.sw:disabled { opacity: .4; }
.times { display: flex; align-items: center; gap: 8px; }
.times input { width: 110px; height: 36px; border-radius: 12px; border: 0; background: var(--surface-2); padding: 0 12px; outline: none; font-variant-numeric: tabular-nums; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--page); font-size: 12px;
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none;
}

/* ---------- история ---------- */
.ev { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.ev + .ev { border-top: 1px solid var(--line); }
.ev-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* ---------- лист снизу (sheet) ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; background: var(--surface);
  border-radius: 28px 28px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); display: flex;
  flex-direction: column; gap: 12px; animation: up .18s ease-out;
}
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 4px; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head .gtitle { font-size: 16px; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: 440px; width: calc(100% - 28px); background: var(--surface-2); color: var(--ink); border-radius: 16px;
  padding: 12px 16px; font-size: 13px; line-height: 1.5; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); z-index: 60;
  animation: up .18s ease-out;
}
.toast.err { color: var(--danger); }

/* ---------- состояние ---------- */
.center { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 0 16px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-inline { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.loading-inline .spinner { width: 16px; height: 16px; }
.mono-id { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* пустые служебные блоки (статус, предупреждения) не должны давать лишний отступ в колонке */
.panel > div:empty { display: none; }

/* в листе снизу фон = surface — таблетки на нём на surface-2, иначе сливаются */
.sheet .chip { background: var(--surface-2); }
