/* The fonts are served from here (SIL OFL, see fonts/): no other hosts to reach. */
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 600; font-display: swap; src: url(fonts/onest-v11-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 600; font-display: swap; src: url(fonts/onest-v11-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 500 700; font-display: swap; src: url(fonts/unbounded-v12-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 500 700; font-display: swap; src: url(fonts/unbounded-v12-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: var(--tg-theme-bg-color, #f3f4f1);
  --bg2: var(--tg-theme-secondary-bg-color, #e7e9e3);
  --text: var(--tg-theme-text-color, #1c211d);
  --hint: var(--tg-theme-hint-color, #7c847d);
  --link: var(--tg-theme-link-color, #2a6fdb);
  --like: #1f9d6b;
  --nope: var(--tg-theme-destructive-text-color, #d2463c);
  --tag: #f2c230;
  --ink: #17201a;
  --score-mid: #ece6d1;
  --score-low: #d9d9d4;
  --score-ink: var(--ink);
  --radius-card: 22px;
  --display: "Unbounded", system-ui, sans-serif;
  --body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
}

/* The dark theme: Telegram gives the main colours, these are for the
   rest and for a page opened outside Telegram. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #17191a);
  --bg2: var(--tg-theme-secondary-bg-color, #24282a);
  --text: var(--tg-theme-text-color, #e9ece9);
  --hint: var(--tg-theme-hint-color, #8d958e);
  --link: var(--tg-theme-link-color, #6aa5ff);
  --like: #2fb67f;
  --nope: var(--tg-theme-destructive-text-color, #e5584e);
  --tag: #e3b72c;
  --score-mid: #50492f;
  --score-low: #3b3f3c;
  --score-ink: #f2efe4;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--body);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { height: 100%; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; }
.sheet { max-width: 640px; margin: 0 auto; }

/* Tabs */
.top { padding: 10px 16px 6px; }
.tabs { display: flex; gap: 4px; background: var(--bg2); border-radius: 14px; padding: 4px; }
.tab {
  flex: 1; padding: 8px 6px; border-radius: 10px;
  font-weight: 500; font-size: 14px; color: var(--hint);
  transition: background .2s, color .2s;
}
.tab.is-on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tab { white-space: nowrap; }
/* The views of all the ads: list, map, market. */
.seg { display: flex; gap: 18px; margin: 8px 6px 0; }
.seg-btn { padding: 2px 0 4px; font-size: 14px; font-weight: 500; color: var(--hint); border-bottom: 2px solid transparent; }
.seg-btn.is-on { color: var(--text); border-bottom-color: var(--text); }
.count { font-variant-numeric: tabular-nums; color: var(--hint); font-weight: 400; }
.count:empty { display: none; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Deck */
.stack { position: relative; flex: 1; margin: 6px 12px 0; min-height: 0; }
.card {
  position: absolute; inset: 0;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: #2a302b;
  color: #fff;
  touch-action: none;
  will-change: transform;
  box-shadow: 0 12px 30px -14px rgba(10, 20, 12, .55);
  transform-origin: 50% 110%;
}
.card.is-back { transform: scale(.94) translateY(14px); filter: brightness(.8); transition: transform .3s, filter .3s; }
.card.is-back2 { transform: scale(.88) translateY(28px); filter: brightness(.65); opacity: .7; }
.card.is-settling { transition: transform .35s cubic-bezier(.2,.9,.3,1.2); }
.card.is-flying { transition: transform .38s ease-in, opacity .38s ease-in; }

.photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #2a302b; pointer-events: none; }
.no-photo { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.5); font-size: 14px; }

.bars { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; gap: 4px; z-index: 2; }
.bar { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.35); }
.bar.is-on { background: #fff; }

.badges { position: absolute; top: 22px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 6px; z-index: 2; }
.badge {
  padding: 4px 9px; border-radius: 999px;
  background: rgba(15, 20, 16, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 12.5px; font-weight: 500;
}
.badge.score { background: var(--tag); color: var(--ink); font-family: var(--display); font-weight: 700; }
.badge.score.is-mid { background: var(--score-mid); color: var(--score-ink); }
.badge.score.is-low { background: var(--score-low); color: var(--score-ink); }
.badge.vote-like { background: rgba(31,157,107,.9); }
.badge.vote-nope { background: rgba(210,70,60,.9); }
.badge.gone { background: rgba(0,0,0,.75); }
.badge.seen { background: rgba(0,0,0,.55); }

.stamp {
  position: absolute; top: 64px; z-index: 3;
  padding: 6px 14px; border: 4px solid currentColor; border-radius: 12px;
  font: 700 30px/1 var(--display);
  opacity: 0; pointer-events: none;
}
.stamp-like { left: 20px; color: #4fe0a6; transform: rotate(-14deg); }
.stamp-nope { right: 20px; color: #ff6b5f; transform: rotate(14deg); }

.info {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 80px 18px 18px;
  background: linear-gradient(to top, rgba(8,12,9,.92) 0%, rgba(8,12,9,.75) 45%, rgba(8,12,9,0) 100%);
}
.price-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price { font: 700 34px/1 var(--display); letter-spacing: -.02em; }
.price small { font-size: 16px; font-weight: 500; margin-left: 3px; opacity: .8; }
.median { font-size: 13px; font-weight: 500; padding: 2px 8px; border-radius: 6px; }
.median.is-cheap { background: rgba(79,224,166,.22); color: #7ff0c1; }
.median.is-dear { background: rgba(255,107,95,.2); color: #ffa39b; }
.facts { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-weight: 500; font-size: 15px; }
.place { margin-top: 6px; font-size: 14px; color: rgba(255,255,255,.78); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.when { margin-top: 6px; font-size: 12.5px; color: rgba(255,255,255,.55); }

.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 10px;
}
.empty-key { width: 76px; height: 76px; stroke: var(--hint); fill: none; stroke-width: 1.6; }
.empty h2 { margin: 6px 0 0; font: 700 20px/1.2 var(--display); }
.empty p { margin: 0; color: var(--hint); max-width: 30ch; }
.btn {
  margin-top: 8px; padding: 11px 18px; border-radius: 12px;
  background: var(--tg-theme-button-color, var(--like)); color: var(--tg-theme-button-text-color, #fff); font-weight: 600;
}
.btn-quiet { background: var(--bg2); color: var(--text); }

/* Reason chips */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; padding: 7px 12px; border-radius: 999px;
  background: var(--bg2); font-size: 14px; white-space: nowrap;
  transition: background .15s, color .15s, transform .1s;
}
.chip:active { transform: scale(.95); }
.chip.is-on.like { background: var(--like); color: #fff; }
.chip.is-on.nope { background: var(--nope); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Reasons asked after a swipe */
.picker-backdrop, #picker-backdrop { background: rgba(0,0,0,.25); z-index: 12; }
#picker { z-index: 13; }
.picker-title { margin: 6px 0 2px; font: 700 20px/1.2 var(--display); }
.picker-title.like { color: var(--like); }
.picker-title.nope { color: var(--nope); }
.picker-hint { margin: 0 0 12px; color: var(--hint); font-size: 13.5px; }
.picker .chip { padding: 9px 14px; font-size: 15px; }
.own-input {
  width: 100%; margin-top: 12px; padding: 11px 12px; border: 0; border-radius: 12px;
  background: var(--bg2); color: var(--text); font: inherit;
}
.picker-actions { display: flex; gap: 8px; margin-top: 14px; }
.picker-actions .btn { flex: 1; margin: 0; }
.btn-like { background: var(--like); color: #fff; }
.btn-nope { background: var(--nope); color: #fff; }
.btn:disabled { opacity: .4; }

/* Controls */
.controls { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 12px 0 calc(14px + var(--safe-b)); }
.ctl {
  display: grid; place-items: center; border-radius: 50%;
  background: var(--bg); box-shadow: 0 4px 14px -4px rgba(0,0,0,.25), inset 0 0 0 1px rgba(127,127,127,.15);
  transition: transform .12s;
}
.ctl:active { transform: scale(.9); }
.ctl:disabled { opacity: .35; }
.ctl svg { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ctl-undo, .ctl-info { width: 46px; height: 46px; color: var(--hint); }
.ctl-undo svg, .ctl-info svg { width: 22px; height: 22px; stroke-width: 2; }
.ctl-nope, .ctl-like { width: 66px; height: 66px; }
.ctl-nope svg, .ctl-like svg { width: 30px; height: 30px; }
.ctl-nope { color: var(--nope); }
.ctl-like { color: var(--like); }
.ctl-like svg { fill: var(--like); stroke: var(--like); }

/* Lists */
.list { flex: 1; overflow-y: auto; padding: 6px 12px calc(16px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.row {
  display: flex; gap: 12px; width: 100%; text-align: left; padding: 8px; border-radius: 16px;
  align-items: center;
}
.row:active { background: var(--bg2); }
.row + .row { margin-top: 2px; }
.thumb { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; background: var(--bg2); flex: none; }
.row-main { min-width: 0; flex: 1; }
.row-price { font: 700 18px/1.2 var(--display); display: flex; align-items: center; gap: 8px; }
.row-sub { font-size: 13.5px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-votes { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.pill { padding: 2px 8px; border-radius: 999px; background: var(--bg2); }
.pill.like { color: var(--like); }
.pill.nope { color: var(--nope); }
.pill.gone { color: var(--hint); }
.pill.seen { color: var(--link); }
.row.is-gone .thumb { filter: grayscale(1); opacity: .6; }
.row.is-gone .row-price { color: var(--hint); text-decoration: line-through; }
.list-empty { text-align: center; color: var(--hint); padding: 60px 24px; }
.list-head { margin: 10px 8px 4px; font-size: 13px; color: var(--hint); }

/* Sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-height: 92%; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0;
  animation: up .28s cubic-bezier(.2,.9,.3,1);
  user-select: text; -webkit-user-select: text;
}
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--bg2); margin: 8px auto 4px; flex: none; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(20px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.gallery { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 8px -16px 14px; padding: 0 16px; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { height: 210px; width: auto; max-width: 85%; border-radius: 14px; object-fit: cover; scroll-snap-align: center; background: var(--bg2); flex: none; }
.caption { white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; }
.caption a { color: var(--link); text-decoration: none; }
.caption blockquote { margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--link); background: var(--bg2); border-radius: 0 8px 8px 0; }
.sheet h3 { margin: 18px 0 8px; font: 700 15px/1.3 var(--display); }
.vote-row { display: flex; gap: 8px; margin-top: 14px; }
.vote-btn { flex: 1; padding: 12px; border-radius: 14px; background: var(--bg2); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.vote-btn.like.is-on { background: var(--like); color: #fff; }
.vote-btn.nope.is-on { background: var(--nope); color: #fff; }
.others { display: flex; flex-direction: column; gap: 6px; }
.other { padding: 8px 12px; border-radius: 12px; background: var(--bg2); font-size: 14px; }
.other b { font-weight: 600; }
.my-note {
  display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 10px; padding: 10px 12px;
  border-radius: 12px; background: var(--bg2); color: var(--text); text-align: left; font: inherit;
}
.my-note .chip { pointer-events: none; }
.my-note-text { font-size: 14px; font-style: italic; }
.my-note-edit { color: var(--link); font-size: 13.5px; font-weight: 500; }
.picker-drop { width: 100%; margin: 8px 0 0; }
.links { display: flex; gap: 8px; margin-top: 16px; }
.links .btn { flex: 1; margin: 0; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); z-index: 20;
  padding: 9px 16px; border-radius: 12px; background: rgba(20,24,21,.92); color: #fff; font-size: 14px;
  animation: rise .2s; max-width: calc(100% - 32px); text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (max-height: 620px) {
  .price { font-size: 28px; }
  .ctl-nope, .ctl-like { width: 56px; height: 56px; }
  .controls { padding-top: 8px; }
}

/* Loading placeholder */
.card.skeleton { background: linear-gradient(100deg, var(--bg2) 40%, var(--bg) 50%, var(--bg2) 60%) var(--bg2); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Full screen photos */
.viewer { position: fixed; inset: 0; z-index: 30; background: #000; touch-action: none; overflow: hidden; animation: fade .15s; }
.viewer[hidden] { display: none; }
.viewer-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 50% 50%; will-change: transform; user-select: none; -webkit-user-select: none; }
.viewer-img.is-settling { transition: transform .2s ease-out; }
.viewer-count { position: absolute; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); text-align: center; color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.6); pointer-events: none; }
.viewer-close { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; }
.viewer-close svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.gallery img { cursor: zoom-in; }

/* Arrows for a mouse over the photos. */
.gallery-wrap { position: relative; }
.nav { display: none; position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.45); align-items: center; justify-content: center; z-index: 2; cursor: pointer; }
.nav svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nav-prev { left: 8px; }
.nav-next { right: 8px; }
.gallery-wrap .nav { top: 105px; }
@media (hover: hover) and (pointer: fine) {
  .nav { display: flex; }
  .nav[hidden] { display: none; }
}

/* Taking back the vote before, in the details */
.back-prev { margin: 4px 0 6px; padding: 8px 14px; font-size: 14px; }

/* Filters of the full list */
.filters { padding: 2px 12px 6px; display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.filter-select, .filter-input {
  width: 100%; min-width: 0; padding: 9px 10px; border: 0; border-radius: 12px;
  background: var(--bg2); color: var(--text); font: inherit; font-size: 14px;
}
.filter-input::placeholder { color: var(--hint); }
.chip.is-on:not(.like):not(.nope) { background: var(--text); color: var(--bg); }
.link-btn { padding: 0; color: var(--link); font-size: 13px; }

/* Map */
/* isolation keeps the map layers (z-index 400 and up) under the details. */
.map { isolation: isolate; flex: 1; min-height: 0; margin: 6px 12px calc(12px + var(--safe-b)); border-radius: 18px; overflow: hidden; background: var(--bg2); }
[data-theme="dark"] .map .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9); }
.map .leaflet-popup-content-wrapper, .map .leaflet-popup-tip { background: var(--bg); color: var(--text); }
.map .leaflet-popup-content { margin: 12px 14px; font: inherit; }
.map .leaflet-container a.leaflet-popup-close-button { color: var(--hint); }
.map-pop { display: flex; flex-direction: column; gap: 2px; min-width: 170px; }
.map-pop b { font: 700 18px/1.2 var(--display); }
.map-pop-place { color: var(--hint); font-size: 13px; }
.map-pop .btn { margin-top: 8px; padding: 8px 12px; }

/* Statistics */
.stats { padding-top: 2px; }
.st-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; }
.st-kpi { background: var(--bg2); border-radius: 16px; padding: 10px 12px; }
.st-kpi b { display: block; font: 700 20px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.st-kpi span { font-size: 12.5px; color: var(--hint); }
.st-block { margin-top: 18px; }
.st-block h3 { margin: 0 4px 2px; font: 700 15px/1.3 var(--display); }
.st-note { margin: 0 4px 8px; font-size: 12.5px; color: var(--hint); }
.st-chart { width: 100%; height: auto; display: block; overflow: visible; }
.st-chart text { fill: var(--hint); font: 400 10.5px var(--body); font-variant-numeric: tabular-nums; }
.st-chart .grid { stroke: var(--bg2); stroke-width: 1; }
.st-chart .bar-new { fill: var(--bg2); }
.st-chart .bar-sent, .st-chart .bar-hour { fill: var(--link); }
.st-chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.st-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 4px 0; font-size: 13px; }
.st-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.st-row { display: flex; align-items: baseline; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--bg2); font-size: 14px; }
.st-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-row .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.st-row .sub { color: var(--hint); font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.up { color: var(--nope); }
.down { color: var(--like); }
.st-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 4px; font-size: 13px; }

/* Votes waiting for a connection */
.pending { display: block; width: 100%; margin: 6px 0 0; padding: 5px 10px; border-radius: 10px; background: var(--bg2); color: var(--hint); font-size: 13px; text-align: center; }
.toast.has-action { display: flex; align-items: center; gap: 14px; }
.toast-action { color: #8fc1ff; font-weight: 600; font-size: 14px; padding: 2px 0; }

/* The next step after the vote */
.stage-time { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 14px; }
.stage-time input { padding: 6px 8px; border-radius: 10px; border: 1px solid var(--bg2); background: var(--bg2); color: var(--text); font: inherit; }
.stage-hint { margin: 6px 0 0; color: var(--hint); font-size: 13px; }
.other-stage { margin-top: 2px; color: var(--hint); font-size: 13px; }
.pill.stage { color: var(--link); }

/* The history of the flat */
.history { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.past { display: flex; flex-direction: column; gap: 6px; }
.past-head { text-align: left; color: var(--link); font-size: 14px; padding: 0; }
.past-vote { font-size: 14px; }
