* {
  box-sizing: border-box;
}

:root {
  --paper: #f7f4ec;
  --raised: #fffdf8;
  --ink: #232a1f;
  --ink-soft: #6d7264;
  --line: #d9d4c7;
  --line-soft: #ebe6da;
  --green: #2c5e3f;
  --green-deep: #1e3a2a;
  --lake: #b9d9df;
  --strava: #fc4c02;
  --shadow-panel: 0 12px 36px rgba(35, 42, 31, 0.16), 0 2px 8px rgba(35, 42, 31, 0.09);
  --shadow-card: 0 8px 24px rgba(35, 42, 31, 0.18);
  --sheet-height: 57vh;
  color-scheme: light;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

.test-lab-mode {
  position: fixed;
  z-index: 2000;
  top: 10px;
  left: 50%;
  padding: 7px 11px;
  color: var(--green-deep);
  background: var(--paper);
  border: 1px solid var(--green);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  font:
    600 11.5px / 1.3 system-ui,
    sans-serif;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  transform: translateX(-50%);
}

.test-lab-mode[hidden] {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green), transparent 45%);
  outline-offset: 2px;
}

#zero-state[hidden],
#inspect-card[hidden],
#map-preview[hidden],
#perf[hidden] {
  display: none;
}

.mono {
  font-family: system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

#map {
  position: fixed;
  inset: 0 0 var(--sheet-height);
  background:
    radial-gradient(circle at 70% 20%, rgba(185, 217, 223, 0.7), transparent 35%), var(--paper);
  cursor: grab;
  transition: bottom 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

#map:active {
  cursor: grabbing;
}

#map.map-inspectable {
  cursor: pointer;
}

#panel {
  position: fixed;
  z-index: 1000;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--sheet-height);
  display: flex;
  flex-direction: column;
  padding: 5px 14px calc(10px + env(safe-area-inset-bottom));
  overflow: hidden;
  background: linear-gradient(135deg, rgba(245, 179, 1, 0.05), transparent 42%), var(--raised);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 32px rgba(35, 42, 31, 0.12);
  transform: translateY(12px);
  opacity: 0;
  transition:
    height 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 180ms ease;
}

body.ready #panel {
  transform: none;
  opacity: 1;
}

#panel-handle {
  position: fixed;
  z-index: 1002;
  bottom: calc(var(--sheet-height) - 22px);
  left: 50%;
  width: 72px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--green-deep);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 99px;
  box-shadow: 0 -4px 12px rgba(35, 42, 31, 0.1);
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  transition:
    bottom 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    color 120ms ease,
    transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 180ms ease;
  cursor: pointer;
}

body.ready #panel-handle {
  transform: translateX(-50%);
  opacity: 1;
}

#panel-handle::before {
  width: 9px;
  height: 9px;
  content: "";
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 180ms ease;
}

#panel-header,
#help > header,
#settings > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

#admin-link,
#sim-toggle {
  padding: 6px 9px;
  color: var(--green);
  background: var(--raised);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
}

#admin-link:hover,
#sim-toggle:hover {
  border-color: var(--green);
  background: #f1eee4;
}

#admin-link[hidden],
#sim-toggle[hidden] {
  display: none;
}

#sim-toggle[aria-pressed="true"] {
  color: var(--raised);
  background: var(--green);
  border-color: var(--green);
}

#sim-toggle[aria-pressed="true"]:hover {
  background: var(--green-deep);
  border-color: var(--green-deep);
}

.brand-mark {
  width: 36px;
  height: 36px;
  overflow: visible;
}

.brand-mark path {
  fill: none;
  stroke: var(--green);
  stroke-width: 4;
  stroke-linecap: round;
}

.brand-mark circle {
  fill: var(--green);
  stroke: var(--green-deep);
  stroke-width: 1.5;
}

.eyebrow {
  display: block;
  margin-bottom: -2px;
  color: var(--green);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
}

#panel-header h1,
#help h2,
#settings h2 {
  margin: 0;
  font-family: system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.round-button {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  color: var(--green-deep);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-weight: 700;
  cursor: pointer;
}

.round-button:hover {
  border-color: var(--green);
  background: #f1eee4;
}

#tagline {
  flex: none;
  margin: 5px 0 9px;
  color: var(--ink-soft);
  font-size: 11.5px;
}

.segments {
  display: flex;
  flex: none;
  gap: 3px;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  background: #eeeadf;
  border-radius: 10px;
}

.segments::-webkit-scrollbar {
  display: none;
}

.segment {
  min-height: 30px;
  flex: 1 0 auto;
  padding: 5px 8px;
  color: var(--ink-soft);
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}

.segment.active {
  color: var(--raised);
  background: var(--green-deep);
  box-shadow: 0 1px 3px rgba(35, 42, 31, 0.16);
}

.scope-tabs {
  display: flex;
  flex: none;
  gap: 6px;
  margin-top: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}

.scope-chip {
  padding: 4px 9px;
  color: var(--green);
  white-space: nowrap;
  background: transparent;
  border: 1px solid #b9c5b8;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}

.scope-chip.active {
  color: var(--green-deep);
  background: #e4ebdf;
  border-color: var(--green);
}

.scope-chip:disabled {
  opacity: 0.34;
  cursor: default;
}

#zero-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  gap: 12px;
  margin-top: 9px;
  padding: 9px 10px;
  background: #eef2e8;
  border-left: 3px solid var(--green);
  border-radius: 3px 9px 9px 3px;
}

#zero-state p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.35;
}

#zero-state button {
  flex: none;
  padding: 6px 9px;
  color: var(--raised);
  background: var(--green);
  border: 0;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}

.run-card {
  padding: 4px 10px 12px 26px;
  background: color-mix(in srgb, var(--runner, #2c5e3f), var(--raised) 94%);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: inset 3px 0 var(--runner, #2c5e3f);
  animation: card-in 160ms ease-out;
}

#feed .run-card p {
  margin: 6px 0 0;
  font-size: 9.5px;
  line-height: 1.35;
}

.selection-status {
  color: var(--ink-soft);
}

/* Two stats spread across the card: space at the edges and between. */
.run-stats {
  display: flex;
  justify-content: space-evenly;
  gap: 14px;
  margin-top: 9px;
}

.run-stats span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  text-align: center;
}

.run-stats small {
  color: var(--ink-soft);
  font-size: 8.5px;
}

.run-stats strong {
  color: var(--ink);
  font-size: 10.5px;
}

.place-history {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 9.5px;
}

.place-history summary {
  color: var(--green-deep);
  font-weight: 600;
  cursor: pointer;
}

.place-history summary span {
  margin-left: 3px;
  color: var(--ink-soft);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.place-history ol {
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.place-history li {
  padding: 5px 0;
  border-top: 1px solid var(--line-soft);
}

.place-history li button {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 7px;
  padding: 2px 3px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

.place-history li button:hover {
  background: rgba(44, 94, 63, 0.055);
}

/* The moment being viewed: the selected run's row is marked, rows past the
   playhead read as the future of this point. */
.place-history li.current button {
  background: color-mix(in srgb, var(--runner, #2c5e3f), var(--raised) 90%);
  box-shadow: inset 2px 0 var(--runner, #2c5e3f);
}

.place-history li.future {
  opacity: 0.45;
}

.place-history li button > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.place-history small {
  color: var(--ink-soft);
  font-size: 8.5px;
}

.outline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
}

.outline-toggle input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--runner, var(--green));
  cursor: pointer;
}

.impact-wrap {
  position: relative;
  margin-top: 9px;
}

.impact-bar {
  display: flex;
  height: 16px;
  overflow: hidden;
  background: #eeeadf;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.impact-bar i {
  display: block;
  min-width: 3px;
  cursor: default;
}

.bar-tip {
  position: absolute;
  bottom: calc(100% + 5px);
  z-index: 2;
  padding: 3px 8px;
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 2px 7px rgba(35, 42, 31, 0.12);
  font-size: 9px;
  transform: translateX(-50%);
}

.bar-tip[hidden] {
  display: none;
}

.panel-section {
  flex: none;
  min-height: 0;
  margin-top: 9px;
  border-top: 1px solid var(--line);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 1px 3px;
}

#panel .section-header h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.section-status {
  flex: none;
  color: var(--ink-soft);
  font-size: 9.5px;
}

/* Solo toggle sits at the right of the Standings header; kept compact so it
   never crowds the label (which ellipsizes to make room). */
.solo-toggle {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 4px;
  color: var(--ink-soft);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

.solo-toggle input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--green);
  cursor: pointer;
}

.solo-toggle:hover {
  color: var(--ink);
}

.standings-section {
  max-height: 34%;
  overflow-y: auto;
}

body.has-selection .standings-section {
  max-height: 22%;
}

.feed-section {
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

#feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.standing,
.run {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}

.standing {
  gap: 9px;
  padding: 6px 3px;
  border-radius: 7px;
  font-size: 12.5px;
}

/* No route means nothing to inspect: the row reports the run and stops there. */
.run.no-route {
  cursor: default;
}

.run.no-route .sub-area {
  font-style: italic;
}

.standing:hover,
.run:not(.no-route):hover {
  background: rgba(44, 94, 63, 0.055);
}

.standing.isolated,
.standing.solo.selected {
  background: #e8eee3;
  box-shadow: inset 3px 0 var(--green);
}

.standing .rank {
  width: 15px;
  color: var(--ink-soft);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  text-align: center;
}

/* Solo standings are single-select: a radio dot replaces the rank number. */
.standing .radio {
  display: flex;
  width: 15px;
  flex: none;
  justify-content: center;
}

.standing .radio::before {
  content: "";
  width: 10px;
  height: 10px;
  box-sizing: border-box;
  border: 1.5px solid var(--ink-soft);
  border-radius: 50%;
}

.standing.solo.selected .radio::before {
  border-color: var(--green);
  background: var(--green);
  box-shadow: inset 0 0 0 2px var(--raised);
}

.runner-swatch {
  width: 11px;
  height: 11px;
  flex: none;
  background: var(--runner);
  border: 1px solid color-mix(in srgb, var(--runner), #232a1f 24%);
  border-radius: 50%;
}

.standing .name {
  flex: 1;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.standing .area {
  font-size: 10.5px;
}

.run {
  gap: 9px;
  padding: 8px 3px;
  font-size: 11.5px;
}

.run.selected {
  background: color-mix(in srgb, var(--runner, #2c5e3f), var(--raised) 90%);
  box-shadow: inset 3px 0 var(--runner, #2c5e3f);
  border-bottom-color: transparent;
}

.run .what {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
}

/* Headline carries the load-bearing facts. The date and distance columns are
   fixed width so the name column is constant down the list — that keeps the
   centered dates truly lined up as you scroll (an auto date column would size
   to each row's text and drift). Year-bearing historical dates can run tight;
   revisit the date-column width if that becomes common. */
.run .headline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px 46px;
  align-items: baseline;
  gap: 6px;
}

.run .who {
  overflow: hidden;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run .when {
  color: var(--ink);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.run .dist {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

/* Second line, de-emphasized: description + location on the left, area added
   right-aligned so it stacks under the distance in the headline above. */
.run .sub {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 9.5px;
}

.run .sub-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run .sub-area {
  flex: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.run.future {
  opacity: 0.4;
}

.empty,
.feed-limit {
  margin: 0;
  padding: 10px 3px;
  color: var(--ink-soft);
  font-size: 11.5px;
}

#panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

#account {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 8.5px;
  line-height: 1.25;
}

#account strong {
  color: var(--ink);
  font-weight: 600;
}

.signout-form {
  flex: none;
  margin: 0;
}

.signout {
  padding: 0;
  color: var(--ink-soft);
  font: inherit;
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}

.signout:hover {
  color: var(--ink);
}

/* Quiet label on the Madison competition-boundary rectangle. */
.madison-border-label.leaflet-tooltip {
  padding: 1px 6px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  background: color-mix(in srgb, var(--raised), transparent 10%);
  border: 0;
  border-radius: 4px;
  box-shadow: none;
}

.madison-border-label.leaflet-tooltip::before {
  display: none;
}

/* Hidden once the map zooms out to where bubbles take over (main.js sets the
   class), so the label stops crowding a small map. */
.leaflet-container.hide-border-label .madison-border-label {
  display: none;
}

#account .connect {
  display: inline-block;
  flex: none;
  padding: 6px 9px;
  color: white;
  text-decoration: none;
  background: var(--strava);
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 600;
}

#account .consent {
  max-width: none;
}

#attribution {
  flex: none;
  margin: 0;
  color: var(--ink-soft);
  font-size: 8.5px;
  white-space: nowrap;
}

#inspect-card {
  position: fixed;
  z-index: 1100;
  right: 12px;
  bottom: calc(var(--sheet-height) + 12px);
  width: min(280px, calc(100vw - 24px));
  padding: 13px 14px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-top: 3px solid var(--green);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  animation: card-in 160ms ease-out;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

.inspect-close {
  position: absolute;
  top: 6px;
  right: 7px;
  padding: 3px 6px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  font-size: 17px;
  cursor: pointer;
}

#inspect-card h3 {
  margin: 7px 22px 2px 0;
  font-family: system-ui, sans-serif;
  font-size: 17px;
}

#inspect-card p {
  margin: 4px 0;
  color: var(--ink-soft);
  font-size: 10.5px;
  line-height: 1.4;
}

#inspect-card .inspect-kicker {
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.clump-owner {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  font-size: 10px;
}

.clump-owner strong {
  font-size: 9px;
}

.clump-zoom {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  color: var(--raised);
  background: var(--green);
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

#map-preview {
  position: fixed;
  z-index: 1080;
  display: flex;
  align-items: center;
  max-width: 230px;
  gap: 7px;
  padding: 8px 10px;
  pointer-events: none;
  background: rgba(255, 253, 248, 0.97);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}

#map-preview > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

#map-preview strong,
#map-preview small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#map-preview strong {
  font-size: 10.5px;
}

#map-preview small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 8.5px;
}

#map-preview .preview-meta {
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  font-size: 8px;
}

#map-preview.clump-preview {
  display: block;
  width: 220px;
  max-width: min(240px, calc(100vw - 20px));
}

#map-preview.clump-preview > span {
  display: block;
}

#map-preview .clump-kicker {
  margin: 0 0 2px;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#map-preview.clump-preview .preview-meta {
  display: block;
  margin-top: 4px;
}

#timeline {
  position: fixed;
  z-index: 1010;
  /* the sheet handle pokes 22px above the sheet on phones; stay clear of it */
  bottom: calc(var(--sheet-height) + 34px);
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transition: bottom 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

#timeline > * {
  pointer-events: auto;
}

#timeline-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  color: var(--green-deep);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 99px;
  box-shadow: 0 4px 12px rgba(35, 42, 31, 0.14);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

#timeline-toggle:disabled {
  opacity: 0.4;
  cursor: default;
}

#timeline-toggle svg {
  width: 10px;
  height: 10px;
  fill: var(--green);
}

#timeline.open #timeline-toggle {
  display: none;
}

/* One slim line: play · the timeline itself · close */
#timeline-strip {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 99px;
  box-shadow: var(--shadow-panel);
}

#timeline-strip[hidden] {
  display: none;
}

#timeline-strip > button {
  display: grid;
  min-width: 34px;
  height: 34px;
  flex: none;
  padding: 0;
  place-items: center;
  color: var(--green-deep);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

#timeline-strip > button:hover:not(:disabled) {
  border-color: var(--green);
}

#timeline-strip > button:disabled {
  opacity: 0.4;
  cursor: default;
}

#timeline-track {
  position: relative;
  flex: 1;
  height: 48px;
  cursor: pointer;
  touch-action: none;
}

#timeline-line {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 4px;
  margin-top: -2px;
  pointer-events: none;
  background: #e6e1d3;
  border-radius: 2px;
}

/* Cap ticks: the ends of the line are dates too (the clickable end labels). */
#timeline-line::before,
#timeline-line::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 1px;
  height: 10px;
  background: #cfc9b8;
}

#timeline-line::before {
  left: 0;
}

#timeline-line::after {
  right: 0;
}

#timeline-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Each tick is a real control: a calendar boundary the playhead jumps to. */
#timeline-marks .tick {
  position: absolute;
  top: 0;
  height: 100%;
  width: 24px;
  padding: 0;
  pointer-events: auto;
  background: transparent;
  border: 0;
  transform: translateX(-50%);
  cursor: pointer;
}

#timeline-marks .tick i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 10px;
  margin: -5px 0 0 -0.5px;
  background: #cfc9b8;
}

#timeline-marks .tick span {
  position: absolute;
  bottom: 0;
  left: 50%;
  color: var(--ink-soft);
  white-space: nowrap;
  transform: translateX(-50%);
  font-size: 8px;
}

/* Year boundaries anchor the scan: darker, taller tick, bolder label. */
#timeline-marks .tick.year i {
  height: 14px;
  margin-top: -7px;
  background: var(--line-strong);
}

#timeline-marks .tick.year span {
  color: var(--ink);
  font-size: 9px;
  font-weight: 700;
}

#timeline-marks .tick:hover:not(:disabled) span {
  color: var(--green-deep);
  text-decoration: underline;
}

#timeline-marks .tick:hover:not(:disabled) i {
  background: var(--green);
}

#timeline-marks .tick:disabled {
  cursor: default;
  opacity: 0.5;
}

#timeline-fill {
  position: absolute;
  top: 50%;
  left: 0;
  height: 4px;
  margin-top: -2px;
  pointer-events: none;
  background: var(--green);
  border-radius: 2px;
}

#timeline-future {
  position: absolute;
  top: 50%;
  right: 0;
  height: 4px;
  margin-top: -2px;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, #cfc9b8 0 3px, transparent 3px 7px);
}

#timeline-future[hidden] {
  display: none;
}

#timeline-handle {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  pointer-events: none;
  background: var(--green-deep);
  border-radius: 50%;
  box-shadow: 0 0 0 2.5px var(--raised);
}

#timeline-cursor {
  position: absolute;
  top: -1px;
  padding: 1px 7px;
  color: var(--green-deep);
  white-space: nowrap;
  pointer-events: none;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 9px;
  transform: translateX(-50%);
}

/* The end labels are the first and last ticks: exact dates, clickable. */
.timeline-end-label {
  position: absolute;
  bottom: 0;
  padding: 2px 3px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 8px;
}

.timeline-end-label:hover {
  color: var(--green-deep);
  text-decoration: underline;
}

#timeline-start {
  left: 0;
}

#timeline-endlabel {
  right: 0;
}

.leaflet-tile-pane {
  transition: filter 160ms ease;
}

#map[data-basemap="muted"] .leaflet-tile-pane {
  filter: saturate(0.38) contrast(0.88) brightness(1.07);
}

#perf {
  position: fixed;
  z-index: 1200;
  top: 8px;
  right: 8px;
  margin: 0;
  padding: 8px 9px;
  color: #eaf3e8;
  background: rgba(30, 58, 42, 0.9);
  border-radius: 6px;
  font: 10px / 1.45 monospace;
  pointer-events: none;
}

/* Same bottom-sheet-on-mobile treatment as the help dialog. */
#settings {
  width: 100%;
  max-width: none;
  max-height: 88vh;
  margin: auto 0 0;
  padding: 20px 20px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  color: var(--ink);
  background: var(--raised);
  border: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 38px rgba(35, 42, 31, 0.24);
}

#settings::backdrop {
  background: rgba(30, 58, 42, 0.36);
  backdrop-filter: blur(2px);
}

.settings-fields > section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.settings-fields h3 {
  margin: 0;
  font: var(--text-body-strong);
}

.settings-fields h3 + .settings-note {
  margin-top: 3px;
}

.settings-note {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font: var(--text-meta);
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(35, 42, 31, 0.18);
  cursor: pointer;
}

.swatch[aria-pressed="true"] {
  border-color: var(--ink);
}

.swatch:disabled {
  cursor: not-allowed;
  opacity: 0.28;
}

.settings-toggle {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: 10px;
  color: var(--ink);
  font: var(--text-meta);
  line-height: 1.45;
  cursor: pointer;
}

.settings-toggle input {
  flex: none;
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--green);
}

.settings-status {
  min-height: 16px;
  margin: 14px 0 0;
  color: var(--ink-soft);
  font: var(--text-meta);
}

.settings-danger {
  color: #7f2f26;
}

.settings-disconnect {
  padding: 8px 10px;
  color: #7f2f26;
  background: transparent;
  border: 1px solid #c99b93;
  border-radius: 7px;
  font: var(--text-meta);
  font-weight: 650;
  cursor: pointer;
}

.settings-disconnect:disabled {
  opacity: 0.45;
  cursor: wait;
}

.account-actions {
  display: flex;
  flex: none;
  gap: 10px;
  align-items: center;
}

#help {
  width: 100%;
  max-width: none;
  max-height: 88vh;
  margin: auto 0 0;
  padding: 20px 20px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  color: var(--ink);
  background: var(--raised);
  border: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 38px rgba(35, 42, 31, 0.24);
}

#help::backdrop {
  background: rgba(30, 58, 42, 0.36);
  backdrop-filter: blur(2px);
}

#help .rule {
  margin: 14px 0 2px;
  font-family: system-ui, sans-serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
}

#help section {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

#help svg {
  display: block;
  width: 100%;
  max-width: 300px;
  margin-bottom: 4px;
}

#help p {
  margin: 5px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
}

#help .help-notes p + p {
  margin-top: 9px;
}

#help footer {
  margin-top: 14px;
  padding-top: 13px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}

#help footer p {
  font-size: 11.5px;
}

@media (max-width: 639px) {
  .brand-mark {
    width: 28px;
    height: 28px;
  }

  #panel-header h1 {
    font-size: 19px;
  }

  #tagline {
    margin: 3px 0 7px;
    font-size: 10.5px;
  }

  body.panel-collapsed {
    --sheet-height: 86px;
  }

  body.panel-collapsed #panel > :not(#panel-header) {
    display: none;
  }

  body.panel-collapsed #panel-header {
    flex: 1;
  }

  body.panel-collapsed #panel-handle::before {
    transform: translateY(2px) rotate(225deg);
  }
}

.leaflet-control-zoom a {
  color: var(--green-deep);
  background: var(--raised);
}

.leaflet-control-attribution {
  font-family: system-ui, sans-serif;
  font-size: 8px;
}

@media (min-width: 640px) {
  #map {
    inset: 0;
  }

  #panel {
    top: 12px;
    right: auto;
    bottom: 12px;
    left: 12px;
    width: 340px;
    height: auto;
    padding: 12px 16px 14px;
    border-bottom: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-panel);
    transform: translateX(-10px);
  }

  #panel-handle {
    display: none;
  }

  .segment {
    padding-right: 6px;
    padding-left: 6px;
    font-size: 9.5px;
  }

  #inspect-card {
    right: 16px;
    bottom: 22px;
  }

  #timeline {
    bottom: 14px;
    left: 364px;
    right: 12px;
  }

  #help {
    width: 470px;
    max-height: 84vh;
    margin: auto;
    padding: 22px 24px;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(35, 42, 31, 0.26);
  }

  #settings {
    width: 420px;
    max-height: 84vh;
    margin: auto;
    padding: 22px 24px;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(35, 42, 31, 0.26);
  }

  .leaflet-left {
    left: 358px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto;
    animation-duration: 0.01ms;
    transition-duration: 0.01ms;
  }
}

/* Private access, invitation, and pending-approval pages. */
body.access-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(circle at 75% 15%, rgba(185, 217, 223, 0.48), transparent 35%), var(--paper);
}

.access-card {
  width: min(100%, 520px);
  padding: 24px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-panel);
}

.access-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
}

.access-brand small {
  display: block;
  color: var(--green);
  font-size: 9px;
  letter-spacing: 0.16em;
  line-height: 1;
}

.access-copy {
  margin-top: 30px;
}

#access-card h1 {
  margin: 4px 0 12px;
  font-size: clamp(25px, 6vw, 34px);
  letter-spacing: -0.035em;
}

#access-card p {
  color: var(--ink-soft);
  line-height: 1.5;
}

.access-connect,
.access-submit {
  width: 100%;
  display: block;
  margin-top: 24px;
  padding: 12px 16px;
  color: white;
  background: var(--strava);
  border: 0;
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.access-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.access-message,
.access-error {
  padding: 10px 12px;
  border-radius: 8px;
}

.access-message {
  background: #eef2e8;
}

#access-card .access-error {
  color: #7f2f26;
  background: #f8e8e3;
}

.onboarding-form {
  display: grid;
  gap: 22px;
  margin-top: 24px;
}

.onboarding-form fieldset {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
}

.onboarding-form legend {
  margin-bottom: 8px;
  font-weight: 700;
}

.access-swatches {
  display: flex;
  gap: 10px;
}

.access-swatch input {
  position: absolute;
  opacity: 0;
}

.access-swatch > span {
  width: 42px;
  height: 42px;
  display: block;
  background: var(--runner);
  border: 4px solid var(--raised);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

.access-swatch input:checked + span {
  box-shadow: 0 0 0 3px var(--green-deep);
}

.access-swatch input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--green), transparent 45%);
  outline-offset: 3px;
}

.access-choice,
.access-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.access-choice small {
  display: block;
  margin-top: 3px;
  color: var(--ink-soft);
  line-height: 1.35;
}

.access-consent {
  color: var(--ink-soft);
  line-height: 1.4;
}

.access-detail {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

@media (max-width: 520px) {
  body.access-page {
    place-items: start center;
    padding: 12px;
  }

  .access-card {
    padding: 20px;
  }
}

body.access-page.test-lab-access-page {
  padding-top: 70px;
}
