:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e2e2de;
  --accent: #0a66d8;
  --accent-ink: #ffffff;
  --high: #1f8a3b;
  --medium: #c77700;
  --low: #c4321f;
  --hl: #ffd400;
  --radius: 10px;
  --gap: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --surface: #1e1e21;
    --ink: #f1f1f2;
    --muted: #a3a3aa;
    --line: #34343a;
    --accent: #4c9bff;
    --accent-ink: #0b1220;
    --high: #46c46a;
    --medium: #f0a63a;
    --low: #ff6b57;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.bar {
  display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.bar .sub { color: var(--muted); font-size: 13px; }
.bar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; min-height: 32px;
  font-size: 13px; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.seg-label { font-size: 13px; color: var(--muted); }
.switch { font-size: 13px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.switch:hover { text-decoration: underline; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; min-width: 36px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
a.text { color: var(--accent); text-decoration: none; font-size: 14px; }
a.text:hover { text-decoration: underline; }

/* Map */
.leaflet-container { background: #dcdcd8; font: inherit; }
.legend {
  background: var(--surface); color: var(--ink); padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.6;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 5px; margin-right: 6px; vertical-align: -1px; }
.legend i.hollow { background: transparent !important; border: 2px solid var(--low); width: 10px; height: 10px; }
.pole-label {
  background: transparent; border: 0; box-shadow: none; color: #fff; font-weight: 700; font-size: 10px;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}
.pole-label::before { display: none; }

/* Panorama view */
.pv {
  position: relative; overflow: hidden; background: #101012; border-radius: var(--radius);
  cursor: grab; touch-action: none; user-select: none; outline-offset: 2px;
}
.pv.dragging { cursor: grabbing; }
.pv-cam { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.pv-face {
  position: absolute; background-size: 100% 100%; backface-visibility: hidden; transform-style: preserve-3d;
}
.pv-box { position: absolute; border: 2px solid rgba(80, 220, 120, .9); border-radius: 2px; pointer-events: none; }
.pv-box.rejected { border: 1px dashed rgba(255, 110, 90, .85); }
.pv-box.hl { border: 3px solid var(--hl); box-shadow: 0 0 0 1px rgba(0,0,0,.6); }
.pv-box.hl span {
  position: absolute; left: -3px; bottom: 100%; margin-bottom: 2px; background: var(--hl); color: #111;
  font-size: 11px; font-weight: 700; padding: 0 4px; border-radius: 3px;
}
.pv-pin {
  position: absolute; width: 0; padding: 0; border: 0; border-left: 2px dashed rgba(255,255,255,.85);
  background: transparent; cursor: pointer; transform: translateX(-1px);
}
.pv-pin.active { border-left: 2px dashed var(--hl); }
.pv-pin-label {
  position: absolute; bottom: 100%; left: 0; transform: translate(-50%, -4px); white-space: nowrap;
  background: rgba(17,17,20,.85); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  display: inline-flex; gap: 5px; align-items: baseline;
}
.pv-pin-label small { font-weight: 500; opacity: .75; font-size: 11px; }
.pv-pin.active .pv-pin-label { background: var(--hl); color: #111; }
.pv-hud { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.pv-hud .pv-anchor { pointer-events: auto; }
a.btn { text-decoration: none; }
.pv-compass {
  position: absolute; right: 10px; top: 10px; background: rgba(17,17,20,.7); color: #fff; font-size: 12px;
  padding: 3px 8px; border-radius: 999px; pointer-events: none;
}
.hint { color: var(--muted); font-size: 12px; margin: 6px 2px 0; }
.key { display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--ink); background: var(--surface); }

/* Crops strip */
.views { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.view {
  flex: 0 0 auto; border: 2px solid transparent; border-radius: 8px; padding: 0; background: var(--surface);
  cursor: pointer; text-align: left; overflow: hidden; width: 92px;
}
.view img { display: block; height: 118px; width: 100%; object-fit: cover; background: #222; }
.view span { display: block; font-size: 11px; color: var(--muted); padding: 2px 6px 4px; }
.view[aria-pressed="true"] { border-color: var(--accent); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.chip i { width: 10px; height: 10px; border-radius: 5px; display: inline-block; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px; text-align: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Street view: anchored pole buttons ------------------------------------------- */
:root { --elec: #ffb800; --light: #3fb6ff; --tower: #c084fc; }
.pv-abox { position: absolute; border: 2px solid var(--elec); border-radius: 3px; pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.55); }
.pv-abox.street_light { border-color: var(--light); }
.pv-abox.tower { border-color: var(--tower); }
.pv-abox.weak { border-style: dashed; }
.pv-abox.active { border-width: 3px; }
.pv-anchor {
  position: absolute; transform: translate(-50%, calc(-100% - 8px)); display: flex; flex-direction: column; gap: 1px;
  background: rgba(17,17,20,.9); color: #fff; border: 2px solid var(--elec); border-radius: 10px;
  padding: 5px 10px; font-size: 13px; line-height: 1.25; text-align: left; white-space: nowrap; cursor: pointer;
  min-height: 44px; justify-content: center; font-variant-numeric: tabular-nums;
}
.pv-anchor::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent;
  border-top-color: var(--elec); }
.pv-anchor.street_light { border-color: var(--light); }
.pv-anchor.tower { border-color: var(--tower); }
.pv-anchor.tower::after { border-top-color: var(--tower); }
.pv-anchor.tower:hover, .pv-anchor.tower.active { background: var(--tower); color: #160a24; }
.pv-anchor.street_light::after { border-top-color: var(--light); }
.pv-anchor b { font-size: 13px; }
.pv-anchor span { font-size: 12px; opacity: .85; }
.pv-anchor:hover, .pv-anchor.active { background: var(--elec); color: #111; }
.pv-anchor.street_light:hover, .pv-anchor.street_light.active { background: var(--light); color: #06121c; }

/* Ground navigation arrows */
.pv-nav { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 10px; z-index: 2; }
.pv-nav button {
  min-width: 48px; min-height: 48px; border-radius: 24px; border: 2px solid rgba(255,255,255,.9); background: rgba(17,17,20,.55);
  color: #fff; font-size: 20px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 14px;
}
.pv-nav button span { font-size: 13px; }
.pv-nav button:hover { background: rgba(17,17,20,.8); }
.pv-nav button:disabled { opacity: .35; cursor: default; }

/* Pole dialog */
dialog.pole {
  border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
dialog.pole::backdrop { background: rgba(0,0,0,.45); }
dialog.pole .dh { display: flex; align-items: center; gap: 10px; padding: 16px 16px 0; }
dialog.pole .dh h2 { margin: 0; font-size: 20px; }
dialog.pole .type { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
dialog.pole .type i { width: 10px; height: 10px; border-radius: 5px; display: inline-block; }
dialog.pole .db { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.coords { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.coords output { font: 600 20px/1.2 ui-monospace, "SF Mono", Menlo, monospace; flex: 1; user-select: all; }
.coords small { display: block; font: 12px/1.4 -apple-system, system-ui, sans-serif; color: var(--muted); margin-top: 2px; }
.share { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.share .actions { display: flex; flex-direction: column; gap: 8px; }
.share input { width: 100%; font: 12px ui-monospace, Menlo, monospace; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.qr { background: #fff; padding: 8px; border-radius: 8px; line-height: 0; }
.qr img, .qr canvas { width: 116px; height: 116px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 9999; }
.toast.show { opacity: 1; }
