:root {
  --bg: #f5f3ee; --card: #fff; --text: #1d2a2f; --muted: #6b7a80;
  --accent: #0f766e; --line: #e4e0d6; --err: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14191b; --card: #1d2528; --text: #e8eef0; --muted: #93a3a9; --accent: #5eead4; --line: #2c373b; --err: #f97066; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, sans-serif; }
main { max-width: 1000px; margin: 0 auto; padding: 16px; }
header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
h1 { font-size: 1.5rem; margin: 8px 0; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols .card { margin: 0; }
.cols { margin-bottom: 16px; }
@media (max-width: 700px) { .cols { grid-template-columns: 1fr; } }
.muted { color: var(--muted); font-size: .9rem; }
.err { color: var(--err); min-height: 1.4em; }
#map { height: 380px; border-radius: 8px; }
.item { padding: 8px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item time { color: var(--muted); font-size: .85rem; display: block; }
.tag { font-size: .75rem; background: var(--accent); color: var(--bg); border-radius: 4px; padding: 0 6px; margin-right: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: var(--line); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--card); border: 1px solid var(--line); padding: 24px; border-radius: 12px; width: min(360px, 100%); }
input, textarea, select, button { font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; margin-bottom: 8px; }
button { background: var(--accent); color: var(--bg); border: 0; cursor: pointer; font-weight: 600; }
button.link { background: none; color: var(--muted); width: auto; padding: 0 4px; margin: 0; font-weight: normal; }
#lightbox { position: fixed; inset: 0; z-index: 5000; background: rgba(0, 0, 0, .85); display: grid; place-items: center; cursor: zoom-out; }
#lightbox[hidden] { display: none; }
#lightbox figure { margin: 0; text-align: center; }
#lightbox img { max-width: 95vw; max-height: 88vh; }
#lightbox p { color: #fff; margin: 8px 0 0; }
[hidden] { display: none !important; }

/* Timeline */
header { display: block; }
header h1 { margin-bottom: 0; }
.timeline { position: sticky; top: 0; z-index: 1000; display: flex; gap: 6px; overflow-x: auto; padding: 8px 2px; margin: 8px 0; background: var(--bg); scrollbar-width: thin; }
.day { flex: 0 0 auto; width: 58px; padding: 6px 0 8px; text-align: center; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font-weight: normal; line-height: 1.2; margin: 0; }
.day small { display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.day b { display: block; font-size: 1.15rem; }
.day .mon { display: block; height: .8rem; font-size: .65rem; color: var(--accent); }
.day.future { border-style: dashed; }
.day.today { border-color: var(--accent); }
.day.selected { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.day.selected small, .day.selected .mon { color: var(--bg); }
.dots { display: block; height: 8px; margin-top: 3px; }
.dots i { display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%; background: var(--accent); }
.dots i.plan { background: none; border: 1.5px solid var(--accent); }
.day.selected .dots i { background: var(--bg); }
.day.selected .dots i.plan { background: none; border-color: var(--bg); }
.dayhead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.dayhead h2 { font-size: 1.25rem; margin: 0; }
.dayhead .muted { margin-left: auto; }
.cap { color: var(--muted); font-size: .85rem; }

/* Post bodies (rendered from Markdown) */
.body { overflow-wrap: anywhere; }
.body p, .body ul, .body ol, .body blockquote { margin: 4px 0; }
.body ul, .body ol { padding-left: 1.3rem; }
.body h4 { margin: 8px 0 2px; font-size: 1rem; }
.body blockquote { padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.body code { background: var(--bg); padding: 0 4px; border-radius: 4px; font-size: .9em; }
.body a { color: var(--accent); }
.body hr { border: 0; border-top: 1px solid var(--line); }
.box { font-size: .95em; }

/* Two-column rows: top-aligned so a short card doesn't stretch to match a tall one */
.cols { align-items: start; }
.stack { display: grid; gap: 16px; }
.stack .card { margin: 0; }
.mapcard #map { height: 420px; }
@media (max-width: 700px) {
  .mapcard { order: -1; } /* on a phone the map comes first, then the plans */
  .mapcard #map { height: 320px; }
}

/* Hikes */
.hike + .hike { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.hike h3 { margin: 0 0 8px; font-size: 1.05rem; }
.hike h3 a { color: var(--text); }
.stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 6px; }
.stat b { display: block; font-size: 1.25rem; line-height: 1.2; }
.stat small { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.splits { border-collapse: collapse; font-size: .9rem; margin-top: 4px; }
.splits th, .splits td { padding: 2px 18px 2px 0; text-align: left; }
.splits th { color: var(--muted); font-weight: normal; font-size: .75rem; text-transform: uppercase; }
.legend { margin: 6px 0 0; font-size: .8rem; }
.legend i { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin: 0 4px 3px 10px; vertical-align: middle; }
.legend i:first-child { margin-left: 0; }
.legend i.dot { width: 9px; height: 9px; border-radius: 50%; }

/* Leaflet's panes use z-indexes up to 1000; keep them inside the map so they can't outrank the lightbox. */
#map { isolation: isolate; }

.private { background: var(--card); border: 1px solid var(--line); padding: 24px; border-radius: 12px; width: min(420px, 100%); text-align: center; }
.private h1 { margin-top: 0; }
.sharebox { display: flex; gap: 8px; }
.sharebox input { margin: 0; }
.sharebox button { width: auto; padding: 10px 16px; margin: 0; }
.daterow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.daterow input { min-width: 0; }

/* Heart rate on a hike */
.hr { margin: 10px 0 6px; }
.hr h4 { margin: 0 0 6px; font-size: .8rem; color: var(--muted); text-transform: uppercase; font-weight: normal; }
.zonebar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; }
.zonekey { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 8px; font-size: .8rem; }
.zonekey i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.hrchart { width: 100%; max-width: 640px; height: auto; display: block; color: var(--text); }
.hrchart text { fill: var(--muted); font-size: 11px; }

/* Late arrivals ("new information on earlier days") */
.day { position: relative; }
.badge { position: absolute; top: -6px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #f97316; color: #fff; font-size: .7rem; font-style: normal; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.whatsnew { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 12px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid #f97316; border-radius: 10px; font-size: .92rem; }
.whatsnew .chip { width: auto; margin: 0; padding: 4px 10px; border-radius: 999px; background: none; color: var(--text); border: 1px solid #f97316; font-weight: 500; font-size: .88rem; }
.tag.late { background: none; color: var(--muted); border: 1px solid var(--muted); font-weight: normal; }
.tag.late.fresh { background: #f97316; border-color: #f97316; color: #fff; font-weight: 700; }
.grid img.fresh { outline: 3px solid #f97316; outline-offset: -3px; }
.hike h3 .tag { font-size: .7rem; vertical-align: middle; }

/* Flights */
.flightbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 12px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid #0ea5e9; border-radius: 10px; font-size: .92rem; }
.flightbar .chip { width: auto; margin: 0; padding: 4px 10px; border-radius: 999px; background: none; color: var(--text); border: 1px solid #0ea5e9; font-weight: 500; font-size: .88rem; }
.flightstat { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.planeicon { background: none; border: 0; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45)); }
.planeicon.est svg { opacity: .6; }

/* weather */
.day .wx { display: block; margin-top: 5px; line-height: 1.3; font-size: .68rem; color: var(--muted); white-space: nowrap; }
.day.selected .wx { color: var(--bg); }
.weather { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 12px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid #f59e0b; border-radius: 10px; font-size: .92rem; }
.weather .ico { font-size: 1.5rem; line-height: 1; }
.weather .place { font-weight: 600; }
.weather .temps { font-weight: 600; }
.weather .tag { margin-left: auto; }
.weather .none { color: var(--muted); }
