/* Mapa graffiti: a photocopied city map, paint-coloured pins, plaster-grey chrome with ink edges. */
:root {
  --wall: #f0ede7;        /* plaster */
  --wall-2: #ddd8cf;      /* shadowed plaster */
  --paper: #fffdf9;       /* inputs, popups */
  --ink: #121110;
  --ink-soft: #3f3b35;
  --line: #121110;
  --focus: #2f6fe4;
  --cat-hate: #e0141a;
  --cat-hooligan: #ff8a00;
  --cat-art: #12a862;
  --cat-tag: #1f6cff;
  --cat-sticker: #b935cc;
  --cat-other: #6b665e;
  --cat-removed: #b9b3a8;
  --top-h: 58px;
  --r: 4px;
  --body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.5 var(--body);
  background: var(--wall); color: var(--ink);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.2; }
h2 { font-size: 1.15rem; }
a { color: var(--ink); }
p { margin: .4rem 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  height: var(--top-h); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 0 14px; padding-top: env(safe-area-inset-top);
  background: var(--wall); border-bottom: 3px solid var(--line);
  position: relative; z-index: 1001;
}
.top-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }

/* ---------- buttons ---------- */
.btn {
  font: 600 .92rem/1 var(--body); cursor: pointer; color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--r); background: var(--paper);
  padding: 10px 14px; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn.solid { background: var(--ink); color: var(--wall); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--wall-2); }
.btn.solid:hover { background: #000; }
.btn.icon { width: 40px; padding: 0; }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: .85rem; }
.btn.danger { border-color: var(--cat-hate); color: var(--cat-hate); background: transparent; }
.btn.danger:hover { background: var(--cat-hate); color: var(--paper); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.textlink { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; font-weight: 500; }

/* ---------- map ---------- */
#map { flex: 1 1 auto; min-height: 0; background: #e2ded6; }
.leaflet-container { font: inherit; }
.tiles-copy { filter: grayscale(1) brightness(1.06) contrast(.9); }
.tiles-dark { filter: invert(1) hue-rotate(180deg) grayscale(1) brightness(.78) contrast(.95); }
body.adding #map { cursor: crosshair; }

.leaflet-bar { border: 2px solid var(--line) !important; border-radius: var(--r) !important; box-shadow: none !important; }
.leaflet-bar a { background: var(--paper); color: var(--ink); border-bottom: 2px solid var(--line) !important; width: 34px; height: 34px; line-height: 34px; font-weight: 700; }
.leaflet-bar a:last-child { border-bottom: 0 !important; }
.leaflet-bar a:hover { background: var(--wall-2); }
.zoom-locate { display: flex; align-items: flex-end; gap: 8px; }
.zoom-locate .leaflet-bar { margin: 0; }
.locate-ctl a { display: flex; align-items: center; justify-content: center; }
.locate-ctl svg { width: 20px; height: 20px; display: block; }
.leaflet-control-layers { background: var(--paper); color: var(--ink); border: 2px solid var(--line); border-radius: var(--r); box-shadow: none; }
.leaflet-control-layers-toggle { background-size: 22px; }
.leaflet-control-layers-expanded { padding: 8px 12px; font: 500 .9rem var(--body); }
.leaflet-control-scale-line { border: 2px solid var(--line); border-top: 0; background: rgba(245,243,238,.85); color: var(--ink); font: 600 .72rem var(--body); }
.leaflet-control-attribution { background: rgba(230,226,218,.85) !important; color: var(--ink-soft) !important; font: .68rem var(--body); }
.leaflet-control-attribution a { color: var(--ink-soft); }

/* pins */
.pin { display: block; overflow: visible; filter: drop-shadow(0 2px 2px rgba(0,0,0,.45)); }
.pin.temp .drop { animation: wobble 1.1s ease-in-out infinite; transform-origin: 12px 26px; }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.marker-cluster { background: transparent; }
.marker-cluster div {
  width: 36px; height: 36px; margin: 2px; border-radius: 50%;
  background: var(--ink); color: var(--wall); border: 2px solid var(--paper);
  font: 700 .95rem/32px var(--body); text-align: center; box-shadow: 0 2px 3px rgba(0,0,0,.4);
}

/* ---------- hint / empty / toast ---------- */
.hint, .empty, .toast {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 1002;
  max-width: calc(100% - 24px); background: var(--paper); color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--r); box-shadow: 3px 3px 0 var(--ink);
}
.hint { top: calc(var(--top-h) + 12px); padding: 8px 8px 8px 14px; display: flex; gap: 12px; align-items: center; font-weight: 600; }
.empty { bottom: 48px; padding: 10px 14px; font-weight: 500; }
.toast { top: calc(var(--top-h) + 12px); padding: 10px 14px; font-weight: 500; z-index: 1005; }
.toast.err { border-color: var(--cat-hate); box-shadow: 3px 3px 0 var(--cat-hate); }

/* ---------- address search ---------- */
.search {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 1004;
  top: calc(var(--top-h) + 12px); width: min(560px, calc(100% - 24px));
  background: var(--wall); border: 2px solid var(--line); border-radius: var(--r); box-shadow: 3px 3px 0 var(--ink);
  padding: 8px;
}
.search-row { display: flex; gap: 8px; margin: 0; }
.search-row input { flex: 1 1 auto; min-width: 0; }
.search-row input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-results { list-style: none; margin: 8px 0 0; padding: 0; max-height: min(46vh, 360px); overflow: auto; border-top: 2px solid var(--line); }
.search-results li { border-bottom: 1px dashed var(--ink-soft); }
.search-results li:last-child { border-bottom: 0; }
.search-results button {
  width: 100%; text-align: left; background: transparent; border: 0; cursor: pointer;
  font: 500 .95rem/1.35 var(--body); color: var(--ink); padding: 10px 8px; display: block;
}
.search-results button:hover { background: var(--wall-2); }
.search-results .sub { display: block; color: var(--ink-soft); font-size: .84rem; font-weight: 400; }
.search-results .none { padding: 10px 8px; color: var(--ink-soft); font-size: .9rem; }
.search-foot { margin: 6px 2px 0; font-size: .72rem; color: var(--ink-soft); }
.search-foot a { color: var(--ink-soft); }
.search-pin { stroke: var(--ink); fill: none; }

/* ---------- panels ---------- */
.panel {
  position: absolute; z-index: 1003; display: flex; flex-direction: column;
  right: 14px; top: calc(var(--top-h) + 14px); width: 380px; max-height: calc(100% - var(--top-h) - 28px);
  background: var(--wall); border: 2px solid var(--line); border-radius: var(--r); box-shadow: 4px 4px 0 var(--ink);
}
.panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 2px solid var(--line); }
.panel-body { padding: 14px 16px 16px; overflow: auto; }
.group { border: 0; padding: 0; margin: 0 0 14px; }
.group legend, .field > span, .field legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; display: block; padding: 0; }
.field { display: block; margin: 0 0 14px; border: 0; padding: 0; }
.check, .chip { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-weight: 500; }
.check.sep { margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--ink-soft); }
.check input, .chip input { accent-color: var(--ink); width: 18px; height: 18px; margin: 0; }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.cats legend { grid-column: 1 / -1; }
.count { color: var(--ink-soft); font-size: .88rem; margin: 0 0 14px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea {
  width: 100%; font: 400 1rem var(--body); color: var(--ink); background: var(--paper);
  border: 2px solid var(--line); border-radius: var(--r); padding: 10px 12px;
}
input::placeholder, textarea::placeholder { color: #7d776e; }
input[type=file] { width: 100%; font: 500 .9rem var(--body); color: var(--ink-soft); }
input[type=file]::file-selector-button {
  font: 600 .9rem var(--body); color: var(--ink); background: var(--paper); border: 2px solid var(--line);
  border-radius: var(--r); padding: 8px 12px; margin-right: 10px; cursor: pointer;
}
textarea { resize: vertical; }
.row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.row input { margin: 0; }
.help { color: var(--ink-soft); font-size: .88rem; margin: 0 0 12px; }
.coords { font-variant-numeric: tabular-nums; }
.error { color: var(--cat-hate); font-weight: 600; margin-top: 10px; }
.admin { margin-top: 10px; border-top: 2px solid var(--line); padding-top: 10px; }
.admin summary { cursor: pointer; font-weight: 600; }
.admin .help { margin: 8px 0; }

.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--ink); flex: 0 0 auto; }
.cat-hate { background: var(--cat-hate); }
.cat-hooligan { background: var(--cat-hooligan); }
.cat-art { background: var(--cat-art); }
.cat-tag { background: var(--cat-tag); }
.cat-sticker { background: var(--cat-sticker); }
.cat-other { background: var(--cat-other); }
.cat-removed { background: var(--cat-removed); border-radius: 2px; transform: rotate(-8deg); }

/* ---------- new since last visit / duplicates / reports ---------- */
.new-dot { background: #ffd400; }
.new-dot.small { width: 10px; height: 10px; vertical-align: middle; margin-left: 4px; }
.pill { font: 700 .8rem/22px var(--body); min-width: 22px; padding: 0 7px; text-align: center; border-radius: 999px; background: var(--ink); color: var(--wall); margin-left: 4px; }
.popup .tag.new { background: #ffd400; }
.popup .tag.flag, .report .tag.flag { background: var(--cat-hate); color: var(--paper); border-color: var(--cat-hate); }
.dup { margin: 0 0 14px; padding: 10px 10px 6px; border: 2px solid var(--line); border-radius: var(--r); background: var(--paper); box-shadow: 3px 3px 0 #ffd400; }
.dup-head { margin: 0 0 4px; font-weight: 600; }
.dup .list-items { margin: 0; }
.dup .list-item { padding-left: 6px; }
.dup .help { margin: 6px 0 4px; font-size: .82rem; }
.toast .btn { margin-left: 10px; }
.btn.attention { border-color: var(--cat-hate); color: var(--cat-hate); }
.report { border-top: 2px solid var(--line); padding: 10px 2px; }
.report:last-child { border-bottom: 2px solid var(--line); }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.report .sub { color: var(--ink-soft); font-size: .82rem; font-weight: 400; }
.report .tag { display: inline-flex; align-items: center; font: 600 .78rem var(--body); padding: 3px 8px; border: 1.5px solid var(--ink); border-radius: 999px; }
.report-title { margin: 0; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.report-reason { margin: 2px 0 0; font-size: .9rem; }
.report-note { margin: 4px 0 0; padding: 6px 8px; background: var(--wall-2); border-radius: var(--r); white-space: pre-wrap; font-size: .9rem; }
.report .row { margin-top: 8px; }

/* ---------- list by city ---------- */
.list-body { display: flex; flex-direction: column; min-height: 0; }
.list-help { margin: 8px 0 10px; }
.list-groups { overflow: auto; min-height: 0; }
.list-city { border-top: 2px solid var(--line); }
.list-city:last-child { border-bottom: 2px solid var(--line); }
.list-city summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 4px; cursor: pointer; font-weight: 600; list-style: none;
}
.list-city summary::-webkit-details-marker { display: none; }
.list-city summary::before { content: "▸"; margin-right: 8px; color: var(--ink-soft); }
.list-city[open] summary::before { content: "▾"; }
.list-city-name { flex: 1 1 auto; }
.star { background: transparent; border: 0; padding: 4px; margin: -4px 2px -4px 0; cursor: pointer; color: var(--ink-soft); display: inline-flex; border-radius: var(--r); }
.star svg path { fill: none; }
.star:hover { background: var(--wall-2); color: var(--ink); }
.star.on { color: var(--ink); }
.star.on svg path { fill: #ffd400; }
#newScope { margin: 2px 0 0 28px; font-size: .8rem; }
.list-city-n { font: 700 .8rem/22px var(--body); min-width: 22px; padding: 0 7px; text-align: center; border-radius: 999px; background: var(--ink); color: var(--wall); }
.list-items { list-style: none; margin: 0 0 8px; padding: 0; }
.list-item {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  padding: 8px 6px 8px 24px; border: 0; border-top: 1px dashed var(--ink-soft); background: transparent;
  font: 500 .95rem/1.3 var(--body); color: var(--ink); border-radius: var(--r);
}
.list-item:hover { background: var(--wall-2); }
.list-item.removed .list-item-title { text-decoration: line-through; color: var(--ink-soft); }
.list-item-text { display: flex; flex-direction: column; min-width: 0; }
.list-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { color: var(--ink-soft); font-size: .8rem; font-weight: 400; }

/* ---------- popup ---------- */
.leaflet-popup-content-wrapper { background: var(--paper); color: var(--ink); border: 2px solid var(--line); border-radius: var(--r); box-shadow: 4px 4px 0 var(--ink); }
.leaflet-popup-tip { background: var(--paper); border: 2px solid var(--line); border-top: 0; border-left: 0; box-shadow: none; }
.leaflet-popup-content { margin: 14px 16px 14px; width: 270px !important; line-height: 1.45; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink); font-size: 22px; top: 6px; right: 6px; }
.popup h3 { font-size: 1.05rem; margin: 0 24px 6px 0; }
.popup .city { color: var(--ink-soft); font-size: .85rem; font-weight: 600; margin: -2px 0 6px; }
.popup .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.popup .tag { display: inline-flex; align-items: center; gap: 6px; font: 600 .78rem var(--body); padding: 3px 8px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--wall); }
.popup .tag.removed { background: var(--cat-removed); }
.popup .when { color: var(--ink-soft); font-size: .8rem; margin: 0 0 6px; }
.popup img { width: 100%; display: block; border: 2px solid var(--line); margin: 8px 0; }
.popup .desc { white-space: pre-wrap; margin: 6px 0 0; }
.popup .addphoto { display: flex; align-items: center; gap: 10px; margin: 8px 0; padding: 8px; border: 2px dashed var(--ink-soft); border-radius: var(--r); }
.popup .addphoto .help { margin: 0; font-size: .8rem; }
.popup .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.popup .actions .btn { min-height: 34px; padding: 6px 10px; font-size: .85rem; }

/* ---------- legend ---------- */
.legend {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 7px 14px;
  padding-bottom: calc(7px + env(safe-area-inset-bottom));
  background: var(--wall); border-top: 3px solid var(--line); font-size: .82rem; font-weight: 500;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 11px; height: 11px; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .btn.solid#btnAdd { padding: 10px 12px; }
  .hint { width: calc(100% - 24px); flex-wrap: wrap; justify-content: center; gap: 8px; padding: 8px 10px; text-align: center; }
  .hint span { flex: 1 1 100%; }
  .panel {
    left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-height: 82%;
    border-left: 0; border-right: 0; border-bottom: 0; border-radius: 0; box-shadow: none;
    border-top-width: 3px;
  }
  .panel-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .legend { display: none; }
  .leaflet-control-layers { display: none; }
  #btnLocate { display: none; }
  .top-actions { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .pin.temp .drop { animation: none; }
  .btn.busy svg { animation: none; opacity: .5; }
}
