:root {
  --bg: #f6f5f2; --card: #fff; --ink: #1d1d1b; --muted: #6b6a66; --line: #e2e0da;
  --accent: #2f6f4f; --accent-ink: #fff; --warn: #b45309; --bad: #b42318; --new: #1d4ed8;
  --chip: #eeece6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --card: #201f1d; --ink: #ecebe7; --muted: #a09e98; --line: #34322f;
    --accent: #5fae86; --accent-ink: #0d1a13; --warn: #f0a24a; --bad: #f97066; --new: #7aa2ff; --chip: #2b2a27;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, select, input, textarea, .btnlike {
  font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px;
}
button, .btnlike { cursor: pointer; text-decoration: none; display: inline-block; }
button:not(.ghost):not(.icon), #saveSettings { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .6; cursor: default; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; margin: 0; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.logbox { margin: 8px 16px 0; background: var(--card); border: 1px solid var(--line); border-radius: 6px; max-height: 160px; overflow: auto; }
.logbox pre { margin: 0; padding: 8px 10px; font-size: 12px; white-space: pre-wrap; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 10px 16px; }
.toolbar label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.toolbar input[type=search] { min-width: 200px; flex: 1 1 200px; max-width: 320px; }
.seg { display: inline-flex; }
.seg button:not(.on) { background: var(--card); color: var(--ink); border-color: var(--line); }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.summary { padding: 0 16px; margin: 0 0 8px; }

main { padding: 0 16px 40px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
#map { height: calc(100vh - 170px); min-height: 400px; border-radius: 8px; border: 1px solid var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.card.hidden-l { opacity: .55; }
.card.flash { outline: 3px solid var(--accent); }
.photo { position: relative; aspect-ratio: 4 / 3; background: var(--chip); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo button.nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.45); color: #fff; border: 0; border-radius: 50%; width: 32px; height: 32px; padding: 0; }
.photo .prev { left: 6px; } .photo .next { right: 6px; }
.photo .count { position: absolute; bottom: 6px; right: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.photo .badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; background: var(--chip); color: var(--ink); }
.badge.new { background: var(--new); color: #fff; }
.badge.gone { background: var(--bad); color: #fff; }
.badge.drop { background: var(--accent); color: var(--accent-ink); }

.body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.price { display: flex; align-items: baseline; gap: 8px; }
.price strong { font-size: 20px; }
.price s { color: var(--muted); }
.price .dist { margin-left: auto; font-weight: 600; }
.specs { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--chip); border-radius: 4px; padding: 1px 7px; font-size: 13px; }
.chip.park0 { color: var(--bad); }
.chip.park1 { color: var(--warn); }
.chip.park2 { color: var(--accent); font-weight: 600; }
.addr { font-weight: 600; }
.meta { font-size: 13px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: auto; padding-top: 6px; }
.actions .icon { padding: 4px 8px; }
.actions .icon.on { color: #d97706; border-color: #d97706; }
.actions select { padding: 4px 6px; }
.links { display: flex; gap: 10px; flex-wrap: wrap; font-size: 14px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details.more .desc { white-space: pre-wrap; font-size: 14px; max-height: 320px; overflow: auto; margin: 6px 0; }
details.more table { font-size: 13px; border-collapse: collapse; }
details.more td { padding: 1px 8px 1px 0; vertical-align: top; }
details.more td:first-child { color: var(--muted); }
textarea.note { width: 100%; min-height: 54px; resize: vertical; font-size: 14px; }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); max-width: 520px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; }
fieldset label { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > label { flex: 1 1 100px; }
.row.end { justify-content: flex-end; }
.presets button { background: var(--card); color: var(--ink); border-color: var(--line); }

.leaflet-popup-content { font: 14px/1.4 system-ui, sans-serif; }
.leaflet-popup-content img { width: 220px; height: 150px; object-fit: cover; border-radius: 4px; display: block; margin-bottom: 4px; }

.loginpage { display: grid; place-items: center; min-height: 100vh; }
.login { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 24px; display: flex; flex-direction: column; gap: 12px; width: min(320px, calc(100% - 32px)); }
.login h1 { margin: 0; font-size: 20px; }
.login label { display: flex; flex-direction: column; gap: 4px; }
.bad { color: var(--bad); margin: 0; }

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .top-actions { margin-left: 0; }
  .toolbar input[type=search] { max-width: none; }
}
