:root {
  --paper: #f5f0e4;
  --paper-2: #ece4d1;
  --card: #fbf8f1;
  --ink: #2a2823;
  --ink-soft: #5d584d;
  --rule: #d8ceb8;
  --river: #3d7397;
  --river-pale: #a9c7d8;
  --moss: #5c7a45;
  --fell-1: #c9c39f;
  --fell-2: #a8ae84;
  --fell-3: #8a9a6c;
  --fell-4: #6e8459;
  --route: #b5452f;
  --bike: #6a4c93;
  --accent: #8b5a2b;
  --warn-bg: #f6e3d4;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 6px 24px rgba(40, 30, 10, .06);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1c1e1b; --paper-2: #23261f; --card: #262922; --ink: #ece6d6; --ink-soft: #b3ab98;
    --rule: #3b3f35; --river: #7fb2d3; --river-pale: #335468; --moss: #9bbb7d;
    --fell-1: #3a3f30; --fell-2: #333a2b; --fell-3: #2c3326; --fell-4: #252b20;
    --route: #e2795f; --bike: #b79ce0; --accent: #d9a26a; --warn-bg: #3a2a22; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1c1e1b; --paper-2: #23261f; --card: #262922; --ink: #ece6d6; --ink-soft: #b3ab98;
  --rule: #3b3f35; --river: #7fb2d3; --river-pale: #335468; --moss: #9bbb7d;
  --fell-1: #3a3f30; --fell-2: #333a2b; --fell-3: #2c3326; --fell-4: #252b20;
  --route: #e2795f; --bike: #b79ce0; --accent: #d9a26a; --warn-bg: #3a2a22; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--river); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.01em; }
h2 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); }
h3 { font-size: 1.25rem; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.site-header nav { display: flex; gap: clamp(10px, 2vw, 22px); overflow-x: auto; scrollbar-width: none; }
.site-header nav a { color: var(--ink-soft); text-decoration: none; font-size: .95rem; white-space: nowrap; }
.site-header nav a:hover { color: var(--ink); }

/* Hero */
.hero { position: relative; min-height: min(78vh, 640px); display: flex; align-items: flex-start; overflow: hidden; background: linear-gradient(var(--paper-2), var(--paper)); }
.hero-art { position: absolute; inset: auto 0 0 0; width: 100%; height: 62%; }
.hero-art .h4 { fill: var(--fell-1); } .hero-art .h3 { fill: var(--fell-2); } .hero-art .h2 { fill: var(--fell-3); }
.hero-art .walls path { fill: none; stroke: var(--fell-4); stroke-width: 2; stroke-dasharray: 2 3; }
.hero-art .barn rect, .hero-art .barn path { fill: var(--fell-4); }
.hero-art .river { fill: none; stroke: var(--river); stroke-width: 10; stroke-linecap: round; opacity: .85; }
.hero-text { position: relative; max-width: 760px; padding: clamp(40px, 9vh, 96px) clamp(16px, 5vw, 64px) 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; color: var(--accent); margin: 0 0 8px; font-weight: 600; }
.hero h1 { font-size: clamp(2.8rem, 8vw, 5.2rem); font-weight: 700; margin-bottom: .2em; }
.lede { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--ink-soft); max-width: 60ch; }
.stats { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 22px 0 0; }
.stats div { min-width: 90px; }
.stats dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.stats dd { margin: 0; font-family: var(--serif); font-size: 1.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Sections */
.section { max-width: 1180px; margin: 0 auto; padding: clamp(48px, 8vw, 88px) clamp(16px, 4vw, 40px) 0; }
.section-head { max-width: 70ch; margin-bottom: 24px; }
.section-head p { color: var(--ink-soft); margin: 0; }

/* Day cards */
.days { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.day-card { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.day-card .day-no { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 600; }
.day-card h3 { margin: 6px 0 4px; }
.day-card .leg { color: var(--ink-soft); font-size: .95rem; margin: 0 0 10px; font-variant-numeric: tabular-nums; }
.day-card p { margin: 0 0 14px; font-size: .97rem; }
.day-card button { margin-top: auto; align-self: flex-start; }

button { font: inherit; cursor: pointer; }
.link-btn { background: none; border: 0; padding: 0; color: var(--river); font-weight: 600; font-size: .92rem; }
.link-btn:hover { text-decoration: underline; }

/* Map */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { border: 1px solid var(--rule); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 14px; font-size: .92rem; }
.chip.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.map-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
#leaflet { height: 560px; border-radius: 14px; border: 1px solid var(--rule); box-shadow: var(--shadow); z-index: 0; background: var(--paper-2); }
.stop-list { list-style: none; margin: 0; padding: 0; height: 560px; overflow-y: auto; border: 1px solid var(--rule); border-radius: 14px; background: var(--card); }
.stop-list li { border-bottom: 1px solid var(--rule); }
.stop-list li:last-child { border-bottom: 0; }
.stop-list button { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; padding: 10px 14px; color: var(--ink); }
.stop-list button:hover, .stop-list button.is-active { background: var(--paper-2); }
.stop-list .km { font-size: .85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.stop-list .nm { font-weight: 600; line-height: 1.25; }
.stop-list .nm small { display: block; font-weight: 400; color: var(--ink-soft); font-size: .82rem; }
.stop-list li.dim { opacity: .4; }

.pin { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 600 12px/1 var(--sans); background: var(--card); color: var(--ink); border: 2px solid var(--route); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.pin.end { background: var(--route); color: #fff; }
.pin.off { border-style: dashed; }
.leaflet-div-icon { background: none; border: 0; }
.leaflet-popup-content-wrapper { background: var(--card); color: var(--ink); border-radius: 12px; }
.leaflet-popup-tip { background: var(--card); }
.leaflet-popup-content { font: 15px/1.45 var(--sans); margin: 14px 16px; }
.leaflet-popup-content h4 { font: 600 1.05rem/1.2 var(--serif); margin: 0 0 2px; }
.leaflet-popup-content .meta { color: var(--ink-soft); font-size: .85rem; margin: 0 0 6px; }
.leaflet-popup-content p { margin: 0 0 8px; }
.walker { width: 16px; height: 16px; border-radius: 50%; background: var(--river); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--river); }

.profile { margin: 16px 0 0; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 12px 14px 8px; }
#profile { width: 100%; height: 170px; display: block; touch-action: pan-y; cursor: crosshair; }
#profile .area { fill: var(--fell-2); opacity: .6; }
#profile .line { fill: none; stroke: var(--fell-4); stroke-width: 1.5; }
#profile .day-band { fill: var(--paper-2); }
#profile .grid { stroke: var(--rule); stroke-width: 1; }
#profile text { fill: var(--ink-soft); font: 11px var(--sans); }
#profile .stop-tick { stroke: var(--route); stroke-width: 1; stroke-dasharray: 2 2; opacity: .6; }
#profile .cursor { stroke: var(--ink); stroke-width: 1; }
#profile .cursor-dot { fill: var(--river); stroke: var(--card); stroke-width: 2; }
.profile figcaption { font-size: .88rem; color: var(--ink-soft); padding-top: 4px; font-variant-numeric: tabular-nums; min-height: 1.5em; }

/* Illustrated map */
.illus-frame { background: #efe4c8; border-radius: 6px; padding: clamp(8px, 2vw, 18px); box-shadow: var(--shadow), inset 0 0 0 1px #c9b98f; }
.illus-frame { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#illus { display: block; max-width: none; height: auto; user-select: none; }
.illus-frame { cursor: grab; }
.illus-frame.dragging { cursor: grabbing; }
#illus .stop-hit { cursor: pointer; }
#illus .stop-hit:hover circle, #illus .stop-hit:focus circle { fill: #b5452f; }
#illus .stop-hit:hover text, #illus .stop-hit:focus text { fill: #fff; }
#illus .stop-hit:focus { outline: none; }

/* Commentary */
.day-block { margin-bottom: 40px; }
.day-block > header { border-top: 2px solid var(--ink); padding-top: 14px; margin-bottom: 8px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; }
.day-block > header h3 { font-size: 1.6rem; margin: 0; }
.day-block > header span { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.day-block > p { color: var(--ink-soft); max-width: 70ch; }
.stop { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 4px 20px; padding: 22px 0; border-top: 1px solid var(--rule); scroll-margin-top: 80px; }
.stop.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--river) 18%, transparent); } to { background: transparent; } }
.stop .num { font-family: var(--serif); font-size: 2.2rem; font-weight: 700; color: var(--route); line-height: 1; }
.stop .num small { display: block; font: 600 .82rem/1.4 var(--sans); color: var(--ink-soft); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stop h4 { font: 600 1.35rem/1.2 var(--serif); margin: 0; }
.stop .tag { font-style: italic; font-family: var(--serif); color: var(--accent); margin: 2px 0 10px; }
.stop .body p { margin: 0 0 .8em; max-width: 68ch; }
.stop .badge { display: inline-block; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; border: 1px dashed var(--ink-soft); color: var(--ink-soft); border-radius: 4px; padding: 0 6px; margin-left: 8px; vertical-align: middle; font-family: var(--sans); font-weight: 600; }
.stop.danger .tag { color: var(--route); }

/* Practical */
.practical-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.practical-grid article { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 20px 22px; }
.practical-grid article p { margin: 0 0 .7em; font-size: .97rem; }
.practical-grid .warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--route) 40%, var(--rule)); }

.site-footer { max-width: 1180px; margin: 72px auto 0; padding: 24px clamp(16px, 4vw, 40px) 40px; border-top: 1px solid var(--rule); color: var(--ink-soft); font-size: .88rem; }

@media (max-width: 860px) {
  .map-wrap { grid-template-columns: 1fr; }
  #leaflet { height: 440px; }
  .stop-list { height: auto; max-height: 300px; }
  .site-header nav a:nth-child(n+4) { display: none; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .stop { grid-template-columns: 1fr; }
  .stop .num { font-size: 1.6rem; display: flex; gap: 10px; align-items: baseline; }
  .stop .num small { margin: 0; }
  .site-header nav { display: none; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .stop.flash { animation: none; } }

/* Route-type switch, legend, GPX */
.map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 14px; }
.map-tools .chips { margin: 0; }
.mode { display: inline-flex; border: 1px solid var(--ink); border-radius: 999px; overflow: hidden; }
.mode button { border: 0; background: var(--card); color: var(--ink); padding: 7px 16px; font-size: .95rem; font-weight: 600; }
.mode button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.map-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-top: 10px; }
.legend { margin: 0; color: var(--ink-soft); font-size: .9rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 22px; height: 4px; border-radius: 2px; margin-left: 6px; }
.legend .sw.dash { background: repeating-linear-gradient(90deg, #e07b00 0 6px, transparent 6px 10px); height: 5px; }
.dl-btn { border: 1px solid var(--rule); background: var(--card); color: var(--ink); border-radius: 8px; padding: 6px 12px; font-size: .9rem; }
.dl-btn:hover { border-color: var(--ink-soft); }
.bike-stats { margin: 0 0 22px; }
.bike-days { margin: 0 0 .7em; padding-left: 1.1em; font-size: .97rem; }
