:root {
    --bg: #fbf8f4;
    --card: #ffffff;
    --ink: #23201c;
    --muted: #7a736a;
    --line: #e8e2d9;
    --accent: #2f6b4f;
    --accent-soft: #e6f0ea;
    --home: #2f6b4f;
    --lost: #c2410c;
    --found: #1d6fa5;
    --help: #b91c1c;
    --ask: #6d5bd0;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(35, 32, 28, .06), 0 8px 24px rgba(35, 32, 28, .05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16150f;
        --card: #211f1a;
        --ink: #f0ece4;
        --muted: #a49c90;
        --line: #322f28;
        --accent: #79c39b;
        --accent-soft: #223229;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------------------------------------------------------------- шапка */

.top {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.top-inner { display: flex; align-items: center; gap: 20px; height: 62px; }

.logo { display: flex; align-items: center; gap: 9px; font-weight: 700; text-decoration: none; font-size: 18px; }
.logo span.paw { font-size: 22px; }

.nav { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.nav a { text-decoration: none; color: var(--muted); font-size: 15px; white-space: nowrap; }
.nav a:hover, .nav a.on { color: var(--ink); }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--accent); color: #fff; text-decoration: none;
    padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 15px;
    border: 0; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }

@media (max-width: 720px) {
    .nav a.hide-sm { display: none; }
    .top-inner { gap: 12px; }
}

/* ---------------------------------------------------------------- герой */

.hero { padding: 34px 0 22px; }
.hero h1 { margin: 0 0 10px; font-size: clamp(26px, 4vw, 40px); line-height: 1.15; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); max-width: 62ch; font-size: 17px; }
.hero .stats { display: flex; gap: 22px; margin-top: 18px; flex-wrap: wrap; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- фильтры */

.filters { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 24px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip {
    flex: 0 0 auto; text-decoration: none; font-size: 14px;
    padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
    background: var(--card); color: var(--muted); white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip b { font-weight: 600; }

.search { display: flex; gap: 8px; }
.search input {
    flex: 1; padding: 11px 14px; border-radius: 999px; font-size: 15px;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------------------------------------------------------------- карточки */

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }

.card {
    display: flex; flex-direction: column; overflow: hidden; text-decoration: none;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(35,32,28,.08), 0 14px 34px rgba(35,32,28,.09); }

.thumb { position: relative; aspect-ratio: 4 / 3; background: var(--accent-soft); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .empty { display: grid; place-items: center; height: 100%; font-size: 44px; opacity: .5; }

.badge {
    position: absolute; left: 10px; top: 10px;
    background: rgba(255,255,255,.94); color: var(--home);
    padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.badge.lost { color: var(--lost); }
.badge.found { color: var(--found); }
.badge.help { color: var(--help); }
.badge.ask { color: var(--ask); }
.badge.done { background: var(--home); color: #fff; }

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-city { font-weight: 600; font-size: 15px; }
.card-text { color: var(--muted); font-size: 14px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin-top: auto; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- карточка объявления */

.detail { display: grid; grid-template-columns: 1.25fr .85fr; gap: 28px; padding: 24px 0 40px; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; gap: 20px; } }

.gallery { display: grid; gap: 10px; }
.gallery img { width: 100%; border-radius: var(--radius); display: block; }
.gallery .more { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.gallery .more img { aspect-ratio: 1; object-fit: cover; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.01em; }
.panel .where { color: var(--muted); margin-bottom: 14px; font-size: 15px; }
.panel .text { white-space: pre-wrap; margin: 0 0 18px; }
.panel .actions { display: flex; flex-direction: column; gap: 9px; }

.mini-map { height: 240px; border-radius: var(--radius); margin-top: 14px; border: 1px solid var(--line); }

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

#map { height: calc(100vh - 210px); min-height: 420px; border-radius: var(--radius); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 12px 14px; font: 14px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif; }
.pin { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.pin span { transform: rotate(45deg); font-size: 15px; }

/* ---------------------------------------------------------------- прочее */

.pager { display: flex; gap: 8px; justify-content: center; margin: 28px 0; flex-wrap: wrap; }
.pager a, .pager span { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; background: var(--card); font-size: 14px; }
.pager .cur { background: var(--accent); border-color: var(--accent); color: #fff; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .big { font-size: 46px; margin-bottom: 10px; }

.section-title { display: flex; align-items: baseline; gap: 12px; margin: 34px 0 14px; }
.section-title h2 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.section-title a { margin-left: auto; color: var(--accent); text-decoration: none; font-size: 15px; }

.list { display: grid; gap: 10px; }
.row { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.row b { display: block; }
.row small { color: var(--muted); }

.foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 22px 0 34px; color: var(--muted); font-size: 14px; }
.foot a { color: var(--muted); }
.foot .cols { display: flex; gap: 26px; flex-wrap: wrap; }

.shelter-tag {
    display: inline-block; font-size: 12.5px; font-weight: 600;
    color: var(--accent); background: var(--accent-soft);
    padding: 3px 9px; border-radius: 999px;
}
.row p { margin: 8px 0 0; color: var(--muted); font-size: 14.5px; }
.row .btn { margin-top: 10px; }
