:root {
  /* Telegram mavzusi ranglari (brauzerda — zaxira qiymatlar) */
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --sec: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --accent: #e5487f;
  --shadow: 0 6px 24px rgba(20, 10, 30, 0.16);
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.map { position: fixed; inset: 0; }

/* ---------- Turkumlar paneli ---------- */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding-top: calc(10px + var(--safe-top));
  pointer-events: none;
}
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 12px 10px;
  scrollbar-width: none;
  pointer-events: auto;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border: 0;
  border-radius: 18px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.chip b { font-size: 12px; font-weight: 600; color: var(--hint); }
.chip--on { background: var(--c); color: #fff; }
.chip--on b { color: rgba(255, 255, 255, 0.85); }

/* ---------- Xaritadagi ikonka ---------- */

.pin {
  position: absolute;
  left: -21px;
  top: -52px;
  width: 42px;
  height: 42px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 124%;
  transition: transform 0.15s ease;
  cursor: pointer;
}
.pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  margin: 2px 0 0 -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 11px solid #fff;
}
.pin__emoji { font-size: 20px; line-height: 1; }
/* Admin yuklagan ikonka: oq doira ichida, chegarasi — turkum rangi */
.pin--img { background: #fff; border-color: var(--c); }
.pin--img::after { border-top-color: var(--c); }
.pin__img { width: 26px; height: 26px; object-fit: contain; pointer-events: none; }
.chip__icon { width: 18px; height: 18px; object-fit: contain; }
.card__icon { width: 14px; height: 14px; object-fit: contain; vertical-align: -2px; }
.pin--active { transform: scale(1.2); }

/* ---------- Balun ichidagi karta (balun har doim oq) ---------- */

.card { color: #1c1c1e; font-size: 14px; line-height: 1.35; padding: 2px 2px 0; }
.card__cat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c);
  background: rgba(0, 0, 0, 0.05);
  background: color-mix(in srgb, var(--c) 12%, transparent);
}
.card__title { margin: 8px 0 2px; font-size: 17px; font-weight: 700; }
.card__price { margin-bottom: 8px; font-size: 16px; font-weight: 600; color: var(--accent); }
.card__row { margin: 3px 0; font-size: 13px; color: #55555a; }
.card__link { color: #2481cc; font-size: 14px; font-weight: 500; text-decoration: none; user-select: text; }
.card__btn {
  display: block;
  width: 100%;
  height: 42px;
  margin-top: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.card__btn:active { filter: brightness(0.92); }
.card__btn:disabled { opacity: 0.6; }

/* ---------- Tugmalar, xabarlar ---------- */

.fab {
  position: fixed;
  right: 14px;
  bottom: calc(44px + var(--safe-bottom));
  z-index: 10;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}
.fab svg { width: 22px; height: 22px; }
.fab--busy svg { animation: spin 1s linear infinite; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(104px + var(--safe-bottom));
  z-index: 50;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  font-size: 14px;
  text-align: center;
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--sec);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Joy tanlash sahifasi ---------- */

.page-pick { display: flex; flex-direction: column; }
.pick-map { position: relative; flex: 1; min-height: 0; }
.pick-map .map { position: absolute; }
.pick-map .fab { position: absolute; bottom: 36px; }

.search { position: absolute; top: calc(12px + var(--safe-top)); left: 12px; right: 12px; z-index: 6; }
.search__icon { position: absolute; left: 12px; top: 12px; width: 20px; height: 20px; color: var(--hint); }
.search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  border: 0;
  border-radius: 12px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 16px; /* iOS kattalashtirmasligi uchun */
  -webkit-appearance: none;
}
.results {
  position: absolute;
  top: calc(62px + var(--safe-top));
  left: 12px;
  right: 12px;
  z-index: 6;
  max-height: 50%;
  margin: 0;
  padding: 6px 0;
  overflow: auto;
  list-style: none;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--shadow);
}
.results button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
}
.results small { display: block; margin-top: 2px; font-size: 12px; color: var(--hint); }
.results__empty { padding: 10px 14px; color: var(--hint); }

.center-pin { position: absolute; left: 50%; top: 50%; z-index: 5; width: 0; height: 0; pointer-events: none; }
.center-pin__head {
  position: absolute;
  left: -18px;
  top: -56px;
  width: 36px;
  height: 36px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.center-pin__head::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px;
  border-radius: 50%;
  background: #fff;
}
.center-pin__stick {
  position: absolute;
  left: -1.5px;
  top: -22px;
  width: 3px;
  height: 22px;
  border-radius: 2px;
  background: var(--accent);
}
.center-pin__shadow {
  position: absolute;
  left: -6px;
  top: -3px;
  width: 12px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
}
.center-pin__head, .center-pin__stick, .center-pin__shadow { transition: transform 0.18s ease, opacity 0.18s ease; }
.center-pin--lift .center-pin__head, .center-pin--lift .center-pin__stick { transform: translateY(-10px); }
.center-pin--lift .center-pin__shadow { transform: scale(1.5); opacity: 0.5; }

.sheet {
  position: relative;
  z-index: 7;
  flex: none;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  background: var(--bg);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}
.sheet__label { font-size: 13px; color: var(--hint); }
.sheet__addr { min-height: 22px; margin: 4px 0 14px; font-size: 16px; font-weight: 600; }
.btn {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.btn:disabled { opacity: 0.55; }
.btn:not(:disabled):active { filter: brightness(0.92); }
