/* summit — app layout. Tokens and component styles come from summit/tokens.css and summit/components.css. */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { overscroll-behavior: none; font: var(--text-body); letter-spacing: -0.02em; }
button { font-family: var(--font-sans); }
.sm-toggle-item { white-space: nowrap; }
a { color: inherit; }
a.sm-link { text-decoration: none; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
[hidden] { display: none !important; }
.m { padding-left: var(--space-4); padding-right: var(--space-4); }
@media (min-width: 760px) { .m { padding-left: var(--space-6); padding-right: var(--space-6); } }
.small { color: var(--ink-2); }
.caption { color: var(--ink-2); }
.nums { font-variant-numeric: tabular-nums; }

/* Tabs — words only, at the bottom */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; display: flex; justify-content: center; gap: var(--space-8);
  padding: 14px var(--space-4) calc(14px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 4px 2px; font: var(--text-small); letter-spacing: -0.02em; color: var(--ink-2); cursor: pointer; min-height: 32px; }
.tab.is-on { color: var(--ink); font-weight: 500; }
:root { --tabs-h: calc(61px + env(safe-area-inset-bottom)); }

.view { position: fixed; inset: 0 0 var(--tabs-h) 0; }
.page > .m { max-width: 1180px; margin: 0 auto; }
.page { overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--paper); padding-top: calc(env(safe-area-inset-top) + var(--space-8)); padding-bottom: var(--space-12); }

/* Map */
#map { position: absolute; inset: 0; background: var(--paper-2); }
.leaflet-container { font-family: var(--font-sans); background: var(--paper-2); }
.leaflet-base-pane { filter: grayscale(1) contrast(.92) brightness(1.04); }
.leaflet-shade-pane { mix-blend-mode: multiply; opacity: .32; }
.leaflet-shade-pane img.leaflet-tile { width: 257px !important; height: 257px !important; }   /* overlap 1px: no light seams between shade tiles */
[data-theme="dark"] .leaflet-base-pane { filter: grayscale(1) invert(1) contrast(.82) brightness(.85); }
[data-theme="dark"] .leaflet-shade-pane { mix-blend-mode: screen; opacity: .08; }
.leaflet-top { top: calc(env(safe-area-inset-top) + 66px); }
.leaflet-control-attribution { font: 9px/12px var(--font-sans); background: transparent !important; color: var(--ink-2); }
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-control-zoom { display: none; }

#topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 800; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) var(--space-4) 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
.wordmark { font: 500 26px/30px var(--font-sans); letter-spacing: -0.05em; color: var(--ink); margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-4); }
.text-btn { border: 0; background: none; color: var(--ink); font: var(--text-small); letter-spacing: -0.02em; cursor: pointer; padding: 6px 0; min-height: 32px; display: inline-flex; align-items: center; gap: var(--space-2); }
.icon-btn { border: 0; background: none; color: var(--ink); width: 44px; height: 44px; margin: -10px -10px -10px 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }

/* Dots: black = been here, white ring = want to go; challenge targets still to do are small grey rings */
.dot-hit { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; position: relative; }
.dot-hit .sm-pin-label { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); pointer-events: none; }
.sm-pin.is-todo .sm-pin-dot { width: 8px; height: 8px; background: var(--paper); border: 1.5px solid var(--ink-2); }
.sm-pin.is-picking .sm-pin-dot { background: var(--paper); border: 2px solid var(--ink); transform: scale(1.5); }
.me-dot { width: 14px; height: 14px; border-radius: 50%; background: #007aff; box-shadow: 0 0 0 3px #fff; }

/* Map bottom sheet: Map / List toggle, marks in view */
#mapsheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 800; background: var(--paper); border-top: 1px solid var(--line);
  max-height: 62%; display: flex; flex-direction: column; transition: max-height .3s ease-out; }
#mapsheet .head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-top: var(--space-3); padding-bottom: var(--space-3); }
#mapsheet .rows { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--space-4); }
@media (min-width: 760px) { #mapsheet { left: var(--space-6); right: auto; width: 400px; bottom: var(--space-6); border: 1px solid var(--line); } }

/* Peek: the selected mark as a tile, with an arrow to open it */
#peek { position: absolute; left: 0; right: 0; bottom: 0; z-index: 810; background: var(--paper); border-top: 1px solid var(--line);
  padding-top: var(--space-4); padding-bottom: var(--space-4); display: flex; gap: var(--space-4); align-items: flex-end; transform: translateY(105%); transition: transform .25s ease-out; }
#peek.is-open { transform: none; }
#peek .sm-tile-media { width: 96px; flex: none; }
#peek .info { flex: 1; min-width: 0; }
#peek .sm-tile-name { display: block; font: var(--text-title); letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 760px) { #peek { left: var(--space-6); right: auto; width: 400px; bottom: var(--space-6); border: 1px solid var(--line); } }

#hint { position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 67px); z-index: 805; }

/* Section headers: title left, control or link right */
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-8); }
.sec-head h1, .sec-head h2 { margin: 0; font: var(--text-section); letter-spacing: -0.02em; }
@media (max-width: 759px) { .sec-head h1, .sec-head h2 { font-size: 30px; line-height: 36px; } }
.block { margin-top: var(--space-12); }
@media (min-width: 760px) { .block { margin-top: var(--space-18); } }
.sub-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 var(--space-3); }
.sub-head h3 { margin: 0; font: var(--text-title); letter-spacing: -0.02em; }

/* Challenge */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-top: var(--space-8); }
.stats .sm-stat-value { font-size: 34px; line-height: 40px; }
@media (min-width: 760px) { .stats .sm-stat-value { font-size: 42px; line-height: 46px; } }
.row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.field { width: 100%; height: 46px; border: 0; border-radius: var(--radius-sm); background: var(--paper-2); color: var(--ink); padding: 0 var(--space-3); font: var(--text-body); letter-spacing: -0.02em; }
textarea.field { height: auto; min-height: 110px; padding: var(--space-3); resize: vertical; }
.field::placeholder { color: var(--ink-2); }
.more { margin-top: var(--space-4); }
.strava-line { margin-top: var(--space-8); padding-top: var(--space-3); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; }

/* Journal */
.colls { display: grid; grid-auto-flow: column; grid-auto-columns: 42%; gap: var(--space-3); overflow-x: auto; margin: 0 calc(-1 * var(--space-4)); padding: 0 var(--space-4); scrollbar-width: none; }
.colls::-webkit-scrollbar { display: none; }
@media (min-width: 760px) { .colls { grid-auto-columns: 220px; margin: 0; padding: 0; } }
.sm-coll { border: 0; padding: 0; cursor: pointer; text-align: left; width: 100%; }
.sm-coll.is-on { outline: 2px solid var(--ink); outline-offset: 3px; }
.month { margin-top: var(--space-8); }
.month-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: var(--space-2); border-bottom: 1px solid var(--line); margin-bottom: var(--space-3); }
.month-head h3 { margin: 0; font: var(--text-title); letter-spacing: -0.02em; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile-btn { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: var(--ink); }
.tile-btn .sm-tile-media img { transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.tile-btn:hover .sm-tile-media img { transform: scale(1.03); }
.empty { color: var(--ink-2); font: var(--text-small); padding: var(--space-6) 0; }

/* Mark page */
.overlay { position: fixed; inset: 0; z-index: 1000; background: var(--paper); overflow-y: auto; -webkit-overflow-scrolling: touch; opacity: 0; pointer-events: none; transition: opacity .25s ease-out; }
.overlay.is-open { opacity: 1; pointer-events: auto; }
.hero { position: relative; height: 72vh; min-height: 380px; background: var(--paper-2); overflow: hidden; display: flex; align-items: flex-end; }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero.has-photo::after { content: ""; position: absolute; inset: 0; background: var(--scrim); }
.hero .words { position: relative; z-index: 1; padding-bottom: var(--space-6); width: 100%; }
.hero.has-photo .words { color: var(--photo-ink); }
.hero .kicker { font: var(--text-small); letter-spacing: -0.02em; margin: 0 0 var(--space-2); opacity: .9; }
.hero h1 { margin: 0; font: var(--text-hero); letter-spacing: -0.03em; text-transform: uppercase; overflow-wrap: anywhere; }
@media (max-width: 759px) { .hero h1 { font-size: 48px; line-height: 52px; } .hero { height: 62vh; } }
.hero:not(.has-photo) { height: 46vh; min-height: 300px; }   /* no photo: a shorter hero */
.hero .cover { z-index: 0; }
.hero-close { position: absolute; z-index: 2; top: calc(env(safe-area-inset-top) + var(--space-4)); right: var(--space-4); }
.mark-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); padding-top: var(--space-4); }
.mark-actions .sm-btn { width: 100%; gap: var(--space-2); min-width: 0; padding: 0 var(--space-3); }
.mark-body { padding-bottom: calc(var(--space-12) + env(safe-area-inset-bottom)); }
.statement { margin: var(--space-12) 0 0; font: var(--text-statement); letter-spacing: -0.02em; white-space: pre-wrap; }
@media (max-width: 759px) { .statement { font-size: 24px; line-height: 31px; } }
.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); margin-top: var(--space-12); }
.photos > * { aspect-ratio: 4 / 5; width: 100%; object-fit: cover; background: var(--paper-2); display: block; }
.mark-foot { margin-top: var(--space-12); padding-top: var(--space-3); border-top: 1px solid var(--line); display: grid; gap: var(--space-2); }
.links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); }
.mark-tools { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-8); }

/* Dialog: a white sheet from the bottom (phone) or a plain panel (desktop) */
#dialog { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s ease-out; }
#dialog.is-open { opacity: 1; pointer-events: auto; }
#dialog .panel { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: var(--paper); padding-top: var(--space-6); padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); }
@media (min-width: 760px) { #dialog { align-items: center; } }
#dialog h2 { margin: 0 0 var(--space-2); font: 400 30px/36px var(--font-sans); letter-spacing: -0.02em; }
#dialog p { margin: 0 0 var(--space-4); }
.stack { display: grid; gap: var(--space-3); }
.kinds { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--ink); border-radius: var(--radius-sm); overflow: hidden; }
.kinds button { height: 44px; border: 0; border-left: 1px solid var(--ink); background: var(--paper); color: var(--ink); font: var(--text-small); letter-spacing: -0.02em; cursor: pointer; }
.kinds button:first-child { border-left: 0; }
.kinds button.is-on { background: var(--ink); color: var(--on-ink); }
.dialog-actions { display: flex; gap: var(--space-3); margin-top: var(--space-4); }
.dialog-actions .sm-btn { flex: 1; }
.check-list { border-top: 1px solid var(--line); max-height: 44vh; overflow-y: auto; margin-bottom: var(--space-3); }
.check-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check-row.is-off { opacity: .45; cursor: default; }
.check-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); flex: none; }
.check-row .t { flex: 1; min-width: 0; }
.check-row .t b { display: block; font: var(--text-title); letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 3px; background: var(--paper-3); margin: var(--space-3) 0 var(--space-4); }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .3s ease-out; }
.search-results { margin-top: var(--space-4); }

/* Toast: the black banner, above the tabs */
#toast { position: fixed; left: 0; right: 0; bottom: var(--tabs-h); z-index: 1200; transform: translateY(100%); opacity: 0; transition: transform .25s ease-out, opacity .25s ease-out; pointer-events: none; }
#toast.is-on { transform: none; opacity: 1; }

/* Login */
#login { position: fixed; inset: 0; z-index: 2000; background: var(--paper); display: none; }
#login.is-on { display: flex; align-items: flex-end; }
#login .inner { width: 100%; max-width: 520px; padding-bottom: calc(var(--space-12) + env(safe-area-inset-bottom)); }
#login .big { margin: 0; font: 500 96px/.92 var(--font-sans); letter-spacing: -0.05em; }
#login .tag { margin: var(--space-3) 0 var(--space-8) 4px; }
body[data-tab="challenge"] #demo, body[data-tab="journal"] #demo { display: none; }
#demo { position: fixed; top: calc(env(safe-area-inset-top) + 72px); left: var(--space-4); z-index: 790; background: var(--paper); padding: 2px 6px; }

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

/* Challenges */
.ch-row { display: flex; align-items: center; gap: var(--space-4); width: 100%; padding: var(--space-4) 0; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); text-align: left; cursor: pointer; font-family: var(--font-sans); letter-spacing: -0.02em; }
.ch-row:hover .sm-row-arrow { transform: translateX(4px); }
.ch-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ch-bar { display: block; height: 2px; background: var(--paper-3); margin: var(--space-2) 0 var(--space-1); }
.ch-bar i { display: block; height: 100%; background: var(--ink); }
.chips { display: flex; gap: var(--space-2); overflow-x: auto; padding-top: var(--space-3); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 30px; padding: 0 var(--space-3); border: 1px solid var(--ink); border-radius: var(--radius-full); background: var(--paper); color: var(--ink); font: var(--text-caption); letter-spacing: -0.01em; cursor: pointer; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.chip.is-on { background: var(--ink); color: var(--on-ink); }

/* Challenge editor */
#editor { z-index: 1050; display: flex; flex-direction: column; overflow: hidden; }
.ed-top { display: flex; align-items: center; justify-content: space-between; padding-top: calc(env(safe-area-inset-top) + var(--space-3)); padding-bottom: var(--space-3); border-bottom: 1px solid var(--line); }
.ed-top .title { font: var(--text-title); letter-spacing: -0.02em; }
.ed-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-top: var(--space-6); padding-bottom: var(--space-8); width: 100%; max-width: 720px; margin: 0 auto; }
.ed-h { font: var(--text-label); letter-spacing: .04em; text-transform: uppercase; margin: var(--space-8) 0 var(--space-3); }
#edMap { height: 46vh; min-height: 280px; background: var(--paper-2); }
#edMap .leaflet-base-pane { filter: grayscale(1) contrast(.92) brightness(1.04); }
[data-theme="dark"] #edMap .leaflet-base-pane { filter: grayscale(1) invert(1) contrast(.82) brightness(.85); }
.ed-range { display: flex; justify-content: space-between; align-items: baseline; margin-top: var(--space-4); font: var(--text-small); }
.ed-range b { font-weight: 500; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--ink); height: 32px; margin: 0; }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.ed-field { display: grid; gap: var(--space-1); }
.ed-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding-top: var(--space-3); padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
.ed-foot .sm-btn { min-width: 150px; }

/* Cover when there is no photo: a near-black slab (like the collection cards) with one oversized figure, cut by the frame */
.sm-tile-media, .hero { container-type: inline-size; }
.cover { position: absolute; inset: 0; overflow: hidden; background: #161616; pointer-events: none; }
.cover-fig { position: absolute; left: 6cqw; bottom: -0.17em; font: 500 78cqw/1 var(--font-sans); letter-spacing: -0.06em; color: #262626; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cover-fig.is-long { font-size: 46cqw; left: 4cqw; }
.hero .cover-fig { font-size: 44cqw; left: auto; right: -0.03em; bottom: auto; top: calc(env(safe-area-inset-top) - 0.14em); }   /* top right, clear of the name */
.hero .cover-fig.is-long { font-size: 30cqw; }
.hero:not(.has-photo) .words { color: var(--photo-ink); }
.hero .words { z-index: 1; }

/* Coordinates as a graphic: two hairlines crossing where the place sits, the dot, the position in degrees */
.cover { --y: calc(22% + var(--fy) * 50%); }
.hero .cover { --y: calc(env(safe-area-inset-top) + 70px + var(--fy) * 22%); }   /* hero: upper part, clear of the name */
.cover-h, .cover-v { position: absolute; background: #3a3a3a; }
.cover-h { left: 0; right: 0; height: 1px; top: var(--y); }
.cover-v { top: 0; bottom: 0; width: 1px; left: var(--x); }
.hero .cover-v { bottom: auto; height: calc(var(--y) + 40px); }
.cover-lat { top: var(--y); }
.cover-lng { left: var(--x); }
.cover-dot { left: var(--x); top: var(--y); }
.cover-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px #161616, 0 0 0 4px #5a5a5a; }
.cover-lat, .cover-lng { position: absolute; font: 500 9px/1 var(--font-sans); letter-spacing: .06em; color: #9a9a9a; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cover-lat { left: 6cqw; transform: translateY(calc(-100% - 5px)); }
.cover-lng { top: 6cqw; transform-origin: 0 0; transform: rotate(90deg) translate(0, -100%) translate(0, -5px); }
@container (max-width: 130px) { .cover-lat, .cover-lng { display: none; } }   /* too small for words: lines and dot only */
.hero .cover-lat, .hero .cover-lng { font-size: 11px; }
.hero .cover-dot { width: 12px; height: 12px; margin: -6px 0 0 -6px; }

/* Cover with the Strava trace: the route as a hairline, the place as a white dot, the position in the corner */
.cover-trace { position: absolute; inset: 9% 8% 12%; width: 84%; height: 79%; overflow: visible; }
.hero .cover-trace { inset: calc(env(safe-area-inset-top) + 56px) 6% 0; width: 88%; height: calc(100% - env(safe-area-inset-top) - 56px); }
.cover-pos { position: absolute; top: 6cqw; left: 6cqw; display: grid; gap: 4px; font: 500 9px/1 var(--font-sans); letter-spacing: .06em; color: #9a9a9a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero .cover-pos { top: calc(env(safe-area-inset-top) + var(--space-6)); left: var(--space-4); font-size: 11px; }
@container (max-width: 130px) { .cover-pos { display: none; } }
.cover.has-trace .cover-fig { color: #202020; }
.cond-row { padding: var(--space-2) 0; }

/* Strava status pill, top of the map: a dot and two words */
.strava-pill { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px 0 10px; border: 1px solid var(--ink); border-radius: var(--radius-full); background: var(--paper); color: var(--ink); font: 500 12px/1 var(--font-sans); letter-spacing: -0.01em; cursor: pointer; white-space: nowrap; }
.strava-pill i { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--ink); box-sizing: border-box; }
.strava-pill.is-on i { background: var(--ink); }
.strava-pill.is-on { background: var(--ink); color: var(--on-ink); }
.strava-pill.is-on i { background: var(--on-ink); border-color: var(--on-ink); }
.strava-pill.is-busy i { animation: pill 1s ease-in-out infinite alternate; }
@keyframes pill { from { opacity: 1; } to { opacity: .25; } }
@media (max-width: 380px) { .topbar-actions { gap: var(--space-3); } #nearMe { display: none; } }

/* Strava's own assets: official Connect button (48 px high, unchanged) and Powered by Strava logo */
.strava-connect { display: inline-block; border: 0; padding: 0; background: none; cursor: pointer; margin: var(--space-2) 0 var(--space-2); }
.strava-connect img { display: block; height: 48px; width: auto; }
.powered-by { display: block; height: 15px; width: auto; margin-top: var(--space-6); }

/* Lakes are a short horizontal pill (a waterline), summits stay round dots. Same states: filled = been, outline = to do */
.sm-pin.is-lake .sm-pin-dot { width: 16px; height: 8px; }
.sm-pin.is-lake.is-todo .sm-pin-dot { width: 12px; height: 6px; }
.sm-pin.is-lake.is-selected .sm-pin-dot { transform: scale(1.4); }
.kind-toggle .sm-toggle-item { min-width: 0; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; }
.shape { display: inline-block; border: 1.5px solid currentColor; box-sizing: border-box; border-radius: 999px; }
.shape.is-summit { width: 8px; height: 8px; }
.shape.is-lake { width: 13px; height: 7px; }
.sm-toggle-item.is-on .shape { background: currentColor; }
#mapsheet .head { padding-bottom: var(--space-2); }
#mapsheet .head2 { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-bottom: var(--space-3); }
#mapsheet .head2 .sm-toggle-item { min-width: 52px; }
