:root {
  --bg: #f6f4ec;
  --ink: #1f2a22;
  --muted: #596052;
  --line: #d8d6ca;
  --accent: #2f6b3a;
  --accent-ink: #fff;
  --warn-bg: #7a2a1f;
  --sheet: #fffdf7;
  --shadow: 0 -2px 14px rgba(0,0,0,.14);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { display: flex; flex-direction: column; overflow: hidden; }

#top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
  background: #2b3a2e; color: #f1efe4; font-size: 15px; z-index: 5;
}
#top .title { display: flex; flex-direction: column; line-height: 1.15; }
#top .title strong { font-size: 17px; letter-spacing: .2px; }
#top .muted { color: #c9cfbf; font-size: 12px; }
.top-actions { display: flex; gap: 6px; }

.ban { background: var(--warn-bg); color: #fff; padding: 8px 12px; font-size: 13px; z-index: 5; }

#map { flex: 1; min-height: 40vh; position: relative; }

#legend {
  position: absolute; left: 10px; top: calc(56px + env(safe-area-inset-top));
  background: rgba(255,253,247,.92); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 9px; font-size: 12px; display: flex; align-items: center; gap: 3px; z-index: 4;
}
#legend .sw { display: inline-block; width: 20px; height: 13px; border: 1px solid rgba(0,0,0,.08); }

#sheet {
  background: var(--sheet); box-shadow: var(--shadow); border-top: 1px solid var(--line);
  padding: 4px 12px calc(10px + env(safe-area-inset-bottom));
  max-height: 55vh; overflow-y: auto; z-index: 6;
}
.handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 2px auto 8px; }
.day-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day-label { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.day-label span:first-child { font-weight: 600; font-size: 16px; }
.day-label .muted { font-size: 12px; }
input[type=range] { width: 100%; margin: 8px 0 4px; accent-color: var(--accent); }

.controls { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lbl { font-size: 12px; color: var(--muted); margin-right: 2px; }

.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 5px 10px; font-size: 13px; cursor: pointer; line-height: 1.2; font-family: inherit;
}
.chip.big { padding: 10px 14px; font-size: 15px; font-weight: 600; }
.finds-actions { gap: 8px; }
.chip.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.tog { display: inline-flex; align-items: center; gap: 4px; }
.chip.tog input { margin: 0; accent-color: var(--accent); }
#top .chip { background: transparent; color: #f1efe4; border-color: #5c6b5f; }

#detail { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; font-size: 14px; }
#detail h3 { margin: 0 0 4px; font-size: 15px; }
#detail .big { font-size: 28px; font-weight: 700; line-height: 1; }
#detail .big small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
#detail table { border-collapse: collapse; width: 100%; margin-top: 6px; font-size: 13px; table-layout: fixed; }
#detail td { padding: 3px 0; border-bottom: 1px solid #eee; vertical-align: top; }
#detail td:last-child { text-align: right; overflow-wrap: anywhere; }
#detail td:first-child { width: 42%; }
#detail .bar { display: inline-block; height: 6px; background: var(--accent); border-radius: 3px; vertical-align: middle; margin-right: 6px; }
#detail .why { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
#detail .nd { color: var(--muted); }

#finds-list { margin-top: 10px; font-size: 13px; }
#finds-list ul { list-style: none; padding: 0; margin: 4px 0; }
#finds-list li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid #eee; }
#finds-list button { font-size: 12px; padding: 2px 8px; }

.foot { font-size: 12.5px; margin: 10px 0 0; line-height: 1.35; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.modal { position: fixed; inset: 0; background: rgba(20,24,20,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal-box { background: var(--sheet); width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto;
  border-radius: 14px 14px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); font-size: 14px; line-height: 1.45; }
.modal-box h2 { margin: 0 0 8px; font-size: 18px; }
.modal-box ul { padding-left: 18px; margin: 6px 0; }
.modal-box p { margin: 6px 0; }

.maplibregl-popup-content { font-size: 13px; padding: 8px 10px; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-group button { width: 40px; height: 40px; }

@media (min-width: 900px) {
  body { flex-direction: row; }
  #top { position: absolute; left: 0; right: 380px; }
  #map { flex: 1; height: 100vh; }
  .maplibregl-ctrl-top-right { margin-top: 56px; }
  #legend { top: 66px; }
  .handle { display: none; }
  #sheet { width: 380px; max-height: 100vh; height: 100vh; border-top: 0; border-left: 1px solid var(--line); padding-top: 64px; }
  .modal { align-items: center; }
  .modal-box { border-radius: 14px; }
}
