:root {
  --bg: #0f172a;
  --panel: #111827;
  --text: #f9fafb;
  --muted: #cbd5e1;
  --line: rgba(255,255,255,.14);
  --accent: #f59e0b;
  --danger: #ef4444;
  --ok: #22c55e;
  --shadow: 0 18px 40px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, main { width: 100%; height: 100%; margin: 0; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; }
.topbar { position: fixed; z-index: 1000; top: env(safe-area-inset-top, 0); left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem .75rem; background: linear-gradient(180deg, rgba(15,23,42,.96), rgba(15,23,42,.72)); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.boot { width: 2.35rem; height: 2.35rem; display: grid; place-items: center; border-radius: .8rem; background: rgba(245,158,11,.18); font-size: 1.35rem; }
h1 { margin: 0; font-size: 1.05rem; line-height: 1.1; letter-spacing: -.02em; }
p { margin: 0; }
.brand p { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button { font: inherit; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ghost, .secondary, .primary, .fab { border-radius: 999px; font-weight: 800; }
.ghost { background: rgba(255,255,255,.12); color: var(--text); padding: .65rem .8rem; white-space: nowrap; }
#map { width: 100vw; height: 100vh; height: 100svh; height: 100dvh; z-index: 1; }
.fab { position: fixed; z-index: 1001; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0)); padding: 1rem 1.15rem; color: #111827; background: var(--accent); box-shadow: var(--shadow); touch-action: manipulation; }

.sheet {
  --sheet-height: 58dvh;
  position: fixed;
  z-index: 1002;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--sheet-drag-height, var(--sheet-height));
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: rgba(17,24,39,.985);
  border-top: 1px solid var(--line);
  border-radius: 1.2rem 1.2rem 0 0;
  box-shadow: var(--shadow);
  transform: translate3d(0,0,0);
  transition: height .22s cubic-bezier(.2,.75,.25,1), transform .22s ease, opacity .18s ease;
  will-change: height, transform;
  overscroll-behavior: contain;
}
.sheet[data-snap="full"] { --sheet-height: 92dvh; }
.sheet[data-snap="half"] { --sheet-height: 58dvh; }
.sheet[data-snap="peek"] { --sheet-height: 184px; }
.sheet[data-snap="hidden"], .sheet.is-hidden { transform: translate3d(0,calc(100% + 1.5rem),0); opacity: 0; pointer-events: none; }
.sheet.no-transition, .sheet.is-dragging { transition: none; }
.sheet.is-dragging { user-select: none; }

.sheet-handle { flex: 0 0 30px; width: 100%; display: grid; place-items: center; padding: 0; margin: 0; background: transparent; color: inherit; touch-action: none; cursor: ns-resize; }
.grabber { display: block; width: 44px; height: 5px; border-radius: 10px; background: rgba(255,255,255,.38); }
.sheet-head { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: 0 1rem .75rem; }
h2 { margin: 0; font-size: 1.25rem; }
#sheetSub { color: var(--muted); font-size: .9rem; margin-top: .15rem; line-height: 1.35; }
.icon { flex: 0 0 auto; width: 2.4rem; height: 2.4rem; border-radius: 999px; background: rgba(255,255,255,.1); color: var(--text); font-size: 1.55rem; line-height: 1; touch-action: manipulation; }
.sheet-form { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sheet-scroll { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: .1rem 1rem 1rem; scrollbar-width: none; -ms-overflow-style: none; }
.sheet-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }
.sheet-footer { flex: 0 0 auto; padding: .7rem 1rem calc(.75rem + env(safe-area-inset-bottom, 0)); border-top: 1px solid var(--line); background: linear-gradient(180deg, rgba(17,24,39,.94), rgba(17,24,39,1)); box-shadow: 0 -10px 24px rgba(0,0,0,.14); }
.sheet[data-snap="peek"] .sheet-scroll { visibility: hidden; pointer-events: none; overflow: hidden; }
.sheet[data-snap="peek"] .sheet-head { padding-bottom: .35rem; }
.sheet[data-snap="peek"] #sheetSub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100vw - 5rem); }
.sheet[data-snap="peek"] .sheet-footer { padding-top: .45rem; border-top: 0; box-shadow: none; background: transparent; }

fieldset { border: 1px solid var(--line); border-radius: 1rem; padding: .85rem; margin: 0 0 .85rem; }
legend { color: var(--muted); padding: 0 .25rem; }
fieldset label { display: block; padding: .72rem .35rem; border-bottom: 1px solid var(--line); font-weight: 800; touch-action: manipulation; }
fieldset label:last-child { border-bottom: 0; }
fieldset span { display: block; margin-left: 1.6rem; color: var(--muted); font-size: .85rem; font-weight: 500; }
.note-label { display: block; color: var(--muted); margin: .7rem 0 .35rem; }
textarea { width: 100%; min-height: 5.5rem; resize: none; border: 1px solid var(--line); border-radius: .9rem; padding: .8rem; color: var(--text); background: rgba(255,255,255,.08); font-size: 16px; }
.actions, .placement-actions { display: grid; grid-template-columns: 1fr; gap: .6rem; margin: 0; }
.placement-actions:has(.reset-points:not([hidden])) { grid-template-columns: 1fr 1fr; }
.primary { background: var(--accent); color: #111827; padding: .95rem; min-height: 48px; }
.secondary { background: rgba(255,255,255,.12); color: var(--text); padding: .9rem; min-height: 48px; }
.cancel-placement { width: 100%; }
.popup { min-width: 190px; }
.popup-title { display: block; margin-bottom: .35rem; }
.popup-note { margin-bottom: .4rem; }
.popup-age { color: #475569; font-size: .82rem; margin-bottom: .55rem; }
.popup-cleared { padding: .5rem .65rem; border-radius: 999px; background: #111827; color: #fff; font-weight: 700; }
.leaflet-control-attribution { font-size: 10px; }

/* phone/tablet */
@media (min-width: 900px) {
  .topbar {
    left: 1rem;
    right: auto;
    top: 1rem;
    width: clamp(360px, 31vw, 430px);
    border: 1px solid var(--line);
    border-radius: 1rem;
    box-shadow: var(--shadow);
  }

  .fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    right: 1.25rem;
    bottom: 1.25rem;
  }

  .sheet,
  .sheet[data-snap="peek"],
  .sheet[data-snap="half"],
  .sheet[data-snap="full"] {
    left: 1rem;
    right: auto;
    top: 5.8rem;
    bottom: 1rem;
    width: clamp(390px, 34vw, 460px);
    height: auto !important;
    min-height: 480px;
    border: 1px solid var(--line);
    border-radius: 1.2rem;
    transform: translate3d(0, 0, 0);
    opacity: 1;
    pointer-events: auto;
  }

  .sheet[data-snap="hidden"],
  .sheet.is-hidden {
    transform: translate3d(calc(-100% - 2rem), 0, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .sheet-handle {
    display: none !important;
  }

  .sheet .icon {
    display: inline-grid;
    place-items: center;
  }

  .sheet-head {
    padding: 1rem 1rem .75rem;
  }

  .sheet[data-snap="peek"] .sheet-scroll,
  .sheet[data-snap="half"] .sheet-scroll,
  .sheet[data-snap="full"] .sheet-scroll {
    visibility: visible;
    pointer-events: auto;
    overflow-y: auto;
  }

  .sheet[data-snap="peek"] .sheet-head {
    padding: 1rem 1rem .75rem;
  }

  .sheet[data-snap="peek"] #sheetSub {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
  }

  .sheet[data-snap="peek"] .sheet-footer,
  .sheet[data-snap="half"] .sheet-footer,
  .sheet[data-snap="full"] .sheet-footer {
    padding: .7rem 1rem .75rem;
    border-top: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(17,24,39,.94), rgba(17,24,39,1));
    box-shadow: 0 -10px 24px rgba(0,0,0,.14);
  }

  .sheet-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.28) transparent;
  }

  .sheet-scroll::-webkit-scrollbar {
    display: block;
    width: 9px;
  }

  .sheet-scroll::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(255,255,255,.28);
    background-clip: padding-box;
  }
}

.hotspot-check {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  margin-top: .8rem;
  padding: .85rem;
  border: 1px solid rgba(96, 165, 250, .45);
  border-radius: .9rem;
  background: rgba(37, 99, 235, .12);
  cursor: pointer;
}
.hotspot-check input { margin-top: .22rem; transform: scale(1.15); }
.hotspot-check span { display: block; min-width: 0; }
.hotspot-check strong { display: block; }
.hotspot-check small { display: block; margin-top: .18rem; color: var(--muted); line-height: 1.35; }
.hotspot-check input:disabled + span { opacity: .78; }
.hotspot-warning { margin: .45rem 0 .65rem; color: #475569; font-size: .78rem; line-height: 1.35; }
.popup-hotspot-report { padding: .55rem .7rem; border-radius: 999px; background: #2563eb; color: #fff; font-weight: 800; }
.map-key { display: flex; align-items: center; gap: .4rem; padding: .42rem .55rem; border-radius: .6rem; background: rgba(255,255,255,.94); color: #1e293b; box-shadow: 0 1px 5px rgba(0,0,0,.25); font: 700 11px/1.2 system-ui, sans-serif; }
.hotspot-key-ring { width: 18px; height: 18px; display: inline-block; border: 3px dashed #2563eb; border-radius: 50%; background: rgba(96,165,250,.18); }

/* Street-section reporting */
.shape-fieldset { margin-bottom: .45rem; }
.reset-points {
  width: 100%;
  margin: 0;
  min-height: 48px;
  padding: .65rem .8rem;
  border: 1px dashed rgba(255,255,255,.25);
  border-radius: .8rem;
  background: rgba(255,255,255,.07);
  color: var(--text);
  font-weight: 750;
}
.reset-points[hidden] { display: none; }
.leaflet-interactive { touch-action: manipulation; }

/* Crowd confirmations */
.crowd-status{margin-top:.75rem;padding-top:.7rem;border-top:1px solid rgba(17,24,39,.14)}
.crowd-status-line{margin:0 0 .25rem;font-weight:800;line-height:1.3}
.crowd-tally{margin:0 0 .6rem;color:#4b5563;font-size:.84rem}
.crowd-disputed .crowd-status-line{color:#b45309}
.crowd-rising .crowd-status-line{color:#c2410c}
.crowd-confirmed .crowd-status-line{color:#166534}
.crowd-actions{display:grid;grid-template-columns:1fr 1fr;gap:.4rem}
.crowd-vote{border:1px solid #d1d5db;border-radius:.55rem;background:#fff;padding:.48rem .55rem;font:inherit;font-size:.82rem;font-weight:750;cursor:pointer}
.crowd-vote:hover{background:#f3f4f6}
.crowd-vote:disabled{opacity:.55;cursor:wait}
.crowd-vote-flooded{border-color:#f59e0b}
.crowd-vote-rising{border-color:#ef4444}
.crowd-vote-clear{border-color:#22c55e}
.crowd-vote-incorrect{border-color:#6b7280}


/* Operational controls */
.site-announcement{position:fixed;z-index:1005;left:50%;top:calc(.55rem + env(safe-area-inset-top,0));transform:translateX(-50%);width:min(760px,calc(100% - 1rem));padding:.62rem .7rem .62rem .95rem;border:1px solid rgba(251,191,36,.6);border-radius:.85rem;background:rgba(120,53,15,.96);color:#fff7ed;box-shadow:0 8px 28px rgba(0,0,0,.3);font-weight:800;text-align:left;line-height:1.3;display:flex;align-items:center;justify-content:center;gap:.65rem}
.site-announcement span{flex:1;text-align:center}
.site-announcement-hide{flex:0 0 auto;border:1px solid rgba(255,247,237,.5);border-radius:999px;background:rgba(255,255,255,.12);color:#fff7ed;font:inherit;font-size:.78rem;font-weight:900;padding:.3rem .55rem;cursor:pointer}
.site-announcement-hide:hover{background:rgba(255,255,255,.2)}
.site-announcement-hide[hidden]{display:none}
.site-announcement-operational{background:rgba(127,29,29,.96);border-color:rgba(252,165,165,.7)}
.site-announcement[hidden]{display:none}
.fab:disabled{opacity:.82;cursor:not-allowed;background:#94a3b8;color:#111827}
@media(max-width:899px){.site-announcement{top:calc(4.9rem + env(safe-area-inset-top,0));font-size:.88rem}.site-announcement-hide{font-size:.75rem;padding:.28rem .5rem}}
@media(min-width:900px){.site-announcement{top:1rem;left:auto;right:1rem;transform:none;width:min(520px,calc(100vw - 470px));min-width:320px}}
