[hidden] { display: none !important; }
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --top-h: calc(52px + var(--sat));
  --bot-h: calc(76px + var(--sab));
  --green: #1f4d2b;
  --green-2: #2e7d32;
  --accent: #ffb300;
  --danger: #c62828;
  --tap: 48px;
}
body[data-theme="dark"] {
  --bg: #0d0f0d; --panel: #161a16; --panel-2: #222822; --fg: #ffffff; --muted: #c9d1c9;
  --border: #4a564a; --btn: #2b332b; --overlay: rgba(10,12,10,.88);
}
body[data-theme="light"] {
  --bg: #ffffff; --panel: #ffffff; --panel-2: #eef2ee; --fg: #000000; --muted: #2b2b2b;
  --border: #6b6b6b; --btn: #e6ebe6; --overlay: rgba(255,255,255,.94);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

#topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--top-h); padding: var(--sat) calc(8px + var(--sar)) 0 calc(12px + var(--sal));
  background: var(--green); color: #fff; display: flex; align-items: center; gap: 10px; z-index: 1000; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
#topbar h1 { font-size: 20px; margin: 0; flex: 1; font-weight: 800; letter-spacing: .2px; white-space: nowrap; }
.badge { font-size: 14px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 2px solid #fff; }
.badge.online { background: #43a047; color: #fff; }
.badge.offline { background: var(--accent); color: #000; border-color: #000; }
.iconbtn { min-width: var(--tap); min-height: var(--tap); border: 0; background: transparent; font-size: 24px; border-radius: 12px; }
#topbar .iconbtn { color: #fff; }

#map { position: fixed; top: var(--top-h); bottom: var(--bot-h); left: 0; right: 0; background: #ddd; }
body[data-theme="dark"] #map { background: #222; }
body[data-theme="dark"].dim-map .leaflet-tile-pane { filter: brightness(.78) contrast(1.05); }

#bottombar { position: fixed; bottom: 0; left: 0; right: 0; height: var(--bot-h); padding: 6px calc(6px + var(--sar)) calc(6px + var(--sab)) calc(6px + var(--sal));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--panel); border-top: 2px solid var(--border); z-index: 1000; }
.bigbtn { min-height: 62px; border: 2px solid var(--border); background: var(--btn); border-radius: 14px; font-size: 14px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.bigbtn span { font-size: 24px; line-height: 1; }
.bigbtn:active, .fab:active, .btn:active { transform: scale(.96); }
.bigbtn.active { background: var(--green-2); color: #fff; border-color: #fff; }

#readout { position: fixed; top: calc(var(--top-h) + 8px); left: calc(8px + var(--sal)); z-index: 900; background: var(--overlay); color: var(--fg);
  border: 2px solid var(--border); border-radius: 12px; padding: 6px 10px; font: 600 14px/1.3 ui-monospace, Menlo, Consolas, monospace; max-width: 62vw; }
#mapCtrls { position: fixed; top: calc(var(--top-h) + 8px); right: calc(8px + var(--sar)); z-index: 900; display: flex; flex-direction: column; gap: 10px; }
.fab { width: 54px; height: 54px; border-radius: 50%; border: 2px solid var(--border); background: var(--overlay); font-size: 24px; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.fab.recording { background: var(--danger); color: #fff; border-color: #fff; animation: pulse 1.6s infinite; }
.fab.paused { background: var(--accent); color: #000; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(198,40,40,.35); } }
#recStats { position: fixed; bottom: calc(var(--bot-h) + 8px); left: 8px; right: 8px; z-index: 900; display: flex; flex-wrap: wrap; gap: 4px 14px;
  justify-content: center; background: var(--overlay); border: 2px solid var(--danger); border-radius: 12px; padding: 6px 10px; font: 700 16px ui-monospace, Menlo, monospace; }
#rsState { color: var(--danger); }
#crosshair { position: fixed; z-index: 800; pointer-events: none; font-size: 34px; color: #d50000; text-shadow: 0 0 3px #fff, 0 0 3px #fff;
  left: 50%; top: calc((var(--top-h) + (100vh - var(--bot-h))) / 2); transform: translate(-50%, -50%); }

#sheetBackdrop { position: fixed; inset: 0; z-index: 1090; background: rgba(0,0,0,.25); }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; max-height: 78vh; background: var(--panel); color: var(--fg);
  border-top: 3px solid var(--green-2); border-radius: 18px 18px 0 0; transform: translateY(105%); transition: transform .22s ease-out;
  display: flex; flex-direction: column; padding-bottom: var(--sab); box-shadow: 0 -4px 16px rgba(0,0,0,.45); }
#sheet.open { transform: translateY(0); }
#sheet.peek { max-height: 46vh; }
.sheet-head { display: flex; align-items: center; padding: 6px 8px 0 16px; }
.sheet-head h2 { flex: 1; font-size: 19px; margin: 0; }
#sheetBody { overflow-y: auto; padding: 4px 16px 16px; -webkit-overflow-scrolling: touch; }

.btn { min-height: var(--tap); padding: 10px 16px; border: 2px solid var(--border); background: var(--btn); border-radius: 12px; font-weight: 700; }
.btn.primary { background: var(--green-2); color: #fff; border-color: var(--green-2); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { min-height: 44px; padding: 6px 12px; font-size: 15px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.row > .btn.grow { flex: 1; }
.opt { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 10px; border: 2px solid var(--border); border-radius: 12px; margin: 8px 0; background: var(--panel-2); }
.opt input[type=radio], .opt input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--green-2); }
.opt small { display: block; color: var(--muted); font-size: 13px; }
label.field { display: block; margin: 10px 0; font-weight: 700; }
label.field input, label.field textarea, label.field select { display: block; width: 100%; margin-top: 4px; min-height: var(--tap); font: inherit; padding: 8px 10px;
  border: 2px solid var(--border); border-radius: 10px; background: var(--panel-2); color: var(--fg); }
.iconpick { display: flex; flex-wrap: wrap; gap: 6px; }
.iconpick button { width: 52px; height: 52px; font-size: 26px; border: 2px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.iconpick button.sel { border-color: var(--accent); background: var(--green-2); }
.tabs { display: flex; gap: 6px; margin: 6px 0 10px; }
.tabs button { flex: 1; min-height: var(--tap); border: 2px solid var(--border); border-radius: 12px; background: var(--btn); font-weight: 700; }
.tabs button.sel { background: var(--green-2); color: #fff; border-color: var(--green-2); }
ul.items { list-style: none; padding: 0; margin: 0; }
ul.items li { border: 2px solid var(--border); border-radius: 12px; padding: 8px 10px; margin: 8px 0; background: var(--panel-2); }
ul.items .title { font-weight: 800; font-size: 17px; }
ul.items .sub { color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.stats div { background: var(--panel-2); border: 2px solid var(--border); border-radius: 10px; padding: 6px; text-align: center; font-size: 13px; color: var(--muted); }
.stats b { display: block; font-size: 18px; color: var(--fg); }
canvas.profile { width: 100%; height: 200px; display: block; border: 2px solid var(--border); border-radius: 10px; background: var(--panel-2); touch-action: none; }
progress { width: 100%; height: 22px; accent-color: var(--green-2); }
.warn { border-left: 5px solid var(--accent); background: var(--panel-2); padding: 8px 10px; border-radius: 8px; font-size: 14px; margin: 8px 0; }
.muted { color: var(--muted); font-size: 14px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bot-h) + 70px); z-index: 1200; background: #000; color: #fff;
  border: 2px solid #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; max-width: 90vw; text-align: center; }

/* map markers */
.wp-icon { font-size: 28px; line-height: 1; text-shadow: 0 0 3px #fff, 0 0 3px #fff; display: flex; justify-content: center; align-items: flex-end; }
.wp-icon span { display: block; }
.heading-cone { width: 0; height: 0; }
.me-dot { width: 20px; height: 20px; border-radius: 50%; background: #1e88e5; border: 3px solid #fff; box-shadow: 0 0 0 2px #1e88e5, 0 0 8px rgba(0,0,0,.6); }
.me-wrap { position: relative; width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; }
.me-head { position: absolute; top: 0; left: 50%; width: 0; height: 0; margin-left: -9px; border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-bottom: 22px solid rgba(30,136,229,.85); transform-origin: 9px 30px; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 11px; max-width: 70vw; }
.leaflet-control-zoom a { width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 24px !important; }
.leaflet-top.leaflet-left { top: 92px; }
.leaflet-tooltip.wp-label { font-weight: 700; font-size: 13px; padding: 2px 6px; }

/* place search */
.topbtn { min-height: 44px; padding: 4px 12px; border: 2px solid #fff; border-radius: 12px; background: rgba(255,255,255,.14); color: #fff;
  font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.topbtn span { font-size: 20px; line-height: 1; }
.topbtn.active { background: #fff; color: var(--green); }
#searchPanel { position: fixed; top: var(--top-h); left: 0; right: 0; z-index: 1150; max-height: calc(100vh - var(--top-h) - var(--bot-h) - 10px);
  display: flex; flex-direction: column; background: var(--panel); color: var(--fg); border-bottom: 3px solid var(--green-2);
  box-shadow: 0 6px 16px rgba(0,0,0,.5); padding: 10px calc(10px + var(--sar)) 6px calc(10px + var(--sal)); border-radius: 0 0 16px 16px; }
.sbar { display: flex; gap: 6px; align-items: center; }
#searchInput { flex: 1; min-width: 0; min-height: 56px; font-family: inherit; font-size: 20px; font-weight: 700; padding: 8px 12px; border: 3px solid var(--border);
  border-radius: 12px; background: var(--panel-2); color: var(--fg); }
#searchInput:focus { outline: none; border-color: var(--accent); }
.sbar .btn { min-height: 56px; min-width: 56px; font-size: 18px; }
.sbar .iconbtn { min-height: 56px; min-width: 48px; color: var(--fg); }
.sstatus { margin: 8px 2px 0; font-size: 15px; color: var(--fg); }
.sstatus.warn { border-left: 5px solid var(--accent); background: var(--panel-2); padding: 8px 10px; border-radius: 8px; }
#searchResults { list-style: none; padding: 0; margin: 6px 0 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#searchResults .shead { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 6px 2px 2px; }
#searchResults .btn.small { margin: 6px 0; }
.sres { width: 100%; min-height: 60px; display: flex; align-items: center; gap: 12px; text-align: left; margin: 6px 0; padding: 8px 12px;
  border: 2px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.sres:active { transform: scale(.98); border-color: var(--accent); }
.sres .sic { font-size: 26px; width: 32px; text-align: center; flex: none; }
.sres b { display: block; font-size: 18px; }
.sres small { display: block; color: var(--muted); font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sattrib { margin: 6px 2px 2px; font-size: 12px; }
.sattrib a, .spop a { color: inherit; }
.search-pin { font-size: 38px; line-height: 1; text-shadow: 0 0 4px #fff, 0 0 4px #fff; display: flex; justify-content: center; align-items: flex-end; }
.spop b { display: block; font-size: 17px; } .spop small { display: block; font-size: 13px; color: #444; }
@media (max-width: 360px) { #topbar h1 { font-size: 17px; } .topbtn { padding: 4px 8px; } }
