:root {
  --bg: #F6F6F9; --card: #FFFFFF; --text: #14141F; --muted: #5C5C70;
  --accent: #4F8A00; --danger: #C4321F; --lime: #C6FF3D; --strava: #FC4C02; --line: #DCDCE6;
  --story-width: min(68vw, 300px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Space Grotesk", system-ui, sans-serif; line-height: 1.4; }
.page { max-width: 1040px; margin: 0 auto; padding: 24px; min-height: 100dvh; }
h1 { font-size: clamp(2rem, 6vw, 3.5rem); line-height: 1.05; margin: .25rem 0 1rem; }
.brand { color: var(--accent); font-weight: 700; font-size: 1.25rem; margin: 0; }
.lead, .muted, .note, small { color: var(--muted); margin: 0; }
.flash { background: var(--card); border: 1px solid var(--line); padding: 12px 16px; border-radius: 12px; }
.top { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; margin-right: auto; color: var(--text); font: 700 1.3rem/1 "Space Grotesk", sans-serif; letter-spacing: -.02em; text-decoration: none; }
.brand-icon { width: 36px; height: 36px; border-radius: 10px; }
.sync-badge { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: .85rem; font-weight: 700; text-decoration: none; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .sync-dot { animation: none; } }

.account { position: relative; }
.account details { position: relative; }
.account summary { display: block; list-style: none; cursor: pointer; border-radius: 50%; }
.account summary::-webkit-details-marker { display: none; }
.account summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--line); color: var(--text); font-weight: 700; box-shadow: 0 0 0 1px var(--line); }
.account-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; display: grid; gap: 8px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(20, 20, 40, .12); }
.account-menu .link { width: 100%; color: var(--text); text-align: left; text-decoration: none; white-space: nowrap; padding: 0 20px; border-radius: 8px; }
.account-menu .link:hover { background: var(--bg); }
.account-logout { padding-top: 8px; border-top: 1px solid var(--line); }
.account-menu .link.danger { color: var(--danger); }
.button.danger { background: var(--danger); color: #FFFFFF; }

.dialog { width: min(440px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 24px; background: var(--card); color: var(--text); box-shadow: 0 24px 64px rgba(20, 20, 40, .25); }
.dialog::backdrop { background: rgba(20, 20, 40, .45); }
.dialog h2 { margin: 0 0 8px; font-size: 1.25rem; }
.dialog p { margin: 0 0 12px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.dialog-actions form { display: contents; }
.field { display: grid; gap: 8px; margin-top: 12px; font-weight: 700; }
.field select { min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); font: 500 1rem "Space Grotesk", sans-serif; }

.hero { max-width: 480px; margin: 10vh auto 0; display: flex; flex-direction: column; gap: 1rem; }
.hero form, .section form { width: 100%; }
.counter { font-size: 1.5rem; font-weight: 700; margin: 0; }
.spinner { width: 48px; height: 48px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 4s; } }
.spinner.small { flex: none; width: 20px; height: 20px; border-width: 3px; }
.marks-loading { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; padding: 0 28px; border: 0; border-radius: 28px; font: 700 1.05rem "Space Grotesk", sans-serif; text-decoration: none; cursor: pointer; color: #FFFFFF; background: var(--text); }
.button.strava { background: var(--strava); color: var(--text); }
.button.primary { background: var(--lime); color: var(--text); }
.button.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.link { background: none; border: 0; min-height: 44px; padding: 0 8px; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }

/* Every section opens the same way: bold title on the left, muted context on the right. */
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; }
.section-head h2 { margin: 0; font-size: 1.25rem; line-height: 1.2; }

/* The progress page is a column of sections (two side by side on wide screens), each ending with its share button. */
.sections { display: grid; gap: 40px; }
.section { display: grid; gap: 12px; align-content: start; scroll-margin-top: 16px; }
/* Side by side, the two sections of a row get the same height: the chart, marks or map grows to fill
   it, so the share buttons line up at the bottom. An odd last section takes the whole row. */
@media (min-width: 900px) {
  .sections { grid-template-columns: 1fr 1fr; gap: 48px 40px; }
  .section { display: flex; flex-direction: column; }
  .section:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .section > .card { flex: 1 0 auto; display: grid; align-content: center; }
  .section > .marks-grid, .section > .journey, .section > .map, .journey > .map, .section > .marks-loading { flex: 1 0 auto; }
  .section > .journey { display: flex; flex-direction: column; }
  .section > .segmented, .journey > .segmented { align-self: flex-start; }
  .section > .marks-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; margin: -10px -10px -10px 0; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--card); color: var(--text); }
.journey { display: grid; gap: 12px; }
.big-number { margin: 0; font-size: clamp(2.5rem, 9vw, 3.5rem); font-weight: 700; line-height: 1; }
.map { height: 320px; border-radius: 24px; border: 1px solid var(--line); overflow: hidden; z-index: 0; }
.segmented { display: inline-flex; flex-wrap: wrap; justify-self: start; padding: 4px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); }
.segmented button { min-height: 36px; padding: 0 16px; border: 0; border-radius: 18px; background: none; color: var(--muted); font: 700 .9rem "Space Grotesk", sans-serif; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--card); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; border: 0; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span { display: grid; place-items: center; min-width: 64px; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); font-weight: 700; }
.choice input:checked + span { background: var(--lime); border-color: var(--lime); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 20px; box-shadow: 0 1px 3px rgba(20, 20, 40, .06); }
.chart { width: 100%; height: auto; display: block; }
.years { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.years li { display: grid; grid-template-columns: 12px 3.5rem 1fr; gap: 4px 12px; align-items: center; }
.years small { grid-column: 3; }
.dot { width: 12px; height: 12px; border-radius: 50%; }

.marks-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mark { display: grid; gap: 6px; align-content: start; padding: 14px; border-radius: 16px; background: var(--text); color: var(--card); }
.mark strong { font-size: 1.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mark small { color: #B4B4C8; }
.mark-tag { justify-self: start; padding: 2px 8px; border-radius: 6px; background: var(--lime); color: var(--text); font-size: .8rem; font-weight: 700; }
.mark.empty { background: transparent; color: var(--text); border: 1.5px dashed var(--line); }
.mark.empty .mark-tag { background: var(--line); }
.mark.empty small { color: var(--muted); }

.carousel { margin: 16px -24px 0; }
.stories { display: flex; gap: 20px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 12px calc(50% - var(--story-width) / 2) 24px; }
.stories::-webkit-scrollbar { display: none; }
.stories:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.story { flex: 0 0 var(--story-width); margin: 0; scroll-snap-align: center; }
.story svg { display: block; width: 100%; height: auto; border-radius: 20px; box-shadow: 0 0 0 1px rgba(20, 20, 40, .12), 0 12px 32px rgba(20, 20, 40, .18); }
/* Checkerboard behind transparent images, so the white text shows in the preview. */
.story.transparent svg { background: repeating-conic-gradient(#3B3B48 0% 25%, #52525F 0% 50%) 50% / 32px 32px; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; }
.dots button { display: grid; place-items: center; width: 28px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; }
.dots button::after { content: ""; width: 8px; height: 8px; border-radius: 4px; background: var(--line); transition: width .2s; }
.dots button[aria-current="true"]::after { width: 20px; background: var(--text); }
.share-caption { text-align: center; }
.share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 480px; margin: 16px auto 0; padding: 0 24px; }

/* Long-form text, like the privacy policy. */
.prose { max-width: 680px; }
.prose h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
.prose h2 { margin: 2rem 0 .5rem; font-size: 1.15rem; }
.prose p, .prose li { line-height: 1.6; }
.prose ul { padding-left: 1.25rem; }
