:root {
  --bg: #1c1f23;
  --card: #ffffff;
  --ink: #22272e;
  --muted: #6a737d;
  --ok: #2e7d32;
  --warn: #b26a00;
  --bad: #c62828;
  --none: #546e7a;
  --accent: #2f6fed;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: absolute; inset: 0; }

#topbar {
  position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 10px; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  background: rgba(28,31,35,.82); color: #fff; backdrop-filter: blur(6px);
  border-radius: var(--radius); padding: 6px 12px 6px 6px; box-shadow: var(--shadow);
}
#topbar h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .3px; }
#topbar button {
  font-size: 17px; background: transparent; color: #fff; border: 0; padding: 6px 9px;
  border-radius: 8px; cursor: pointer;
}
#topbar button:hover { background: rgba(255,255,255,.12); }

#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(330px, 88vw); z-index: 40;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow);
  overflow-y: auto; padding: 12px 14px calc(env(safe-area-inset-bottom) + 12px);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.panel-head button { border: 0; background: #eef1f4; border-radius: 8px; padding: 5px 9px; cursor: pointer; }
.panel-section { border-top: 1px solid #e3e7eb; margin-top: 12px; padding-top: 10px; }
.panel-section strong { display: block; margin-bottom: 6px; }
.layer-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.layer-row .swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.2); }
.layer-row input[type="checkbox"] { accent-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }

#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  background: var(--card); color: var(--ink);
  border-radius: 16px 16px 0 0; box-shadow: 0 -6px 30px rgba(0,0,0,.25);
  max-height: 52vh;
  display: flex; flex-direction: column;
  padding: 4px 16px calc(env(safe-area-inset-bottom) + 14px);
}
#sheet[hidden] { display: none; }
#sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#sheet-head {
  position: relative; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  min-height: 30px; padding: 6px 0 2px;
  cursor: ns-resize; touch-action: none; user-select: none;
}
#sheet-grip { width: 44px; height: 4px; border-radius: 2px; background: #d4d9de; }
#sheet-close {
  position: absolute; right: 0; top: 4px;
  border: 0; background: #eef1f4; color: var(--ink);
  border-radius: 8px; padding: 4px 9px; font-size: 13px; cursor: pointer;
}
#sheet-close:hover { background: #e0e5ea; }
@media (min-width: 900px) {
  #sheet {
    left: auto; right: 12px; bottom: 12px; width: 380px;
    border-radius: var(--radius); max-height: 70vh;
  }
  #sheet-grip { display: none; }
}

.tap-pin {
  font-size: 28px; font-weight: 700; line-height: 1; color: var(--bg);
  text-shadow: 0 0 3px #fff, 0 0 6px #fff, 0 1px 2px rgba(255,255,255,.9);
  pointer-events: none; user-select: none;
}
.coords-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin: 6px 0 2px; }
.coords-row button { border: 0; background: #eef1f4; border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px; }
.coords-row a { background: #e3f0fb; color: #14507e; border-radius: 6px; padding: 2px 8px; font-size: 12px; text-decoration: none; }
.card { border-top: 1px solid #e9edf0; padding: 10px 0; }
.card:first-of-type { border-top: 0; }
.card-title { font-weight: 650; font-size: 15.5px; }
.card-title .sub { font-weight: 400; color: var(--muted); font-size: 13px; display: block; }
.verdict { display: inline-block; margin: 6px 0 2px; font-weight: 600; font-size: 13.5px; padding: 3px 9px; border-radius: 999px; color: #fff; }
.verdict.ok { background: var(--ok); } .verdict.warn { background: var(--warn); }
.verdict.bad { background: var(--bad); } .verdict.none { background: var(--none); }
.card ul { margin: 6px 0 4px; padding-left: 18px; font-size: 13.5px; }
.card li { margin: 2px 0; }
.card .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.card .links a {
  font-size: 12.5px; text-decoration: none; color: var(--accent);
  background: #eef3ff; padding: 3px 9px; border-radius: 999px;
}
.notice { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; color: var(--ink); border-radius: 14px; max-width: 440px; padding: 20px 22px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card p { font-size: 14px; line-height: 1.45; }
.modal-card button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; font-size: 14px; cursor: pointer; margin-top: 4px; }

.maplibregl-ctrl-bottom-right { margin-bottom: 6px; }

#picker-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 10px); z-index: 45;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  max-width: min(560px, calc(100vw - 16px));
  background: rgba(28,31,35,.85); color: #fff; backdrop-filter: blur(6px);
  border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow);
  font-size: 13px;
}
#picker-bar .status { font-weight: 600; white-space: nowrap; }
#picker-bar label { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; white-space: nowrap; }
#picker-bar input[type="checkbox"] { accent-color: var(--accent); }
#picker-bar button {
  border: 0; background: rgba(255,255,255,.14); color: #fff;
  border-radius: 8px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
#picker-bar button:hover { background: rgba(255,255,255,.26); }
#picker-bar button:disabled { opacity: .5; cursor: default; }
#picker-bar button.primary { background: var(--accent); }
#picker-bar button.primary:hover { background: #2861d8; }

/* picker box-draw rubber band (positioned in map-container pixels) */
#map .draw-box {
  position: absolute; z-index: 5; pointer-events: none;
  border: 2px dashed var(--accent); background: rgba(47,111,237,.12);
}
