:root {
  --surface: #fffdf9;
  --soft: #f4efe7;
  --line: #e7dfd3;
  --ink: #22201c;
  --muted: #6f675c;
  --accent: #b4532a;
  --accent-ink: #fff;
  --accent-soft: #f8e9e1;
  --ok: #2f7d4f;
  --ok-soft: #e3f1e8;
  --danger: #b42318;
  --wa: #1f8f4e;
  --shadow-float: 0 1px 2px rgb(34 32 28 / 6%), 0 4px 14px rgb(34 32 28 / 8%);
  --shadow-sheet: 0 -8px 30px rgb(34 32 28 / 12%);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --gutter: 16px;
  --field: #fff;
  --glass: rgb(255 253 249 / 90%);
  --tiles: none;
  color-scheme: light;
}
/* Dark: same roles, warm charcoal surfaces. Accent is lightened and takes dark text to keep contrast.
   data-theme is set before first paint by the inline script in index.html (saved choice, else system). */
:root[data-theme="dark"] {
  --surface: #1c1a17;
  --soft: #2a2723;
  --line: #3a362f;
  --ink: #f1ece4;
  --muted: #a89f92;
  --accent: #e07a4f;
  --accent-ink: #1c1a17;
  --accent-soft: #3d2a20;
  --ok: #63b884;
  --ok-soft: #1f3327;
  --danger: #f0766b;
  --wa: #25a25a;
  --field: #24211d;
  --glass: rgb(28 26 23 / 88%);
  --shadow-float: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 30%);
  --shadow-sheet: 0 -8px 30px rgb(0 0 0 / 45%);
  /* ponytail: inverted OSM tiles instead of a separate dark tile provider; swap for a styled dark basemap at scale. */
  --tiles: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--surface); color: var(--ink); }
body { font: 15px/1.5 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { flex: none; }
#map { position: fixed; inset: 0; z-index: 0; background: var(--soft); }

/* ---------- floating chrome ---------- */
header, #chips { position: fixed; left: 0; right: 0; z-index: 10; display: flex; gap: 8px; padding: 0 var(--gutter); }
header { top: max(12px, env(safe-area-inset-top)); z-index: 11; }
#chips { top: calc(max(12px, env(safe-area-inset-top)) + 54px); overflow-x: auto; scrollbar-width: none; }
#chips::-webkit-scrollbar { display: none; }

#brand { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 23px; color: var(--accent); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-float); }
#search { flex: 1; min-width: 0; position: relative; }
#q, #account { height: 46px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-float); }
#q { width: 100%; padding: 0 18px; border-radius: 23px; font-size: 16px; }
#q::placeholder { color: var(--muted); }
#city { flex: none; height: 36px; padding: 0 10px; border: 1px solid var(--ink); border-radius: 18px; background: var(--surface); font-weight: 700; font-size: 14px; box-shadow: var(--shadow-float); }
#account { padding: 0 16px; border-radius: 23px; font-weight: 600; white-space: nowrap; }

#results { position: absolute; top: 54px; left: 0; right: 0; margin: 0; padding: 6px 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-float); }
#results li { padding: 10px 18px; cursor: pointer; font-weight: 600; }
#results li:hover { background: var(--soft); }
#results li + li { border-top: 1px solid var(--line); }
#results small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }

#chips button { flex: none; height: 36px; padding: 0 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-float); transition: background-color 120ms, color 120ms; }
#chips button.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }

#add, #locate, #theme { position: fixed; z-index: 10; right: var(--gutter); border: 0; box-shadow: var(--shadow-float); }
#add { bottom: max(20px, env(safe-area-inset-bottom)); height: 52px; padding: 0 24px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
#add:active { transform: scale(0.97); }
#theme { bottom: calc(max(20px, env(safe-area-inset-bottom)) + 120px); }
#locate { bottom: calc(max(20px, env(safe-area-inset-bottom)) + 64px); }
#locate, #theme { display: grid; place-items: center; color: var(--ink); width: 46px; height: 46px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); }
#hint { position: fixed; z-index: 10; left: var(--gutter); right: 150px; bottom: max(20px, env(safe-area-inset-bottom)); margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: 13px; box-shadow: var(--shadow-float); }

/* ---------- map pins ---------- */
.pin { position: absolute; transform: translate(-50%, -100%); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; box-shadow: 0 1px 2px rgb(34 32 28 / 15%), 0 2px 8px rgb(34 32 28 / 12%); }
.pin.price { padding: 5px 10px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--accent); color: var(--ink); font: 700 13px/1 'Plus Jakarta Sans', system-ui, sans-serif; }
.pin.price::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 8px; height: 8px; background: inherit; border: inherit; border-top: 0; border-left: 0; transform: translateX(-50%) rotate(45deg); }
.pin.price.verified { border-color: var(--ok); }
.pin.price.verified svg { width: 13px; height: 13px; color: var(--ok); stroke-width: 3; }
.pin.dot { transform: translate(-50%, -50%); width: 30px; height: 30px; justify-content: center; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--muted); color: var(--muted); }
.pin.dot svg { width: 15px; height: 15px; }
.leaflet-marker-icon:hover .pin, .leaflet-marker-icon:focus .pin { z-index: 1; background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ---------- sheets ---------- */
dialog { width: min(560px, 100%); max-width: 100%; max-height: 90vh; margin: auto auto 0; padding: 0; border: 0; border-radius: 20px 20px 0 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sheet); overscroll-behavior: contain; }
dialog[open] { animation: sheet-in 280ms var(--ease-out); }
dialog::backdrop { background: rgb(34 32 28 / 40%); animation: fade-in 200ms ease-out; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@media (min-width: 700px) {
  dialog { margin: auto; border-radius: 20px; }
  .body::before { display: none; }
}
@media (min-width: 900px) {
  #details { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 420px; height: 100vh; max-height: none; margin: 0; border-radius: 0; border-right: 1px solid var(--line); box-shadow: 8px 0 30px rgb(34 32 28 / 10%); overflow-y: auto; }
  #details[open] { animation: panel-in 280ms var(--ease-out); }
  #details .body { min-height: 100%; display: flex; flex-direction: column; padding-top: 20px; }
  #details .contact { margin-top: auto; }
  #details .badge { align-self: flex-start; }
  body.panel-open header, body.panel-open #chips { left: 420px; }
}
@keyframes panel-in { from { transform: translateX(-24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  dialog[open], dialog::backdrop { animation: none !important; }
}
.body { position: relative; padding: 24px var(--gutter) 20px; }
.body::before { content: ''; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line); }
h2 { margin: 0 0 4px; font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h3 { margin: 24px 0 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.msg { min-height: 1.5em; color: var(--danger); font-size: 14px; }
.msg.info { color: var(--muted); }
.close { position: absolute; top: 12px; right: 12px; z-index: 1; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--glass); box-shadow: var(--shadow-float); }

.photos { display: flex; gap: 8px; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)) 16px; padding: 0 var(--gutter); scroll-snap-type: x mandatory; scrollbar-width: none; }
.photos img { display: block; height: 210px; max-width: 80vw; border-radius: 12px; object-fit: cover; scroll-snap-align: center; background: var(--soft); }
.eyebrow { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; color: var(--accent); font-size: 13px; font-weight: 700; }
.eyebrow svg { width: 15px; height: 15px; }
.badge { display: inline-flex; align-items: center; gap: 4px; margin: 4px 0 14px; padding: 3px 10px; border-radius: 6px; background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge svg { width: 14px; height: 14px; stroke-width: 3; }
.facts { display: grid; grid-template-columns: 3fr 2fr; gap: 1px; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--line); }
.facts div { padding: 10px 14px; background: var(--surface); }
.facts small { display: block; color: var(--muted); font-size: 12px; }
.facts b { font-size: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { padding: 4px 10px; border-radius: 14px; background: var(--soft); font-size: 13px; font-weight: 600; }
.desc { white-space: pre-line; }
.nearby { list-style: none; margin: 0; padding: 0; }
.nearby li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.nearby li b { flex: 1; font-weight: 600; }
.nearby .ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--soft); color: var(--muted); }

/* reports */
.link { align-self: flex-start; margin: 16px 0 0; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.reported { margin: 16px 0 0; font-size: 14px; }
.reports { margin-top: 16px; padding: 4px 14px 10px; border: 1px solid var(--accent-soft); border-radius: 12px; background: var(--accent-soft); }
.reports h3 { margin-top: 10px; color: var(--accent); }
.reports ul { list-style: none; margin: 0; padding: 0; }
.reports li { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
.reports li p { margin: 0; }
.reports .btn { justify-self: start; min-height: 36px; margin-top: 6px; }
.nearby .grow { flex: 1; display: grid; }
.reasons label.check { margin: 10px 0; }

/* sticky contact bar at the bottom of the details sheet */
.contact { position: sticky; bottom: 0; display: flex; gap: 8px; margin: 20px calc(-1 * var(--gutter)) -20px; padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.contact .btn { flex: 1; }
.admin-row { margin-top: 12px; }

/* ---------- buttons ---------- */
.btn, form .row button {
  display: inline-grid; place-items: center; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-weight: 700; text-decoration: none; transition: transform 120ms var(--ease-out);
}
.btn:active, form .row button:active { transform: scale(0.98); }
.primary { background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-ink) !important; }
.whatsapp { background: var(--wa) !important; border-color: var(--wa) !important; color: #fff !important; }
.danger { color: var(--danger) !important; }
.ghost { background: var(--soft) !important; border-color: var(--soft) !important; }
button:disabled { opacity: 0.6; cursor: progress; }

/* ---------- forms ---------- */
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
form label { display: block; margin: 12px 0; font-size: 13px; font-weight: 600; color: var(--muted); }
form input:not([type=checkbox]), form select, form textarea {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--field); color: var(--ink); font-size: 16px; font-weight: 400;
}
form input:focus, form select:focus, form textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
fieldset { margin: 12px 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
legend { padding: 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.amen { display: grid; grid-template-columns: 1fr 1fr; }
label.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; color: var(--ink); font-size: 15px; font-weight: 400; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
#pickmap { height: 220px; border-radius: 12px; border: 1px solid var(--line); }
form .row:last-child { position: sticky; bottom: 0; margin: 16px calc(-1 * var(--gutter)) -20px; padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }

.admin-only { display: none !important; }
body.admin .admin-only { display: flex !important; }
body.admin label.admin-only:not(.check) { display: block !important; }
[hidden] { display: none !important; }

.leaflet-container { font-family: inherit; }
.leaflet-tile-pane { filter: var(--tiles); }
.leaflet-control-attribution { font-size: 10px; background: var(--glass) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--soft); }
