* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, sans-serif; font-size: 15px; color: #222; }
.hidden { display: none !important; }
.muted { color: #777; font-size: 13px; }
.error { color: #c0392b; min-height: 1em; }
.hint { font-size: 13px; color: #555; }
.spacer { flex: 1; }

button, input, select, textarea { font: inherit; }
button { padding: 7px 12px; border: 1px solid #bbb; border-radius: 6px; background: #f6f6f6; cursor: pointer; }
button:hover { background: #eee; }
button.primary { background: #2e7d32; color: #fff; border-color: #2e7d32; }
button.danger { color: #c0392b; }
button.link { border: none; background: none; color: #2e6fb7; padding: 4px; }
button.icon { border: none; background: none; font-size: 20px; padding: 2px 6px; }
input, select, textarea { padding: 6px 8px; border: 1px solid #bbb; border-radius: 6px; width: 100%; }
input[type=color] { padding: 2px; height: 36px; }
label { display: block; font-size: 13px; color: #555; margin: 6px 0; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #2f3b2f; z-index: 2000; }
.card { background: #fff; padding: 24px; border-radius: 10px; width: min(340px, 90vw); display: flex; flex-direction: column; gap: 10px; }
.card h1 { margin: 0 0 8px; font-size: 22px; }

#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; }

#panel {
  position: absolute; top: 10px; right: 10px; bottom: 10px; width: 340px; z-index: 1000;
  background: #fff; border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,.25);
  display: flex; flex-direction: column; overflow: hidden;
}
#panel header { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid #eee; }
#panel-body { overflow-y: auto; padding: 10px 12px; flex: 1; }
#panel.collapsed { bottom: auto; }
#panel.collapsed #panel-body { display: none; }
#panel h2 { margin: 6px 0; font-size: 18px; }
#panel h3 { margin: 16px 0 6px; font-size: 15px; border-top: 1px solid #eee; padding-top: 12px; }
.notes { white-space: pre-wrap; }

#hunt-list { list-style: none; padding: 0; margin: 0 0 10px; }
#hunt-list li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 6px; cursor: pointer; }
#hunt-list li:hover { background: #f3f3f3; }
#hunt-list li .meta { flex: 1; }
#hunt-list li .meta small { display: block; color: #777; }
#hunt-list li.empty { color: #888; cursor: default; }

.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 14px; color: #fff; font-weight: 700; text-shadow: 0 0 2px rgba(0,0,0,.6); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.hunt-label { background: none; border: none; }
.hunt-label .badge { font-size: 15px; transform: translate(-50%, -50%); position: absolute; }

.legend { font-size: 13px; color: #555; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 2px #000; }
.dot.driver { background: #ff9800; }
.dot.flank { background: #e91e63; }
.dot.stander { background: #1565c0; }
#sim-scrub { margin: 8px 0; padding: 0; }

body.picking #map, body.picking .leaflet-interactive { cursor: crosshair !important; }

@media (max-width: 700px) {
  #panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 55vh; }
  #panel.collapsed { bottom: 8px; }
}
body:not(.is-editor) .editor-only { display: none !important; }

.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.tools button:first-child { grid-column: 1 / -1; }
.tools button:disabled { opacity: .4; cursor: default; }
.toolbox { background: #fff8e1; border: 1px solid #ffe082; border-radius: 8px; padding: 4px 10px; margin: 8px 0; }

.setup-marker { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 3px rgba(0,0,0,.7); cursor: move; }
.setup-marker.drivers { background: #ff9800; }
.setup-marker.standers { background: #1565c0; }
#sim-auto-params { gap: 0 10px; }
.tools button:nth-child(4):last-child { grid-column: auto; }

.measure-control a { font-size: 18px; line-height: 30px; text-align: center; text-decoration: none; }
.measure-control a.active { background: #ffeb3b; }
.measure-panel { background: #fff; padding: 6px 10px; border-radius: 4px; box-shadow: 0 1px 5px rgba(0,0,0,.4); margin-top: 6px; font-size: 14px; min-width: 150px; }
.measure-panel .row { margin: 4px 0 0; gap: 4px; }
.measure-panel button { padding: 3px 8px; }
.measure-label { background: rgba(255,255,255,.9); border: none; box-shadow: 0 0 3px rgba(0,0,0,.4); font-weight: 600; font-size: 12px; padding: 1px 5px; }
.measure-control .leaflet-bar { width: fit-content; }
/* no browser focus box around clicked map shapes */
.leaflet-interactive:focus, .leaflet-container path:focus { outline: none; }

/* point handles (drawing tool, arrow, setup) */
.point-handle { background: #fff; border: 2px solid #222; border-radius: 50%; box-shadow: 0 0 3px rgba(0,0,0,.6);
  cursor: grab; transition: transform .15s ease .25s; }
.point-handle.first { background: #ffeb3b; }
.point-handle:hover, .setup-marker:hover { transform: scale(1.5); }
.leaflet-dragging .point-handle { cursor: grabbing; }
.setup-marker { transition: transform .15s ease .25s; }

/* action bar for all drawing tools: bottom centre of the map */
#action-bar { position: absolute; left: calc(50% - 175px); bottom: 24px; transform: translateX(-50%); z-index: 1100;
  background: #fff; border-radius: 12px; box-shadow: 0 3px 16px rgba(0,0,0,.35); padding: 10px 14px;
  display: flex; align-items: center; gap: 14px; max-width: min(760px, calc(100vw - 420px)); }
#action-bar .ab-text { font-size: 14px; }
#action-bar .ab-buttons { display: flex; gap: 6px; flex-shrink: 0; }
#action-bar .ab-done { font-weight: 600; }
@media (max-width: 700px) {
  #action-bar { bottom: 70px; max-width: calc(100vw - 16px); width: calc(100vw - 16px); flex-direction: column; align-items: stretch; gap: 8px; }
  #action-bar .ab-buttons button { flex: 1; }
}

.locate-control a, .measure-control a { font-size: 18px; line-height: 30px; text-align: center; text-decoration: none; }
.locate-control a.active { background: #bbdefb; }
/* long press on the map must not select text (Android WebView) */
#map { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

label.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: #333; }
label.check input { width: auto; }

/* markers */
.map-marker { background: none; border: none; }
.map-marker span { position: relative; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  font-size: 18px; background: #fff; border: 2px solid #2f3b2f; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,.4); }
.map-marker span::after { content: ''; position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top: 7px solid #2f3b2f; }
.marker-control a { font-size: 18px; line-height: 30px; text-align: center; text-decoration: none; }
.marker-control a.active { background: #ffe082; }
.marker-popup .row, .marker-form .row { margin: 6px 0 0; }
.marker-popup p.notes { margin: 6px 0; }
.marker-form label { margin: 4px 0; }
