/* Telegram supplies --tg-theme-* inside the app; the values after the comma are for a plain browser. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f3f6);
  --surface: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #16202c);
  --muted: var(--tg-theme-hint-color, #6d7885);
  --accent: var(--tg-theme-button-color, #2481cc);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--muted) 25%, transparent);
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

#list-screen { max-width: 560px; margin: 0 auto; }

.top { padding: 16px 16px 6px; }
.top h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.top p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.filters {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  background: var(--bg);
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.pill {
  flex: none;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
  white-space: nowrap;
}
.pill.active { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.pill.reset { border-color: transparent; background: none; color: var(--accent); }

.count { margin: 0; padding: 2px 16px 10px; color: var(--muted); font-size: 14px; }

.cards { display: grid; gap: 12px; padding: 0 16px 24px; }

.card {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}
.card-photo { position: relative; aspect-ratio: 16 / 10; background: var(--line); }
.card-photo img, .gallery img { display: block; width: 100%; height: 100%; object-fit: cover; }
.badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 12px;
}
.card-info { padding: 11px 13px 13px; }
.price { font-size: 19px; font-weight: 700; }
.price small { font-size: 13px; font-weight: 400; color: var(--muted); }
.card-title { margin-top: 3px; font-weight: 600; }
.card-meta { margin-top: 1px; color: var(--muted); font-size: 14px; }

.message { padding: 40px 16px; color: var(--muted); text-align: center; }
.message button { margin-top: 12px; }

.detail {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  padding-bottom: 84px;
  background: var(--surface);
}
.detail.in-telegram { padding-bottom: 16px; }
.detail.in-telegram .back, .detail.in-telegram .contact-bar { display: none; }
#detail-body { max-width: 560px; margin: 0 auto; }
.back {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  min-height: 36px;
  padding: 0 13px;
  border: 0;
  border-radius: 18px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
}

.gallery-wrap { position: relative; }
.gallery {
  display: flex;
  aspect-ratio: 4 / 3;
  overflow-x: auto;
  background: var(--line);
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: 0 0 100%; scroll-snap-align: center; }

.detail-section { padding: 14px 16px 0; }
.detail-section h1 { margin: 4px 0 0; font-size: 19px; line-height: 1.25; }
.detail-section h2 { margin: 0 0 6px; font-size: 16px; }
.district { margin-top: 2px; color: var(--muted); }

.rows { margin: 0; }
.row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row dt { color: var(--muted); }
.row dd { margin: 0; text-align: right; font-weight: 500; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 4px 10px; border-radius: 12px; background: var(--bg); font-size: 14px; }
.tag.warn { color: #c0392b; }
.post-text { white-space: pre-line; overflow-wrap: anywhere; }
.number { padding: 12px 16px 0; color: var(--muted); font-size: 14px; }

.contact-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.contact {
  display: block;
  width: 100%;
  max-width: 528px;
  min-height: 48px;
  margin: 0 auto;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .4); }
.sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 21;
  max-width: 560px;
  max-height: 75vh;
  margin: 0 auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
}
.sheet h2 { margin: 0 0 8px; font-size: 17px; }
.option {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
}
.option.selected { background: var(--accent); color: var(--on-accent); font-weight: 600; }
