/* Patrol map. Built for night use on a phone: dark surfaces to keep night vision,
   big thumb targets at the bottom, colour reserved for meaning:
   cone orange = you and your actions, green = on patrol, red = SOS only. */
:root {
  /* Lorraine Neighbourhood Watch: royal blue, gold and white (from the badge), Montserrat. */
  --asphalt: #0A1640;
  --kerb: #12215A;
  --kerb-2: #1A2D72;
  --line: #2B3F88;
  --reflector: #F4F6FB;
  --muted: #A7B2D4;
  --cone: #F2C014;
  --cone-ink: #0A1640;
  --royal: #0C2484;
  --live: #34C77B;
  --siren: #E5252A;
  --sodium: #FF9F43;
  --sky: #6FA8FF;
  --tabs-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --radius: 14px;
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-cond: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--asphalt);
  color: var(--reflector);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.tool svg, .tabs svg { width: 22px; height: 22px; }
a { color: var(--cone); }

/* ---------- gate (login / pending) ---------- */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--asphalt); z-index: 50; }
.gate-card { max-width: 26rem; width: 100%; }
.gate-logo { width: 128px; height: 128px; display: block; filter: drop-shadow(0 4px 14px rgba(0, 0, 0, .45)); }
.gate h1 { font: 800 1.75rem/1.15 var(--font-cond); margin: 18px 0 8px; }
.gate p { color: var(--muted); margin: 0 0 20px; max-width: 34ch; }
.gate-actions { display: grid; gap: 10px; }
.gate-actions .note { font-size: .92rem; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0;
  font: 700 1rem/1.1 var(--font-cond); text-decoration: none;
  background: var(--kerb-2); color: var(--reflector);
}
.btn.small { min-height: 38px; padding: 0 12px; font-size: .95rem; border-radius: 10px; }
.btn.primary { background: var(--cone); color: var(--cone-ink); }
.btn.go { background: var(--live); color: #062012; }
.btn.danger { background: transparent; color: #FF8F8A; box-shadow: inset 0 0 0 1.5px #7A2E2C; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.light { background: #fff; color: #23090A; }
.btn.ghost-light { background: transparent; color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .6); }
.btn.sos-solid { background: #fff; color: var(--siren); font-size: 1.25rem; min-height: 58px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.tool {
  width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: rgba(10, 22, 64, .92); color: var(--reflector); box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.tool.flat { background: transparent; box-shadow: none; }
.tool.active { color: var(--cone); }

/* ---------- map ---------- */
.app { position: fixed; inset: 0; }
.map { position: absolute; inset: 0; z-index: 0; background: #0A1028; }
.map.night .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.85) saturate(.4) sepia(.35) hue-rotate(185deg) saturate(1.5); }
.leaflet-container { font: 14px/1.4 var(--font); background: #0A1028; }
/* Google Maps (public/gmap.js): stop above the tabs so Google's logo and credits stay visible. */
.map.gmap { bottom: calc(var(--tabs-h) + var(--safe-b)); }
.gm-icon { position: relative; }
.gm-tip { position: absolute; z-index: 5; pointer-events: none; padding: 3px 8px; border-radius: 8px; background: rgba(10, 22, 64, .92); color: var(--reflector); font: 600 .8rem/1.2 var(--font); white-space: nowrap; }
.gm-tip[hidden] { display: none; }
.leaflet-bottom.leaflet-right { bottom: calc(var(--tabs-h) + var(--safe-b)); }
.leaflet-control-attribution {
  background: transparent !important; color: var(--muted) !important; font-size: 10px; line-height: 14px;
  margin: 0 !important; padding: 0 8px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-tooltip.route-label {
  background: var(--kerb); color: var(--reflector); border: 0; border-radius: 6px;
  font: 600 .8rem var(--font-cond); padding: 2px 6px; box-shadow: none;
}
.leaflet-tooltip.route-label::before { display: none; }

/* patroller pin */
.pm-pin {
  --c: var(--sky);
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--asphalt); border: 3px solid var(--c); color: var(--c);
  display: grid; place-items: center;
  font: 700 .82rem/1 var(--font-cond); letter-spacing: .02em;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35), 0 3px 8px rgba(0, 0, 0, .45);
  transition: opacity .3s;
}
.pm-pin.stale { opacity: .55; border-style: dashed; }
.pm-pin.sos { border-color: var(--siren); color: #fff; background: var(--siren); }
.pm-pin.mine { --c: var(--cone); }

/* you */
.pm-me { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 5px solid var(--cone); box-shadow: 0 0 0 3px rgba(242, 192, 20, .32), 0 2px 6px rgba(0, 0, 0, .5); }
.pm-me.off { border-color: var(--muted); box-shadow: 0 0 0 3px rgba(167, 178, 212, .25); }

/* SOS beacon */
.pm-beacon { position: relative; width: 26px; height: 26px; }
.pm-beacon i { position: absolute; inset: 0; border-radius: 50%; background: var(--siren); box-shadow: 0 0 0 3px #fff; }
.pm-beacon::before, .pm-beacon::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid var(--siren);
  animation: beacon 1.6s ease-out infinite; opacity: 0;
}
.pm-beacon::after { animation-delay: .8s; }
@keyframes beacon { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(3.2); opacity: 0; } }

.pm-endpoint { width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; }

/* ---------- top bar ---------- */
.topbar {
  position: absolute; top: calc(var(--safe-t) + 10px); left: 10px; right: 10px; z-index: 500;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 6px 0 7px; border-radius: 23px;
  background: rgba(10, 22, 64, .92); box-shadow: 0 2px 10px rgba(0, 0, 0, .35); max-width: calc(100vw - 86px);
}
.watch-name { font: 800 1rem/1 var(--font-cond); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.conn.on { background: var(--live); }
.brand-mark { position: relative; width: 32px; height: 32px; flex: none; }
.brand-mark img { width: 32px; height: 32px; display: block; }
.brand-mark .conn { position: absolute; right: -2px; bottom: -1px; width: 11px; height: 11px; box-shadow: 0 0 0 2px var(--asphalt); }
.out-pill {
  border: 0; border-radius: 16px; min-height: 34px; padding: 0 11px; white-space: nowrap;
  background: var(--kerb-2); font: 600 .82rem/1 var(--font-cond);
}
.out-pill.has { background: rgba(52, 199, 123, .16); color: var(--live); }
.map-tools { display: grid; gap: 8px; }

/* ---------- banners ---------- */
.banners {
  position: absolute; z-index: 520; left: 10px; right: 66px; top: calc(var(--safe-t) + 64px);
  display: grid; gap: 8px; pointer-events: none;
}
.banner {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: 12px;
  background: var(--kerb); box-shadow: 0 4px 14px rgba(0, 0, 0, .4); max-width: 560px;
}
.banner .txt { flex: 1; min-width: 0; }
.banner b { display: block; font: 700 1.02rem/1.2 var(--font-cond); }
.banner small { display: block; color: var(--muted); font-size: .86rem; }
.banner.sos { background: var(--siren); color: #fff; }
.banner.sos small { color: rgba(255, 255, 255, .85); }
.banner.warn { box-shadow: inset 4px 0 0 var(--sodium), 0 4px 14px rgba(0, 0, 0, .4); }

/* ---------- drawing toolbar ---------- */
.drawbar {
  position: absolute; z-index: 560; left: 10px; right: 10px; top: calc(var(--safe-t) + 10px);
  background: var(--kerb); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5); max-width: 520px;
}
.drawbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drawbar-row:empty { display: none; }
.drawbar-title { font: 700 1.05rem/1.2 var(--font-cond); }
.drawbar-meta { color: var(--muted); font-size: .9rem; }
.drawbar label { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.drawbar input[type=range] { flex: 1; accent-color: var(--cone); }

.history-chip {
  position: absolute; z-index: 530; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 66px);
  display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 14px; border-radius: 24px;
  background: var(--kerb); box-shadow: 0 4px 14px rgba(0, 0, 0, .4); white-space: nowrap; font-weight: 500;
}

/* ---------- dock ---------- */
.dock {
  position: absolute; z-index: 500; left: 10px; right: 10px;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 16px);
  display: flex; align-items: flex-end; gap: 10px; pointer-events: none;
}
.dock > * { pointer-events: auto; }
.patrol-card {
  flex: 1; min-width: 0; max-width: 460px; background: var(--kerb); border-radius: 18px; padding: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.pc-row { display: flex; align-items: center; gap: 10px; }
.pc-status { display: flex; align-items: center; gap: 8px; font: 600 .95rem/1 var(--font-cond); color: var(--muted); }
.pc-status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.patrol-card.on .pc-status { color: var(--live); }
.patrol-card.on .pc-status .dot { background: var(--live); animation: livedot 1.8s ease-in-out infinite; }
@keyframes livedot { 50% { box-shadow: 0 0 0 6px rgba(52, 199, 123, 0); } 0% { box-shadow: 0 0 0 0 rgba(52, 199, 123, .55); } }
.pc-timer { font: 700 1.9rem/1 var(--font-cond); font-variant-numeric: tabular-nums; }
.pc-meta { color: var(--muted); font-size: .92rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-main { flex: 1; min-width: 0; }
.pc-route {
  border: 0; background: transparent; padding: 4px 0; color: var(--muted); font-size: .92rem; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.pc-route b { color: var(--reflector); font-weight: 600; }
.pc-start { width: 100%; min-height: 54px; font-size: 1.15rem; margin-top: 8px; }
.pc-warn { margin-top: 8px; font-size: .88rem; color: var(--sodium); }

.sos-btn {
  position: relative; flex: none; width: 76px; height: 76px; border-radius: 50%; border: 0;
  background: var(--siren); color: #fff; font: 700 1.3rem/1 var(--font-cond); letter-spacing: .04em;
  box-shadow: 0 0 0 4px rgba(229, 37, 42, .25), 0 6px 18px rgba(0, 0, 0, .5);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.sos-btn span { position: relative; }
.sos-ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; }
.sos-ring circle { fill: none; stroke: #fff; stroke-width: 5; stroke-dasharray: 289; stroke-dashoffset: 289; stroke-linecap: round; }
.sos-btn.holding .sos-ring circle { stroke-dashoffset: 0; transition: stroke-dashoffset 1.4s linear; }
.sos-btn.holding { transform: scale(.96); }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 990; left: 50%; top: calc(var(--safe-t) + 12px);
  transform: translate(-50%, -12px); opacity: 0; pointer-events: none; transition: .2s;
  background: var(--reflector); color: var(--asphalt); padding: 10px 16px; border-radius: 12px;
  font-weight: 600; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #FFD9D7; color: #4A0D0B; }

/* ---------- tabs ---------- */
.tabs {
  position: absolute; z-index: 600; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--asphalt); border-top: 1px solid var(--kerb-2);
}
.tabs button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; align-content: center; gap: 3px; font: 600 .8rem/1 var(--font-cond);
}
.tabs button.active { color: var(--cone); }

/* ---------- sheet ---------- */
.sheet {
  position: absolute; z-index: 580; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b));
  max-height: min(68vh, 640px); display: flex; flex-direction: column;
  background: var(--kerb); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .45);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 6px 18px; }
.sheet-head h2 { margin: 0; font: 700 1.35rem/1.1 var(--font-cond); }
.sheet-body { overflow-y: auto; padding: 4px 18px 22px; -webkit-overflow-scrolling: touch; }
.sheet h3 { font: 700 1.05rem/1.2 var(--font-cond); margin: 18px 0 8px; color: var(--reflector); }
.sheet h3:first-child { margin-top: 4px; }
.sheet p.help { color: var(--muted); font-size: .92rem; margin: 4px 0 10px; }
.empty { color: var(--muted); padding: 10px 0; font-size: .95rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--kerb-2); }
.list li:last-child { border-bottom: 0; }
.list li.click { cursor: pointer; }
.list .main { flex: 1; min-width: 0; }
.list .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .sub { color: var(--muted); font-size: .88rem; }
.list .end { text-align: right; font: 600 .95rem/1.2 var(--font-cond); white-space: nowrap; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.swatch.round { border-radius: 50%; }
.swatch.line { width: 22px; height: 4px; border-radius: 2px; }
.check { width: 22px; height: 22px; accent-color: var(--cone); flex: none; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--kerb-2); border-radius: 12px; padding: 10px 12px; }
.stat .v { font: 700 1.6rem/1.05 var(--font-cond); font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: .85rem; }
.stat .s { color: var(--muted); font-size: .8rem; margin-top: 2px; }

.seg { display: inline-flex; background: var(--kerb-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: 600 .9rem/1 var(--font-cond); color: var(--muted); }
.seg button.on { background: var(--asphalt); color: var(--reflector); }

/* forms */
.field { display: grid; gap: 6px; margin: 12px 0; }
.field > span { font-size: .9rem; color: var(--muted); }
.field input[type=text], .field input[type=number], .field input[type=datetime-local], .field input[type=date], .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--asphalt); font-size: 16px;
}
.field textarea { min-height: 80px; resize: vertical; }
.toggle { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.toggle input { width: 22px; height: 22px; accent-color: var(--cone); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 0; border-radius: 20px; padding: 8px 14px; background: var(--kerb-2); color: var(--reflector);
  display: inline-flex; align-items: center; gap: 8px; font: 600 .95rem/1 var(--font-cond);
}
.chip.on { box-shadow: inset 0 0 0 2px var(--cone); }
.colors { display: flex; flex-wrap: wrap; gap: 10px; }
.colors button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.colors button.on { border-color: #fff; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 800; background: rgba(4, 8, 24, .62); display: grid; align-items: end; justify-items: center; }
.modal-card {
  width: 100%; max-width: 480px; background: var(--kerb); border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(18px + var(--safe-b)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .5); max-height: 86vh; overflow-y: auto;
}
.modal-card h2 { font: 700 1.4rem/1.15 var(--font-cond); margin: 0 0 6px; }
.modal-card p { color: var(--muted); margin: 0 0 14px; }
.modal-actions { display: grid; gap: 10px; margin-top: 16px; }
.person-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.person-head .pm-pin { flex: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- SOS alarm ---------- */
.alarm { position: fixed; inset: 0; z-index: 950; background: var(--siren); color: #fff; display: grid; place-items: center; padding: 24px; overflow: hidden; }
.alarm-inner { position: relative; width: 100%; max-width: 420px; text-align: center; }
.alarm-beacon {
  position: relative; width: 96px; height: 96px; margin: 0 auto; border-radius: 50%;
  border: 4px solid #fff; display: grid; place-items: center; font: 700 1.5rem/1 var(--font-cond); letter-spacing: .05em;
}
.alarm-beacon::before, .alarm-beacon::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .7);
  animation: alarm 1.6s ease-out infinite;
}
.alarm-beacon::after { animation-delay: .8s; }
@keyframes alarm { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(2.6); opacity: 0; } }
.alarm h2 { position: relative; font: 700 2.4rem/1.05 var(--font-cond); margin: 40px 0 10px; }
.alarm p { position: relative; font-size: 1.15rem; margin: 0 0 28px; color: rgba(255, 255, 255, .92); }
.alarm-actions { position: relative; display: grid; gap: 12px; }

/* ---------- wider screens ---------- */
@media (min-width: 900px) {
  :root { --tabs-h: 0px; }
  .tabs {
    left: 12px; right: auto; bottom: auto; top: calc(var(--safe-t) + 66px); width: 380px; height: 54px;
    border-radius: 14px; border: 0; background: rgba(10, 22, 64, .95); box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  }
  .tabs button { grid-auto-flow: column; gap: 8px; font-size: .95rem; }
  .brand { max-width: 380px; }
  .sheet { left: 12px; right: auto; width: 380px; top: calc(var(--safe-t) + 128px); bottom: 116px; max-height: none; border-radius: 18px; }
  .dock { left: 404px; right: auto; width: 480px; bottom: 16px; }
  .sheet { bottom: 16px; }
  .leaflet-bottom.leaflet-right { bottom: 0; }
  .banners { left: 404px; right: auto; width: 460px; top: calc(var(--safe-t) + 10px); }
  .drawbar { left: 404px; right: auto; width: 460px; }
  .modal { align-items: center; }
  .modal-card { border-radius: 20px; }
  .history-chip { top: calc(var(--safe-t) + 10px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
  .sos-btn.holding .sos-ring circle { transition-duration: 1.4s !important; }
}

/* ---------- private patrols, perimeter, app download ---------- */
.pc-alt {
  display: block; width: 100%; margin-top: 6px; border: 0; background: transparent; padding: 8px 0 2px;
  color: var(--muted); font: 600 .95rem/1 var(--font-cond); text-decoration: underline; text-underline-offset: 3px;
}
.pc-mode {
  display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 8px 10px; border-radius: 10px;
  background: var(--kerb-2); font-size: .88rem; color: var(--muted);
}
.pc-mode span { flex: 1; min-width: 0; }
.pc-mode.private { box-shadow: inset 3px 0 0 var(--sky); color: var(--reflector); }
.pc-outside { margin-top: 8px; font-size: .88rem; color: var(--sodium); }
.pm-pin.outside { box-shadow: 0 0 0 3px var(--sodium), 0 3px 8px rgba(0, 0, 0, .45); }
.tag { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--kerb-2); color: var(--reflector); font-size: .8rem; line-height: 1.5; }
.tag.amber { background: rgba(255, 159, 67, .16); color: var(--sodium); }
.warn-text { color: var(--sodium); }
.perimeter-note { display: flex; align-items: center; gap: 10px; }
.perimeter-note .swatch.line { background-image: repeating-linear-gradient(90deg, var(--reflector) 0 6px, transparent 6px 9px) !important; background-color: transparent !important; }
.pm-vertex { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 4px solid var(--cone); box-shadow: 0 2px 6px rgba(0, 0, 0, .5); cursor: grab; }
.pm-mid { width: 18px; height: 18px; border-radius: 50%; background: rgba(242, 192, 20, .6); border: 2px solid #fff; cursor: grab; }
.pm-cross { width: 16px; height: 16px; border-radius: 4px; transform: rotate(45deg); border: 2px solid #fff; }
.pm-cross.left { background: var(--sodium); }
.pm-cross.returned { background: var(--live); }
.pm-cross.hidden { background: var(--sky); }

/* ---------- app-only patrols ---------- */
.pc-note { margin: 8px 0 0; font-size: .9rem; color: var(--muted); }
.modal-card ol.steps { list-style: none; counter-reset: s; margin: 4px 0 14px; padding: 0; display: grid; gap: 10px; }
.modal-card ol.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; color: var(--reflector); }
.modal-card ol.steps li::before {
  content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--cone); color: var(--cone-ink); font: 700 .95rem/1 var(--font-cond);
}
.modal-card p.modal-note { font-size: .9rem; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--cone); font: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- how you're patrolling (sign-on message) and route chips ---------- */
.pc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pc-chip {
  border: 0; border-radius: 14px; min-height: 32px; padding: 0 11px; background: var(--kerb-2); color: var(--muted);
  font: 500 .9rem/1 var(--font); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-chip b { color: var(--reflector); font-weight: 600; }
.mode-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 14px; }
.mode-pick { display: inline-flex; align-items: center; border-radius: 18px; background: var(--kerb-2); overflow: hidden; }
.mode-pick button { border: 0; background: transparent; color: var(--reflector); font: 600 .98rem/1 var(--font); min-height: 40px; padding: 0 14px; }
.mode-pick .mode-del { padding: 0 12px 0 4px; color: var(--muted); font-size: 1.2rem; }
.mode-pick.on { background: var(--cone); }
.mode-pick.on button { color: var(--asphalt); }
.mode-add { display: flex; gap: 8px; margin-bottom: 6px; }
.mode-add input { flex: 1; min-width: 0; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--asphalt); color: var(--reflector); padding: 0 12px; font: 400 1rem var(--font); }

/* ---------- tucked controls: a clear map, a small SOS, and the patrol timer ---------- */
#btn-tuck svg { transition: transform .2s; }
.app.tucked #btn-tuck svg { transform: rotate(180deg); }
.app.tucked .map-tools .tool:not(#btn-tuck):not(#loc-state),
.app.tucked .patrol-card,
.app.tucked .watch-name,
.app.tucked .out-pill { display: none; }
.app.tucked .brand { padding-right: 7px; }
.app.tucked .dock { justify-content: flex-end; align-items: center; }
.app.tucked .sos-btn { width: 56px; height: 56px; font-size: 1rem; }
.tuck-chip {
  display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 18px; min-height: 36px; padding: 0 12px;
  background: rgba(10, 22, 64, .92); color: var(--live); font: 700 1rem/1 var(--font-cond); font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.tuck-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--live); }
.tuck-chip[hidden] { display: none; }

/* Google's logo and Terms sit at the bottom of the map: keep the panel and SOS above them. */
.map.gmap ~ .dock { bottom: calc(var(--tabs-h) + var(--safe-b) + 30px); }

/* ---------- group chat ---------- */
.tabs button { position: relative; }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--siren); color: #fff; font: 700 .72rem/18px var(--font); font-style: normal; text-align: center;
}
.badge[hidden] { display: none; }
.sheet.chat { max-height: calc(100% - var(--tabs-h) - var(--safe-b) - var(--safe-t) - 70px); height: calc(100% - var(--tabs-h) - var(--safe-b) - var(--safe-t) - 70px); }
.sheet-foot { padding: 8px 10px calc(10px + 0px); border-top: 1px solid var(--kerb-2); }
.sheet-foot[hidden] { display: none; }
.chat-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 6px; }
.chat-older { display: block; margin: 0 auto 10px; }
.chat-note { background: var(--kerb-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: .92rem; color: var(--muted); }
.chat-note b { display: block; color: var(--reflector); margin-bottom: 4px; }
.chat-demo-note { font-size: .82rem; line-height: 1.35; color: var(--muted); padding: 0 4px 8px; }
.chat-day { align-self: center; font: 600 .78rem/1 var(--font-cond); color: var(--muted); background: var(--kerb-2); padding: 5px 10px; border-radius: 10px; margin: 6px 0 2px; }
.chat-event { align-self: center; max-width: 92%; text-align: center; font-size: .86rem; color: var(--muted); }
.chat-event time { opacity: .75; margin-left: 4px; }
.chat-msg { align-self: flex-start; max-width: 84%; background: var(--asphalt); border-radius: 4px 14px 14px 14px; padding: 7px 10px 6px; }
.chat-msg.mine { align-self: flex-end; background: #1D3A8A; border-radius: 14px 4px 14px 14px; }
.chat-msg.bot { box-shadow: inset 3px 0 0 var(--cone); }
.chat-from { font: 700 .86rem/1.2 var(--font-cond); color: var(--sky); margin-bottom: 3px; }
.chat-text { white-space: normal; overflow-wrap: anywhere; line-height: 1.38; }
.chat-text a { color: var(--sky); }
.chat-sticker { font-size: 2.4rem; line-height: 1.1; }
.chat-meta { font-size: .72rem; color: var(--muted); text-align: right; margin-top: 3px; }
.chat-media { display: block; position: relative; border: 0; padding: 0; margin: 2px 0 4px; width: min(260px, 64vw); max-height: 320px; border-radius: 10px; overflow: hidden; background: var(--kerb-2); }
.chat-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-media img:not([src]) { visibility: hidden; }
.chat-media .play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, .6); color: #fff; border-radius: 18px; padding: 7px 12px; font: 700 .9rem/1 var(--font-cond); }
.chat-file { display: block; border: 0; background: var(--kerb-2); color: var(--reflector); border-radius: 10px; padding: 9px 11px; margin: 2px 0 4px; text-align: left; font: 500 .92rem/1.3 var(--font); text-decoration: none; }
.chat-viewer { display: grid; place-items: center; margin: 4px 0 12px; }
.chat-viewer img, .chat-viewer video { max-width: 100%; max-height: 62vh; border-radius: 12px; }
.chat-viewer audio { width: 100%; }
.chat-compose { display: flex; align-items: flex-end; gap: 6px; }
.chat-compose textarea {
  flex: 1; min-width: 0; resize: none; min-height: 42px; max-height: 120px; border-radius: 21px; border: 1px solid var(--line);
  background: var(--asphalt); color: var(--reflector); padding: 10px 14px; font: 400 1rem/1.3 var(--font);
}
.chat-attach input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chat-attach { position: relative; cursor: pointer; }
.chat-send { background: var(--cone); color: var(--asphalt); }

@media (min-width: 900px) {
  .map.gmap ~ .dock { bottom: 40px; }
  .sheet.chat { height: auto; max-height: none; }
}

/* ---------- beacons: quick reports on the map ---------- */
.dock-side { flex: none; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.report-btn {
  width: 58px; height: 58px; border-radius: 50%; border: 0; padding: 0; background: var(--cone); color: var(--cone-ink);
  display: grid; place-items: center; align-content: center; gap: 2px; font: 700 .6rem/1 var(--font-cond); letter-spacing: .04em; text-transform: uppercase;
  box-shadow: 0 0 0 4px rgba(242, 192, 20, .22), 0 6px 18px rgba(0, 0, 0, .5);
}
.report-btn svg { width: 24px; height: 24px; }
.app.tucked .report-btn { width: 46px; height: 46px; }
.app.tucked .report-btn span { display: none; }
.app.placing .dock, .app.placing .tabs, .app.placing .banners, .app.placing .map-tools .tool:not(#btn-layer) { display: none; }

/* the pin: a teardrop in the beacon's colour with its icon; its tip is the spot */
.pm-bcn { --c: var(--sky); position: relative; width: 40px; height: 48px; }
.pm-bcn::before {
  content: ''; position: absolute; left: 2px; top: 0; width: 36px; height: 36px; box-sizing: border-box;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c); border: 3px solid #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .5);
}
.pm-bcn span { position: absolute; left: 0; top: 0; width: 40px; height: 36px; display: grid; place-items: center; font-size: 18px; line-height: 1; z-index: 1; }
.pm-bcn.new::after {
  content: ''; position: absolute; left: 2px; top: 0; width: 36px; height: 36px; box-sizing: border-box; border-radius: 50%;
  border: 3px solid var(--c); animation: beacon 1.6s ease-out infinite; opacity: 0;
}
.pm-bcn.ending { opacity: .62; }
.pm-bcn.past { opacity: .55; filter: grayscale(.7); }
.person-head .pm-bcn { flex: none; }
.crosshair { position: fixed; z-index: 540; transform: translate(-50%, -100%); pointer-events: none; }
.crosshair::after {
  content: ''; position: absolute; left: 50%; bottom: -5px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .45);
}
.bcn-dot {
  --c: var(--sky); flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--kerb-2);
  box-shadow: inset 0 0 0 2px var(--c); display: grid; place-items: center; font-size: 1.1rem;
}
.list li.past { opacity: .72; }
.bcn-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; }
.bcn-kind {
  --c: var(--sky); border: 0; border-radius: 12px; min-height: 50px; padding: 8px 10px; background: var(--kerb-2); color: var(--reflector);
  display: flex; align-items: center; gap: 10px; font: 600 .92rem/1.15 var(--font-cond); text-align: left; box-shadow: inset 5px 0 0 var(--c);
}
.bcn-kind span { font-size: 1.35rem; line-height: 1; }
.bcn-kind.on { box-shadow: inset 0 0 0 2px var(--cone), inset 7px 0 0 var(--c); background: var(--line); }
.bcn-icons { display: flex; flex-wrap: wrap; gap: 6px; }
.bcn-icons button { width: 42px; height: 42px; border-radius: 10px; border: 0; background: var(--kerb-2); font-size: 1.3rem; line-height: 1; padding: 0; }
.bcn-icons button.on { box-shadow: inset 0 0 0 2px var(--cone); background: var(--line); }
.chip:disabled { opacity: .5; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

/* ---------- route loops ---------- */
.pc-route-prog { margin-top: 6px; font: 600 .92rem/1.2 var(--font-cond); color: var(--cone); }
.pc-route-prog.done { color: var(--live); }
.chips.loops { gap: 6px; }
.chips.loops .chip { min-width: 40px; justify-content: center; padding: 8px 0; }

/* ---------- chat: emojis, @mentions, editing ---------- */
.chat-box { position: relative; flex: 1; min-width: 0; display: flex; }
.chat-box textarea { padding-right: 44px !important; width: 100%; }
.chat-emoji-btn {
  position: absolute; right: 4px; bottom: 3px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; font-size: 1.3rem; line-height: 1; padding: 0; cursor: pointer;
}
.chat-emoji { margin-bottom: 8px; background: var(--asphalt); border-radius: 14px; padding: 6px; }
.emoji-tabs { display: flex; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--kerb-2); margin-bottom: 6px; }
.emoji-tabs button { border: 0; background: transparent; font-size: 1.15rem; width: 38px; height: 32px; border-radius: 8px; padding: 0; opacity: .6; }
.emoji-tabs button.on { background: var(--kerb-2); opacity: 1; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); max-height: 168px; overflow-y: auto; }
.emoji-grid button { border: 0; background: transparent; font-size: 1.45rem; height: 42px; padding: 0; border-radius: 8px; line-height: 1; }
.emoji-grid button:active { background: var(--kerb-2); }
.chat-mention { display: grid; margin-bottom: 8px; background: var(--asphalt); border-radius: 12px; overflow: hidden; }
.chat-mention button {
  display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--reflector);
  padding: 10px 12px; font: 600 .95rem/1.2 var(--font); text-align: left; border-bottom: 1px solid var(--kerb-2);
}
.chat-mention button:last-child { border-bottom: 0; }
.chat-mention small { color: var(--muted); font-weight: 400; }
.chat-editing { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; padding: 2px 2px 2px 12px; border-left: 3px solid var(--cone); color: var(--cone); font: 600 .9rem/1.2 var(--font-cond); }
.chat-editing .tool { width: 34px; height: 34px; }
.mention { color: var(--cone); font-weight: 600; }
.mention.me { background: rgba(242, 192, 20, .18); border-radius: 4px; padding: 0 2px; }
.chat-msg.for-me { box-shadow: inset 3px 0 0 var(--cone); }
.chat-msg { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.chat-quote { background: var(--asphalt); border-radius: 10px; padding: 8px 10px; color: var(--reflector) !important; white-space: pre-wrap; }

/* ---------- location symbol (under ») and "find my location" ---------- */
.loc-state { width: 36px; height: 36px; justify-self: center; position: relative; }
.loc-state svg, .loc-badge svg { width: 17px; height: 17px; }
.loc-state[data-state="shared"], .loc-badge[data-state="shared"] { color: var(--live); box-shadow: 0 0 0 2px rgba(52, 199, 123, .55), 0 2px 10px rgba(0, 0, 0, .35); }
.loc-state[data-state="on"], .loc-badge[data-state="on"] { color: var(--sky); }
.loc-state[data-state="weak"], .loc-badge[data-state="weak"] { color: var(--sodium); }
.loc-state[data-state="finding"], .loc-badge[data-state="finding"] { color: var(--muted); animation: locfind 1.4s ease-in-out infinite; }
.loc-state[data-state="idle"], .loc-badge[data-state="idle"] { color: var(--muted); }
.loc-state[data-state="off"], .loc-badge[data-state="off"] { color: var(--siren); box-shadow: 0 0 0 2px rgba(229, 37, 42, .8), 0 2px 10px rgba(0, 0, 0, .35); }
@keyframes locfind { 50% { opacity: .45; } }
.loc-badge { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--asphalt); }
.loc-badge svg { width: 20px; height: 20px; }
.pm-findme { position: relative; width: 140px; height: 140px; pointer-events: none; }
.pm-findme i {
  position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  border: 3px solid var(--cone); animation: findme 1.5s ease-out 2 forwards; opacity: 0;
}
.pm-findme i + i { animation-delay: .5s; }
@keyframes findme { 0% { transform: scale(.4); opacity: .95; } 100% { transform: scale(4.4); opacity: 0; } }

/* ---------- chat: voice notes ---------- */
.chat-compose:not(.has-text) .chat-send { display: none; }
.chat-compose.has-text .chat-mic { display: none; }
.chat-mic { background: var(--cone); color: var(--asphalt); }
.chat-rec { display: flex; align-items: center; gap: 6px; }
.rec-info {
  flex: 1; min-width: 0; height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: var(--asphalt); border: 1px solid var(--line); border-radius: 21px;
}
.rec-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--siren); animation: rec-pulse 1.2s ease-in-out infinite; }
.rec-time { flex: none; min-width: 2.7em; font: 700 1.02rem/1 var(--font-cond); font-variant-numeric: tabular-nums; }
.rec-level { flex: 1; min-width: 24px; height: 6px; border-radius: 3px; background: var(--kerb-2); overflow: hidden; }
.rec-level i { display: block; height: 100%; background: var(--cone); transform-origin: left center; transform: scaleX(.05); transition: transform .08s linear; }
.rec-note { flex: none; max-width: 45%; font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-cancel { color: #FF8F8A; }
.chat-rec[data-state="sending"] .rec-dot, .chat-rec[data-state="failed"] .rec-dot { animation: none; background: var(--muted); }
.chat-rec[data-state="sending"] .rec-level, .chat-rec[data-state="failed"] .rec-level { display: none; }
.chat-rec[data-state="failed"] .rec-info { height: auto; min-height: 42px; padding-block: 6px; }
.chat-rec[data-state="failed"] .rec-note { flex: 1; max-width: none; white-space: normal; color: #FF8F8A; }
@keyframes rec-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } .rec-level i { transition: none; } }

.voice { --p: 0; display: flex; align-items: center; gap: 10px; width: min(250px, 62vw); margin: 2px 0 4px; }
.voice-btn {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: var(--cone); color: var(--asphalt); cursor: pointer;
}
.voice-btn svg { width: 20px; height: 20px; }
.voice.loading .voice-btn { opacity: .55; }
.voice-track { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; padding: 10px 0; cursor: pointer; }
.voice-name { grid-column: 1 / -1; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-bar { position: relative; height: 4px; border-radius: 2px; background: rgba(244, 246, 251, .22); overflow: hidden; }
.voice-bar i { position: absolute; inset: 0; background: var(--cone); transform-origin: left center; transform: scaleX(var(--p)); }
.voice-time { font: 600 .8rem/1 var(--font-cond); color: var(--muted); font-variant-numeric: tabular-nums; }
.chat-msg.mine .voice-time { color: #C7D3F5; }

/* ---------- the demo site (src/demo.js) ---------- */
.demo-tips { margin: 0 0 16px; padding-left: 1.1rem; display: grid; gap: 8px; color: var(--muted); font-size: .95rem; }
.demo-tips b { color: var(--reflector); }
.gate .demo-name { margin: 0; }
.demo-row { margin: 0 0 4px; }

/* ---------- Patrol App demo: matte black and white, Inter. Added to the end of app.css by
   scripts/build-demo.mjs for the demo site only (the watch's own site keeps its colours). ---------- */
:root {
  --asphalt: #121212;
  --kerb: #1C1C1C;
  --kerb-2: #2A2A2A;
  --line: #3A3A3A;
  --reflector: #F5F5F5;
  --muted: #A3A3A3;
  --cone: #FFFFFF;
  --cone-ink: #121212;
  --royal: #262626;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-cond: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.tool, .brand, .tuck-chip, .gm-tip { background: rgba(18, 18, 18, .92); }
@media (min-width: 900px) { .tabs { background: rgba(18, 18, 18, .95); } }
.map, .leaflet-container { background: #161616; }
.modal { background: rgba(0, 0, 0, .62); }
/* You on the map: gold, like your track and accuracy circle. */
.pm-me { border-color: #F2C014; }
.gate-logo { filter: none; border-radius: 28px; }
