/* Рыбы говорят! — стили приложения. */

:root {
	--ink: #1d2b30;
	--muted: #5b6a6d;
	--paper: #f7f3ea;
	--surface: #fffdf8;
	--line: #e4dccb;
	--sand: #e9dcc0;
	--deep: #0f3b4c;
	--water: #1f6f78;
	--accent: #e4572e;
	--danger: #b3372a;
	--radius: 16px;
	--shadow: 0 1px 2px rgb(15 59 76 / .08), 0 8px 24px rgb(15 59 76 / .14);
	--serif: "Alegreya", "PT Serif", Georgia, "Times New Roman", serif;
	--sans: "Alegreya Sans", "PT Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
	--bar: 58px;
	color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
/* Обычные цифры вместо «старых» у Alegreya; !important — сокращение font: сбрасывает свойство. */
*, *::before, *::after { font-variant-numeric: lining-nums !important; }
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; height: 100dvh; background: var(--paper); color: var(--ink); font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
h1, h2, h3 { font-family: var(--serif); font-weight: 800; color: var(--deep); line-height: 1.1; margin: 0 0 .4em; }
h2 { font-size: 1.5rem; }
p { margin: 0 0 .8em; }
a { color: var(--water); }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg { flex: none; }

/* ---------- Шапка ---------- */
.bar {
	flex: none; display: flex; align-items: center; gap: 8px; min-height: var(--bar);
	padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; background: var(--deep); color: #fff; z-index: 30;
}
.bar__brand { display: flex; align-items: center; gap: 8px; min-width: 0; margin-right: auto; color: #fff; text-decoration: none; font: 800 1.25rem var(--serif); white-space: nowrap; }
.bar__brand img { flex: none; }
.bar__brand span { overflow: hidden; text-overflow: ellipsis; }
.region-chip {
	display: inline-flex; align-items: center; gap: 4px; max-width: 46vw; min-height: 38px; padding: 6px 12px 6px 8px;
	border: 1px solid rgb(255 255 255 / .3); border-radius: 999px; background: rgb(255 255 255 / .1); color: #fff; font-weight: 600; font-size: .85rem; cursor: pointer;
}
.region-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.region-chip svg, .icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgb(255 255 255 / .3); border-radius: 50%; background: rgb(255 255 255 / .1); color: #fff; cursor: pointer; }
.site-link { display: none; color: var(--sand); font-size: .85rem; text-decoration: none; }
@media (min-width: 900px) { .site-link { display: inline; margin-left: 6px; } }
@media (max-width: 380px) { .bar__brand span { display: none; } }

/* ---------- Раскладка ---------- */
.layout { position: relative; flex: 1; display: flex; min-height: 0; }
.map-wrap { position: relative; z-index: 0; flex: 1; min-width: 0; } /* свой слой: окна карты не перекрывают поиск */
.map { position: absolute; inset: 0; z-index: 0; isolation: isolate; background: #dfe9e6; } /* слои Leaflet остаются внутри карты */

/* На телефоне: поиск и фильтры поверх карты, список — шторкой */
.side { position: absolute; left: 0; right: 0; top: 0; z-index: 20; padding: 10px 10px 0; pointer-events: none; }
.side > * { pointer-events: auto; }
.stats, .list { display: none; }
@media (min-width: 900px) {
	.side { position: static; flex: none; width: 380px; display: flex; flex-direction: column; padding: 14px; overflow-y: auto; background: var(--paper); border-right: 1px solid var(--line); pointer-events: auto; }
	.stats, .list { display: block; }
	.btn--list { display: none; }
}

.search { position: relative; display: flex; align-items: center; height: 46px; padding: 0 8px 0 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--water); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; height: 100%; padding: 0 8px; border: 0; background: none; outline: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search__clear { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--paper); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.results { margin-top: 6px; max-height: 55vh; overflow-y: auto; padding: 6px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.results .muted { margin: 8px; }
.results__head { margin: 8px 8px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hit { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer; }
.hit:hover, .hit:focus-visible { background: var(--paper); }
.hit strong { display: block; color: var(--deep); }
.hit small { display: block; color: var(--muted); font-size: .8rem; }
.hit__pin { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--sand); color: var(--deep); font-size: .9rem; }

.filters { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .filters { flex-wrap: wrap; overflow: visible; } }
.fchip {
	flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 5px 12px 5px 9px;
	border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: .82rem; font-weight: 600; cursor: pointer; box-shadow: 0 1px 3px rgb(15 59 76 / .12);
}
.fchip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); opacity: .4; }
.fchip.is-on { color: var(--deep); border-color: var(--c); }
.fchip.is-on::before { opacity: 1; }

.stats { margin: 10px 0 6px; padding: 12px 14px; border-radius: 14px; background: var(--deep); color: #e6f1ef; }
.stats strong { display: block; font: 800 1.05rem var(--serif); color: #fff; }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 12px; background: var(--surface); text-align: left; cursor: pointer; box-shadow: 0 1px 3px rgb(15 59 76 / .08); }
.item:hover { background: #fff; }
.item__dot { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; }
.item__main strong { display: block; color: var(--deep); }
.item__main span { font-size: .8rem; color: var(--muted); }

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 18px; border: 2px solid transparent; border-radius: 14px; background: var(--surface); color: var(--deep); font-weight: 700; text-decoration: none; cursor: pointer; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--ghost { border-color: var(--line); }
.btn--danger { background: #fbe4df; color: var(--danger); }
.btn--block { display: flex; width: 100%; margin-bottom: 10px; }
.link { border: 0; background: none; color: var(--water); font-weight: 600; text-decoration: underline; cursor: pointer; }

.actions { position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 15; display: flex; justify-content: center; gap: 8px; padding: 0 12px; pointer-events: none; }
.actions .btn { pointer-events: auto; box-shadow: var(--shadow); }
.btn--add { box-shadow: 0 8px 24px rgb(228 87 46 / .4) !important; }
@media (min-width: 900px) { .actions { justify-content: flex-end; padding-right: 20px; } }

/* ---------- Постановка метки ---------- */
.crosshair { position: absolute; left: 50%; top: 50%; z-index: 16; width: 36px; height: 46px; transform: translate(-50%, -100%); pointer-events: none; filter: drop-shadow(0 4px 4px rgb(0 0 0 / .3)); }
.crosshair svg { width: 36px; height: 46px; }
.crosshair::after { content: ""; position: absolute; left: 50%; bottom: -4px; width: 8px; height: 3px; transform: translateX(-50%); border-radius: 50%; background: rgb(0 0 0 / .35); }
.pick-bar { position: absolute; left: 10px; right: 10px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 17; max-width: 520px; margin: 0 auto; padding: 12px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.pick-bar p { margin: 0 0 10px; font-weight: 600; color: var(--deep); text-align: center; }
.pick-bar__btns { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; }
.is-picking .side { display: none; }

/* ---------- Метки и всплывающие карточки ---------- */
.pin { background: none; border: 0; }
.pin svg { display: block; filter: drop-shadow(0 3px 4px rgb(0 0 0 / .3)); transition: transform .15s; transform-origin: 50% 100%; }
.pin:hover svg { transform: scale(1.12); }
.pin--resolved svg { opacity: .85; }
.leaflet-popup-content-wrapper { padding: 0; border-radius: 14px; overflow: hidden; }
.leaflet-popup-content { margin: 0; width: auto !important; font: 14px/1.45 var(--sans); }
.pop__img { display: block; width: 100%; height: 130px; object-fit: cover; }
.pop__body { padding: 12px 14px; }
.pop__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tag { padding: 2px 9px; border-radius: 999px; color: #fff; font-size: .72rem; font-weight: 700; }
.status { padding: 2px 9px; border-radius: 999px; background: #f1ece0; color: var(--deep); font-size: .72rem; font-weight: 600; }
.status--confirmed { background: #fdf1ec; color: #a8401f; }
.status--resolved { background: #e3f2e7; color: #2d6b42; }
.pop__title { margin: 0 0 4px; font: 800 1.05rem/1.25 var(--serif); color: var(--deep); }
.pop__text { margin: 0 0 8px !important; color: var(--muted); font-size: .85rem; }
.pop__foot { display: flex; justify-content: space-between; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.pop__foot a { flex: none; font-weight: 700; text-decoration: none; }
.leaflet-bar, .leaflet-control-layers { border-radius: 10px !important; overflow: hidden; }
.leaflet-top { top: 112px; }
@media (min-width: 900px) { .leaflet-top { top: 0; } }

/* ---------- Шторка ---------- */
.sheet { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; justify-content: center; }
.sheet__backdrop { position: absolute; inset: 0; background: rgb(15 30 36 / .5); }
.sheet__panel { position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 8px 18px calc(18px + env(safe-area-inset-bottom, 0px)); border-radius: 22px 22px 0 0; background: var(--paper); animation: up .2s ease-out; }
@media (min-width: 900px) { .sheet { align-items: center; } .sheet__panel { border-radius: 22px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet__grip { width: 44px; height: 5px; margin: 4px auto 12px; border-radius: 3px; background: var(--line); }
.sheet__nav { display: flex; gap: 10px; margin-top: 6px; }
.sheet__nav .btn { flex: 1; }
.regions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.region { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; cursor: pointer; }
.region small { color: var(--muted); }
.region.is-on { border-color: var(--deep); background: var(--deep); color: #fff; }
.region.is-on small { color: var(--sand); }

/* ---------- Формы ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--deep); }
.field input, .field textarea { width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.field input[type="file"] { min-height: 0; padding: 8px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--water); box-shadow: 0 0 0 3px rgb(31 111 120 / .15); }
.form__error { margin: 0; padding: 10px 12px; border-radius: 12px; background: #fbe4df; color: #9c2b14; font-size: .9rem; }
.hp { position: absolute; left: -9999px; }
.types { display: flex; flex-wrap: wrap; gap: 6px; }
.type input { position: absolute; opacity: 0; }
.type span { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: .86rem; cursor: pointer; }
.type span::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.type input:checked + span { border-color: var(--c); background: var(--c); color: #fff; }
.type input:checked + span::before { background: #fff; }
.type input:focus-visible + span { outline: 3px solid var(--accent); }

.toast { position: fixed; left: 50%; top: calc(var(--bar) + 106px + env(safe-area-inset-top, 0px)); z-index: 1100; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; background: var(--deep); color: #fff; font-weight: 600; text-align: center; box-shadow: var(--shadow); }
@media (min-width: 900px) { .toast { top: calc(var(--bar) + 16px); } }
