/* Telegram sets --tg-theme-* on the page; the fallbacks cover a plain browser in light or dark mode. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2a7de1);
  --button: var(--tg-theme-button-color, #2a7de1);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --section: var(--tg-theme-section-bg-color, var(--tg-theme-secondary-bg-color, #f1f1f4));
  --sep: var(--tg-theme-section-separator-color, rgba(127, 127, 127, 0.2));
  --accent: var(--tg-theme-accent-text-color, #2a7de1);
  --bad: var(--tg-theme-destructive-text-color, #d93a3a);
  --good: #2e9e5b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17181c; --text: #f2f2f2; --hint: #8d8f96; --section: #23252b; --link: #5ea8ff; --accent: #5ea8ff;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--link); text-decoration: none; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 8px; }
.brand { font-weight: 700; font-size: 18px; }
.donate {
  border: 1px solid var(--button); background: transparent; color: var(--button);
  border-radius: 14px; padding: 4px 12px; font-size: 13px;
}
.donate[hidden] { display: none; }

.tabs { display: flex; gap: 4px; background: var(--section); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 7px 4px; border-radius: 8px; font-size: 14px; }
.tabs button.on { background: var(--bg); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }

.card { background: var(--section); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--hint); font-weight: 600; }
.hint { color: var(--hint); font-size: 13px; margin: 6px 0; }
.note { color: var(--hint); font-size: 14px; padding: 8px 0; }
.err { color: var(--bad); }

.search { display: flex; gap: 8px; }
input, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--sep);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
.primary { background: var(--button); color: var(--button-text); border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.ghost { background: transparent; border: 1px solid var(--sep); border-radius: 10px; padding: 10px 14px; }
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--sep); }
.list li:last-child { border-bottom: 0; }
.list li.tap { cursor: pointer; }
.list .main { min-width: 0; overflow: hidden; }
.list .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { color: var(--hint); font-size: 12px; }
.list .right { text-align: right; white-space: nowrap; }
.list .usd { color: var(--hint); font-size: 12px; }

.gift-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.tile {
  width: 84px; height: 84px; border-radius: 16px; flex: none; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 26px; overflow: hidden;
}
.tile img { width: 100%; height: 100%; object-fit: cover; }
.gift-head h2 { margin: 0; font-size: 20px; }
.big { font-size: 22px; font-weight: 700; }

.traits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.trait { background: var(--bg); border-radius: 10px; padding: 8px; min-width: 0; }
.trait .k { color: var(--hint); font-size: 11px; text-transform: uppercase; }
.trait .v { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trait .r { color: var(--accent); font-size: 12px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { background: var(--button); color: var(--button-text); border-radius: 10px; padding: 2px 8px; font-size: 12px; }
.badge.soft { background: var(--bg); color: var(--text); border: 1px solid var(--sep); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips button { border: 1px solid var(--sep); background: var(--bg); border-radius: 14px; padding: 4px 10px; font-size: 13px; }
.chips button.on { background: var(--button); color: var(--button-text); border-color: var(--button); }

.steps { margin: 6px 0 0; padding-left: 18px; }
.steps li { margin: 4px 0; }
details summary { cursor: pointer; color: var(--link); margin-top: 6px; }

.up { color: var(--good); }
.down { color: var(--bad); }

.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-card { background: var(--bg); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-card h2 { margin: 0 0 4px; font-size: 18px; }
.field { display: block; font-size: 13px; color: var(--hint); }
.field input { margin-top: 4px; }

.spinner { color: var(--hint); padding: 16px 0; text-align: center; }
