:root {
  --bg: #05070d;
  --panel: rgba(13, 16, 25, 0.95);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8eaf0;
  --muted: #9097a8;
  --accent: #ff9933;
  --killing: #ff4d5e;
  --mass: #c06bff;
  --assault: #ff9933;
  --harassment: #f5d547;
  --institutional: #4fc3f7;
  --vandalism: #5bd68a;
  --discrimination: #ff7eb6;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, sans-serif; }
#globe { position: fixed; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- side panel ---------- */
.panel {
  position: fixed; top: 16px; left: 16px; bottom: 16px; width: 360px;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  z-index: 5; overflow: hidden;
}
.panel-head { padding: 20px 20px 12px; border-bottom: 1px solid var(--line); }
.sheet-handle { display: none; }
h1 { font-family: Fraunces, Georgia, serif; font-size: 26px; line-height: 1.1; margin: 0 0 8px; letter-spacing: -0.01em; }
h1 span { display: block; color: var(--accent); }
.lede { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: rgba(255,255,255,0.04); border-radius: 10px; padding: 8px 10px; }
.stats strong { display: block; font-size: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.filters { padding: 12px 20px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
input[type=search], dialog input, dialog select, dialog textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.05); color: var(--text); font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line); background: transparent; font-size: 12px; color: var(--muted);
}
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip.on { color: var(--text); background: rgba(255,255,255,0.07); border-color: color-mix(in srgb, var(--c) 60%, transparent); }

.layers { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.layers label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.layers input { accent-color: var(--accent); margin: 0; }
.layers span { font-variant-numeric: tabular-nums; color: var(--text); }
.range-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.range-track { position: relative; height: 22px; }
.range-track input { position: absolute; inset: 0; width: 100%; pointer-events: none; appearance: none; background: none; margin: 0; }
.range-track::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 2px; background: var(--line); }
.range-track input::-webkit-slider-thumb { pointer-events: auto; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.range-track input::-moz-range-thumb { pointer-events: auto; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }

.list { list-style: none; margin: 0; padding: 6px 8px; overflow-y: auto; flex: 1; }
.list li {
  content-visibility: auto; contain-intrinsic-size: auto 58px;
  display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: baseline;
  padding: 9px 12px; border-radius: 10px; cursor: pointer;
}
.list li:hover, .list li.active { background: rgba(255,255,255,0.06); }
.list li i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); align-self: center; }
.list li b { font-weight: 500; display: block; }
.list li small { color: var(--muted); font-size: 12px; }
.list li time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.list .empty { color: var(--muted); text-align: center; display: block; cursor: default; }

.note { margin: 0; padding: 10px 20px 0; font-size: 11px; color: var(--muted); line-height: 1.45; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.btn { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: #1a1006; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
.btn.small { padding: 5px 10px; font-size: 12px; }

/* ---------- toolbar ---------- */
.toolbar { position: fixed; top: 16px; right: 16px; display: flex; gap: 8px; z-index: 5; }
.seg, .icon-btn { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.seg { display: flex; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 7px; color: var(--muted); font-size: 12px; }
.seg button.on { background: rgba(255,255,255,0.1); color: var(--text); }
.icon-btn { width: 36px; height: 36px; font-size: 16px; }
.icon-btn.off { color: var(--muted); }

/* ---------- map ---------- */
#globe { background: radial-gradient(circle at 62% 48%, #101a2e 0%, #070a12 50%, #04060b 100%); }
.maplibregl-canvas { outline: none; }
body.adding .maplibregl-canvas { cursor: crosshair; }
.selection { position: relative; width: 16px; height: 16px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px #fff, 0 2px 10px rgba(0,0,0,.6); pointer-events: none; }
.selection::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--c); animation: pulse 1.8s ease-out infinite; will-change: transform, opacity; }
@keyframes pulse { from { transform: scale(1); opacity: .65; } to { transform: scale(3.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .selection::after { animation: none; } }
.atlas-popup { pointer-events: none; }
.atlas-popup .maplibregl-popup-content { background: #0d1019; color: var(--text); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); font: 12px/1.4 Inter, system-ui, sans-serif; box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.atlas-popup .maplibregl-popup-tip { display: none; }
.atlas-popup b { display: block; font-weight: 600; }
.atlas-popup span { color: var(--muted); }
.maplibregl-ctrl-attrib { font-size: 10px; }
.no-webgl { position: fixed; top: 50%; left: calc(50% + 190px); transform: translate(-50%, -50%); max-width: 320px; color: var(--muted); text-align: center; }
.gpu-hint { position: fixed; top: 64px; right: 16px; z-index: 6; display: flex; gap: 10px; align-items: flex-start; max-width: 320px; padding: 10px 12px; background: var(--panel); border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 10px; font-size: 12px; color: var(--muted); }
.gpu-hint[hidden] { display: none; }
.gpu-hint b { color: var(--text); font-weight: 600; }
.gpu-hint button { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 0; }
.reports-status { color: var(--muted); font-size: 12px; }
.note b { color: var(--text); font-weight: 600; }

/* ---------- detail card ---------- */
.detail {
  position: fixed; right: 16px; bottom: 40px; width: 380px; max-height: calc(100% - 120px); overflow-y: auto;
  padding: 20px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); z-index: 6;
}
.detail h2 { font-family: Fraunces, Georgia, serif; font-size: 22px; margin: 6px 0 2px; line-height: 1.2; }
.detail .place { color: var(--muted); margin: 0 0 12px; }
.detail-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); padding-right: 26px; }
.tag { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #111; background: var(--c); }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 22px; color: var(--muted); }
.kind { margin-left: auto; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.sources h3 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 4px; }
.sources a.report { display: block; padding: 8px 0; border-top: 1px solid var(--line); text-decoration: none; word-break: normal; }
.sources a.report span { display: block; font-size: 11px; color: var(--muted); }
.sources a.report q { color: var(--text); font-size: 13px; }
.sources a.report:hover q { color: var(--accent); }
.sources a { display: block; color: var(--accent); font-size: 12px; word-break: break-all; margin-top: 4px; }
.unverified { color: var(--harassment); font-size: 12px; }

.add-hint {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 7;
  background: var(--accent); color: #1a1006; padding: 8px 14px; border-radius: 99px; font-weight: 600;
}
.add-hint button { border: 0; background: rgba(0,0,0,.15); border-radius: 99px; padding: 2px 10px; margin-left: 6px; }
body.adding #globe { cursor: crosshair; }

dialog { background: #0e121c; color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); width: min(480px, calc(100% - 32px)); padding: 22px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0; font-family: Fraunces, Georgia, serif; }
dialog label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 10px; }
dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 18px 0 0; }
.coords { color: var(--muted); font-size: 12px; margin: 2px 0 0; font-variant-numeric: tabular-nums; }


/* ---------- mobile: panel becomes a bottom sheet ---------- */
@media (max-width: 760px) {
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 58vh; border-radius: var(--radius) var(--radius) 0 0; transition: height .25s; }
  .panel.collapsed { height: 150px; }
  .sheet-handle { display: block; width: 44px; height: 5px; border: 0; border-radius: 99px; background: rgba(255,255,255,.25); margin: -8px auto 10px; }
  .panel-head { padding: 16px 16px 10px; }
  .lede, .note { display: none; }
  h1 { font-size: 20px; }
  .filters, .panel-foot { padding: 10px 16px; }
  .toolbar { left: 16px; right: 16px; justify-content: flex-end; }
  .no-webgl { left: 50%; top: 25%; }
  .detail { left: 16px; right: 16px; width: auto; top: 64px; bottom: auto; max-height: 50vh; }
  }
