/* Премиум Mini App: графит + золото, fallback на тему Telegram (ADR-008) */
:root {
  --bg: #0f1115;
  --elev: #151922;
  --card: #1a1f29;
  --card-2: #202634;
  --line: rgba(255, 255, 255, .08);
  --text: #f2f3f5;
  --muted: #9aa2b1;
  --gold: #c8a96a;
  --gold-soft: rgba(200, 169, 106, .14);
  --ok: #4ec98a;
  --err: #e5675f;
  --radius: 20px;
  --pad: 16px;
  --shadow: 0 18px 44px rgba(0, 0, 0, .38);
}
html[data-theme="light"] {
  --bg: #f7f4ee;
  --elev: #fffdf9;
  --card: #ffffff;
  --card-2: #f3efe6;
  --line: rgba(15, 17, 21, .09);
  --text: #15181d;
  --muted: #6b7280;
  --gold: #a8873f;
  --gold-soft: rgba(168, 135, 63, .12);
  --shadow: 0 18px 44px rgba(15, 17, 21, .10);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) var(--pad) 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--gold), #8d7443);
  color: #15181d;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .6px;
  flex: none;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 16px;
  letter-spacing: -.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--elev);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 1.7; }
.icon-btn.active { border-color: var(--gold); background: var(--gold-soft); }
.icon-btn.active svg { fill: var(--gold); stroke: var(--gold); }
.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--gold);
  color: #15181d;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

main { max-width: 760px; margin: 0 auto; padding: 16px var(--pad) 0; }

.searchbar { display: flex; gap: 8px; }
.field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--elev);
}
.field svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; flex: none; }
.field input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  min-width: 0;
}
.field input::placeholder { color: var(--muted); }
#sort {
  height: 46px;
  padding: 0 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--text);
  font-size: 13px;
  max-width: 42%;
}

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .16s ease;
}
.chip.active { background: var(--gold); border-color: transparent; color: #15181d; }

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 2px 12px;
  font-size: 13px;
  color: var(--muted);
}
.link { border: 0; background: transparent; color: var(--gold); font-size: 13px; font-weight: 600; cursor: pointer; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(2, 1fr); } }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease;
}
.card:active { transform: scale(.985); }
.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--card-2), var(--elev));
}
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 26px;
  opacity: .55;
}
.card-price { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.card-price small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.card-title { font-size: 13px; line-height: 1.35; color: var(--text); }
.card-meta { font-size: 11px; color: var(--muted); }
.tag {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(15, 17, 21, .72);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  backdrop-filter: blur(6px);
}
.fav-mini {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 0;
  background: rgba(15, 17, 21, .6);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.fav-mini.on { background: var(--gold); color: #15181d; }

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--elev), var(--card-2), var(--elev));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
.card-skeleton { height: 260px; }
@keyframes shimmer { 0% { background-position: 0 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.empty { padding: 48px 18px; text-align: center; color: var(--muted); }
.empty-mark { font-size: 34px; color: var(--gold); margin-bottom: 10px; }

.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
.sheet-card {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 16px var(--pad) calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  animation: sheet-in .22s ease;
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.gallery { position: relative; border-radius: 16px; overflow: hidden; background: var(--card-2); aspect-ratio: 16 / 10; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-nav { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.gallery-nav button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(15, 17, 21, .6);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; gap: 5px; justify-content: center; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .45); }
.dots span.on { background: var(--gold); }

.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 14px 0 6px; }
.sheet-price { font-size: 24px; font-weight: 800; letter-spacing: -.8px; }
.sheet-price small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 3px; letter-spacing: 0; }
.sheet-title { font-size: 16px; line-height: 1.35; margin-top: 2px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.meta-chip {
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--elev);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text);
}
.desc { font-size: 14px; line-height: 1.55; color: var(--muted); margin: 10px 0 16px; }

.lead-form { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.lead-form h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.lead-form input,
.lead-form textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.lead-form textarea { min-height: 74px; resize: vertical; }
.lead-form input:focus,
.lead-form textarea:focus { border-color: var(--gold); }
.consent { display: flex; align-items: flex-start; gap: 9px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.consent input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--gold); }
.actions { display: flex; gap: 8px; margin-top: 4px; }
.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform .16s ease, opacity .16s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--gold); border-color: transparent; color: #15181d; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.hint { font-size: 12px; color: var(--muted); }
.hint.err { color: var(--err); }
.hint.ok { color: var(--ok); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }
