:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f0f3f5;
  --text: #16202a;
  --muted: #5d6b78;
  --line: #dde3e8;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f1;
  --dead: #c62828;
  --dead-soft: #fdecea;
  --warn: #8a5a00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 4px 14px rgba(16, 32, 48, .06);
  --seg-track: rgba(118, 118, 128, .14);
  --seg-thumb: #ffffff;
  --seg-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04);
  color-scheme: light dark;
}
@font-face {
  font-family: "Rubik";
  src: url("fonts/rubik-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1418;
    --surface: #161e24;
    --surface-2: #1d2830;
    --text: #e6edf2;
    --muted: #93a3b0;
    --line: #2a3640;
    --accent: #2dd4bf;
    --accent-ink: #062521;
    --accent-soft: #123530;
    --dead: #ff6b6b;
    --dead-soft: #3a1b1d;
    --warn: #f1b44c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .35);
    --seg-track: rgba(118, 118, 128, .24);
    --seg-thumb: #3a4750;
    --seg-shadow: 0 3px 8px rgba(0, 0, 0, .35), 0 3px 1px rgba(0, 0, 0, .1);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- header / footer ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1560px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); text-decoration: none; font-family: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 700; font-size: 1.4rem; letter-spacing: -.015em; }
.brand-name { color: var(--text); }
.foot { margin-top: 48px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .9rem; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.foot-inner { max-width: 1560px; margin: 0 auto; padding: 32px 16px 26px; display: grid; grid-template-columns: minmax(240px, 1.6fr) repeat(2, minmax(160px, 1fr)); gap: 28px 40px; }
.foot-logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text) !important; text-decoration: none !important; font-family: "Rubik", system-ui, sans-serif; font-weight: 700; font-size: 1.15rem; letter-spacing: -.015em; }
.foot-brand p { margin: 10px 0 0; max-width: 38ch; line-height: 1.45; }
.foot-col { display: flex; flex-direction: column; gap: 9px; }
.foot-title { margin: 0 0 3px; color: var(--text); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.foot-bottom { border-top: 1px solid var(--line); }
.foot-bottom p { max-width: 1560px; margin: 0 auto; padding: 14px 16px 22px; font-size: .8rem; }
@media (max-width: 640px) {
  .foot-inner { grid-template-columns: 1fr 1fr; gap: 24px 20px; padding-top: 26px; }
  .foot-brand { grid-column: 1 / -1; }
}

/* ---------- buy / rent tabs and search in the header ---------- */
.mode-tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; min-height: 42px; border-radius: 10px; background: var(--seg-track); isolation: isolate; }
.mode-thumb { position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 7px; background: var(--seg-thumb); box-shadow: var(--seg-shadow); opacity: 0; transition: transform .34s cubic-bezier(.3, .8, .25, 1), opacity .2s; }
.mode-tabs[data-active] .mode-thumb { opacity: 1; }
.mode-tabs[data-active="rent"] .mode-thumb { transform: translateX(100%); }
.mode-tab { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; min-width: 118px; text-align: center; padding: 6px 18px; border-radius: 7px; font-weight: 600; text-decoration: none; color: var(--muted); transition: color .25s; -webkit-tap-highlight-color: transparent; user-select: none; }
.mode-tab:hover { color: var(--text); }
.mode-tab.is-active { color: var(--text); font-weight: 700; }
.mode-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mode-tabs:active .mode-thumb { transform: scale(.97); }
.mode-tabs[data-active="rent"]:active .mode-thumb { transform: translateX(100%) scale(.97); }
@media (prefers-reduced-motion: reduce) { .mode-thumb, .mode-tab { transition: none; } }
.head-search { display: flex; align-items: center; gap: 8px; flex: 1 1 380px; min-width: 0; }
.head-search input[type="search"] { flex: 1 1 160px; min-width: 0; }
.head-search .btn { white-space: nowrap; }

/* ---------- advanced search panel ---------- */
.advanced { background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.advanced-inner { max-width: 1560px; margin: 0 auto; padding: 16px; }
.advanced-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.advanced-head h2 { margin: 0; font-size: 1.1rem; }
.advanced-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 24px; align-items: start; }
.advanced-grid .field { margin: 0; }
.features-field { grid-column: 1 / -1; border: 0; padding: 0; min-width: 0; }
.features-field legend { padding: 0; margin-bottom: 8px; font-weight: 600; font-size: .9rem; }
.feat-list { display: flex; flex-wrap: wrap; gap: 8px; }
.feat { position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.feat input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.feat span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: .88rem; font-weight: 600; transition: background .15s, border-color .15s, color .15s; }
.feat span::before { content: "+"; font-weight: 700; color: var(--muted); }
.feat:hover span { border-color: var(--accent); }
.feat input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.feat input:checked + span::before { content: "✓"; color: var(--accent-ink); }
.feat input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { margin: 6px 0 0; font-size: .8rem; color: var(--muted); }
.advanced .actions { margin-top: 16px; justify-content: flex-start; }
.advanced .actions .btn-primary { flex: 0 0 auto; min-width: 160px; }

/* ---------- layout ---------- */
.layout {
  max-width: 1560px; margin: 0 auto; padding: 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start;
}
.side { position: sticky; top: 12px; display: grid; gap: 16px; }
.layout--wide { grid-template-columns: minmax(0, 1fr); }
.main { min-width: 0; }

@media (max-width: 1279px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
}
@media (max-width: 899px) {
  .layout { padding: 12px; }
}
@media (max-width: 760px) {
  .mode-tabs { flex: 1 1 100%; }
  .mode-tab { flex: 1; min-width: 0; }
  .head-search { flex-wrap: wrap; flex-basis: 100%; }
  .head-search input[type="search"] { flex-basis: 100%; }
  .head-search .btn { flex: 1; }
  .advanced-grid { grid-template-columns: 1fr; }
}

/* ---------- form ---------- */
.field { margin-bottom: 14px; }
.field > label:not(.check), .field > .label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
input[type="search"], input[type="number"], select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; min-height: 42px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#results:focus, #results:focus-visible { outline: none; }
input[aria-invalid="true"] { border-color: var(--dead); }
.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-top: 8px; }
.range input { min-width: 0; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick-btn { font: inherit; font-size: .8rem; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; }
.quick-btn:hover { border-color: var(--accent); }
.quick-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.field-error { margin: 6px 0 0; color: var(--dead); font-size: .85rem; min-height: 0; }
.field-error:empty { display: none; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: .9rem; cursor: pointer; }
.actions { display: flex; gap: 8px; margin-top: 4px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 16px; min-height: 42px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.actions .btn-primary { flex: 1; }
.icon-btn { background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: 6px 10px; }

/* ---------- results bar ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.bar-right { display: flex; gap: 10px; align-items: center; margin-left: auto; min-width: 0; }
.sort { width: auto; min-width: 210px; }
.view { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.view button { font: inherit; background: var(--surface); color: var(--muted); border: 0; padding: 8px 12px; cursor: pointer; min-height: 42px; }
.view button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.summary { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 14px; }
.summary-title { flex: 1 1 100%; margin: 0; font-size: 1.25rem; line-height: 1.25; letter-spacing: -.01em; }
.summary p { margin: 0; }
.active { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.active a { display: inline-flex; gap: 6px; align-items: center; text-decoration: none; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 10px; font-size: .85rem; font-weight: 600; }
.notice { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.notice-error { background: var(--dead-soft); color: var(--dead); }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 36px 20px; text-align: center; }
.empty h2 { margin: 0 0 6px; }

/* ---------- grid + cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(260px, calc((100% - 32px) / 3)), 1fr)); gap: 16px; }
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s; }
.card-link { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.card:has(.card-link:active) { transform: scale(.985); transition-duration: .08s; }
.chip, .pick { -webkit-tap-highlight-color: transparent; }
.chip:active, .pick:active { filter: brightness(.94); }
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card-link:focus-visible { outline: none; }
.card:has(.card-link:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) {
  .card:hover { box-shadow: 0 2px 4px rgba(16, 32, 48, .08), 0 12px 28px rgba(16, 32, 48, .14); transform: translateY(-2px); }
  .card:hover .card-link { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
  .card:hover .open-cue { text-decoration: underline; }
}
.sources .chip { position: relative; z-index: 2; }
.sources-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.sources-head .sources-label { margin-bottom: 0; }
.open-cue { font-size: .8rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.card.is-sold { opacity: .72; }
.media { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; background: var(--surface-2); }
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: linear-gradient(160deg, var(--surface-2), var(--bg)); color: var(--muted); }
.noimg .roof { fill: none; stroke: currentColor; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.noimg .roof-1 { opacity: .55; stroke-width: 5; }
.noimg .roof-2 { opacity: .35; }
.noimg .roof-3 { opacity: .2; }
.noimg .door { fill: currentColor; opacity: .4; }
.noimg-text { font-size: .78rem; font-weight: 600; letter-spacing: .02em; opacity: .85; }
.badge { position: absolute; left: 10px; top: 10px; background: rgba(16, 32, 48, .78); color: #fff; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge-sold { left: auto; right: 10px; background: var(--dead); }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.price-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ppm2 { font-size: 1.25rem; color: var(--accent); letter-spacing: -.01em; }
.total { color: var(--muted); font-size: .95rem; }
.title { margin: 0; font-size: 1rem; line-height: 1.3; font-weight: 600; }
.deal { margin: -2px 0 0; font-size: .82rem; font-weight: 700; color: var(--accent); }
.deal::before { content: "▼ "; font-size: .7rem; }
.facts { list-style: none; padding: 0; margin: 2px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }
.facts li { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: .84rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.facts .ico { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; list-style: none; margin: 8px 0 0; padding: 0; }
.tags li { font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.where { margin: 0; color: var(--muted); font-size: .88rem; }
.sources { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.sources-label { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.sources ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 600; text-decoration: none; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.chip:hover { border-color: var(--accent); }
.chip--dead { color: var(--dead); border-color: var(--dead); background: var(--dead-soft); }
.chip--dead:hover { border-color: var(--dead); filter: brightness(.97); }
.chip--dead .chip-note { font-weight: 500; text-decoration: none; }
.chip--unreachable { color: var(--muted); border-style: dashed; }
.chip--suspect { border-color: var(--warn); }
.chip-adv { font-weight: 500; color: var(--muted); font-size: .76rem; }
.chip-note { font-size: .72rem; font-weight: 500; opacity: .9; }
.alert-dead { margin: 4px 0 0; font-size: .85rem; font-weight: 600; color: var(--dead); background: var(--dead-soft); border-radius: 8px; padding: 6px 10px; }
.more { display: flex; justify-content: center; margin: 24px 0 8px; }

.grid.is-list { grid-template-columns: 1fr; }
.grid.is-list .card { flex-direction: row; }
.grid.is-list .media { width: 280px; flex: none; aspect-ratio: 4 / 3; }
@media (max-width: 640px) {
  .view { display: none; }
  .bar > .btn { flex: none; }
  .grid.is-list .card { flex-direction: column; }
  .grid.is-list .media { width: 100%; }
  .sort { min-width: 0; flex: 1; }
  .bar-right { flex: 1; }
}

/* ---------- ads ---------- */
.hl { display: grid; gap: 6px; }
.hl-tag { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hl-link { display: block; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.hl-link img { display: block; width: 100%; height: auto; }
.hl--rail .hl-link { width: 300px; aspect-ratio: 1 / 2; }
.card--hl { border-style: dashed; }
.hl-card { display: flex; flex-direction: column; flex: 1; color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.hl-card .card-body { gap: 4px; }
.hl-cta { margin-top: auto; padding-top: 8px; font-size: .85rem; font-weight: 700; color: var(--accent); }
@media (hover: hover) { .hl-card:hover .title { text-decoration: underline; text-underline-offset: 3px; } }
.grid.is-list .card--hl .hl-card { flex-direction: row; }
.grid.is-list .card--hl .media { width: 280px; flex: none; }

/* ---------- text pages ---------- */
.page { max-width: 760px; margin: 28px auto; padding: 0 16px; }
.page h1 { font-size: 1.8rem; letter-spacing: -.01em; }
.page h2 { margin-top: 28px; }
.page p, .page li { color: var(--text); }
.page .lead { color: var(--muted); font-size: 1.05rem; }

/* ---------- source picker ---------- */
.picker { border: 0; padding: 0 0 6px; width: min(440px, calc(100% - 32px)); max-height: 85vh; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .3); }
.picker::backdrop { background: rgba(8, 16, 20, .5); }
.picker[open] { animation: picker-in .22s ease-out; }
@keyframes picker-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.sheet-grip { display: none; }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; }
.picker-head h2 { margin: 0; font-size: 1.05rem; }
.picker:focus { outline: none; }
.picker-list { list-style: none; margin: 0; padding: 0 12px 10px; display: grid; gap: 8px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-decoration: none; }
.pick:hover, .pick:focus-visible { border-color: var(--accent); outline: none; }
.pick:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.pick-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pick-main strong { font-size: .95rem; }
.pick-adv { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-meta { font-size: .82rem; color: var(--muted); text-align: right; white-space: nowrap; }
.pick-go { color: var(--accent); font-weight: 700; font-size: 1.05rem; }
.pick--dead { border-color: var(--dead); background: var(--dead-soft); }
.pick--dead strong, .pick--dead .pick-meta { color: var(--dead); }
.pick--unreachable { border-style: dashed; }
@media (max-width: 640px) {
  .picker { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .picker[open] { animation: sheet-up .3s cubic-bezier(.3, .8, .25, 1); }
  .sheet-grip { display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
  .pick-meta { white-space: normal; max-width: 45%; }
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) {
  .picker[open] { animation: none; }
  .card { transition: none; }
  .card:hover, .card:has(.card-link:active) { transform: none; }
  .card:has(.card-link:active) { filter: brightness(.97); }
}

/* ---------- loading state ---------- */
.loadbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 200; overflow: hidden; pointer-events: none; }
.loadbar::before { content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: var(--accent); animation: loadbar 1s ease-in-out infinite; }
@keyframes loadbar { to { left: 100%; } }
#results > * { transition: opacity .15s; }
#results[aria-busy="true"] { pointer-events: none; }
#results[aria-busy="true"] > * { opacity: .45; }
#results[aria-busy="true"]::before { content: "Се вчитува…"; position: sticky; top: 12px; z-index: 5; display: block; width: max-content; margin: 0 auto 12px; padding: 6px 14px; border-radius: 999px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: .85rem; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .loadbar::before { animation: none; left: 0; width: 100%; opacity: .6; } }
