:root {
  --bg: #f4f1e8;
  --surface: #fffdf7;
  --surface-2: #efeadd;
  --ink: #1d2721;
  --muted: #5a695f;
  --line: #ddd5c3;
  --accent: #2e6a4c;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe1;
  --trip-bg: #fdebc8;
  --trip-line: #c97a1c;
  --trip-ink: #7a4508;
  --warn-bg: #fff4d6;
  --warn-line: #e2b340;
  --route: #d4460f;
  --wpt: #1f5fa8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 40, 30, .06), 0 4px 16px rgba(30, 40, 30, .05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111713;
    --surface: #19211c;
    --surface-2: #222c26;
    --ink: #e6ede8;
    --muted: #9db0a4;
    --line: #2d3a32;
    --accent: #78c79b;
    --accent-ink: #0d1a12;
    --accent-soft: #203a2b;
    --trip-bg: #3b2d14;
    --trip-line: #e3a44d;
    --trip-ink: #f5c983;
    --warn-bg: #352c12;
    --warn-line: #a88420;
    --route: #ff7a3d;
    --wpt: #6fb0ff;
    --shadow: none;
  }
  .leaflet-tile-pane { filter: brightness(.82) contrast(1.05); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; letter-spacing: .01em; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden, [hidden] { display: none !important; }

/* ---- top bar + header -------------------------------------------------- */
.topbar {
  background: var(--accent);
  color: var(--accent-ink);
}
.topbar .wrap { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; font-size: .95rem; }
.topbar a { color: inherit; text-decoration: none; }
.brand-mark { font-size: 1.1rem; }

.trail-head { padding: 20px 0 8px; }
.trail-head h1 { font-size: clamp(1.5rem, 5.5vw, 2.2rem); overflow-wrap: anywhere; }
.coords { margin-top: 4px; font-variant-numeric: tabular-nums; }
.coords a { font-size: .875rem; margin-left: 4px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.fact {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}
.fact b { font-weight: 600; }

.banner {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  font-size: .92rem;
}

/* ---- cards ---------------------------------------------------------------- */
main { padding-bottom: 32px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-top: 16px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---- forecast ------------------------------------------------------------ */
.trip-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: .95rem;
}
.trip-note.is-trip { background: var(--trip-bg); color: var(--trip-ink); }
.days {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  margin: 0; padding: 0; list-style: none;
}
.day {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px 12px;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}
.day.on-trip { background: var(--trip-bg); border: 2px solid var(--trip-line); padding: 9px 11px 11px; }
.day-name { font-weight: 700; }
.day-date { color: var(--muted); font-size: .85rem; }
.day.on-trip .day-date { color: var(--trip-ink); }
.day-sym { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; min-height: 44px; }
.day-emoji { font-size: 2rem; line-height: 1; }
.day-text { font-size: .85rem; line-height: 1.25; }
.day-temp { font-size: 1.15rem; font-weight: 700; }
.day-temp .lo { font-weight: 500; color: var(--muted); }
.day.on-trip .day-temp .lo { color: var(--trip-ink); }
.day-f { font-size: .8rem; color: var(--muted); }
.day.on-trip .day-f { color: var(--trip-ink); }
.day-row { display: flex; gap: 12px; margin-top: 6px; font-size: .85rem; }
.tag {
  display: inline-block;
  font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 6px; margin-left: 4px; vertical-align: 2px;
}
.tag-trip { background: var(--trip-line); color: #fff; }
.tag-partial { background: var(--surface-2); color: var(--muted); }
.skeleton { height: 150px; border-radius: 12px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.updated { margin-top: 12px; }

/* ---- map ------------------------------------------------------------------ */
.map-card { padding: 0; overflow: hidden; }
.map-card .card-head { padding: 16px 16px 0; }
#map { height: min(58vh, 460px); min-height: 280px; background: var(--surface-2); }
.map-fallback { padding: 24px 16px; }
.leaflet-container { font: inherit; font-size: .85rem; }
.leaflet-control-layers-toggle { width: 44px !important; height: 44px !important; }
.leaflet-control-layers label { padding: 6px 4px; font-size: .95rem; }
.leaflet-bar a { width: 40px !important; height: 40px !important; line-height: 40px !important; font-size: 20px !important; }
.pin {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.pin span { transform: rotate(45deg); font-size: 16px; line-height: 1; }
.wpt-pin {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--wpt); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

/* ---- GPX ------------------------------------------------------------------ */
.map-card .gpx { padding: 16px; border-top: 1px solid var(--line); }
.drop {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  transition: background .15s, border-color .15s;
}
.drop.dragging { border-color: var(--accent); background: var(--accent-soft); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
}
.btn:focus-visible, .profile svg:focus-visible { outline: 3px solid var(--trip-line); outline-offset: 2px; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn-link { background: none; border: 0; color: var(--accent); text-decoration: underline; min-height: 44px; padding: 0 8px; font-weight: 500; }
.drop .btn { width: 100%; max-width: 320px; }
.privacy { display: block; margin-top: 8px; }
.gpx-error { color: #b3261e; margin-top: 10px; }
@media (prefers-color-scheme: dark) { .gpx-error { color: #ffb4a9; } }
.gpx-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.gpx-name { font-weight: 700; overflow-wrap: anywhere; }
.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin: 12px 0; padding: 0; list-style: none;
  font-variant-numeric: tabular-nums;
}
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-weight: 700; }
.stat-sub { font-size: .82rem; color: var(--muted); }

.profile { margin-top: 4px; }
.profile svg { display: block; width: 100%; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.profile .area { fill: var(--accent); opacity: .18; }
.profile .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.profile .grid { stroke: var(--line); stroke-width: 1; }
.profile .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.profile .cursor { stroke: var(--route); stroke-width: 1.5; }
.profile .cursor-dot { fill: var(--route); stroke: var(--surface); stroke-width: 2; }
.readout {
  min-height: 1.5em; margin-top: 6px; font-variant-numeric: tabular-nums; font-size: .92rem;
}
.wpts { margin: 12px 0 0; padding: 0; list-style: none; }
.wpts li { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0 8px; border-top: 1px solid var(--line); }
.wpts button { text-align: left; padding: 0; font-size: 1rem; font-weight: 600; }
.wpt-dot { flex: none; width: 12px; height: 12px; margin-top: 16px; border-radius: 50%; background: var(--wpt); }

/* ---- missing coords / landing -------------------------------------------- */
.steps { padding-left: 1.3em; }
.steps li { margin: 8px 0; }
kbd, code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88em;
  background: var(--surface-2); border-radius: 6px; padding: 1px 5px;
}
pre.contract { overflow-x: auto; background: var(--surface-2); padding: 12px; border-radius: 10px; font-size: .85rem; }
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: clamp(1.7rem, 6vw, 2.5rem); }
.hero p { font-size: 1.05rem; max-width: 60ch; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ---- footer --------------------------------------------------------------- */
footer { border-top: 1px solid var(--line); padding: 20px 0 40px; font-size: .85rem; color: var(--muted); }
footer p { margin: 6px 0; }
.nav-note { font-weight: 700; color: var(--ink); }
