:root {
  --bg: #ffffff; --fg: #0b1f3a; --muted: #5b6b82; --line: #d9e1ec; --card: #f4f7fb;
  --accent: #1f4e8c; --accent-fg: #ffffff; --danger: #b3261e;
  --c-police: #1f4e8c; --c-traffic: #c77700; --c-accident: #b3261e; --c-other: #5b6b82;
  --shadow: 0 6px 24px rgba(11,31,58,.18);
  --bar-h: 52px;
}
:root[data-theme="dark"] {
  --bg: #0b1f3a; --fg: #eaf1fb; --muted: #9db0c9; --line: #213a5e; --card: #12294a;
  --accent: #5aa2ff; --accent-fg: #06142a; --danger: #ff8a80;
  --c-police: #5aa2ff; --c-traffic: #f0a63a; --c-accident: #ff6b61; --c-other: #9db0c9;
  --shadow: 0 6px 24px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1f3a; --fg: #eaf1fb; --muted: #9db0c9; --line: #213a5e; --card: #12294a;
    --accent: #5aa2ff; --accent-fg: #06142a; --danger: #ff8a80;
    --c-police: #5aa2ff; --c-traffic: #f0a63a; --c-accident: #ff6b61; --c-other: #9db0c9;
    --shadow: 0 6px 24px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--fg); background: var(--bg); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

.bar { position: fixed; z-index: 1000; top: 0; left: 0; right: 0; height: calc(var(--bar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; justify-content: space-between; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; }
nav { display: flex; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; text-decoration: none; color: var(--fg); }

#map { position: fixed; inset: calc(var(--bar-h) + env(safe-area-inset-top)) 0 0 0; background: var(--card); }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(200deg) brightness(.85) contrast(.9) saturate(.7); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(200deg) brightness(.85) contrast(.9) saturate(.7); } }
.leaflet-container { font: inherit; background: var(--card); }
.leaflet-control-attribution { font-size: 10px; }

.fabs { position: fixed; z-index: 900; right: 14px; bottom: calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.fab { width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--accent); box-shadow: var(--shadow); display: grid; place-items: center; }
.fab[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.pin-wrap.camera { --c: #c9a227; }
.pin-wrap.camera .pin { width: 14px; height: 14px; border-radius: 3px; transform: none; border-width: 2px; }
.camera-note { font-size: 11px; color: var(--muted); margin: 0; }
.pin-wrap.camera { overflow: visible; }
.cam-dir { position: absolute; left: -5px; top: -5px; width: 24px; height: 24px; display: flex; justify-content: center; align-items: flex-start;
  color: #6b5200; pointer-events: none; filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff); }
.cam-dir svg { width: 9px; height: 9px; margin-top: -4px; }
.cam-pop table { border-collapse: collapse; margin: 6px 0 4px; font-size: 13px; }
.cam-pop th { text-align: left; font-weight: 600; color: #5b6b82; padding: 1px 10px 1px 0; vertical-align: top; white-space: nowrap; }
.cam-pop td { padding: 1px 0; }
.cam-arrow { display: inline-block; vertical-align: -1px; line-height: 0; color: #1f4e8c; }
.cam-links { margin: 4px 0; font-size: 13px; }
.report { position: fixed; z-index: 900; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom));
  min-width: min(86vw, 360px); padding: 18px 28px; border: 0; border-radius: 999px; font-size: 20px; font-weight: 700;
  background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow); }
.report:active { transform: translateX(-50%) scale(.98); }

.sheet { position: fixed; z-index: 1100; left: 0; right: 0; bottom: 0; max-height: 80vh; overflow: auto; background: var(--bg); color: var(--fg);
  border-top-left-radius: 20px; border-top-right-radius: 20px; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
  border-top: 1px solid var(--line); max-width: 640px; margin: 0 auto; }
.sheet[hidden], #toast[hidden] { display: none; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { margin: 4px 0; font-size: 20px; }
.sheet h3 { margin: 16px 0 6px; font-size: 15px; color: var(--muted); }
.row { display: flex; align-items: center; } .between { justify-content: space-between; } .gap { gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.types { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.type { padding: 20px 8px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); font-size: 18px; font-weight: 600; }
.type::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; background: var(--c); }
.police { --c: var(--c-police); } .traffic { --c: var(--c-traffic); } .accident { --c: var(--c-accident); } .other { --c: var(--c-other); }
.type:hover, .type:focus-visible { border-color: var(--c); }
.primary, .secondary, .ghost { border-radius: 12px; padding: 10px 14px; border: 1px solid var(--accent); font-weight: 600; }
.primary { background: var(--accent); color: var(--accent-fg); }
.secondary { background: transparent; color: var(--accent); }
.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.ghost.danger { color: var(--danger); }
.x { border: 0; background: transparent; font-size: 20px; padding: 4px 8px; color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.comments { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.comments li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; display: flex; gap: 8px; justify-content: space-between; align-items: flex-start; }
.comments .txt { overflow-wrap: anywhere; } .comments .when { color: var(--muted); font-size: 12px; display: block; }
.comments button { border: 0; background: transparent; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 2px; }
textarea { width: 100%; resize: none; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); padding: 10px; font: inherit; margin-bottom: 6px; }

#toast { position: fixed; z-index: 1200; left: 50%; transform: translateX(-50%); top: calc(var(--bar-h) + 14px + env(safe-area-inset-top)); max-width: 90vw;
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }

.pin { width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.pin-wrap { background: none; border: 0; }
.pin-wrap.police { --c: var(--c-police); } .pin-wrap.traffic { --c: var(--c-traffic); } .pin-wrap.accident { --c: var(--c-accident); } .pin-wrap.other { --c: var(--c-other); }
.me { width: 16px; height: 16px; border-radius: 50%; background: #2f80ff; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47,128,255,.25); }

/* privacy page */
.page { max-width: 680px; margin: 0 auto; padding: 24px 16px 60px; overflow: auto; height: 100%; }
body.doc { overflow: auto; }
.page h1 { font-size: 26px; } .page h2 { font-size: 18px; margin-top: 26px; } .page a { color: var(--accent); }

.en { display: none; } html[lang=en] .en { display: block; } html[lang=en] .sv { display: none; }
html[lang=en] .en.inl { display: inline; } .en.inl { display: none; }

/* tap-to-report: temporary pin + compact panel */
.pick { position: fixed; z-index: 1100; left: 8px; right: 8px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto;
  background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 18px; padding: 10px 12px 8px; box-shadow: var(--shadow); }
.pick[hidden] { display: none; }
.pick h2 { margin: 0; font-size: 18px; }
.ptypes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 4px; }
.ptype { padding: 12px 2px; min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 15px; font-weight: 600; }
.ptype::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; background: var(--c); }
.ptype:hover, .ptype:focus-visible { border-color: var(--c); }
.pick .ghost { padding: 6px 12px; }
.pick p { margin: 4px 0 0; }
body.picking .report { display: none; }
body.picking .fabs { bottom: calc(150px + env(safe-area-inset-bottom)); }
.pin-wrap.pending { --c: var(--accent); cursor: grab; }
.pin-wrap.pending .pin { animation: drop .18s ease-out; outline: 2px dashed var(--c); outline-offset: 4px; border-radius: 50% 50% 50% 0; }
@keyframes drop { from { transform: translateY(-14px) rotate(-45deg); } to { transform: rotate(-45deg); } }
@media (prefers-reduced-motion: reduce) { .pin-wrap.pending .pin { animation: none; } }

/* terms link + first-visit disclaimer */
.legal { margin: 4px 0 0; } .legal a, .disclaimer a { color: var(--accent); }
.disclaimer { position: fixed; z-index: 1150; left: 8px; right: 8px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto;
  background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.disclaimer[hidden] { display: none; }
.disclaimer h2 { margin: 0 0 4px; font-size: 17px; } .disclaimer p { margin: 0 0 10px; font-size: 14px; }
body.disclaiming .report, body.disclaiming .fabs { display: none; }
.notice { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 10px 14px; margin: 14px 0; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
@media (max-width: 420px) { nav { gap: 4px; } .chip { padding: 6px 9px; font-size: 13px; } }
@media (max-width: 370px) { .brand span { display: none; } }

/* moderation page */
.mod input[type=password] { width: 100%; margin: 6px 0; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; }
.mod form label { display: block; }
.mod-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 12px; }
.mod-item { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--c, var(--line)); border-radius: 14px; padding: 10px 12px; }
.mod-item p { margin: 6px 0; }
.mod-item.is-hidden { border-style: dashed; }
.mod-item .comments li { background: var(--bg); }
.mod-item .comments li.is-hidden { border-style: dashed; }
.mod-actions { margin-top: 8px; }
.mod-cbtns { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.mod-badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.mod-badge.warn { color: var(--c-traffic); border-color: var(--c-traffic); }
.mod-badge.hid { color: var(--danger); border-color: var(--danger); }

/* settings / nära mig */
.toggle-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle-row .block { display: block; margin-top: 4px; max-width: 42ch; }
.toggle-row input[type=checkbox] { width: 44px; height: 28px; flex-shrink: 0; accent-color: var(--accent); margin-top: 2px; }

/* ---- licence plate search ---- */
.plate-form { margin: 10px 0 8px; }
.plate-row { display: flex; gap: 8px; align-items: stretch; }
.plate-row input { flex: 1; min-width: 0; font-size: 20px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); }
.plate-result { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.plate-status { margin: 0 0 10px; font-weight: 700; font-size: 16px; }
.plate-status.found { color: var(--c-police); }
.plate-status.miss { color: var(--muted); }
.plate-bil { display: inline-block; margin-bottom: 6px; }
.mod-plates { margin: 28px 0 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.mod-plates h2 { font-size: 18px; margin: 0 0 8px; }
.mod-plates .plate-add { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.mod-plates .plate-add input { flex: 1; min-width: 120px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font-size: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.mod-plate-list { list-style: none; padding: 0; margin: 0; }
.mod-plate-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.mod-plate-list .plate-code { font-weight: 700; letter-spacing: .1em; font-variant-numeric: tabular-nums; }
