:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8a8a);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --sec: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --line: color-mix(in srgb, var(--hint) 35%, transparent);
  --ok: #2bb673;
  --warn: #d4a017;
  --err: #e04b4b;
  --r-row: 10px;
  --r-surf: 16px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(72px + var(--safe-b));
  overflow-x: hidden;
}

button, input, select {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: default; }
:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.screen { display: none; padding: var(--pad); }
.screen.active { display: block; }

h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 4px 0 18px;
}
.h-sub {
  color: var(--hint);
  font-size: 14px;
  margin: -12px 0 18px;
}

.list {
  border-top: 1px solid var(--line);
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  transition: background 160ms ease;
}
.row:active { background: var(--sec); }
.row .meta { flex: 1; min-width: 0; }
.row .title { font-weight: 560; }
.row .sub {
  color: var(--hint);
  font-size: 13px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row .chev { color: var(--hint); }

.icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  color: var(--text);
}
.icon svg { width: 100%; height: 100%; display: block; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-row);
  background: var(--bg);
}
.field .err {
  color: var(--err);
  font-size: 13px;
  margin-top: 6px;
  display: none;
}
.field.invalid .err { display: block; }
.field.invalid input { border-color: var(--err); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.chip {
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  transition: background 160ms ease, border-color 160ms ease;
}
.chip.on {
  border-color: var(--btn);
  background: color-mix(in srgb, var(--btn) 12%, var(--bg));
}

.price-block {
  margin: 28px 0 8px;
  padding: 16px;
  border-radius: var(--r-surf);
  background: var(--sec);
}
.price-live {
  font-size: 40px;
  font-weight: 680;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  transition: opacity 180ms ease;
}
.price-live.busy { opacity: 0.35; }
.price-hint {
  margin-top: 6px;
  color: var(--hint);
  font-size: 13px;
}

.pay-list { border-top: 1px solid var(--line); }
.pay-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--r-row);
  text-align: left;
}
.pay-row.selected { background: var(--sec); }
.pay-row .amt {
  font-variant-numeric: tabular-nums;
  font-weight: 560;
}
.radio {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--hint);
  border-radius: 50%;
  position: relative;
}
.pay-row.selected .radio { border-color: var(--btn); }
.pay-row.selected .radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--btn);
}

.ton-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--r-surf);
  background: var(--sec);
  display: none;
}
.ton-box.show { display: block; }
.ton-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 14px;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}
.ton-line .k { color: var(--hint); min-width: 64px; }
.copy {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--link);
}

.status-chain {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 20px 0;
}
.step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  min-height: 52px;
}
.step .dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hint);
}
.step.done .dot { border-color: var(--ok); color: var(--ok); }
.step.active .dot { border-color: var(--btn); color: var(--btn); }
.step.fail .dot { border-color: var(--err); color: var(--err); }
.step .label { padding-top: 4px; }
.step .label small { display: block; color: var(--hint); margin-top: 2px; }

.timer {
  font-variant-numeric: tabular-nums;
  color: var(--hint);
  font-size: 14px;
  margin-bottom: 12px;
}

.skel {
  height: 56px;
  border-radius: var(--r-row);
  background: linear-gradient(90deg, var(--sec), color-mix(in srgb, var(--sec) 40%, var(--bg)), var(--sec));
  background-size: 200% 100%;
  animation: sk 1.2s linear infinite;
  margin-bottom: 8px;
}
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
  .row, .chip, .price-live { transition: none; }
}

.empty {
  padding: 40px 8px;
  text-align: center;
  color: var(--hint);
}
.empty button {
  margin-top: 16px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r-row);
  background: var(--btn);
  color: var(--btn-text);
}

.linkish {
  display: inline-block;
  margin-top: 20px;
  color: var(--link);
  min-height: 44px;
  line-height: 44px;
}

/* Fallback CTA when Telegram MainButton недоступен (браузер). В Mini App скрыт. */
.action-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(430px, 100%);
  padding: 12px var(--pad) calc(12px + var(--safe-b));
  background: var(--bg);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.action-bar.hidden { display: none; }
.action-btn {
  width: 100%;
  min-height: 48px;
  border-radius: var(--r-row);
  background: var(--btn);
  color: var(--btn-text);
  font-weight: 600;
}

.hidden { display: none !important; }
