/* Telegram theme colors (set by telegram-web-app.js), with fallbacks for a plain browser. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --ok: #2e9d4f;
  --radius: 12px;
  --bottom-inset: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #17212b);
    --text: var(--tg-theme-text-color, #f5f5f5);
    --hint: var(--tg-theme-hint-color, #708499);
    --accent: var(--tg-theme-button-color, #5288c1);
    --bg2: var(--tg-theme-secondary-bg-color, #232e3c);
    --danger: var(--tg-theme-destructive-text-color, #ec3942);
    --ok: #4fbf6e;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(64px + var(--bottom-inset));
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea {
  font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 11px 12px; width: 100%; outline: none; resize: vertical;
}
input:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--hint); }
h1 { font-size: 20px; margin: 0 0 6px; }
[hidden] { display: none !important; }

.spinner {
  width: 32px; height: 32px; margin: 40vh auto 0; border-radius: 50%;
  border: 3px solid var(--bg2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- bottom: fallback main button + tabs ---------- */
#bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--bg); padding-bottom: var(--bottom-inset);
}
.main-btn {
  display: block; width: calc(100% - 24px); margin: 8px 12px; padding: 13px;
  border-radius: var(--radius); background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.tabs { display: flex; border-top: 1px solid var(--bg2); }
.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 0 6px; color: var(--hint); font-size: 11px; position: relative;
}
.tabs button.active { color: var(--accent); font-weight: 600; }
.tab-icon { font-size: 20px; line-height: 1.2; filter: grayscale(1); opacity: 0.7; }
.tabs button.active .tab-icon { filter: none; opacity: 1; }
.badge {
  position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px;
}
/* Only outside Telegram, which has its own BackButton. */
.fallback-back { display: block; margin: 8px 12px; width: 36px; height: 36px; border-radius: 50%; background: var(--bg2); font-size: 18px; }

.toast {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 20px; font-size: 14px;
  white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
}

/* ---------- catalog ---------- */
.toolbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 12px 6px; }
.search { -webkit-appearance: none; appearance: none; }
.chips {
  display: flex; gap: 6px; overflow-x: auto; margin: 8px -12px 0; padding: 0 12px 4px; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 16px; background: var(--bg2); font-size: 14px; white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-text); }
.chip.reset { color: var(--danger); background: transparent; border: 1px solid var(--bg2); }
.chip-count { margin-left: 5px; font-size: 12px; opacity: 0.6; }
.brands { margin: 2px 0 0; }
.swatches {
  display: flex; gap: 4px; overflow-x: auto; padding: 4px 12px 2px; scrollbar-width: none;
}
.swatches::-webkit-scrollbar { display: none; }
.swatch { flex: none; width: 58px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.swatch-dot {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(127, 127, 127, 0.35);
  box-shadow: 0 0 0 2px var(--bg);
}
.swatch-dot.multi { background: conic-gradient(#e53935, #fbc02d, #43a047, #1e88e5, #8e24aa, #e53935); }
.swatch.on .swatch-dot { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.swatch-name { font-size: 11px; color: var(--hint); max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch.on .swatch-name { color: var(--text); font-weight: 600; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px 0; color: var(--hint); font-size: 13px; }
.sort { font: inherit; font-size: 13px; color: var(--accent); background: none; border: 0; padding: 4px 0; }
.more { padding: 8px 0 16px; }
.spinner.small { width: 24px; height: 24px; margin: 0 auto; border-width: 3px; }
.sentinel { height: 1px; }
.card-brand { margin-top: 6px; font-size: 12px; color: var(--hint); }
.card-brand + .card-name { margin-top: 0; }
.card-colors { color: var(--hint); }
.card-sub { font-size: 12px; color: var(--hint); }
.badge-tag {
  position: absolute; left: 6px; top: 6px; padding: 3px 7px; border-radius: 8px;
  font-size: 11px; font-weight: 600; background: rgba(255, 255, 255, 0.92); color: #1a1a1a;
}
.badge-tag.stock { background: #e3f6e8; color: #1d6b35; }
.product-badges { margin-top: 6px; }
.product-badges .badge-tag { position: static; display: inline-block; }
.price-sub { font-size: 13px; color: var(--hint); }
.section { margin: 10px 0 4px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 12px; }
.section-head h2, .all-title { font-size: 17px; margin: 6px 0; }
.all-title { padding: 0 12px; margin-top: 14px; }
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: 42%; gap: 10px;
  overflow-x: auto; padding: 4px 12px 6px; scrollbar-width: none; scroll-snap-type: x proximity;
}
.rail::-webkit-scrollbar { display: none; }
.rail .card { scroll-snap-align: start; }
.brand { color: var(--hint); font-size: 13px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; padding: 6px 12px 12px; }
.card { min-width: 0; cursor: pointer; }
.card-photo { position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden; background: var(--bg2); }
.cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { background: var(--bg2); }
.card-name {
  margin-top: 6px; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-price { font-weight: 600; font-size: 14px; }
.heart {
  position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.25); font-size: 17px; line-height: 34px;
}
.row .heart { position: static; flex: none; align-self: center; background: transparent; }
.empty, .empty-state { text-align: center; color: var(--hint); padding: 40px 24px; }
.empty-state h1 { color: var(--text); }
.big-emoji { font-size: 56px; }

/* ---------- product ---------- */
.product-photos { position: relative; }
.gallery { position: relative; background: var(--bg2); }
.track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.track::-webkit-scrollbar { display: none; }
.slide { flex: none; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; scroll-snap-align: center; display: block; }
.dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.dot { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.55); box-shadow: 0 0 2px rgba(0, 0, 0, 0.4); transition: width 0.2s; }
.dot.on { width: 16px; background: #fff; }
.heart.big { top: 12px; right: 12px; width: 40px; height: 40px; line-height: 40px; font-size: 20px; }
.product-body { padding: 14px 16px 24px; }
.price { font-size: 19px; font-weight: 700; }
.avail { font-size: 14px; color: var(--hint); }
.avail.in_stock { color: var(--ok); }
.label { color: var(--hint); font-size: 13px; margin: 16px 0 6px; display: block; }
.options { display: flex; flex-wrap: wrap; gap: 8px; }
.options .chip { padding: 8px 14px; min-width: 44px; border: 1px solid transparent; }
.options .chip.sold { opacity: 0.45; text-decoration: line-through; cursor: default; }
.description { white-space: pre-line; margin: 18px 0 0; }

/* ---------- the website (a browser, not Telegram) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--bg2);
}
.site-name { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; }
.site-help { color: var(--accent); font-weight: 500; }
.web .toolbar { top: 49px; }
.lang-switch { margin-top: 18px; }
/* Wider screens: the shop in a centred column, more products per row */
@media (min-width: 760px) {
  .web #screen, .web .site-header, .web #bottom { max-width: 1100px; margin-left: auto; margin-right: auto; }
  .web #bottom { left: 0; right: 0; }
  .web .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px 14px; }
  .web .rail { grid-auto-columns: 200px; }
  .web .product { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .web .product-photos { position: sticky; top: 60px; }
}

/* ---------- help, orders ---------- */
.help { padding: 14px 16px 24px; }
.btn.wide { display: block; width: 100%; text-align: center; }
a.btn { text-decoration: none; text-align: center; }
.row-link {
  display: flex; justify-content: space-between; width: 100%; padding: 12px 14px;
  background: var(--bg2); border-radius: var(--radius); font-weight: 500;
}
.track-row { display: flex; gap: 8px; align-items: center; }
.track-row .btn { margin: 0; white-space: nowrap; }
.how { white-space: pre-line; font-size: 14px; background: var(--bg2); border-radius: var(--radius); padding: 10px 12px; }
.order { background: var(--bg2); border-radius: var(--radius); padding: 12px; margin: 10px 0; }
.order-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; letter-spacing: 0.5px; }
.order-item { font-size: 14px; margin-top: 4px; }
.order-total { font-weight: 600; margin-top: 6px; }
.order-status { margin-top: 8px; font-weight: 600; }
.steps { list-style: none; padding: 0; margin: 10px 0 4px; }
.steps li { position: relative; padding: 3px 0 3px 24px; font-size: 14px; color: var(--hint); }
.steps li::before { content: "○"; position: absolute; left: 4px; }
.steps li.done { color: var(--text); }
.steps li.done::before { content: "✓"; color: var(--ok); font-weight: 700; }
.steps li.now { color: var(--text); font-weight: 700; }
.steps li.now::before { content: "●"; color: var(--accent); }
.code-box { background: var(--bg2); border-radius: var(--radius); padding: 10px 16px; margin: 12px auto; display: inline-block; }
.code-box .code { font-size: 22px; color: var(--text); }

/* ---------- size guide ---------- */
.guide { padding: 14px 16px 24px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row .link { padding: 0; font-size: 13px; }
.measures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.measure span { display: block; font-size: 12px; color: var(--hint); margin-bottom: 4px; }
.measure input { padding: 9px 10px; }
.size-result { margin: 12px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--bg2); font-weight: 600; }
.size-result.found { background: var(--accent); color: var(--accent-text); }
.chart { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.chart th { text-align: left; color: var(--hint); font-weight: 500; font-size: 12px; padding: 6px 4px; }
.chart td { padding: 7px 4px; border-top: 1px solid var(--bg2); }
.chart td:first-child { font-weight: 600; }

/* ---------- filter screen ---------- */
.filters { padding: 14px 16px 24px; }
.filters-head { display: flex; align-items: center; justify-content: space-between; }
.filters .options .chip { padding: 8px 12px; }
.price-range { display: flex; align-items: center; gap: 8px; }
.price-range span { color: var(--hint); }

/* ---------- lists: favorites, cart ---------- */
.list { padding: 8px 12px; }
.row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--bg2); }
.row.tap { cursor: pointer; }
.thumb { width: 76px; height: 96px; flex: none; border-radius: 10px; object-fit: cover; background: var(--bg2); }
.row-body { flex: 1; min-width: 0; }
.row-name { font-weight: 500; }
.row-price { font-weight: 600; }
.row-hint { color: var(--hint); font-size: 13px; }
.row-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.qty { display: flex; align-items: center; background: var(--bg2); border-radius: 18px; }
.qty button { width: 36px; height: 32px; font-size: 18px; color: var(--accent); }
.qty span { min-width: 24px; text-align: center; font-weight: 600; }
.link { color: var(--accent); font-size: 14px; padding: 6px 0; }
.danger { color: var(--danger); }
.total { font-weight: 700; font-size: 17px; text-align: right; padding: 14px 0 4px; }

/* ---------- checkout ---------- */
.checkout { padding: 14px 16px 24px; }
.field { display: block; }
.btn {
  display: inline-block; margin-top: 16px; padding: 11px 18px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.btn.secondary { display: block; width: 100%; margin-top: 8px; background: var(--bg2); color: var(--accent); }
.segmented { display: flex; gap: 4px; padding: 3px; background: var(--bg2); border-radius: var(--radius); }
.seg { flex: 1; padding: 9px 6px; border-radius: 10px; font-size: 14px; }
.seg.on { background: var(--bg); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.hint { color: var(--hint); font-size: 13px; margin: 8px 0 0; white-space: pre-line; }
.summary { background: var(--bg2); border-radius: var(--radius); padding: 10px 12px; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 3px 0; }
.summary .total { padding: 8px 0 0; border-top: 1px solid var(--bg); margin-top: 6px; }
.prepay { font-size: 14px; text-align: right; white-space: pre-line; padding-top: 4px; }
.nowrap { white-space: nowrap; }

.chip.more-colors { color: var(--accent); background: transparent; border: 1px solid var(--bg2); }

.ready-line { margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--ok); }
