:root {
  /* Layout: the map fills the screen; a slim title bar floats on top; one dock at the
     bottom holds the timeline. Sheets for reporting and alerts take the dock's place.
     Purple is the old USGS "photorevision" ink, used on topo maps for features added
     after the survey. Here it marks everything neighbors have added. */
  --paper: #F3F5F0;
  --ink: #1C2624;
  --ink-2: #55625E;
  --rule: #CDD3CA;
  --rev: #8E2A8B;
  --rev-deep: #5A1763;
  --rev-wash: #F1DDF0;
  --moss: #2F6B48;
  --warn: #9A3B1E;
  --font-display: 'Barlow Semi Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --inset: 0px;      /* height of whatever covers the bottom of the map; set from script */
  --inset-left: 0px; /* width of the floating panel on wide screens */
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.4 var(--font-body);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--rev); outline-offset: 2px; }

#app { position: relative; height: 100%; overflow: hidden; }
#map { position: absolute; inset: 0; background: #BCD5E0; }

/* ---------- top bar ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: 12px 16px 0;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px 7px 9px;
  background: var(--ink); color: var(--paper);
  border-radius: 10px;
  font: 600 19px/1 var(--font-display); letter-spacing: 0.01em;
  text-decoration: none; white-space: nowrap;
}
.brand { padding-top: 6px; padding-bottom: 6px; }
.brand-name small { display: block; margin-top: 2px; font: 500 12px/1 var(--font-display); letter-spacing: 0.02em; color: #C9D2CB; }
.brand-about { flex: none; width: 17px; height: 17px; margin-left: 3px; color: #C9D2CB; }
.brand-mark { width: 22px; height: 22px; color: #E7B6E6; }
.topnav { display: flex; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 12px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 10px;
  font: 600 15px/1 var(--font-display); letter-spacing: 0.01em;
  text-decoration: none; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(28, 38, 36, 0.18);
}
.pill svg { width: 16px; height: 16px; color: var(--rev); }
.pill.on svg { color: var(--moss); }
.pill.quiet { font-weight: 500; color: var(--ink-2); }

.preview-tag {
  position: absolute; left: 16px; z-index: 4;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 9px;
  background: rgba(243, 245, 240, 0.92);
  border: 1px solid var(--rule); border-radius: 8px;
  font: 500 12px/1.2 var(--font-display); color: var(--ink-2);
}
.preview-tag { top: 64px; left: 16px; right: auto; max-width: calc(100% - 32px); color: var(--rev-deep); border-color: #D9B4D8; background: rgba(241, 221, 240, 0.94); }

/* ---------- map furniture ---------- */
.crosshair {
  position: absolute; z-index: 3;
  left: calc((100% + var(--inset-left)) / 2);
  top: calc((100% - var(--inset)) / 2);
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  color: var(--rev-deep); pointer-events: none;
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 2px #fff);
}
.map-actions {
  position: absolute; z-index: 4; right: 16px;
  bottom: calc(var(--inset) + 12px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
.round {
  width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 50%;
  box-shadow: 0 1px 4px rgba(28, 38, 36, 0.22);
}
.round svg { width: 22px; height: 22px; }
.zoom {
  position: absolute; z-index: 4; right: 16px; top: 60px;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: 0 1px 4px rgba(28, 38, 36, 0.22);
}
.zoom button { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; background: none; border: 0; }
.zoom button + button { border-top: 1px solid var(--rule); }
.zoom button:focus-visible { outline-offset: -3px; }
.zoom button:disabled { color: #A9B3AC; cursor: default; }
.zoom svg { width: 20px; height: 20px; }
.report {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 0 18px 0 14px;
  background: var(--rev); color: #fff;
  border: 0; border-radius: 24px;
  font: 600 17px/1 var(--font-display); letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(90, 23, 99, 0.4);
}
.report svg { width: 18px; height: 18px; }
.report:active { background: var(--rev-deep); }

/* ---------- dock ---------- */
.dock, .sheet {
  position: absolute; z-index: 6; left: 0; right: 0; bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -3px 14px rgba(28, 38, 36, 0.14);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
.dock { display: flex; flex-direction: column; gap: 10px; }
.dock-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.controls { justify-content: space-between; }

.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips input:focus-visible + span { outline: 3px solid var(--rev); outline-offset: 2px; }

.presets { display: flex; gap: 2px; }
.presets button {
  min-width: 40px; min-height: 34px; padding: 0 6px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  font: 500 15px/1 var(--font-display); color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.presets button[aria-pressed="true"] { color: var(--rev-deep); border-bottom-color: var(--rev); font-weight: 600; }

.timeline-row { align-items: flex-start; gap: 10px; }
.play {
  position: relative; z-index: 1; /* above the start handle's touch area */
  flex: none; width: 44px; height: 44px; padding: 0; margin-top: 1px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--paper); border: 0; border-radius: 50%;
}
.play svg { width: 18px; height: 18px; }
.timeline { position: relative; flex: 1; min-width: 0; }
.track {
  position: relative; height: 46px;
  border-bottom: 1px solid var(--ink-2);
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: crosshair;
}
.bars { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.bars rect { fill: #B9C1B8; }
.bars rect.in { fill: var(--rev); }
.bars line { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.brush {
  position: absolute; top: 0; bottom: -1px;
  background: rgba(142, 42, 139, 0.1);
  border-left: 2px solid var(--rev-deep); border-right: 2px solid var(--rev-deep);
  cursor: grab; min-width: 4px;
}
.brush.dragging { cursor: grabbing; }
.brush.full { background: none; cursor: crosshair; }
.handle {
  position: absolute; top: 50%; width: 36px; height: 44px; margin-top: -22px;
  padding: 0; background: none; border: 0; cursor: ew-resize; touch-action: none;
}
.handle::after {
  content: ''; position: absolute; top: 12px; left: 13px; width: 10px; height: 20px;
  background: var(--rev-deep); border: 2px solid var(--paper); border-radius: 5px;
}
.handle.start { left: -19px; }
.handle.end { right: -19px; }
.playhead { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); pointer-events: none; }
.axis { position: relative; height: 18px; margin-top: 3px; font: 500 12px/18px var(--font-display); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.axis span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.axis.off { visibility: hidden; }
.span-text { position: absolute; left: 0; bottom: 0; font: 600 13px/18px var(--font-display); color: var(--rev-deep); white-space: nowrap; font-variant-numeric: tabular-nums; }
.axis span.edge { transform: translateX(-100%); color: var(--ink); }

.tally { min-width: 0; }
.since { margin-top: 1px; font: 500 13px/1.1 var(--font-display); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.count { white-space: nowrap; font: 600 21px/1.15 var(--font-display); font-variant-numeric: tabular-nums; }

/* ---------- sheets ---------- */
.sheet { max-height: 64%; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet h2 { margin: 0; font: 600 22px/1.15 var(--font-display); text-wrap: balance; }
.close { flex: none; width: 40px; height: 40px; margin: -6px -8px -6px 0; padding: 0; display: grid; place-items: center; background: none; border: 0; border-radius: 50%; color: var(--ink-2); }
.close svg { width: 20px; height: 20px; }
.sheet form, .panel, #alerts-on, #contact-step, #code-step { display: flex; flex-direction: column; gap: 12px; }
.sheet form > [hidden], .panel > [hidden] { display: none; }
.hint { font-size: 15px; color: var(--ink-2); }
.pair { display: flex; flex-wrap: wrap; gap: 12px 20px; }
.pair > fieldset { flex: none; }
.when-pick { display: flex; gap: 12px; max-width: 420px; }
.when-pick .field { flex: 1; min-width: 0; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
legend, .field > span { padding: 0; font: 600 14px/1.3 var(--font-display); color: var(--ink-2); }
.field em { font-style: normal; font-weight: 500; opacity: 0.8; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span {
  display: block; padding: 8px 13px; min-height: 38px;
  border: 1px solid var(--rule); border-radius: 19px; background: #fff;
  font-size: 15px; line-height: 20px; cursor: pointer;
}
.chips input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.field { display: flex; flex-direction: column; gap: 6px; }
input[type="text"], input[type="tel"], input[type="email"], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  background: #fff; border: 1px solid var(--rule); border-radius: 10px;
  font-size: 16px;
}
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; font-family: inherit; color: inherit; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 7.5l5 5 5-5' fill='none' stroke='%2355625E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 18px;
}
input::placeholder, textarea::placeholder { color: #8C9792; }
textarea { font: inherit; color: inherit; resize: vertical; line-height: 1.35; }
.field small { font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.demo-only { display: none; }
.demo .demo-only { display: inline; }
.demo [data-locate], .demo #locate { display: none; }
.you { width: 18px; height: 18px; border-radius: 50%; background: #1C6FD0; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(28, 111, 208, 0.35), 0 1px 4px rgba(0, 0, 0, 0.3); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.primary, .secondary {
  min-height: 46px; padding: 0 20px; border-radius: 12px;
  font: 600 17px/1 var(--font-display); letter-spacing: 0.01em;
}
.primary { background: var(--rev); color: #fff; border: 0; }
.primary:active { background: var(--rev-deep); }
.primary[disabled], .secondary[disabled] { opacity: 0.55; cursor: default; }
.secondary { background: none; border: 1.5px solid var(--ink); color: var(--ink); }
.secondary.danger { border-color: var(--warn); color: var(--warn); }
.link { padding: 0; background: none; border: 0; color: var(--rev-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.fine { font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.fine a { color: inherit; }
.note { font-size: 15px; color: var(--ink-2); }
.error { padding: 9px 12px; border-left: 3px solid var(--warn); background: #F7E9E3; color: #6E2912; font-size: 15px; border-radius: 0 8px 8px 0; }
.status-on { display: flex; align-items: flex-start; gap: 8px; font-size: 16px; }
.status-on svg { flex: none; width: 20px; height: 20px; margin-top: 2px; color: var(--moss); }
.test-link { align-self: flex-start; min-height: 32px; font-size: 16px; }
.test-sent { padding: 10px 14px; background: #E4E8E0; border-radius: 12px; font-size: 15px; display: flex; flex-direction: column; gap: 4px; }
.howto { padding: 12px 14px; background: var(--rev-wash); border-radius: 12px; font-size: 15px; }
.howto ol { margin: 6px 0 0; padding-left: 20px; }
.howto li + li { margin-top: 2px; }
.human:empty { display: none; }
.demo .brand { pointer-events: none; }
.demo .brand-about { display: none; }
#alerts-form.install-first > .hint, #alerts-form.install-first > fieldset,
#alerts-form.stopping > .hint, #alerts-form.stopping > fieldset, #alerts-form.stopping #contact-back, #alerts-form.stopping .other-ways { display: none; }
.other-ways { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 10px; border-top: 1px solid var(--rule); }
.other-ways .link { font-size: 14px; font-weight: 500; }
.howto p + ol, .howto ol + p { margin-top: 6px; }

.toast {
  position: absolute; z-index: 8; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--inset) + 72px);
  max-width: min(340px, calc(100% - 32px)); padding: 10px 14px;
  background: var(--ink); color: var(--paper); border-radius: 10px;
  font-size: 15px; text-align: center;
  box-shadow: 0 3px 12px rgba(28, 38, 36, 0.3);
}

/* ---------- MapLibre overrides ---------- */
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: var(--inset); }
.maplibregl-ctrl-attrib { font: 11px/1.3 var(--font-body); }
.maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(243, 245, 240, 0.85); }
.maplibregl-popup-content {
  padding: 11px 14px; border-radius: 12px; background: var(--paper); color: var(--ink);
  font: 400 15px/1.35 var(--font-body);
  box-shadow: 0 3px 14px rgba(28, 38, 36, 0.28);
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--paper); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--paper); }
.maplibregl-popup-close-button { width: 30px; height: 30px; font-size: 20px; color: var(--ink-2); }
.pop-when { padding-right: 18px; font: 600 17px/1.2 var(--font-display); }
.pop-what { color: var(--ink-2); }
.pop-note { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--rule); overflow-wrap: anywhere; }

.pop-actions { display: flex; gap: 18px; }
.pop-edit, .pop-delete { margin-top: 8px; padding: 6px 0; min-height: 32px; background: none; border: 0; color: var(--warn); font: 600 15px/1.2 var(--font-display); text-decoration: underline; text-underline-offset: 2px; }

.pop-source { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--rule); font-size: 14px; color: var(--ink-2); }
.pop-source a { color: inherit; }
.pop-edit { color: var(--rev-deep); }
.mine { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.mine li { padding: 10px 0; border-top: 1px solid var(--rule); }
.mine li:first-child { border-top: 0; }
.mine b { display: block; font: 600 17px/1.2 var(--font-display); }
.mine p { color: var(--ink-2); font-size: 15px; overflow-wrap: anywhere; }
.mine .pop-actions { gap: 22px; }
.mine .pop-actions button { min-height: 40px; margin-top: 2px; }

/* ---------- wider screens: the dock and sheets become a floating panel ---------- */
@media (min-width: 760px) {
  .dock, .sheet {
    left: 16px; right: auto; bottom: 16px; width: 520px;
    border: 1px solid var(--rule); border-radius: 16px;
    box-shadow: 0 4px 18px rgba(28, 38, 36, 0.2);
  }
  .sheet { max-height: calc(100% - 96px); }
  .map-actions { bottom: 28px; }
  .toast { bottom: 28px; }
  .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: 0; }
  .maplibregl-ctrl-bottom-left { left: 552px; }
}

@media (max-width: 759px) {
  .topnav { flex-direction: column; align-items: flex-end; }
}
@media (max-width: 759px) and (pointer: coarse) {
  .zoom { display: none; } /* phones zoom with two fingers */
}

@media (max-width: 400px) {
  .presets { gap: 0; }
  .presets button { min-width: 34px; padding: 0 5px; }
  .dock-row.controls { gap: 8px; }
}

@media (max-width: 380px) {
  .brand { font-size: 17px; padding-right: 10px; }
  .pill { padding: 0 9px; }
}

@media (max-width: 350px) {
  .count { font-size: 17px; }
  .presets button { min-width: 29px; padding: 0 3px; font-size: 14px; }
  .brand-mark { display: none; }
  .brand { padding-left: 10px; }
  .pill { padding: 0 7px; }
}

@media (prefers-reduced-motion: no-preference) {
  .sheet:not([hidden]) { animation: rise 0.18s ease-out; }
  @keyframes rise { from { transform: translateY(14px); } to { transform: none; } }
}
