/* ============================================================
   Погнали — дизайн-система (референс: ДВИЖ)
   палитра: #6B5CFF фиолет, #0A84FF синий, #30B852 зелёный,
   #FF9F0A оранж, #FF375F розовый, #00C7BE бирюза
   ============================================================ */

:root {
  --ink: #1C1C1E;
  --ink-soft: #6E6E73;
  --ink-faint: #AEAEB2;
  --bg: #F4F4F6;
  --card: #FFFFFF;
  --purple: #6B5CFF;
  --purple-deep: #5747E8;
  --blue: #0A84FF;
  --green: #30B852;
  --green-soft: #E2F7E8;
  --orange: #FF9F0A;
  --pink: #FF375F;
  --teal: #00C7BE;
  --r-card: 28px;
  --r-btn: 22px;
  --shadow-card: 0 18px 40px rgba(28, 28, 30, .16);
  --shadow-soft: 0 8px 24px rgba(28, 28, 30, .08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ============ верхняя панель ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 10px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-rocket { font-size: 26px; }
.brand-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.5px;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative;
  width: 42px; height: 42px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:active { background: rgba(28,28,30,.06); }
.avatar-btn { border: none; background: transparent; padding: 2px; cursor: pointer; margin-left: 4px; }

.badge {
  position: absolute; top: 4px; right: 3px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--pink);
  color: #fff;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.badge-accent { top: -3px; right: -5px; background: var(--purple); }

/* ============ аватары ============ */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: 16px; font-weight: 700;
  background: var(--purple);
  flex: none;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: 14px; }
.avatar.xs { width: 28px; height: 28px; font-size: 12px; }
.avatar.crown { position: relative; }
.avatar.crown::before {
  content: "👑";
  position: absolute; top: -10px; right: -6px;
  font-size: 14px;
  transform: rotate(15deg);
}

/* ============ вкладки ============ */
.tabs {
  display: flex;
  gap: 22px;
  padding: 4px 20px 12px;
}
.tab {
  border: none; background: none;
  font-size: 24px; font-weight: 800;
  letter-spacing: -.4px;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 0 4px;
  border-bottom: 3px solid transparent;
  transition: color .2s;
}
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ============ панель управления ============ */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 20px 14px;
}
.seg {
  display: flex;
  gap: 2px;
  background: rgba(28,28,30,.06);
  border-radius: 15px;
  padding: 3px;
}
.seg-btn {
  border: none; background: transparent;
  padding: 7px 18px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .2s;
}
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(28,28,30,.10); }
.filter-btn {
  position: relative;
  width: 42px; height: 42px;
  border: none; border-radius: 14px;
  background: rgba(28,28,30,.06);
  color: var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
}

/* ============ контент ============ */
.content { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 20px; }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ============ колода ============ */
.deck-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 10px;
}
.deck-counter { font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.deck-hint { font-size: 12.5px; color: var(--ink-faint); text-align: right; max-width: 60%; }

.deck {
  position: relative;
  flex: 1;
  min-height: 380px;
  margin-bottom: 8px;
}

.swipecard {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: var(--r-card);
  color: #fff;
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  cursor: grab;
  user-select: none;
  touch-action: none;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  will-change: transform;
}
.swipecard::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 90% at 85% -10%, rgba(255,255,255,.28), transparent 55%);
  pointer-events: none;
}
.swipecard.back-1 { transform: scale(.96) translateY(26px); opacity: .97; z-index: 1 !important; pointer-events: none; box-shadow: 0 8px 20px rgba(28,28,30,.10); }
.swipecard.back-2 { transform: scale(.92) translateY(50px); opacity: .9; z-index: 0 !important; pointer-events: none; box-shadow: none; }

.card-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: auto; }
.chip {
  padding: 7px 13px;
  border-radius: 13px;
  font-size: 13px; font-weight: 700;
  background: rgba(255,255,255,.22);
  backdrop-filter: blur(4px);
}
.chip.new { background: #fff; color: var(--ink); }
.chip.friends { background: rgba(255,255,255,.22); }
.chip.new::before { content: "NEW · "; color: var(--pink); }

.card-emoji { font-size: 62px; line-height: 1; margin: 14px 0 6px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.25)); }
.card-title { font-size: 30px; font-weight: 800; letter-spacing: -.6px; margin: 0 0 8px; }
.card-desc {
  font-size: 15px; line-height: 1.42;
  opacity: .95;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: auto;
  padding-top: 14px;
  font-size: 13.5px; font-weight: 600;
  opacity: .95;
}
.card-footer .dot { opacity: .6; }
.card-price { letter-spacing: 1px; }

/* штампы при свайпе */
.stamp {
  position: absolute;
  top: 24px;
  padding: 8px 16px;
  border-radius: 12px;
  border: 3px solid #fff;
  font-size: 20px; font-weight: 900;
  letter-spacing: 1px;
  opacity: 0;
  transform: rotate(-12deg);
  pointer-events: none;
  z-index: 5;
}
.stamp.want { left: 20px; color: #fff; background: var(--green); }
.stamp.skip { right: 20px; color: #fff; background: rgba(28,28,30,.72); transform: rotate(12deg); }

.deck-empty {
  position: absolute; inset: 0;
  border-radius: var(--r-card);
  background: #fff;
  box-shadow: var(--shadow-soft);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  padding: 30px;
  text-align: center;
}
.deck-empty-emoji { font-size: 56px; }
.deck-empty-title { font-size: 22px; font-weight: 800; }
.deck-empty-text { font-size: 14.5px; color: var(--ink-soft); line-height: 1.45; margin-bottom: 8px; }

/* ============ нижняя панель ============ */
.actionbar {
  display: flex;
  gap: 12px;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
}
.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--r-btn);
  padding: 16px 20px;
  font-size: 16.5px; font-weight: 700;
  cursor: pointer;
  transition: transform .12s, opacity .12s;
}
.btn:active { transform: scale(.97); }
.btn-white { background: #fff; color: var(--ink); box-shadow: var(--shadow-soft); }
.btn-black { background: var(--ink); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-ghost { background: rgba(28,28,30,.06); color: var(--ink); }

/* кнопки свайпа для десктопа */
.deck-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding-bottom: 4px;
}
.round-btn {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .12s;
}
.round-btn:active { transform: scale(.9); }
.round-btn.skip { background: #fff; color: var(--ink-faint); }
.round-btn.want { background: var(--green); color: #fff; }

/* ============ списки (Мои) ============ */
.list { display: flex; flex-direction: column; gap: 12px; padding-bottom: 16px; }
.row-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
  transition: transform .12s;
}
.row-card:active { transform: scale(.98); }
.row-emoji {
  width: 54px; height: 54px;
  border-radius: 18px;
  display: grid; place-items: center;
  font-size: 26px;
  flex: none;
}
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 16.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13.5px; color: var(--ink-soft); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.row-avatars { display: flex; }
.row-avatars .avatar { margin-left: -8px; border: 2px solid #fff; }
.row-avatars .avatar:first-child { margin-left: 0; }
.row-badge {
  flex: none;
  font-size: 12px; font-weight: 700;
  padding: 6px 11px;
  border-radius: 10px;
}
.row-badge.match { background: var(--green-soft); color: #1E7A38; }
.row-badge.chat { background: rgba(107,92,255,.12); color: var(--purple); }

.empty-state {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  padding: 56px 24px;
  text-align: center;
}
.empty-state .big { font-size: 54px; }
.empty-state h3 { margin: 0; font-size: 20px; }
.empty-state p { margin: 0; font-size: 14.5px; color: var(--ink-soft); line-height: 1.5; }

/* ============ карта ============ */
.map-wrap {
  position: relative;
  flex: 1;
  min-height: 420px;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  background: #E8ECF1;
  box-shadow: var(--shadow-soft);
}
.map-hint {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--ink-soft);
  font-size: 14px;
}
#ymap { position: absolute; inset: 0; }
.map-card {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  z-index: 10;
}

/* ============ шторки ============ */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(28,28,30,.45);
  z-index: 40;
  opacity: 0;
  transition: opacity .22s;
}
.sheet-backdrop.show { opacity: 1; }
.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translate(-50%, 105%);
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  background: var(--bg);
  border-radius: 30px 30px 0 0;
  z-index: 50;
  transition: transform .28s cubic-bezier(.32,.72,.33,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet.show { transform: translate(-50%, 0); }
.sheet-grip {
  width: 42px; height: 5px;
  border-radius: 3px;
  background: rgba(28,28,30,.18);
  margin: 10px auto 2px;
  flex: none;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 6px;
  flex: none;
}
.sheet-title { font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.sheet-close {
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: rgba(28,28,30,.07);
  font-size: 17px;
  color: var(--ink-soft);
  cursor: pointer;
}
.sheet-body { overflow-y: auto; padding: 8px 20px calc(24px + env(safe-area-inset-bottom, 0px)); }

/* детальное место: шапка */
.place-hero {
  border-radius: var(--r-card);
  color: #fff;
  padding: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.place-hero::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 100% at 90% -20%, rgba(255,255,255,.3), transparent 55%);
}
.place-hero .card-emoji { margin: 6px 0 10px; font-size: 54px; }
.place-hero h2 { margin: 0 0 6px; font-size: 27px; font-weight: 800; letter-spacing: -.5px; }
.place-hero .place-addr { font-size: 14px; opacity: .92; }

.detail-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.dchip {
  padding: 9px 14px;
  border-radius: 13px;
  background: #fff;
  font-size: 13.5px; font-weight: 700;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}
.dchip.open { background: var(--green-soft); color: #1E7A38; }
.dchip.purple { background: rgba(107,92,255,.12); color: var(--purple); }

.green-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--green-soft);
  border-radius: 18px;
  padding: 12px 14px;
  margin: 14px 0;
}
.green-banner .gb-text { flex: 1; font-size: 14.5px; font-weight: 700; color: #1E7A38; line-height: 1.35; }
.green-banner .gb-text small { display: block; font-weight: 500; color: #3E9B54; font-size: 12.5px; margin-top: 2px; }

.detail-desc {
  background: #fff;
  border-radius: 20px;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.participants { margin: 16px 0; }
.participants-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px; font-weight: 700; color: var(--ink-soft);
}
.participants-row { display: flex; gap: 10px; flex-wrap: wrap; }
.p-person { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 56px; }
.p-name { font-size: 11.5px; color: var(--ink-soft); max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.detail-actions .btn { flex: none; }

/* ============ чат ============ */
.chat { display: flex; flex-direction: column; min-height: 300px; max-height: 58vh; }
.chat-place {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 16px;
  padding: 10px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow-soft);
}
.chat-place .row-emoji { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
.chat-msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 12px; }
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.4;
}
.msg.mine { align-self: flex-end; background: var(--purple); color: #fff; border-bottom-right-radius: 6px; }
.msg.theirs { align-self: flex-start; background: #fff; border-bottom-left-radius: 6px; box-shadow: var(--shadow-soft); }
.msg .msg-author { display: block; font-size: 11px; font-weight: 700; opacity: .75; margin-bottom: 2px; }
.chat-input { display: flex; gap: 8px; padding-top: 8px; }
.chat-input input {
  flex: 1;
  border: none;
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow-soft);
}
.chat-input button {
  width: 50px; height: 50px;
  border: none; border-radius: 16px;
  background: var(--ink); color: #fff;
  font-size: 19px;
  cursor: pointer;
}

/* ============ формы ============ */
.form { display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 0 0 7px 4px; }
.field input, .field textarea, .field select {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 15px 16px;
  font-size: 15.5px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow-soft);
}
.field textarea { resize: none; min-height: 84px; }
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cat-pill {
  border: 2px solid transparent;
  border-radius: 15px;
  padding: 11px 6px;
  font-size: 13.5px; font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
  background: var(--c, var(--purple));
}
.cat-pill.active { border-color: var(--ink); transform: scale(1.05); }
.seg3 { display: flex; gap: 6px; }
.seg3 button {
  flex: 1;
  border: none; border-radius: 13px;
  padding: 11px 0;
  background: #fff;
  font-size: 14px; font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.seg3 button.active { background: var(--ink); color: #fff; }

/* ============ уведомления ============ */
.notif {
  display: flex; gap: 12px;
  background: #fff;
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
}
.notif .n-ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; flex: none; }
.notif.unread .n-ico { background: rgba(107,92,255,.14); }
.notif.read .n-ico { background: rgba(28,28,30,.05); }
.notif .n-title { font-size: 14.5px; font-weight: 700; }
.notif .n-body { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.notif .n-time { font-size: 11.5px; color: var(--ink-faint); margin-top: 4px; }

/* ============ друзья ============ */
.invite-card {
  border-radius: 24px;
  background: var(--purple);
  color: #fff;
  padding: 22px;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}
.invite-card::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 120% at 90% -20%, rgba(255,255,255,.3), transparent 50%);
}
.invite-card h3 { margin: 0 0 6px; font-size: 21px; font-weight: 800; }
.invite-card p { margin: 0 0 16px; font-size: 14px; opacity: .92; line-height: 1.45; }
.invite-card .btn { position: relative; z-index: 2; flex: none; }

/* ============ тосты ============ */
.toast-wrap {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
}
.toast {
  background: var(--ink);
  color: #fff;
  border-radius: 16px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  animation: toast-in .25s cubic-bezier(.3,1.3,.5,1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.match { background: var(--green); }
.toast.error { background: var(--pink); }
@keyframes toast-in { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* конфетти-матч */
.match-pop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.match-pop .mp-card {
  background: #fff;
  border-radius: 26px;
  padding: 26px 34px;
  text-align: center;
  box-shadow: var(--shadow-card);
  animation: mp-in .4s cubic-bezier(.3,1.4,.5,1);
}
.match-pop .mp-emoji { font-size: 54px; }
.match-pop h3 { margin: 8px 0 4px; font-size: 22px; }
.match-pop p { margin: 0; color: var(--ink-soft); font-size: 14px; }
@keyframes mp-in { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* фильтры-лист */
.filter-list { display: flex; flex-direction: column; gap: 8px; }
.filter-row {
  display: flex; align-items: center; gap: 12px;
  background: #fff;
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 13px 16px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}
.filter-row.active { border-color: var(--ink); }
.filter-row .fr-emoji { font-size: 20px; }
.filter-row .fr-check { margin-left: auto; color: var(--green); font-weight: 900; }

/* профиль */
.profile-card {
  background: #fff;
  border-radius: 24px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
}
.profile-card .avatar { width: 62px; height: 62px; font-size: 24px; }
.profile-card h3 { margin: 0; font-size: 19px; }
.profile-card p { margin: 3px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.stats-row { display: flex; gap: 10px; margin-bottom: 14px; }
.stat {
  flex: 1;
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.stat .st-num { font-size: 22px; font-weight: 800; }
.stat .st-label { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

@media (min-width: 520px) {
  body { background: #E3E3E8; }
  #app { box-shadow: 0 0 60px rgba(28,28,30,.12); }
}

/* hidden должен побеждать любые display-правила */
[hidden] { display: none !important; }
