@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #07120f;
  --panel: #0d1d19;
  --panel-2: #122621;
  --line: rgba(218, 241, 231, 0.13);
  --text: #f4f8f6;
  --muted: #9eb3aa;
  --mint: #56f0ad;
  --mint-soft: rgba(86, 240, 173, 0.12);
  --amber: #f4b860;
  --red: #f27070;
  --blue: #58a6ff;
  --radius: 18px;
  font-family: "DM Sans", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 15% -10%, #163c2f 0, transparent 30rem), var(--bg); color: var(--text); }
button, input, select { font: inherit; touch-action: manipulation; }
button, select, input { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(86, 240, 173, 0.45); outline-offset: 2px; }

.topbar, main { width: min(1600px, calc(100% - 48px)); margin-inline: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 116px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 5px; color: var(--mint); font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Manrope", sans-serif; }
h1 { margin: 0; font-size: clamp(27px, 3vw, 42px); letter-spacing: -.045em; }
h1 span { color: var(--mint); font-weight: 500; }
.course-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 5px rgba(244, 184, 96, .1); }

.planner { display: grid; grid-template-columns: minmax(245px, .85fr) minmax(550px, 1.9fr) minmax(200px, .8fr) minmax(160px, .6fr); gap: 18px; align-items: start; padding: 27px 0 24px; }
.control-label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.control-hint { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.time-fields { display: flex; align-items: end; }
.time-fields label { display: grid; gap: 5px; }
.time-fields label span { color: var(--muted); font-size: 10px; }
.time-fields b { padding: 0 6px 9px; color: var(--muted); }
.time-fields input { width: 62px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); text-align: center; font-weight: 700; }
.field-error { min-height: 14px; margin: 4px 0 -18px; color: var(--red); font-size: 11px; }
select { width: 100%; height: 42px; padding: 0 36px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.range-heading, .scrubber-label { display: flex; justify-content: space-between; gap: 16px; }
.range-heading .control-label { margin-bottom: 0; }
.range-heading output { font-size: 13px; font-weight: 700; }
input[type="range"] { width: 100%; accent-color: var(--mint); }
.range-control > input { margin-top: 14px; }
.strategy-control { display: grid; grid-template-columns: minmax(260px, .95fr) minmax(275px, 1.05fr); gap: 12px; }
.strategy-info { min-height: 126px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(86, 240, 173, .045); }
.strategy-info-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.strategy-info-heading strong { font-size: 13px; }
.strategy-info-heading span { flex: none; padding: 4px 7px; border-radius: 999px; background: var(--mint-soft); color: var(--mint); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.strategy-info-heading span[data-tone="situational"] { background: rgba(88, 166, 255, .12); color: var(--blue); }
.strategy-info-heading span[data-tone="caution"] { background: rgba(242, 112, 112, .12); color: var(--red); }
.strategy-info > p { margin: 7px 0 0; color: #dfe9e5; font-size: 11px; line-height: 1.4; }
.strategy-tradeoffs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.strategy-tradeoffs p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.35; }
.strategy-tradeoffs strong { display: block; margin-bottom: 2px; color: var(--text); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.strategy-tradeoffs span { display: block; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: rgba(13, 29, 25, .78); backdrop-filter: blur(12px); }
.metrics article { position: relative; min-width: 0; padding: 18px 22px; }
.metrics article + article::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 1px; background: var(--line); }
.metrics span, .active-stats span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.metrics strong { display: inline-block; margin: 5px 6px 0 0; font: 600 clamp(21px, 2vw, 28px) "Manrope", sans-serif; letter-spacing: -.04em; }
.metrics small { color: var(--muted); font-size: 11px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(390px, .8fr); min-height: 650px; margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.map-shell { position: relative; min-height: 650px; }
#map { position: absolute; inset: 0; background: #11241e; overscroll-behavior: contain; }
.leaflet-container { font-family: "DM Sans", sans-serif; }
.leaflet-control-attribution { background: rgba(7, 18, 15, .78) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--mint); }
.leaflet-bar a { border-color: var(--line) !important; background: var(--panel) !important; color: var(--text) !important; }
.map-tools, .pace-legend { position: absolute; z-index: 500; display: flex; align-items: center; gap: 12px; border: 1px solid rgba(255,255,255,.15); border-radius: 12px; background: rgba(7,18,15,.88); box-shadow: 0 10px 35px rgba(0,0,0,.22); backdrop-filter: blur(12px); }
.map-tools { top: 14px; right: 14px; padding: 8px; }
.map-tools button { padding: 7px 10px; border: 0; border-radius: 7px; background: var(--mint); color: #052016; font-size: 12px; font-weight: 700; cursor: pointer; }
.map-tools label { color: var(--text); font-size: 11px; white-space: nowrap; }
.map-tools input { accent-color: var(--mint); vertical-align: -2px; }
.pace-legend { left: 14px; bottom: 14px; padding: 8px 11px; color: var(--text); font-size: 10px; }
.pace-legend i { width: 90px; height: 5px; border-radius: 9px; background: linear-gradient(90deg, #42e6a4, #57a9f5, #f4b860, #f27070); }

.analysis-panel { padding: 25px; border-left: 1px solid var(--line); background: linear-gradient(155deg, rgba(20,45,37,.85), var(--panel) 45%); }
.panel-heading, .section-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.panel-heading h2, .section-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.03em; }
.clock { padding-top: 20px; color: var(--mint); font: 600 20px "Manrope", sans-serif; font-variant-numeric: tabular-nums; }
.active-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 22px 0; }
.active-stats div { min-width: 0; }
.active-stats strong { display: block; margin-top: 6px; font-size: 14px; }
.playback-controls { display: flex; align-items: end; gap: 10px; }
.play-button { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 96px; height: 42px; border: 0; border-radius: 10px; background: var(--mint); color: #052016; font-weight: 700; cursor: pointer; }
.speed-control { flex: 1; }
.speed-control span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px; }
.speed-control select { height: 42px; }
.follow-control { padding-bottom: 11px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.follow-control input { accent-color: var(--mint); }
.scrubber-label { margin: 19px 0 6px; color: var(--muted); font-size: 11px; }
.scrubber { margin: 0; }
.insight { min-height: 76px; margin: 21px 0; padding: 15px; border-left: 3px solid var(--amber); background: rgba(244,184,96,.07); }
.insight-label { color: var(--amber); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.insight p { margin: 5px 0 0; color: #dfe9e5; font-size: 13px; line-height: 1.45; }
.elevation-heading { display: flex; justify-content: space-between; align-items: baseline; margin-top: 20px; }
.elevation-heading h3 { margin: 0; font-size: 15px; }
.elevation-heading span { color: var(--muted); font-size: 10px; }
#elevation-chart { display: block; width: 100%; height: auto; margin-top: 8px; overflow: visible; cursor: crosshair; }
.chart-grid { stroke: rgba(218,241,231,.1); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 10px; }
.elevation-area { fill: rgba(86,240,173,.1); stroke: var(--mint); stroke-width: 2; }
.pace-line { fill: none; stroke: var(--amber); stroke-width: 2; }
.chart-cursor { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-dot { fill: var(--text); stroke: var(--panel); stroke-width: 3; }

.runner-marker { width: 20px; height: 20px; border: 4px solid #052016; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(86,240,173,.3), 0 4px 18px rgba(0,0,0,.4); }
.km-marker { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid rgba(7,18,15,.8); border-radius: 50%; background: var(--text); color: #07120f; font-size: 10px; font-weight: 700; box-shadow: 0 3px 12px rgba(0,0,0,.25); }
.fuel-marker { display: grid; place-items: center; width: 25px; height: 25px; border: 2px solid #07120f; border-radius: 8px; background: var(--amber); color: #07120f; font-size: 12px; font-weight: 700; box-shadow: 0 3px 12px rgba(0,0,0,.3); }
.start-finish-marker { display: grid; place-items: center; width: 30px; height: 30px; border: 3px solid #07120f; border-radius: 50%; background: var(--mint); color: #07120f; font-size: 14px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.leaflet-tooltip { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); box-shadow: 0 8px 25px rgba(0,0,0,.3); }
.leaflet-tooltip-top::before { border-top-color: var(--panel); }

.splits-section { margin: 44px 0 24px; }
.section-heading { align-items: end; margin-bottom: 18px; }
.section-heading p { max-width: 560px; margin-bottom: 0; color: var(--muted); font-size: 13px; }
.splits-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 700; }
td:nth-child(2), td:nth-child(4) { font-variant-numeric: tabular-nums; }
.cue { color: var(--muted); white-space: normal; min-width: 210px; }
.grade-up { color: var(--amber); }
.grade-down { color: var(--mint); }

.source-note { display: flex; justify-content: space-between; gap: 28px; margin: 32px 0 60px; padding-top: 24px; border-top: 1px solid var(--line); }
.source-note strong { font-size: 12px; }
.source-note p { max-width: 900px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.source-note nav { display: flex; gap: 18px; white-space: nowrap; }
.source-note a { color: var(--mint); font-size: 12px; text-decoration: none; }
.source-note a:hover { text-decoration: underline; }

@media (max-width: 1050px) {
  .planner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strategy-control { grid-column: 1 / -1; }
  .workspace { grid-template-columns: 1fr; }
  .map-shell { min-height: 520px; }
  .analysis-panel { border-top: 1px solid var(--line); border-left: 0; }
  #elevation-chart { max-height: 280px; }
}

@media (max-width: 720px) {
  .topbar, main { width: min(100% - 28px, 1600px); }
  .topbar { min-height: 96px; }
  .course-status { max-width: 145px; text-align: right; font-size: 10px; }
  .planner { grid-template-columns: 1fr; gap: 20px; }
  .strategy-control { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics article:nth-child(3)::before { display: none; }
  .metrics article:nth-child(n+3) { border-top: 1px solid var(--line); }
  .workspace { min-height: 0; }
  .map-shell { min-height: 440px; }
  .map-tools { right: 10px; left: 10px; justify-content: center; }
  .pace-legend { left: 10px; bottom: 10px; }
  .analysis-panel { padding: 20px 16px; }
  .section-heading, .source-note { align-items: start; flex-direction: column; }
  .source-note nav { white-space: normal; flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
  .metrics article + article::before { display: none; }
  .metrics article:nth-child(n+2) { border-top: 1px solid var(--line); }
  .map-tools { gap: 7px; }
  .map-tools label { font-size: 10px; }
  .active-stats { grid-template-columns: 1fr 1fr; }
  .active-stats div:last-child { display: none; }
}

@media (max-width: 1050px), (hover: none), (pointer: coarse) {
  select, .play-button { min-height: 44px; }
  .time-fields input { min-height: 44px; }
  input[type="range"] { min-height: 32px; }
  .map-tools { gap: 5px; }
  .map-tools button { min-height: 44px; padding-inline: 13px; }
  .map-tools label { display: flex; align-items: center; min-height: 44px; gap: 5px; padding-inline: 3px; }
  .map-tools input[type="checkbox"], .follow-control input { width: 20px; height: 20px; }
  .leaflet-bar a { width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 22px !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
