/* RentHub — палитра и компоненты по макету (Design: «Дом на Пхукете — web-app») */
:root {
  --bg: #F3F5F2;
  --card: #FFFFFF;
  --ink: #17201C;
  --ink-2: #33403A;
  --muted: #55625C;
  --line: #C9D1CC;
  --line-soft: #E2E7E4;
  --soft: #EEF2EF;
  --teal: #0E6B58;
  --teal-dark: #0A4F41;
  --teal-soft: #E3F1EC;
  --orange: #E8743B;
  --orange-dark: #C85A22;
  --orange-ink: #8A3A12;
  --orange-soft: #F6E8DF;
  --amber: #F2C14E;
  --amber-ink: #3B2A05;
  --amber-text: #6B4E0E;
  --blue: #2F5E8C;
  --radius: 24px;
  --tabbar-h: 68px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: Manrope, "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
button, textarea { font: inherit; }
h1, h2, p { margin: 0; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1 1 auto; display: flex; flex-direction: column; padding-bottom: 88px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1; }

/* ── шапка ── */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 8px; }
.top h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.counter { padding: 0 20px 8px; font-size: 13px; color: var(--muted); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px; flex: none; border: none;
  background: var(--card); color: var(--ink); display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(23, 32, 28, .12); cursor: pointer;
}
.icon-btn.soft { background: var(--soft); box-shadow: none; }
.icon-btn.floating { position: absolute; top: 14px; left: 14px; }

/* ── карточка свайпа ── */
.card {
  margin: 0 16px; background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 10px 28px rgba(23, 32, 28, .12); touch-action: pan-y; will-change: transform;
}
.photo { position: relative; height: min(52vh, 420px); background: #DDE3DF; cursor: grab; user-select: none; touch-action: none; }

/* Экран свайпов целиком помещается над нижним меню: фото забирает оставшееся место */
.screen.swipe {
  flex: none;  /* иначе .app (min-height: 100dvh) растягивает экран и кнопки уходят под меню */
  height: calc(100vh - var(--tabbar-h));
  height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-bottom));
  padding-bottom: 0; overflow: hidden;
}
.swipe .card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; position: relative; }
.swipe .photo { flex: 1 1 0; height: auto; min-height: 160px; }
.swipe .info { flex: none; }
.swipe .empty { flex: 1 1 auto; justify-content: center; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.no-photo { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; color: #4A5852; font-size: 13px; }
.segments { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; pointer-events: none; }
.segments span { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .5); }
.segments span.on { background: #FFFFFF; }
.photo-count { position: absolute; top: 12px; right: 12px; padding: 5px 10px; border-radius: 999px; background: rgba(23, 32, 28, .72); color: #FFF; font-size: 12px; font-weight: 700; }
.photo-badges { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px; font-size: 13px; font-weight: 700; background: #FFF; color: var(--ink); }
.badge.tub-yes { background: var(--teal); color: #FFF; }
.badge.tub-unknown { background: var(--amber); color: var(--amber-ink); }
.badge.tub-no { background: var(--orange-dark); color: #FFF; }
.stamp {
  position: absolute; top: 44px; padding: 6px 14px; border: 4px solid; border-radius: 12px;
  font-size: 30px; font-weight: 800; letter-spacing: .06em; background: rgba(255, 255, 255, .85); pointer-events: none;
}
.stamp.like { left: 20px; color: var(--teal); transform: rotate(-14deg); }
.stamp.nope { right: 20px; color: var(--orange-dark); transform: rotate(14deg); }
.preload { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.info { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.price-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.price.big { font-size: 30px; }
.price small { font-size: 14px; font-weight: 600; color: var(--muted); }
.title { font-size: 15px; color: var(--ink-2); overflow-wrap: anywhere; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--ink-2); }
.facts span { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); }
.facts svg { color: var(--muted); }
.evidence { font-size: 13px; color: var(--ink-2); font-style: italic; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tub-check { display: flex; flex-direction: column; gap: 8px; }
.tub-check p { font-size: 13px; color: var(--amber-text); }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.chip {
  min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: #FFF;
  font-size: 13px; font-weight: 700; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; cursor: pointer; text-align: center;
}
.chip.yes { border: none; background: var(--teal-soft); color: var(--teal-dark); }
.chip.no { border: none; background: var(--orange-soft); color: var(--orange-ink); }
.chip.yes.on { background: var(--teal); color: #FFF; }
.chip.no.on { background: var(--orange-dark); color: #FFF; }
.chip.dark { border: none; background: var(--ink); color: #FFF; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── кнопки решения ── */
.actions { flex: none; display: flex; justify-content: center; align-items: flex-start; gap: 28px; padding: 12px 0 8px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.action.small { padding-top: 6px; }
.round { width: 64px; height: 64px; border-radius: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; background: #FFF; }
.round.nope { border: 2px solid var(--orange); color: var(--orange-dark); }
.round.later { width: 52px; height: 52px; border: 2px solid var(--line); color: var(--muted); }
.round.like { border: none; background: var(--teal); color: #FFF; }
.round:active { transform: scale(.94); }

.empty { margin: 8px 16px; padding: 40px 28px; background: #FFF; border-radius: var(--radius); display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.empty h2 { font-size: 22px; font-weight: 800; }
.empty p { color: var(--muted); line-height: 1.5; font-size: 14px; }

.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: #FFF; color: var(--ink);
  font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; cursor: pointer;
}
.btn.primary { border: none; background: var(--teal); color: #FFF; }
.btn.primary:hover { color: #FFF; background: var(--teal-dark); }
.link { border: none; background: none; padding: 8px 0; color: var(--teal); font-weight: 700; font-size: 14px; cursor: pointer; align-self: flex-start; }

/* ── совпадение ── */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(12, 20, 17, .74); display: flex; align-items: center; justify-content: center; padding: 24px; }
.dialog { width: 100%; max-width: 360px; background: #FFF; border-radius: var(--radius); padding: 28px 22px 22px; display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: stretch; }
.dialog h2 { font-size: 26px; font-weight: 800; }
.dialog p { color: var(--ink-2); line-height: 1.45; }
.avatars { display: flex; align-items: center; justify-content: center; }
.ava { width: 56px; height: 56px; border-radius: 28px; display: flex; align-items: center; justify-content: center; color: #FFF; font-weight: 800; }
.ava.me { background: var(--teal); }
.ava.other { background: var(--blue); font-size: 20px; }
.ava-heart { width: 40px; height: 40px; border-radius: 20px; margin: 0 -8px; z-index: 1; background: #FFF; color: var(--orange-dark); display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(23, 32, 28, .18); }

/* ── избранное ── */
.segmented { margin: 4px 16px 12px; padding: 4px; background: #E4E9E6; border-radius: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.segmented button { min-height: 40px; border: none; border-radius: 10px; background: transparent; color: #4A5852; font-size: 13px; font-weight: 700; cursor: pointer; }
.segmented button.on { background: #FFF; color: var(--ink); box-shadow: 0 1px 3px rgba(23, 32, 28, .14); }
.list { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 12px; padding: 12px; background: #FFF; border-radius: 18px; text-decoration: none; color: var(--ink); }
.row:hover { color: var(--ink); }
.thumb { width: 84px; height: 84px; flex: none; border-radius: 14px; object-fit: cover; background: #DDE3DF; }
.empty-thumb { display: flex; align-items: center; justify-content: center; color: #5E6E66; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-top, .row-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.row-top b { font-size: 18px; font-weight: 800; }
.row-title { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--ink-2); font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.pill.match { background: #FBE9DF; color: var(--orange-ink); }
.tub-text { font-size: 12px; font-weight: 700; }
.tub-text.tub-yes { color: var(--teal-dark); }
.tub-text.tub-unknown { color: var(--amber-text); }
.tub-text.tub-no { color: var(--orange-ink); }

/* ── карточка дома ── */
.gallery-wrap { position: relative; }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; height: min(46vh, 360px); background: #DDE3DF; }
.gallery img { flex: none; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: start; }
.gallery .no-photo { position: static; width: 100%; }
.head { padding: 14px 20px 0; display: flex; flex-direction: column; gap: 6px; }
.head .title { font-size: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px 16px 0; }
.tile { background: #FFF; border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.tile span { font-size: 12px; color: var(--muted); }
.tile b { font-size: 19px; font-weight: 800; overflow-wrap: anywhere; }
.panel { margin: 12px 16px 0; background: #FFF; border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.list .panel { margin: 0; }
.panel h2 { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.panel p { line-height: 1.45; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vote-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.ava-sm { width: 32px; height: 32px; border-radius: 16px; background: var(--blue); color: #FFF; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; }
.yes-text { color: var(--teal-dark); }
.no-text { color: var(--orange-ink); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field textarea { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 15px; color: var(--ink); resize: vertical; }
.field input[type="text"], .field input[type="number"] {
  min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; font: inherit; font-size: 16px; color: var(--ink); background: #FFF;
}
.field input[type="range"] { accent-color: var(--teal); width: 100%; }
.field b { color: var(--ink); }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(42px, 1fr)); gap: 6px; }
.seg button { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #FFF; color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.seg button.on { border: none; background: var(--teal); color: #FFF; }
.feature-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; padding: 6px 0; border-top: 1px solid var(--line-soft); }
.feature-row select { flex: none; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; font: inherit; font-size: 14px; background: #FFF; color: var(--ink); }
.btn:disabled { opacity: .6; cursor: default; }
.description { white-space: pre-line; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.description.clamped { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.bottom-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px; }
.bottom-actions .btn { flex: 1 1 140px; }

/* ── нижнее меню ── */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 10;
  display: flex; justify-content: space-around; padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  background: #FFF; border-top: 1px solid var(--line-soft);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 72px; min-height: 44px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tab.active { color: var(--teal); font-weight: 700; }

/* ── вход, загрузка, ошибки ── */
.login { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 32px 24px; text-align: center; }
.login h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; }
.tagline { font-size: 17px; color: var(--ink-2); line-height: 1.45; }
.tg-widget { min-height: 48px; }
.error { color: var(--orange-ink); font-weight: 600; }
.loading { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 48px 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 30; max-width: 90vw; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #FFF; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  .card { transition: none !important; }
  .spinner { animation: none; }
}
