:root {
  --bg: #14171c;
  --panel: #1c2026;
  --card: #20252c;
  --line: #2c323b;
  --text: #e7ebf0;
  --muted: #8b95a3;
  --accent: #e8743b;
  --danger: #d8554a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

button {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: 8px 14px; font-size: 0.9rem; cursor: pointer;
}
button.danger { background: var(--danger); }
button:hover { filter: brightness(1.08); }

input[type=text], input[type=password], input[type=file], select {
  background: #11141a; border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 9px 11px; font-size: 0.9rem;
}

.flash {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 10px 16px; border-radius: 6px; z-index: 9999; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}

/* --- centered login / passphrase --- */
.centered { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px; display: flex; flex-direction: column; gap: 12px; min-width: 300px;
}
.card h1 { margin: 0; font-size: 1.3rem; }

/* --- map view: warm expedition field-journal identity --- */
.mapview { overflow: hidden; }
#map { position: fixed; inset: 0; z-index: 1; background: #ECE3D1; }
.panel {
  position: fixed; top: 16px; left: 16px; z-index: 1000; max-width: 300px;
  background: #F4EDDE; color: #2A2118;
  border: 1px solid #D8C7A0; border-radius: 14px; padding: 15px 18px 13px;
  box-shadow: 0 12px 34px rgba(40,28,14,.30);
}
.panel .eyebrow {
  font-size: .64rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .2em; color: #C0561F; margin-bottom: 5px;
}
.panel h1 {
  font-family: "Fraunces", Georgia, serif; font-weight: 600;
  font-size: 1.55rem; line-height: 1.02; letter-spacing: -.01em;
  margin: 0 0 13px; color: #241C12;
}
.stats { display: flex; gap: 18px; margin-bottom: 4px; flex-wrap: wrap; }
.stats span {
  display: block; font-family: "Fraunces", Georgia, serif;
  font-size: 1.15rem; font-weight: 600; color: #241C12;
}
.stats label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: .08em; color: #9A7438; }
.panel-foot { margin-top: 11px; padding-top: 10px; border-top: 1px solid #DECDA6; color: #9A7438; }
.panel-foot a { color: #C0561F; }

/* "Follow the journey" pill: appears only when the viewer has panned away from follow mode,
   tap to snap the map back onto the bikes and resume auto-following. */
.follow-btn {
  position: fixed; left: 50%; z-index: 1200;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: #241C12; color: #F4EDDE; border: 0; border-radius: 999px;
  padding: 12px 22px; min-height: 44px; font: 600 .95rem "Fraunces", Georgia, serif;
  letter-spacing: .015em; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(40,28,14,.42); cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.follow-btn::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #E2552D; box-shadow: 0 0 0 3px rgba(226,85,45,.3);
}
.follow-btn:hover { filter: brightness(1.1); }
.follow-btn.hidden { display: none; }

/* live "you are here": red Monkey bike on top of the black one, soft live pulse, label tag */
.leaflet-div-icon.live-wrap { background: transparent; border: 0; }
.live { width: 150px; text-align: center; pointer-events: none; }
.live-label {
  display: inline-block; background: #241C12; color: #F4EDDE;
  font-family: "Fraunces", Georgia, serif; font-weight: 600;
  font-size: 11px; letter-spacing: .01em;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
  box-shadow: 0 1px 5px rgba(0,0,0,.4); margin-bottom: 3px;
}
.bikes { position: relative; width: 90px; height: 72px; margin: 0 auto; }
/* !important defeats Leaflet's `.leaflet-marker-pane img { width: auto }`, which is more
   specific than .bike and loads after us - without this the bikes render at natural size. */
/* will-change promotes each bike to its own GPU layer, so its drop-shadow is painted once
   and the bob just translates the cached texture - no per-frame repaint. */
.bike { position: absolute; width: 60px !important; height: auto !important; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); will-change: transform; }
/* red on top of black: red front + upper, black behind + lower-left */
.b-red   { top: 0;   left: 28px; z-index: 2; animation: bike-bob 1.15s ease-in-out infinite; }
.b-black { top: 22px; left: 0;   z-index: 1; animation: bike-bob 1.15s ease-in-out infinite .32s; }
/* Solid base dot; the expanding ring is a pseudo-element animated with transform+opacity only
   (GPU-composited, zero per-frame repaint). The old box-shadow ping repainted every frame and
   was the main reason the phone ran hot. */
.live-pulse {
  position: absolute; left: 34px; bottom: 0; width: 16px; height: 16px;
  border-radius: 50%; background: rgba(226,85,45,.55); z-index: 0;
}
.live-pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: rgba(226,85,45,.45); transform-origin: center;
  will-change: transform, opacity;
  animation: live-ping 2.2s ease-out infinite;
}
@keyframes bike-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2.5px); } }
@keyframes live-ping {
  0%        { transform: scale(1);   opacity: .6; }
  70%, 100% { transform: scale(2.8); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .b-red, .b-black { animation: none; } .live-pulse::after { animation: none; } }

/* --- phones --- */
@media (max-width: 600px) {
  /* Keep the panel narrow and left-anchored so it never reaches the top-right zoom control,
     and shrink it so it doesn't eat the whole screen. */
  .panel { top: 10px; left: 10px; max-width: 62vw; padding: 11px 13px 10px; border-radius: 12px; }
  .panel .eyebrow { font-size: .58rem; margin-bottom: 3px; }
  .panel h1 { font-size: 1.2rem; margin-bottom: 9px; }
  .stats { gap: 12px; }
  .stats span { font-size: 1rem; }
  .panel-foot { margin-top: 8px; padding-top: 8px; }
  /* Bigger leaflet zoom buttons = easier thumb targets. */
  .leaflet-touch .leaflet-bar a { width: 34px; height: 34px; line-height: 34px; }
  .follow-btn { font-size: .9rem; padding: 12px 20px; }
}

/* photo pins */
.photo-pin-inner {
  width: 50px; height: 50px; border-radius: 8px; background-size: cover; background-position: center;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5); position: relative; cursor: pointer;
}
.photo-pin-inner .play {
  position: absolute; inset: 0; margin: auto; width: 0; height: 0;
  border-left: 14px solid #fff; border-top: 9px solid transparent; border-bottom: 9px solid transparent;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); left: 4px;
}
.leaflet-div-icon.photo-pin, .leaflet-div-icon.photo-cluster { background: transparent; border: 0; }

/* a cluster of overlapping photos = a little stack with a count badge */
.photo-stack { position: relative; width: 50px; height: 50px; cursor: pointer; }
.photo-stack .photo-pin-inner { position: absolute; inset: 0; z-index: 2; }
.stack-card {
  position: absolute; inset: 0; border-radius: 8px; background: #fff;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.45);
}
.stack-card.c1 { transform: rotate(5deg) translate(2px,1px); z-index: 1; }
.stack-card.c2 { transform: rotate(10deg) translate(4px,2px); z-index: 0; }
.photo-count {
  position: absolute; top: -7px; right: -7px; z-index: 3;
  min-width: 20px; height: 20px; padding: 0 5px; box-sizing: border-box;
  border-radius: 10px; background: #E2552D; color: #F4EDDE;
  font: 700 11px/20px "Fraunces", Georgia, serif; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.45); border: 1.5px solid #F4EDDE;
}

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 5000; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.lightbox.hidden { display: none; }
.lightbox-inner { max-width: 92vw; max-height: 92vh; text-align: center; }
.lightbox-inner img, .lightbox-inner video { max-width: 92vw; max-height: 80vh; border-radius: 8px; }
.lb-close {
  position: absolute; top: 18px; right: 22px; background: rgba(255,255,255,.15); z-index: 2;
}
.lb-prev, .lb-next {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 48px; height: 48px; border-radius: 50%; padding: 0;
  background: rgba(255,255,255,.14); color: #fff; font-size: 1.9rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,.28); }
.lb-counter {
  color: #F4EDDE; margin-top: 8px; font: 600 .85rem "Fraunces", Georgia, serif; letter-spacing: .04em;
}
#lightbox-caption { color: var(--text); margin-top: 12px; }

/* --- admin --- */
.admin { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }
.admin header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.admin .card { margin-bottom: 18px; }
.admin .row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.admin h2 { font-size: 1.05rem; margin: 0 0 6px; }
.admin form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.share input { width: 320px; max-width: 60vw; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tile.unpublished { opacity: 0.5; }
.tile img { width: 100%; height: 150px; object-fit: cover; display: block; }
.tile-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.tile-actions { display: flex; gap: 6px; }
.tile-actions form { margin: 0; }
.cap { margin: 0; }
.cap input { flex: 1; min-width: 80px; }
.badge {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 10px; background: #2c323b; color: var(--muted);
}
.badge.gps { background: #1e3a2a; color: #6fd18a; }
.badge.timestamp { background: #3a341e; color: #d1bb6f; }
.badge.fallback { background: #3a2e1e; color: #d1a86f; }
.badge.none { background: #3a1e1e; color: #d18a6f; }
.kind { font-size: 0.72rem; color: var(--muted); }

/* user/login table */
.users { width: 100%; border-collapse: collapse; margin-top: 12px; }
.users td { padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.users td:first-child { font-weight: 600; }
.users form { margin: 0; }
button.small { padding: 4px 9px; font-size: 0.78rem; }
