:root {
  --bg: #03060a;
  --ink: #d8f6ff;
  --dim: #7fa3b3;
  --faint: #3b5664;
  --glow: #00e5ff;
  --glass: rgba(6, 14, 20, 0.78);
  --line: rgba(0, 229, 255, 0.18);
  --vodovod: #38b6ff;
  --kanalizacija: #4be38a;
  --plin: #ffd84a;
  --elektrika: #ff4f5e;
  --telekom: #ff9a3c;
  --toplota: #c77dff;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); overflow: hidden; }
button { font: inherit; color: inherit; }
#map { position: fixed; inset: 0; }
.maplibregl-canvas { outline: none; }
.maplibregl-ctrl-group { background: var(--glass); border: 1px solid var(--line); box-shadow: none; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line); }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) sepia(1) hue-rotate(150deg) saturate(3); }
.maplibregl-ctrl-attrib { display: none; }

/* X-ray film: scan lines, grain-like stripes and a vignette over the map. */
.film {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.65) 100%),
    repeating-linear-gradient(0deg, rgba(0, 229, 255, 0.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
}

/* Brand */
.brand {
  position: fixed; z-index: 3; top: calc(14px + env(safe-area-inset-top, 0px)); left: 16px;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand h1 { margin: 0; font-size: 17px; letter-spacing: 0.32em; text-transform: uppercase; font-weight: 700; text-shadow: 0 0 12px rgba(0, 229, 255, 0.6); }
.brand p { margin: 0; color: var(--dim); font-size: 12px; }
.logo { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--glow); position: relative; box-shadow: 0 0 14px rgba(0, 229, 255, 0.5), inset 0 0 10px rgba(0, 229, 255, 0.35); }
.logo span { position: absolute; inset: 6px; border-radius: 50%; background: conic-gradient(from 0deg, rgba(0, 229, 255, 0.9), transparent 35%); animation: spin 2.4s linear infinite; }
.tools { display: flex; gap: 6px; margin-left: 6px; }
.r-btn { gap: 5px; font: 11px ui-monospace, monospace; white-space: nowrap; }
.icon, .lang {
  height: 32px; min-width: 32px; padding: 0 8px; border-radius: 9px; cursor: pointer;
  background: rgba(0, 229, 255, 0.06); border: 1px solid var(--line); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; letter-spacing: 0.08em;
  transition: background 0.2s, border-color 0.2s;
}
.icon:hover, .lang:hover { background: rgba(0, 229, 255, 0.16); border-color: rgba(0, 229, 255, 0.5); }
.icon.busy svg { animation: spin 1.2s linear infinite; }

/* Byte meter: the punchline */
.meter {
  position: fixed; z-index: 3; top: calc(14px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  min-width: 360px; padding: 10px 16px 12px; text-align: center;
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-family: var(--mono);
}
.meter-main { font-size: 13px; color: var(--dim); }
.meter-main b { font-size: 22px; color: var(--ink); font-weight: 600; text-shadow: 0 0 14px rgba(0, 229, 255, 0.55); font-variant-numeric: tabular-nums; }
.meter-main #m-total { font-size: 15px; color: var(--dim); text-shadow: none; }
.meter .lbl { margin: 0 4px; }
.meter-sub { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 2px; font-size: 12px; color: var(--dim); }
.meter-sub b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.meter-sub .zero b { color: var(--glow); text-shadow: 0 0 10px var(--glow); }
.meter-sec { margin-top: 3px; text-align: center; font: 11px ui-monospace, monospace; color: #bff6ff; }
.meter-bar { height: 2px; margin-top: 8px; background: rgba(0, 229, 255, 0.1); border-radius: 2px; overflow: hidden; }
.meter-bar i { display: block; height: 100%; width: 0; background: var(--glow); box-shadow: 0 0 8px var(--glow); transition: width 0.4s ease; }
.log-toggle { margin-top: 8px; padding: 2px 10px; border-radius: 99px; background: none; border: 1px solid var(--line); color: var(--dim); font: 11px var(--mono); cursor: pointer; letter-spacing: 0.05em; }
.log-toggle:hover, .log-toggle[aria-expanded="true"] { color: var(--ink); border-color: rgba(0, 229, 255, 0.5); }
.meter.pulse b#m-bytes { animation: flash 0.5s ease; }

/* Intro card */
.intro {
  position: fixed; z-index: 3; left: 16px; bottom: calc(44px + env(safe-area-inset-bottom, 0px)); width: min(420px, calc(100vw - 32px));
  padding: 16px 18px; background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.4s, transform 0.4s;
}
.intro.gone { opacity: 0; transform: translateY(10px); pointer-events: none; }
.intro h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.intro p { margin: 0 0 10px; color: var(--dim); }
.examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--dim); font-size: 12px; }
.examples button { padding: 4px 10px; border-radius: 99px; background: rgba(0, 229, 255, 0.06); border: 1px solid var(--line); cursor: pointer; font-size: 12px; }
.examples button:hover { background: rgba(0, 229, 255, 0.16); border-color: rgba(0, 229, 255, 0.5); }
.boot { margin: 10px 0 0 !important; font: 11px var(--mono); color: var(--faint) !important; }
.boot.err { color: var(--elektrika) !important; }

/* Panel */
.panel {
  position: fixed; z-index: 4; top: calc(14px + env(safe-area-inset-top, 0px)); right: 16px; bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  width: min(400px, calc(100vw - 32px)); overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 18px 22px; background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: slidein 0.35s ease;
  scrollbar-width: thin; scrollbar-color: var(--faint) transparent;
}
.panel[hidden] { display: none; }
.scanline { position: sticky; top: -18px; height: 0; z-index: 2; }
.panel.scanning .scanline::after {
  content: ""; position: absolute; left: -18px; right: -18px; top: 0; height: 70px;
  background: linear-gradient(180deg, transparent, rgba(0, 229, 255, 0.10) 70%, rgba(0, 229, 255, 0.55) 98%, transparent);
  animation: sweep 1.6s linear infinite; pointer-events: none;
}
.close { position: absolute; top: 10px; right: 12px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--dim); font-size: 20px; line-height: 1; cursor: pointer; }
.close:hover { color: var(--ink); border-color: var(--line); }
.coords { font: 11px var(--mono); color: var(--faint); margin-bottom: 12px; padding-right: 30px; }
.coords b { color: var(--dim); font-weight: 500; }
.coords small { font-size: 9px; opacity: .7; margin-right: 4px; }
.coords div + div { margin-top: 2px; }

/* Synthesis */
.synth { margin-bottom: 14px; }
.synth h3, .sec h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--glow); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.synth h3::after, .sec h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.fact { position: relative; padding: 9px 11px 9px 12px; margin-bottom: 7px; border-radius: 10px; background: rgba(0, 229, 255, 0.05); border: 1px solid rgba(0, 229, 255, 0.12); animation: rise 0.45s ease both; }
.fact .t { font-size: 14px; }
.fact .t strong { font-weight: 600; color: #fff; }
.fact .s { color: var(--dim); font-size: 12px; margin-top: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { font: 10px var(--mono); letter-spacing: 0.04em; padding: 1px 6px; border-radius: 99px; color: var(--glow); border: 1px solid rgba(0, 229, 255, 0.3); background: rgba(0, 229, 255, 0.06); }
.tag + .tag::before { content: "+ "; color: var(--faint); }
.big { font: 600 26px/1.1 var(--mono); color: #fff; text-shadow: 0 0 12px rgba(0, 229, 255, 0.5); }
.bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, rgba(255, 255, 255, 0.6), #fff); box-shadow: 0 0 10px rgba(255, 255, 255, 0.6); width: 0; transition: width 0.9s cubic-bezier(.2, .8, .2, 1); }
.reach { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 6px; }
.reach span { font: 11px var(--mono); padding: 4px 6px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, 0.08); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reach span.on { color: var(--ink); border-color: currentColor; }
.reach span.on b { color: var(--c); }
.reach span i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); margin-right: 5px; vertical-align: 0; opacity: 0.35; }
.reach span.on i { opacity: 1; }
.conn { list-style: none; margin: 6px 0 0; padding: 0; font: 11px var(--mono); color: var(--dim); }
.conn li { padding: 2px 0; }
.conn li i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); margin-right: 6px; }
.conn b.agree { color: #4be38a; font-weight: 600; }
.conn b.disagree { color: #ffb84a; font-weight: 600; }

/* Sections, top to bottom */
.sec { margin-top: 14px; animation: rise 0.45s ease both; }
.row { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; border-bottom: 1px dashed rgba(0, 229, 255, 0.08); }
.row:last-child { border-bottom: 0; }
.row .k { flex: 0 0 112px; color: var(--dim); font-size: 12px; }
.row .v { flex: 1; min-width: 0; }
.row .v small { color: var(--dim); }
.row .b { font: 10px var(--mono); color: var(--faint); white-space: nowrap; }
.row.wait .v { color: var(--faint); }
.row.wait .v::after { content: ""; display: inline-block; width: 60px; height: 8px; margin-left: 2px; border-radius: 4px; background: linear-gradient(90deg, rgba(0, 229, 255, 0.05), rgba(0, 229, 255, 0.25), rgba(0, 229, 255, 0.05)); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; }
.net { padding: 7px 0; border-bottom: 1px dashed rgba(0, 229, 255, 0.08); }
.net:last-child { border-bottom: 0; }
.net .h { display: flex; align-items: center; gap: 8px; }
.net .h i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); flex: 0 0 auto; }
.net .h .n { flex: 1; }
.net.none .h i { opacity: 0.25; box-shadow: none; }
.net.none .h .n { color: var(--faint); }
.net .d { font: 11px var(--mono); color: var(--dim); }
.net ul { list-style: none; margin: 4px 0 0 18px; padding: 0; font-size: 12px; color: var(--dim); }
.net li { padding: 1px 0; }
.net li b { color: var(--ink); font-weight: 500; }
.err { color: var(--elektrika); font-size: 12px; }

/* Click marker: rings while scanning, a dot after. */
.probe { position: relative; width: 0; height: 0; pointer-events: none; }
.probe i { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 0 12px var(--glow), 0 0 28px var(--glow); }
.probe b { position: absolute; left: -60px; top: -60px; width: 120px; height: 120px; border-radius: 50%; border: 1px solid rgba(0, 229, 255, 0.7); opacity: 0; }
.probe.scan b { animation: ring 1.6s ease-out infinite; }
.probe.scan b:nth-child(3) { animation-delay: 0.53s; }
.probe.scan b:nth-child(4) { animation-delay: 1.06s; }
.probe s { position: absolute; left: -90px; top: -90px; width: 180px; height: 180px; border-radius: 50%; background: conic-gradient(from 0deg, rgba(0, 229, 255, 0.35), transparent 22%); opacity: 0; transition: opacity 0.4s; }
.probe.scan s { opacity: 1; animation: spin 1.4s linear infinite; }
.lbl-m { font: 11px var(--mono); color: #fff; padding: 1px 6px; border-radius: 6px; background: rgba(3, 6, 10, 0.75); border: 1px solid rgba(255, 255, 255, 0.25); white-space: nowrap; pointer-events: none; }
.hover-name { position: fixed; z-index: 2; pointer-events: none; font: 12px var(--sans); color: var(--ink); padding: 2px 8px; border-radius: 6px; background: var(--glass); border: 1px solid var(--line); transform: translate(12px, 12px); }

/* Request log */
.log {
  position: fixed; z-index: 5; left: 16px; bottom: calc(40px + env(safe-area-inset-bottom, 0px)); width: min(760px, calc(100vw - 32px)); max-height: 44vh;
  display: flex; flex-direction: column; background: rgba(3, 7, 11, 0.92); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: rise 0.3s ease;
}
.log[hidden] { display: none; }
.log-head { padding: 10px 14px 6px; display: flex; flex-direction: column; gap: 2px; }
.log-head b { font-size: 12px; }
.log-head span { font: 11px var(--mono); color: var(--faint); }
.log-scroll { overflow: auto; padding: 0 6px 8px; }
.log table { width: 100%; border-collapse: collapse; font: 11px var(--mono); }
.log th { position: sticky; top: 0; text-align: left; color: var(--faint); font-weight: 500; padding: 4px 8px; background: rgba(3, 7, 11, 0.98); }
.log td { padding: 2px 8px; white-space: nowrap; color: var(--dim); }
.log td.f { max-width: 280px; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.log td.n { text-align: right; font-variant-numeric: tabular-nums; }
.log tr.new td { animation: flashrow 0.8s ease; }
.log .k { font-size: 10px; padding: 0 5px; border-radius: 4px; border: 1px solid; }
.log .k.http { color: var(--glow); }
.log .k.mem { color: var(--kanalizacija); }
.log tr.memrow td { opacity: 0.6; }

.foot {
  position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 6px; justify-content: center; font-size: 11px; color: var(--faint); pointer-events: none;
}
.foot a { color: var(--dim); text-decoration: none; pointer-events: auto; }
.foot a:hover { color: var(--glow); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ring { 0% { transform: scale(0.1); opacity: 0.9; } 100% { transform: scale(1.4); opacity: 0; } }
@keyframes sweep { 0% { transform: translateY(-70px); } 100% { transform: translateY(100vh); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes flash { 0% { color: #fff; text-shadow: 0 0 24px var(--glow); } 100% { } }
@keyframes flashrow { from { background: rgba(0, 229, 255, 0.18); } to { background: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Phone: meter on top, panel as a bottom sheet. */
@media (max-width: 760px) {
  .brand { left: 10px; right: 10px; top: calc(8px + env(safe-area-inset-top, 0px)); padding: 7px 8px 7px 10px; }
  .brand .tools { margin-left: auto; }
  .brand p { display: none; }
  .meter { top: calc(62px + env(safe-area-inset-top, 0px)); min-width: 0; width: calc(100vw - 20px); padding: 7px 10px 9px; }
  .meter-main b { font-size: 18px; }
  .meter-sub { gap: 10px; font-size: 11px; }
  .intro { left: 10px; right: 10px; width: auto; bottom: calc(34px + env(safe-area-inset-bottom, 0px)); padding: 12px 14px; }
  .intro p { font-size: 13px; }
  .panel { top: auto; left: 0; right: 0; width: auto; bottom: 0; max-height: 58vh; border-radius: 16px 16px 0 0; padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px)); animation: sheet 0.35s ease; }
  .row .k { flex-basis: 92px; }
  .log { left: 10px; right: 10px; width: auto; bottom: auto; top: calc(150px + env(safe-area-inset-top, 0px)); max-height: 50vh; }
  .log td.f { max-width: 150px; }
  .foot { display: none; }
  .maplibregl-ctrl-bottom-right { display: none; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Attribute and section popups */
.rg-pop .maplibregl-popup-content { background: #0b1220ee; color: #d7e6f5; border: 1px solid #1f3b57; border-radius: 8px; padding: 10px 12px; box-shadow: 0 6px 24px #0008; font: 12px system-ui, sans-serif; }
.rg-pop .maplibregl-popup-tip { border-top-color: #1f3b57; border-bottom-color: #1f3b57; }
.rg-pop .maplibregl-popup-close-button { color: #9fb6cc; font-size: 16px; }
.pop h4 { margin: 0 0 6px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: #7fe9ff; }
.pop table { border-collapse: collapse; max-height: 260px; display: block; overflow: auto; }
.pop th { text-align: left; font-weight: 500; color: #8aa3bb; padding: 1px 10px 1px 0; vertical-align: top; white-space: nowrap; }
.pop td { color: #e8f2fb; padding: 1px 0; word-break: break-word; }
.pop p { margin: 0 0 8px; font: 11px ui-monospace, monospace; color: #9fb6cc; }
.pop button { display: block; width: 100%; padding: 7px 10px; border: 1px solid #00e5ff88; border-radius: 6px; background: #00e5ff1a; color: #bff6ff; font: 600 12px system-ui, sans-serif; cursor: pointer; }
.pop button:hover { background: #00e5ff33; }
.pop small { display: block; margin-top: 6px; color: #7d93a8; font-size: 10px; }

/* Layer menu */
.brand { position: relative; }
.layers-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; width: min(300px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  background: #0b1220f2; border: 1px solid #1f3b57; border-radius: 10px; padding: 10px 12px; box-shadow: 0 8px 28px #0009; font: 12px system-ui, sans-serif; color: #d7e6f5; }
.layers-menu fieldset { border: 0; margin: 0 0 8px; padding: 0; }
.layers-menu legend { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: #7fe9ff; margin-bottom: 4px; }
.layers-menu legend .b { color: #7d93a8; text-transform: none; letter-spacing: 0; margin-left: 6px; font-family: ui-monospace, monospace; }
.layers-menu label { display: inline-flex; align-items: center; gap: 5px; margin: 2px 12px 2px 0; cursor: pointer; }
.layers-menu input { accent-color: #00e5ff; }
.layers-menu .radius input[type=range] { width: 100%; margin: 2px 0; }
.r-warn { margin: 6px 0 2px; padding: 6px 8px; border-radius: 7px; border: 1px solid #ffd84a55; background: #ffd84a12; color: #f3e6b0; font-size: 11px; line-height: 1.35; }
.r-warn summary { display: flex; gap: 7px; align-items: flex-start; cursor: pointer; list-style: none; }
.r-warn summary::-webkit-details-marker { display: none; }
.r-warn summary u { color: #ffd84a; text-underline-offset: 2px; }
.r-warn[open] summary u { display: none; }
.r-warn summary svg { flex: 0 0 auto; margin-top: 1px; }
.r-warn p { margin: 6px 0 0 23px; color: #e6dcb8; }
.r-warn[hidden] { display: none; }
.r-est { margin: 4px 0 0; color: #bff6ff; font: 11px ui-monospace, monospace; line-height: 1.35; }
.r-est:empty { display: none; }
.layers-menu small { display: block; color: #7d93a8; font-size: 10px; margin-top: 2px; }

/* Search */
.search { flex: 1 1 160px; min-width: 0; max-width: 300px; margin-left: auto; }
.search input { width: 100%; box-sizing: border-box; padding: 7px 10px; border-radius: 8px; border: 1px solid rgba(0, 229, 255, 0.3);
  background: rgba(8, 16, 28, 0.85); color: #e8f2fb; font: 13px system-ui, sans-serif; }
.search input::placeholder { color: #7d93a8; }
.search input:focus { outline: none; border-color: rgba(0, 229, 255, 0.7); box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.15); }
.search { position: relative; }
.sugg { position: absolute; top: calc(100% + 6px); left: 0; z-index: 25; width: max(100%, min(340px, calc(100vw - 32px)));
  background: #0b1220f2; border: 1px solid #1f3b57; border-radius: 10px; box-shadow: 0 8px 28px #0009; font: 12px system-ui, sans-serif; color: #d7e6f5; overflow: hidden; }
.sugg ul { list-style: none; margin: 0; padding: 4px 0; max-height: min(50vh, 360px); overflow: auto; }
.sugg li { display: flex; align-items: baseline; gap: 8px; padding: 5px 10px; cursor: pointer; }
.sugg li[aria-selected="true"], .sugg li:hover { background: #00e5ff1f; }
.sugg li b { font-weight: 600; color: #e8f2fb; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg li small { margin-left: auto; color: #7d93a8; font-size: 10px; white-space: nowrap; }
.sugg-note { margin: 0; padding: 5px 10px 6px; border-top: 1px solid #1f3b57; color: #7d93a8; font: 10px ui-monospace, monospace; }
.sugg-note:empty { display: none; }
.coords .found { color: #7d93a8; font: 10px ui-monospace, monospace; margin-top: 3px; }
