/* Верстаем только под мобилу: приложение открывают с телефона. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --fg: var(--tg-theme-text-color, #111111);
  --muted: var(--tg-theme-hint-color, #7d8b99);
  --card: var(--tg-theme-secondary-bg-color, #f2f4f7);
  --accent: var(--tg-theme-button-color, #2f9ae0);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #d1453b);
  --border: rgba(127, 143, 160, .35);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.screen {
  min-height: 100vh;
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom))
           calc(16px + env(safe-area-inset-left));
}

.screen-full { padding: 0; position: relative; height: 100vh; overflow: hidden; }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 10px; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 14px; }
.center { display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- форма --- */

.field { margin-bottom: 16px; }
.field-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field-hint { margin-top: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  width: auto;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font-size: 15px;
  font-weight: 500;
}
.chip-on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chip:disabled { opacity: .55; }

.input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  font-family: inherit;
}

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.error-box {
  background: rgba(209, 69, 59, .12);
  color: var(--danger);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

button {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
}
button:disabled { opacity: .5; }
button.secondary { background: var(--card); color: var(--fg); }
button.danger { background: transparent; color: var(--danger); }
button + button { margin-top: 8px; }

.pick-map {
  height: 240px;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid var(--border);
}
.place-status { margin-top: 6px; }

/* --- карта --- */

#map { position: absolute; inset: 0; }

.map-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(12px + env(safe-area-inset-top));
  z-index: 500;
  display: flex;
  gap: 8px;
}
.map-bar button {
  padding: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}

.map-empty {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 500;
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.pin {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  color: #fff;
  background: #2f9ae0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.pin-host { background: #e0642f; }
.pin-guest { background: #2f9ae0; }
.pin-mine { background: #3aa757; outline: 2px solid #fff; }

/* --- шторки --- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 900;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, .25);
}

.card-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.card-row:last-of-type { border-bottom: 0; }

.card-comment {
  margin-top: 10px;
  padding: 10px;
  background: var(--card);
  border-radius: 10px;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.map-bar button { position: relative; }

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  font-weight: 700;
}

.ping-head { font-weight: 600; margin-bottom: 4px; }
.ping-timer { margin: 6px 0 10px; }
.match-hint { margin: 12px 0; }

.offer p { margin-bottom: 12px; font-size: 15px; }

.agree {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
  font-size: 15px;
}
.agree input { width: 22px; height: 22px; margin: 0; flex: none; }
