:root {
  --paper: #f5f3ed;
  --paper-strong: #fcfbf7;
  --panel: rgba(252, 251, 247, 0.94);
  --ink: #18201d;
  --muted: #343a37;
  --line: #dcded8;
  --line-strong: #c7cbc4;
  --accent: #ed5a3d;
  --control-size: 42px;
  --radius-sm: 9px;
  --radius-md: 14px;
  --shadow-sm: 0 5px 18px rgba(24, 32, 29, 0.1);
  --shadow-lg: 0 20px 52px rgba(24, 32, 29, 0.16);
  color: var(--ink);
  background: #ffffff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body,
.app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2000;
  display: flex;
  width: clamp(310px, 24vw, 380px);
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff60;
  border-right: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: flex-end;
  min-height: 10px;
  padding: 10px 24px 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.4rem, 2vw, 1.7rem);
}

.screen-title {
  position: absolute;
  z-index: 1000;
  top: 14px;
  left: 50%;
  max-width: min(720px, calc(100vw - 430px));
  margin: 0;
  padding: 10px 16px;
  color: var(--ink);
  background: #ffffff60;
  border: 1px solid rgba(24, 32, 29, 0.1);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  font-size: clamp(0.9rem, 1.4vw, 1.15rem);
  text-align: center;
  white-space: nowrap;
  transform: translateX(-50%);
}

h2 {
  max-width: 480px;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
}

.collection-summary {
  display: grid;
  flex: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 24px 20px;
  padding: 15px 0;
  border-block: 1px solid var(--line);
}

.collection-summary div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.collection-summary strong {
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-summary span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.toolbar {
  display: flex;
  flex: none;
  gap: 8px;
  padding: 0 16px 12px;
}

.search {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  background: #eae9e4;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background 150ms ease, border-color 150ms ease;
}

.search:focus-within {
  background: var(--paper-strong);
  border-color: var(--line-strong);
}

.search svg,
.sidebar-trigger svg {
  width: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.search input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 0.8rem;
}

.search input::placeholder {
  color: #3f4642;
}

.text-button,
.icon-button,
.detail-close {
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.text-button {
  flex: none;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 0.7rem;
  font-weight: 750;
}

.text-button:hover,
.icon-button:hover,
.detail-close:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.65);
}

.loading {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 0 24px 12px;
  color: var(--muted);
  font-size: 0.67rem;
}

.loading.is-done {
  display: none;
}

.loading-track {
  width: 72px;
  height: 2px;
  overflow: hidden;
  background: var(--line);
}

.loading-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.ride-list {
  background: #ffffff61;
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 0 8px 24px;
  overscroll-behavior: contain;
  scrollbar-color: #aeb5ae #e5e5df;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
}

.ride-list::-webkit-scrollbar {
  width: 11px;
}

.ride-list::-webkit-scrollbar-track {
  margin-block: 3px 10px;
  background: #ffffff;
  border-radius: 999px;
}

.ride-list::-webkit-scrollbar-thumb {
  background: #aeb5ae;
  background-clip: padding-box;
  border: 2px solid #e5e5df;
  border-radius: 999px;
}

.ride-list::-webkit-scrollbar-thumb:hover {
  background: #858f87;
  background-clip: padding-box;
}

.ride-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 10px;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: background 130ms ease, box-shadow 130ms ease, transform 130ms ease;
}

.ride-row:hover {
  background: rgba(255, 255, 255, 0.62);
}

.ride-row.is-selected {
  background: var(--paper-strong);
  box-shadow: inset 3px 0 var(--ride-color), 0 2px 8px rgba(24, 32, 29, 0.05);
}

.visibility {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  padding: 0;
  color: var(--ride-color);
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 50%;
  cursor: pointer;
}

.visibility::after {
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
  content: "";
}

.ride-row.is-hidden {
  opacity: 0.55;
}

.ride-row.is-hidden .visibility::after {
  display: none;
}

.ride-info {
  min-width: 0;
}

.ride-name {
  display: block;
  overflow: hidden;
  font-size: 0.77rem;
  font-weight: 680;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ride-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.63rem;
}

.ride-distance {
  color: var(--muted);
  font-size: 0.67rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.map-panel,
#map {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
}

.map-panel {
  position: absolute;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  background: var(--paper-strong);
}

#map {
  z-index: 0;
}

.leaflet-container {
  background: #dde3de;
  font-family: inherit;
}

.leaflet-control-attribution {
  max-width: min(70vw, 520px);
  font-size: 9px;
}

.leaflet-control-zoom {
  display: none;
}

.race-marker-wrapper {
  background: transparent;
  border: 0;
}

.race-marker-content {
  display: inline-flex;
  align-items: center;
  gap: clamp(5px, 0.6vw, 10px);
  white-space: nowrap;
}

.race-marker-content.has-details {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 3px rgba(24, 32, 29, 0.24));
}

.race-marker-content.label-left {
  justify-content: flex-end;
}

.race-marker {
  position: relative;
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  color: #ffffff;
  border: 1px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(24, 32, 29, 0.3);
  font-size: 0.42rem;
  font-weight: 850;
  line-height: 1;
  opacity: 0.78;
  transform-origin: center;
  transition: opacity 140ms ease, transform 140ms ease;
}

.race-marker-start {
  background: #20a447;
}

.race-marker-finish,
.race-marker-chefchaouen {
  background: #e9486f;
}

.race-marker-finish-overall {
  background: #f47b28;
}

.race-marker-letter {
  position: relative;
  z-index: 1;
}

.race-marker-image {
  display: grid;
  width: clamp(42px, 4.8vw, 58px);
  height: clamp(42px, 4.8vw, 58px);
  flex: none;
  place-items: center;
  overflow: hidden;
  background-color: #52b7d8;
  background-image: var(--marker-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  border: 2px solid #0d00ff;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(24, 32, 29, 0.28);
}

.race-marker-label {
  max-width: min(42vw, 220px);
  padding: clamp(4px, 0.45vw, 7px) clamp(8px, 0.8vw, 12px);
  overflow: hidden;
  color: var(--ink);
  background: rgba(252, 251, 247, 0.72);
  border: 1px solid rgba(24, 32, 29, 0.1);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  font-size: clamp(0.9rem, 1.4vw, 1.15rem);
  font-weight: 400;
  line-height: 1.15;
  text-overflow: ellipsis;
}


.race-marker-wrapper.is-active .race-marker {
  opacity: 1;
  transform: scale(1.25);
}

.story-map-marker-wrapper {
  background: transparent;
  border: 0;
}

.story-map-marker {
  position: relative;
  display: block;
  width: clamp(42px, 4.6vw, 54px);
  height: clamp(42px, 4.6vw, 54px);
  padding: 0;
  overflow: hidden;
  background-color: rgba(252, 251, 247, 0.62);
  background-image: var(--story-marker-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  border: 2px solid rgba(0, 26, 255, 0.7);
  border-radius: 50%;
  box-shadow: 0 5px 16px rgba(24, 32, 29, 0.22);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.story-map-marker:hover,
.story-map-marker:focus-visible {
  transform: scale(1.12);
  box-shadow: 0 8px 22px rgba(24, 32, 29, 0.28);
  outline: none;
}

.story-map-marker span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.leaflet-top.leaflet-right {
  top: 8px;
  right: 8px;
}

.leaflet-control-layers {
  overflow: hidden;
  margin: 0 !important;
  background: var(--panel);
  border: 1px solid rgba(24, 32, 29, 0.1) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-sm) !important;
  backdrop-filter: blur(14px);
}

.leaflet-control-layers-toggle {
  width: var(--control-size) !important;
  height: var(--control-size) !important;
  background-size: 20px 20px !important;
}

.leaflet-control-layers-expanded {
  min-width: 150px;
  padding: 10px 12px !important;
  color: var(--ink);
  font-size: 0.75rem;
}

.leaflet-control-layers label {
  padding-block: 3px;
  cursor: pointer;
}

.sidebar-trigger {
  position: absolute;
  z-index: 1000;
  top: 10px;
  left: 10px;
  width: var(--control-size);
  height: var(--control-size);
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid rgba(24, 32, 29, 0.1);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.journal-menu {
  position: absolute;
  z-index: 1600;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
}

.video-menu {
  position: absolute;
  z-index: 1600;
  top: calc(50% + 54px);
  right: 12px;
}

.journal-trigger,
.video-trigger {
  display: flex;
  width: auto;
  min-width: 92px;
  min-height: var(--control-size);
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(24, 32, 29, 0.13);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  backdrop-filter: blur(14px) saturate(1.15);
  transition: background 140ms ease, transform 140ms ease;
}

.journal-trigger:hover,
.journal-menu.is-open .journal-trigger,
.video-trigger:hover {
  background: rgba(252, 251, 247, 0.42);
  transform: translateX(-2px);
}

.journal-trigger span,
.video-trigger span {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.journal-trigger svg,
.video-trigger svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 150ms ease;
}

.video-trigger svg {
  fill: currentColor;
  stroke: none;
}

.journal-symbol {
  width: 17px;
}

.journal-trigger svg:not(.journal-symbol) {
  transform: rotate(180deg);
}

.journal-menu.is-open .journal-trigger svg:not(.journal-symbol) {
  transform: rotate(0);
}

.journal-list {
  position: absolute;
  top: 50%;
  right: calc(100% + 8px);
  width: min(300px, calc(100vw - 430px));
  max-height: min(70vh, 560px);
  padding: 8px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid rgba(24, 32, 29, 0.13);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transform: translate(8px, -50%);
  transition: opacity 150ms ease, transform 150ms ease;
}

.journal-menu.is-open .journal-list {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%);
}

.journal-list-header {
  display: none;
}

.journal-panel-close {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0;
  line-height: 1;
}

.journal-item {
  display: grid;
  width: 100%;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 10px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.journal-item:hover {
  background: rgba(255, 255, 255, 0.72);
}

.journal-item-number {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.journal-item-title {
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-overlay {
  position: fixed;
  z-index: 5000;
  inset: 0;
  padding: clamp(18px, 4vw, 54px);
  overflow-y: auto;
  color: var(--ink);
  background: rgba(20, 25, 23, 0.7);
  backdrop-filter: blur(16px);
}

.story-overlay[hidden] {
  display: none;
}

.story-shell {
  display: grid;
  width: min(1120px, 100%);
  min-height: min(720px, calc(100vh - 108px));
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
  margin: auto;
  overflow: hidden;
  background: var(--paper-strong);
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 20px;
  box-shadow: 0 28px 90px rgba(12, 17, 15, 0.35);
}

.story-visual {
  position: relative;
  display: grid;
  min-height: 430px;
  place-items: center;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.82);
  background:
    linear-gradient(145deg, rgba(88, 88, 88, 0.185), rgba(50, 50, 50, 0.28)),
    linear-gradient(35deg, #5e716a18, #ffffff);
}

.story-gallery {
  display: grid;
  width: 100%;
  height: 100%;
  max-height: min(720px, calc(100vh - 108px));
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  grid-auto-rows: minmax(180px, 1fr);
  gap: 6px;
  padding: 6px;
  overflow-y: auto;
}

.story-gallery[hidden] {
  display: none;
}

.story-gallery.is-single {
  display: block;
  padding: 0;
}

.photo-thumb {
  display: block;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: zoom-in;
}

.story-gallery.is-single .photo-thumb {
  border-radius: 0;
}

.story-gallery img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  transition: transform 170ms ease, filter 170ms ease;
}

.photo-thumb:hover img,
.photo-thumb:focus-visible img {
  filter: saturate(1.05);
  transform: scale(1.025);
}

.story-gallery.is-single img {
  border-radius: 0;
}

.story-visual span {
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 760;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.story-content {
  align-self: center;
  padding: clamp(30px, 5vw, 72px);
}

.story-content h2 {
  max-width: none;
  font-size: clamp(2rem, 5vw, 2.8rem);
  overflow-wrap: anywhere;
}

.story-text {
  display: grid;
  gap: 18px;
  margin-top: 28px;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.2vw, 1.03rem);
  line-height: 1.75;
}

.story-text p {
  margin: 0;
}

.story-close {
  position: fixed;
  z-index: 1;
  top: 14px;
  right: 18px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--paper-strong);
  border: 0;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 0;
  line-height: 1;
}

body.has-story-open {
  overflow: hidden;
}

.photo-overlay {
  position: fixed;
  z-index: 7000;
  inset: 0;
  display: grid;
  padding: clamp(12px, 2.5vw, 28px);
  place-items: center;
  overflow: hidden;
  color: #ffffff;
  background: rgba(8, 10, 9, 0.88);
  backdrop-filter: blur(12px);
}

.photo-overlay[hidden] {
  display: none;
}

.photo-shell {
  display: grid;
  width: min(1500px, calc(100vw - clamp(24px, 5vw, 56px)));
  height: calc(100dvh - clamp(24px, 5vw, 56px));
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 0;
  min-width: 0;
  min-height: 0;
}

.photo-shell img {
  display: block;
  align-self: center;
  justify-self: center;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: min(100%, 100vw);
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.photo-caption {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(8, 10, 9, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  backdrop-filter: blur(14px);
}

.photo-caption strong,
.photo-caption span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-caption strong {
  font-size: clamp(0.88rem, 1.3vw, 1.05rem);
}

.photo-caption span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.76rem;
}

.photo-kicker {
  flex: none;
  font-weight: 760;
}

.photo-close {
  position: fixed;
  z-index: 1;
  top: clamp(10px, 2vw, 18px);
  right: clamp(10px, 2vw, 18px);
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--paper-strong);
  border: 0;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 0;
  line-height: 1;
}

body.has-photo-open {
  overflow: hidden;
}

.video-overlay {
  position: fixed;
  z-index: 6500;
  inset: 0;
  display: grid;
  padding: clamp(18px, 4vw, 54px);
  place-items: center;
  overflow-y: auto;
  color: var(--ink);
  background: rgba(20, 25, 23, 0.7);
  backdrop-filter: blur(16px);
}

.video-overlay[hidden] {
  display: none;
}

.video-shell {
  display: grid;
  width: min(1280px, 100%);
  gap: 16px;
  margin: auto;
  padding: clamp(14px, 2vw, 22px);
  background: var(--paper-strong);
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 20px;
  box-shadow: 0 28px 90px rgba(12, 17, 15, 0.35);
}

.video-heading {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.video-heading h2 {
  max-width: none;
  font-size: clamp(1.25rem, 2vw, 1.9rem);
}

.video-frame-wrap {
  position: relative;
  width: 100%;
  min-height: min(72dvh, 720px);
  overflow: hidden;
  background: #000000;
  border-radius: 10px;
  aspect-ratio: 16 / 9;
}

.video-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-close {
  position: fixed;
  z-index: 1;
  top: clamp(10px, 2vw, 18px);
  right: clamp(10px, 2vw, 18px);
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--paper-strong);
  border: 0;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 0;
  line-height: 1;
}

.journal-panel-close::before,
.story-close::before,
.photo-close::before,
.video-close::before {
  position: absolute;
  top: 50%;
  left: 50%;
  content: "×";
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.45rem;
  font-weight: 400;
  line-height: 1;
  transform: translate(-50%, -52%);
}

.journal-panel-close::before {
  font-size: 1.2rem;
}

body.has-video-open {
  overflow: hidden;
}

.ride-details {
  position: fixed;
  z-index: 1500;
  right: 18px;
  bottom: 18px;
  width: min(600px, calc(100vw - 420px));
  padding: 20px;
  background: #ffffff60;
  border: 1px solid rgba(24, 32, 29, 0.1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  transition: opacity 170ms ease, transform 170ms ease;
}

.ride-details.is-empty {
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
}

.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.detail-heading > div {
  min-width: 0;
}

.detail-heading h2 {
  overflow-wrap: anywhere;
}

.detail-close {
  position: absolute;
  top: 6px;
  right: 7px;
  display: none;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 1.2rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.stats div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.stats strong {
  overflow: hidden;
  font-size: 0.94rem;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats span,
.profile-labels {
  color: var(--muted);
  font-size: 0.59rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-wrap {
  margin-top: 14px;
}

#elevation-profile {
  display: block;
  width: 100%;
  height: 70px;
}

.profile-labels {
  display: flex;
  justify-content: space-between;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.mobile-only {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 1050px) {
  .sidebar {
    width: 300px;
  }

  .brand {
    padding-inline: 18px;
  }

  .screen-title {
    max-width: calc(100vw - 360px);
  }

  .collection-summary {
    margin-inline: 18px;
  }

  .ride-details {
    width: min(560px, calc(100vw - 336px));
  }

  .journal-list {
    width: min(280px, calc(100vw - 80px));
  }
}

@media (min-width: 1400px) {
  .sidebar {
    width: clamp(360px, 22vw, 430px);
  }

  .ride-details {
    width: min(680px, calc(100vw - 500px));
  }
}

@media (max-width: 900px) {
  :root {
    --control-size: 40px;
  }

  html,
  body,
  .app {
    height: 100dvh;
  }

  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    z-index: 3000;
    width: 100%;
    border-right: 0;
    box-shadow: var(--shadow-lg);
    background: rgba(252, 251, 247, 0.98);
    transform: translateX(-105%);
    transition: transform 190ms ease;
  }

  .brand {
    min-height: calc(54px + env(safe-area-inset-top));
    padding: calc(10px + env(safe-area-inset-top)) 12px 0;
  }

  .collection-summary {
    margin: 0 16px 14px;
    padding: 12px 0;
  }

  .toolbar {
    padding: 0 10px 10px;
  }

  .screen-title {
    top: calc(10px + env(safe-area-inset-top));
    right: 60px;
    left: 60px;
    width: auto;
    max-width: none;
    padding: 9px 12px;
    overflow: hidden;
    font-size: 0.78rem;
    text-overflow: ellipsis;
    transform: none;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .journal-menu {
    position: fixed !important;
    z-index: 4500;
    top: calc(58px + env(safe-area-inset-top)) !important;
    right: auto !important;
    left: 10px !important;
    display: block;
    width: var(--control-size);
    height: var(--control-size);
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .video-menu {
    position: fixed;
    z-index: 4500;
    top: calc(106px + env(safe-area-inset-top));
    right: auto;
    left: 10px;
    transform: none;
  }

  .journal-trigger {
    width: 100%;
    height: 100%;
    min-width: var(--control-size);
    min-height: var(--control-size);
    padding: 0;
    gap: 0;
    background: var(--panel);
  }

  .video-trigger {
    width: var(--control-size);
    height: var(--control-size);
    min-width: var(--control-size);
    min-height: var(--control-size);
    padding: 0;
    gap: 0;
    background: var(--panel);
  }

  .video-trigger span {
    display: none;
  }

  .journal-trigger span,
  .journal-trigger svg:not(.journal-symbol) {
    display: none;
  }

  .journal-symbol {
    width: 18px;
  }

  .journal-list {
    position: fixed;
    inset: calc(60px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
    width: auto;
    max-height: none;
    padding: 8px;
    background: rgba(252, 251, 247, 0.98);
    transform: translateX(10px);
  }

  .journal-menu.is-open .journal-list {
    transform: translateX(0);
  }

  .journal-list-header {
    position: sticky;
    z-index: 1;
    top: -8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -8px -8px 4px;
    padding: 10px;
    background: rgba(252, 251, 247, 0.98);
    border-bottom: 1px solid var(--line);
  }

  .journal-list-header strong {
    font-size: 0.76rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .journal-item {
    min-height: 46px;
  }

  .story-overlay {
    padding: calc(8px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom));
  }

  .story-shell {
    min-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    grid-template-columns: 1fr;
    border-radius: 14px;
  }

  .story-visual {
    min-height: min(42vh, 360px);
  }

  .story-gallery {
    max-height: min(42vh, 360px);
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    grid-auto-rows: minmax(132px, 1fr);
  }

  .story-content {
    align-self: start;
    padding: 28px 22px 42px;
  }

  .story-content h2 {
    font-size: clamp(2rem, 12vw, 3.7rem);
  }

  .story-close {
    top: calc(14px + env(safe-area-inset-top));
    right: 14px;
  }

  .mobile-only {
    display: inline-flex;
  }

  .icon-button {
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 1.35rem;
  }

  .sidebar-trigger {
    top: calc(10px + env(safe-area-inset-top));
    left: 10px;
  }

  .leaflet-top.leaflet-right {
    top: calc(58px + env(safe-area-inset-top));
    right: 10px;
    left: auto;
  }

  .leaflet-control-layers-expanded {
    max-width: calc(100vw - 20px);
  }

  .leaflet-control-attribution {
    max-width: calc(100vw - 20px);
    font-size: 7px;
  }

  .ride-details {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto;
    max-height: min(46dvh, 380px);
    overflow-y: auto;
    padding: 17px;
    background: rgba(252, 251, 247, 0.96);
    overscroll-behavior: contain;
  }

  .detail-close {
    display: block;
  }

  .detail-heading {
    padding-right: 18px;
  }

  .detail-heading h2 {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 10px;
  }

  .photo-shell {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    gap: 8px;
  }

  .photo-caption {
    width: 100%;
    flex-wrap: wrap;
  }

  .photo-caption strong {
    flex-basis: 100%;
    order: -1;
  }

  .photo-caption span {
    white-space: normal;
  }

  .video-close {
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
  }

  .video-overlay {
    padding: calc(8px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom));
  }

  .video-shell {
    width: 100%;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
  }

  .video-heading {
    display: grid;
    gap: 2px;
  }

  .video-heading h2 {
    font-size: 1.08rem;
  }

  .video-frame-wrap {
    min-height: auto;
    max-height: calc(100dvh - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (max-width: 440px) {
  .brand {
    padding: 10px 18px 0;
  }

  .collection-summary {
    margin: 0 18px 16px;
    padding: 12px 0;
  }

  .toolbar {
    padding-inline: 10px;
  }

  .ride-list {
    padding-inline: 4px;
  }

  .ride-details {
    max-height: 43dvh;
    padding: 14px;
  }

  .detail-heading {
    gap: 10px;
  }

  h2 {
    font-size: 1.08rem;
  }

  #elevation-profile {
    height: 48px;
  }

  .screen-title {
    right: 56px;
    left: 56px;
    padding-inline: 8px;
    font-size: 0.7rem;
  }

  .story-visual {
    min-height: 32dvh;
  }

  .story-content {
    padding: 24px 18px 36px;
  }
}

@media (max-height: 560px) and (max-width: 900px) {
  .journal-menu {
    top: calc(58px + env(safe-area-inset-top)) !important;
  }

  .video-menu {
    top: calc(106px + env(safe-area-inset-top));
  }

  .journal-trigger {
    min-height: var(--control-size);
  }

  .ride-details {
    max-height: 55dvh;
  }

  .profile-wrap {
    display: none;
  }
}

@media (max-height: 560px) {
  .photo-caption {
    padding-block: 9px;
  }
}

@media (max-height: 640px) and (min-width: 761px) {
  .brand {
    padding-block: 18px 12px;
  }

  .collection-summary {
    margin-bottom: 12px;
    padding-block: 10px;
  }

  .ride-details {
    padding: 15px 18px;
  }

  .stats {
    margin-top: 12px;
  }

  .profile-wrap {
    margin-top: 8px;
  }

  #elevation-profile {
    height: 48px;
  }
}

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