:root {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #f7f8fa);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #17181b);
  --muted: var(--tg-theme-hint-color, #74777d);
  --accent: var(--tg-theme-button-color, #246bfd);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --top: #e8501d;
  --highlight: #e3ad1e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(100%, 720px); margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; gap: 12px; margin: 2px 0 18px; }
.topbar h1 { margin: 0; font-size: 25px; letter-spacing: -0.03em; }
.eyebrow { margin: 0 0 2px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.icon-button { flex: 0 0 38px; width: 38px; height: 38px; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); font-size: 24px; }
.is-hidden { display: none !important; }

.search-panel { padding: 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 30px rgba(20, 25, 38, .04); }
.search-box { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 13px; border-radius: 13px; background: color-mix(in srgb, var(--bg) 85%, var(--surface)); color: var(--muted); }
.search-box span { font-size: 25px; transform: rotate(-20deg); }
.search-box input, .price-input input, select { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 12px -2px 0; padding: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 8px 11px; background: transparent; color: var(--text); font-size: 13px; font-weight: 600; }
.chip.is-active { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.filters { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 8px; margin-top: 12px; }
.select-wrap, .price-input { min-width: 0; height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 9px; background: transparent; display: flex; align-items: center; }
.text-button { border: 0; background: transparent; color: var(--accent); font-size: 13px; font-weight: 700; padding: 4px; }

#content { margin-top: 22px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 11px; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.section-heading span { color: var(--muted); font-size: 13px; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.ad-card { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-align: left; color: var(--text); padding: 0; box-shadow: 0 5px 16px rgba(20, 25, 38, .035); }
.ad-card.is-highlighted { border: 2px solid var(--highlight); box-shadow: 0 0 0 2px rgba(227, 173, 30, .18); }
.card-photo, .photo-placeholder { position: relative; display: block; width: 100%; aspect-ratio: 1 / .76; object-fit: cover; background: linear-gradient(135deg, #e9edf4, #dbe2ee); }
.photo-placeholder { display: grid; place-items: center; color: #788398; font-size: 30px; }
.badges { position: absolute; top: 8px; left: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.badge { display: inline-flex; align-items: center; min-height: 21px; border-radius: 6px; padding: 2px 6px; font-size: 10px; font-weight: 800; letter-spacing: .03em; color: #fff; background: #555; }
.badge.top { background: var(--top); }
.badge.highlight { color: #3a2a00; background: #ffdc5b; }
.card-body { padding: 10px; }
.card-title { display: -webkit-box; overflow: hidden; margin: 0; font-size: 14px; line-height: 1.25; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-description { display: -webkit-box; overflow: hidden; min-height: 28px; margin: 6px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.2; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.price { margin: 0; font-size: 15px; font-weight: 800; }
.city { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.load-more, .primary-button, .secondary-button { width: 100%; min-height: 47px; border-radius: 13px; font-weight: 750; }
.load-more, .secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.load-more { margin-top: 16px; }
.primary-button { border: 0; background: var(--accent); color: var(--accent-text); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 18px; }

.detail { display: grid; gap: 16px; }
.gallery { display: flex; gap: 9px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scroll-snap-type: x mandatory; }
.gallery img, .gallery .photo-placeholder { flex: 0 0 calc(100% - 48px); max-width: 380px; aspect-ratio: 1 / .8; border-radius: 18px; scroll-snap-align: start; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.detail-head .badges { position: static; justify-content: flex-end; }
.detail-title { margin: 0; font-size: 24px; letter-spacing: -.035em; line-height: 1.08; }
.detail-description { margin: 0; white-space: pre-wrap; line-height: 1.5; color: color-mix(in srgb, var(--text) 88%, var(--muted)); }
.seller { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; }
.seller p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.notice { margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text); font-size: 13px; }
.empty-state { display: grid; place-items: center; min-height: 180px; border: 1px dashed var(--line); border-radius: 17px; color: var(--muted); text-align: center; padding: 24px; }
.empty-state span { font-size: 34px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (min-width: 560px) { .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 380px) { .filters { grid-template-columns: 1fr 1fr auto; } .select-wrap { grid-column: span 2; } .card-grid { gap: 8px; } .card-body { padding: 8px; } }
