:root {
  --bg:           #f5f0e8;
  --bg2:          #ede8dc;
  --surface:      #fffdf8;
  --border:       #c8b99a;
  --text:         #2c2416;
  --text-muted:   #6b5d47;
  --accent:       #4a7c3f;
  --accent-dim:   #3a6231;
  --accent-gradient: linear-gradient(135deg, #5d9550 0%, #4a7c3f 100%);
  --done-color:   #4a7c3f;
  --header-bg:    #3d5a2c;
  --header-gradient: linear-gradient(180deg, #3d5a2c 0%, #2f4a22 100%);
  --header-text:  #f5f0e8;
  --tab-bg:       #e8e2d6;
  --tab-active:   #4a7c3f;
  --tab-text:     #6b5d47;
  --tab-text-act: #fff;
  --overlay:      rgba(0,0,0,0.5);
  --shadow:       0 2px 10px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:    0 12px 32px rgba(0,0,0,0.16);
  --marker-done:  #4a7c3f;
  --marker-todo:  #8a7a6a;
  --danger:       #c0392b;
  --fill-track:   rgba(255,255,255,0.22);
  --fill-bar:     #a8d58a;

  /* ── Spacing scale (4px base) ─────── */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;

  /* ── Type scale (scaled by --text-scale for accessibility) ─── */
  --text-scale: 1;
  --fs-xs:  calc(11px * var(--text-scale));
  --fs-sm:  calc(13px * var(--text-scale));
  --fs-md:  calc(15px * var(--text-scale));
  --fs-lg:  calc(17px * var(--text-scale));
  --fs-xl:  calc(22px * var(--text-scale));
  --fs-2xl: calc(30px * var(--text-scale));

  /* ── Radius scale ────────────────── */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
}

[data-theme="dark"] {
  --bg:           #191c17;
  --bg2:          #22251f;
  --surface:      #2a2e27;
  --border:       #3c4237;
  --text:         #e6e8e0;
  --text-muted:   #8c9185;
  --accent:       #78bb65;
  --accent-dim:   #5fa04e;
  --done-color:   #78bb65;
  --header-bg:    #1a2116;
  --header-text:  #dde0d6;
  --tab-bg:       #22251f;
  --tab-active:   #78bb65;
  --tab-text:     #8c9185;
  --tab-text-act: #14180f;
  --overlay:      rgba(0,0,0,0.65);
  --shadow:       0 2px 12px rgba(0,0,0,0.45);
  --marker-done:  #78bb65;
  --marker-todo:  #5a6055;
  --fill-track:   rgba(255,255,255,0.1);
  --fill-bar:     #78bb65;
}

/* Text size overrides — one knob (--text-scale) drives ALL px font sizes,
   which are wrapped in calc(… * var(--text-scale)) throughout the app. */
html[data-text-size="small"]  { --text-scale: 0.88; }
html[data-text-size="normal"] { --text-scale: 1.00; }
html[data-text-size="large"]  { --text-scale: 1.15; }
html[data-text-size="xlarge"] { --text-scale: 1.30; }

/* OLED True Black — pixel-off background for battery savings on AMOLED screens */
[data-theme="oled"] {
  --bg:           #000000;
  --bg2:          #0a0a0a;
  --surface:      #121212;
  --border:       #2a2a2a;
  --text:         #e6e6e6;
  --text-muted:   #888888;
  --accent:       #78bb65;
  --accent-dim:   #5fa04e;
  --done-color:   #78bb65;
  --header-bg:    #000000;
  --header-text:  #dddddd;
  --tab-bg:       #000000;
  --tab-active:   #78bb65;
  --tab-text:     #777777;
  --tab-text-act: #000000;
  --overlay:      rgba(0,0,0,0.85);
  --shadow:       0 2px 12px rgba(0,0,0,0.7);
  --marker-done:  #78bb65;
  --marker-todo:  #4a4a4a;
  --fill-track:   rgba(255,255,255,0.08);
  --fill-bar:     #78bb65;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

html, body {
  height: 100%;
  height: 100dvh;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  font-size: calc(15px * var(--text-scale));
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Disable double-tap-to-zoom on the chrome (the map manages its own gestures) */
  touch-action: manipulation;
  font-feature-settings: 'cv11', 'ss01', 'kern';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

/* Smooth page-wide transitions when theme switches */
body, .stat-card, .peak-item, .visit-item, .modal-sheet, .trailhead-card {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.2s ease;
}

/* ── Header ─────────────────────────────── */
header {
  background: var(--header-gradient);
  color: var(--header-text);
  padding: var(--sp-3) var(--sp-4) var(--sp-3);
  flex-shrink: 0;
  user-select: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  position: relative;
  z-index: 10;
  overflow: hidden;
}
/* Faint brand mountain watermark on the right — keeps identity present
   without competing with header content (which sits above via z-index). */
header::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -16px;
  transform: translateY(-50%);
  width: 120px;
  height: 120px;
  background: url('../icon.svg') no-repeat center / contain;
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
}
header > * { position: relative; z-index: 1; }

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}

header h1 {
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: 0.02em;   /* gentle open tracking — reads as a wordmark now that it stands alone */
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-count {
  font-size: calc(12px * var(--text-scale));
  opacity: 0.85;
  white-space: nowrap;
  min-width: 82px;
}

.progress-trio {
  flex: 1;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.progress-cell {
  flex: 1 1 0;            /* each visible cell shares the row equally */
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.progress-cell-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  font-size: calc(10px * var(--text-scale));
  font-weight: 700;
  color: var(--header-text);
  line-height: 1;
}

.progress-cell-label {
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
}

.progress-cell-val {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.progress-mini-bar {
  height: 5px;
  background: var(--fill-track);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.18);
}

.progress-mini-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
  width: 0%;
  box-shadow: 0 0 4px currentColor;
}

.progress-pct {
  font-size: calc(12px * var(--text-scale));
  opacity: 0.85;
  min-width: 32px;
  text-align: right;
}

/* ── Tab bar ─────────────────────────────── */
.tab-bar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.tab {
  flex: 1;
  padding: var(--sp-3) var(--sp-2);
  border: none;
  background: none;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--tab-text);
  transition: color 0.18s ease, background 0.15s ease;
  position: relative;
  letter-spacing: 0.01em;
}

.tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transform: translateX(-50%);
  transition: width 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.tab.active {
  color: var(--accent);
  font-weight: 700;
  background: transparent;
}

.tab.active::after { width: 60%; }
.tab:active { background: var(--bg2); }

/* ── Main ────────────────────────────────── */
main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-content {
  display: none;
  height: 100%;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ── Map tab ─────────────────────────────── */
#tab-map { overflow: hidden; }
#map { flex: 1; background: #ffffff; transition: opacity 0.3s ease; }
/* Hidden until the mask is drawn + first tiles load — avoids a flash of
   unmasked map on startup (see initMapOnce). */
#map.map-loading { opacity: 0; }

/* Leaflet's default tile background — force white so unloaded out-of-NY tiles look clean */
.leaflet-container { background: #ffffff !important; }
[data-theme="dark"] .leaflet-container,
[data-theme="oled"] .leaflet-container { background: #1a1a1a !important; }
[data-theme="dark"] #map,
[data-theme="oled"] #map { background: #1a1a1a; }

/* Dark-mode map: OpenTopoMap only publishes light tiles, so re-tone them with
   a filter. invert+hue-rotate keeps greens green and water blue while turning
   the paper-white background near-black. Tiles only — markers, popups, and
   the NY outline live in other panes and stay untouched. */
[data-theme="dark"] #map .leaflet-tile,
[data-theme="oled"] #map .leaflet-tile {
  filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.65);
}

/* ── List type bar ───────────────────────── */
.list-type-bar {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.type-btn {
  flex: 1;
  position: relative;
  padding: 9px 4px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: calc(13px * var(--text-scale));
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

/* Invisible tap-area expansion — these controls stay visually compact but
   meet the 44px minimum touch target (Apple HIG / Material). */
.filter-chip::before, .type-btn::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: -7px; bottom: -7px;
}

.type-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}

/* ── List tab ────────────────────────────── */
.list-controls {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.list-controls select,
.list-controls input[type="search"] {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: calc(13px * var(--text-scale));
  font-family: inherit;
  outline: none;
  min-width: 0;
}

/* Status filter chips */
.list-filter-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.filter-chip {
  flex: 0 0 auto;
  position: relative;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: calc(12.5px * var(--text-scale));
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-chip:hover { border-color: var(--accent); }
.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#peak-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.peak-item {
  display: flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-3);
  cursor: pointer;
  transition: background 0.14s ease, transform 0.08s ease;
  background: var(--surface);
}

.peak-item:hover  { background: var(--bg2); }
.peak-item:active { background: var(--bg2); transform: scale(0.995); }

.peak-rank {
  font-size: calc(11px * var(--text-scale));
  color: var(--text-muted);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.peak-info { flex: 1; min-width: 0; }

.peak-name {
  font-size: var(--fs-md);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.peak-item.done .peak-name { color: var(--done-color); font-weight: 700; }

.winter-badge {
  display: inline-block;
  margin-left: 6px;
  color: #4a7cb0;
  font-size: calc(13px * var(--text-scale));
  text-shadow: 0 0 4px rgba(74,124,176,0.4);
  vertical-align: middle;
}
.peak-item.winter { border-left: 3px solid #4a7cb0; }

.peak-elev {
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.peak-date-tag {
  font-size: calc(11px * var(--text-scale));
  color: var(--accent);
  margin-top: 2px;
}

.check-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: calc(14px * var(--text-scale));
  font-weight: 700;
  color: transparent;
  transition: all 0.25s cubic-bezier(0.34, 1.5, 0.64, 1);
}

.peak-item.done .check-circle {
  background: var(--accent-gradient);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(74, 124, 63, 0.3);
}

/* ── Stats tab ───────────────────────────── */
#tab-stats {
  overflow-y: auto;
  padding: 14px;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-3);
  text-align: center;
  box-shadow: var(--shadow);
  animation: card-in 0.35s ease both;
}

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

.stat-card.wide { grid-column: 1 / -1; text-align: left; padding: var(--sp-4) var(--sp-4); }

.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: calc(10px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-top: var(--sp-2);
  font-weight: 700;
}

.stat-detail {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  margin-top: var(--sp-1);
  line-height: 1.4;
}

.mini-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s;
}

/* ── Modals ──────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  /* Above Leaflet's map controls (zoom/layer toggle sit at z-index 1000),
     so the modal backdrop fully covers them. Stays below SOS (3000),
     onboarding (5000), and toasts (4000). */
  z-index: 1100;
  animation: fade-in 0.2s ease;
}

.modal.hidden { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-5);
  padding-bottom: max(var(--sp-5), env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  animation: slide-up 0.32s cubic-bezier(0.32, 1.2, 0.4, 1);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
}

@keyframes slide-up {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-hero-img {
  width: calc(100% + 36px);
  margin: -20px -18px 0;
  height: 200px;
  object-fit: cover;
  display: block;
  border-radius: 20px 20px 0 0;
  background: var(--bg2);
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: rgba(255,255,255,0.6);
  border-radius: 2px;
  margin: 10px auto 14px;
  position: relative;
  z-index: 1;
  margin-top: -14px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 10px;
}

.modal-header h2 {
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.modal-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: var(--sp-1);
  font-weight: 500;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Peak metadata ───────────────────────── */
.peak-meta {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meta-stats-row {
  display: flex;
  gap: 8px;
}

.meta-stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-2);
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.meta-stat:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

.meta-stat-label {
  font-size: calc(10px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.meta-stat-value {
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  color: var(--text);
}

.diff-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: calc(11px * var(--text-scale));
  font-weight: 700;
  color: #fff;
}

.meta-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.meta-row-label {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 64px;
  font-size: calc(12px * var(--text-scale));
  padding-top: 1px;
  flex-shrink: 0;
}

.meta-row-value {
  font-size: calc(13px * var(--text-scale));
  color: var(--text);
  line-height: 1.4;
}

.meta-herd-path {
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  color: #b35a00;
  background: #fff0dd;
  border: 1px solid #e8c080;
  border-radius: 8px;
  padding: 7px 10px;
}

[data-theme="dark"] .meta-herd-path {
  color: #f0a030;
  background: #2a2010;
  border-color: #5a4010;
}

.meta-facts {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  margin: 0;
}

.meta-facts li {
  font-size: calc(13px * var(--text-scale));
  color: var(--text);
  line-height: 1.4;
  padding-left: 16px;
  position: relative;
}

.meta-facts li::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: 700;
}

.meta-disclaimer {
  font-size: calc(10px * var(--text-scale));
  color: var(--text-muted);
  text-align: right;
  margin: 0;
}

.directions-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #1a73e8;
  color: #fff;
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

.directions-btn::before {
  content: '↗';
  font-size: calc(11px * var(--text-scale));
}

/* ── Form fields ─────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-group label {
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.field-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: calc(15px * var(--text-scale));
  font-family: inherit;
  outline: none;
  width: 100%;
  resize: none;
}

.field-group textarea:focus { border-color: var(--accent); }

/* Inline date row */
.field-inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.field-inline-label {
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  white-space: nowrap;
}

.field-inline input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: calc(14px * var(--text-scale));
  font-family: inherit;
  outline: none;
}

.field-inline input[type="date"]:focus { border-color: var(--accent); }

/* Condition chips */
.condition-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 5px 13px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: calc(13px * var(--text-scale));
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.4;
}

.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip-section-label {
  width: 100%;
  font-size: calc(10px * var(--text-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: -2px;
  margin-top: 2px;
}

.done-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg2);
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.done-toggle input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.done-toggle-label {
  font-size: calc(16px * var(--text-scale));
  font-weight: 600;
}

/* ── Settings rows ───────────────────────── */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 14px;
  font-size: calc(15px * var(--text-scale));
}

.setting-row:last-child { border-bottom: none; }

.setting-label-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.setting-sub {
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
  line-height: 1.3;
}

.offline-progress {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.offline-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s;
}

.setting-label { font-weight: 500; }

.theme-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.theme-btn {
  padding: 7px 14px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: calc(13px * var(--text-scale));
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.theme-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Text size buttons reuse the theme toggle visual style */
.text-size-btn {
  padding: 4px 10px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  min-width: 32px;
  line-height: 1.4;
}
.text-size-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Star rating ─────────────────────────── */
.rating-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
}

.rating-star {
  background: none;
  border: none;
  color: var(--border);
  font-size: calc(32px * var(--text-scale));
  line-height: 1;
  padding: 4px 2px;
  cursor: pointer;
  transition: color 0.1s, transform 0.1s;
}
.rating-star:hover  { transform: scale(1.15); }
.rating-star:active { transform: scale(0.92); }
.rating-star.selected { color: #e8a410; }

.rating-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: calc(14px * var(--text-scale));
  cursor: pointer;
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  visibility: hidden;
}
.rating-clear:hover { background: var(--bg2); color: var(--text); }

/* Rating display in visit log rows */
.visit-rating {
  font-size: calc(14px * var(--text-scale));
  margin-top: 2px;
  letter-spacing: 1px;
  color: #e8a410;
}
.visit-rating-empty { color: var(--border); }

/* ── Achievement grid ────────────────────── */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.achievement-tile {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 6px;
  text-align: center;
  filter: grayscale(1) brightness(0.7);
  opacity: 0.55;
  transition: filter 0.2s, opacity 0.2s, transform 0.1s;
  cursor: pointer;
  user-select: none;
}
.achievement-status {
  position: absolute;
  top: 3px; right: 4px;
  font-size: calc(9px * var(--text-scale));
  line-height: 1;
  opacity: 0.8;
}
.achievement-tile.selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.achievement-tile.got {
  filter: none;
  opacity: 1;
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg2) 100%);
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(74,124,63,0.15);
}
.achievement-tile.got:hover { transform: translateY(-2px); }

.achievement-icon {
  font-size: calc(26px * var(--text-scale));
  line-height: 1;
  margin-bottom: 4px;
  color: var(--text-muted);
}
.achievement-tile.got .achievement-icon { color: var(--accent); }
.achievement-icon svg {
  width: calc(26px * var(--text-scale));
  height: calc(26px * var(--text-scale));
  display: block;
  margin: 0 auto;
}
.ach-detail-icon svg {
  width: calc(28px * var(--text-scale));
  height: calc(28px * var(--text-scale));
  color: var(--accent);
}

.achievement-name {
  font-size: calc(10px * var(--text-scale));
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

/* Share progress button (rings hero) */
.rings-hero { position: relative; }
.share-progress-btn {
  position: absolute;
  top: 8px; right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text-muted);
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.share-progress-btn:active { background: var(--border); }

/* "Also log to" combo chips in the visit form */
.combo-apply-hint { font-weight: 400; color: var(--text-muted); font-size: calc(11px * var(--text-scale)); }
.combo-apply-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.combo-apply-chip {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-size: calc(12.5px * var(--text-scale));
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 36px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.combo-apply-chip.is-done { color: var(--text-muted); }
.combo-apply-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* "Climb together" combos in the peak modal */
.peak-combo {
  margin: 10px 0;
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
}
.combo-title { font-size: calc(13px * var(--text-scale)); color: var(--text); margin-bottom: 8px; }
.combo-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.combo-chip {
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--accent);
  font-size: calc(12.5px * var(--text-scale));
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.combo-chip:active { background: var(--border); }
.combo-chip.done { color: var(--text-muted); }
.combo-combined {
  margin-top: 8px;
  font-size: calc(12.5px * var(--text-scale));
  color: var(--text);
}
.combo-combined strong { color: var(--accent); }
.combo-combined-note { color: var(--text-muted); font-weight: 400; font-size: calc(11px * var(--text-scale)); }
.combo-note {
  margin-top: 8px;
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
  line-height: 1.4;
}

/* Range completion rows (Stats tab) */
.range-stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.range-stat-name {
  flex: 0 0 38%;
  font-size: calc(12.5px * var(--text-scale));
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.range-stat-track {
  flex: 1;
  height: 8px;
  background: var(--bg2);
  border-radius: 5px;
  overflow: hidden;
}
.range-stat-fill { display: block; height: 100%; border-radius: 5px; transition: width 0.4s ease; }
.range-stat-count {
  flex: 0 0 auto;
  font-size: calc(12px * var(--text-scale));
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Personal records rows */
.record-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: calc(13px * var(--text-scale));
}
.record-row:last-child { border-bottom: none; }
.record-key { color: var(--text-muted); white-space: nowrap; }
.record-val { text-align: right; color: var(--text); font-weight: 600; }
.record-date { display: block; font-size: calc(11px * var(--text-scale)); color: var(--text-muted); font-weight: 400; margin-top: 1px; }

/* Hikes-by-season mini bar chart */
.season-row { display: flex; gap: 8px; align-items: flex-end; }
.season-cell { flex: 1; text-align: center; }
.season-bar-wrap {
  height: 70px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 6px;
}
.season-bar { width: 60%; min-height: 3px; border-radius: 5px 5px 0 0; transition: height 0.4s ease; }
.season-count { font-size: calc(15px * var(--text-scale)); font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.season-name { font-size: calc(10.5px * var(--text-scale)); color: var(--text-muted); margin-top: 1px; }

/* Conditions-braved chips */
.cond-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cond-chip {
  padding: 5px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
}
.cond-chip strong { color: var(--text); }

/* Suggested next hike rows (Stats tab) */
.next-hike-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
}
.next-hike-row:active { background: var(--border); }
.next-hike-name { font-weight: 700; color: var(--text); }
.next-hike-meta {
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
  white-space: nowrap;
}

/* Tap-to-reveal detail panel (how to earn) — the mobile-friendly replacement
   for the hover tooltip, which doesn't exist on touchscreens. */
.achievement-detail {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  min-height: 56px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.ach-detail-hint {
  color: var(--text-muted);
  font-size: calc(13px * var(--text-scale));
  font-style: italic;
}
.ach-detail-icon { font-size: calc(28px * var(--text-scale)); line-height: 1; flex: 0 0 auto; }
.ach-detail-body { flex: 1; min-width: 0; }
.ach-detail-name {
  font-weight: 700; color: var(--text);
  font-size: calc(14px * var(--text-scale));
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ach-detail-pill {
  font-size: calc(10px * var(--text-scale));
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 2px 8px; border-radius: 999px;
}
.ach-detail-pill.earned { background: var(--accent); color: #fff; }
.ach-detail-pill.locked { background: var(--border); color: var(--text-muted); }
.ach-detail-desc {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: calc(13px * var(--text-scale));
  line-height: 1.35;
}

/* ── Pre-hike checklist ──────────────────── */
.checklist-section {
  margin-top: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.checklist-section > summary {
  padding: 12px 14px;
  font-weight: 800;
  color: var(--accent);
  font-size: calc(13px * var(--text-scale));
  cursor: pointer;
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.checklist-section > summary::-webkit-details-marker { display: none; }
.checklist-section > summary::after {
  content: '▾';
  margin-left: auto;
  opacity: 0.6;
  font-weight: 700;
  transition: transform 0.18s;
}
.checklist-section[open] > summary::after { transform: rotate(180deg); }

#checklist-body { padding: 0 14px 14px; }

.checklist-group { margin-top: 12px; }
.checklist-cat {
  font-size: calc(10px * var(--text-scale));
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 4px;
  font-size: calc(13px * var(--text-scale));
  line-height: 1.4;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s;
}
.checklist-item:hover { background: var(--surface); }
.checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--accent);
}
.checklist-item.critical span::before {
  content: '⚠';
  margin-right: 5px;
  color: #d46800;
  font-weight: 700;
}
.checklist-item input:checked + span {
  text-decoration: line-through;
  opacity: 0.5;
}

/* ── Trip planning ───────────────────────── */
.plan-section {
  margin-top: 14px;
  padding: 12px;
  background: var(--bg2);
  border: 1px dashed var(--accent);
  border-radius: var(--r-lg);
}

.plan-header {
  font-size: calc(13px * var(--text-scale));
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.plan-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-list-label {
  font-size: calc(11px * var(--text-scale));
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  margin-top: 8px;
}

.plan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: calc(13px * var(--text-scale));
}

.plan-item-time {
  color: var(--accent);
  font-weight: 600;
  font-size: calc(12px * var(--text-scale));
  margin-left: 4px;
}
.plan-item-hikers {
  font-size: calc(11px * var(--text-scale));
  color: var(--text-muted);
  margin-left: 8px;
}

.plan-item.editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.plan-item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.plan-item-actions .visit-edit svg { display: block; }

/* Upcoming hikes card in Stats */
.upcoming-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  margin: 0 -4px;
  padding-left: 4px;
  padding-right: 4px;
  border-radius: 6px;
}
.upcoming-row:hover { background: var(--bg2); }
.upcoming-row:last-child { border-bottom: none; }

.upcoming-name {
  font-weight: 600;
  font-size: calc(14px * var(--text-scale));
  color: var(--text);
}

.upcoming-date {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
  font-weight: 600;
}

.upcoming-when {
  font-size: calc(10px * var(--text-scale));
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  margin-top: 1px;
}

/* ── Visit photos ────────────────────────── */
.photo-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg2);
  border: 1.5px dashed var(--border);
  color: var(--accent);
  font-size: calc(14px * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
}
.photo-add-btn:active { background: var(--bg); }

.photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.photo-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg2);
}
.photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.photo-thumb-remove {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  font-size: calc(12px * var(--text-scale));
  line-height: 18px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.visit-photo-badge {
  display: inline-block;
  margin-left: 8px;
  font-size: calc(10px * var(--text-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  vertical-align: middle;
}

.visit-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.visit-photo-thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
  border: 1px solid var(--border);
}

/* ── iOS-style toggle switch ─────────────── */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 28px;
  transition: 0.2s;
}
.switch-slider::before {
  position: absolute;
  content: '';
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .switch-slider          { background: var(--accent); }
.switch input:checked + .switch-slider::before  { transform: translateX(20px); }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  white-space: nowrap;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
  letter-spacing: -0.005em;
}

.btn:hover  { background: var(--surface); box-shadow: var(--shadow); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-gradient);
  border-color: var(--accent);
  color: #fff;
  width: 100%;
  padding: var(--sp-4);
  font-size: var(--fs-lg);
  font-weight: 700;
  border-radius: var(--r-lg);
  margin-top: var(--sp-1);
  box-shadow: 0 2px 8px rgba(74, 124, 63, 0.25);
  letter-spacing: -0.01em;
}

.btn-primary:hover  { box-shadow: 0 4px 14px rgba(74, 124, 63, 0.35); }
.btn-primary:active { background: var(--accent-dim); transform: scale(0.98); }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: calc(20px * var(--text-scale));
  color: inherit;
  opacity: 0.8;
  flex-shrink: 0;
  line-height: 1;
}

.icon-btn:active { opacity: 0.5; }

/* ── GPS locate button ───────────────────── */
.locate-btn {
  font-size: calc(18px * var(--text-scale)) !important;
  line-height: 26px !important;
  text-align: center;
  color: #333 !important;
  cursor: pointer;
  text-decoration: none;
}
.locate-btn.locating { animation: pulse-loc 1s infinite; }
@keyframes pulse-loc { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Map layer toggle ────────────────────── */
.map-layer-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255,255,255,0.92);
  border-radius: 10px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.25);
  margin: 0 0 8px 8px;
}

[data-theme="dark"] .map-layer-toggle {
  background: rgba(35,38,32,0.92);
}

.layer-btn .layer-ico {
  width: calc(13px * var(--text-scale));
  height: calc(13px * var(--text-scale));
  vertical-align: -2px;
  margin-right: 1px;
}

.layer-btn {
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: var(--bg2);
  color: var(--text-muted);
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0.55;
}
.layer-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  opacity: 1;
}

/* ── Map popup (peak / tower selection) ──── */
.map-popup {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  min-width: 200px;
}

.map-popup-title {
  font-weight: 800;
  font-size: calc(15px * var(--text-scale));
  color: #1a1a1a;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.map-popup-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.map-popup-range {
  display: inline-block;
  font-size: calc(10px * var(--text-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid;
}

.map-popup-rank {
  font-size: calc(11px * var(--text-scale));
  color: #888;
  font-weight: 600;
}

.map-popup-stats {
  display: flex;
  justify-content: space-around;
  align-items: baseline;
  gap: 6px;
  padding: 8px 4px;
  background: #f5f5f5;
  border-radius: 8px;
  margin-bottom: 6px;
}

.map-popup-stats > div {
  text-align: center;
  flex: 1;
}

.popup-stat-num {
  display: block;
  font-size: calc(14px * var(--text-scale));
  font-weight: 800;
  color: #2c2416;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.popup-stat-lbl {
  display: block;
  font-size: calc(9px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #888;
  font-weight: 600;
  margin-top: 1px;
}

.map-popup-extras {
  font-size: calc(11px * var(--text-scale));
  color: #555;
  text-align: center;
  margin: 6px 0;
  font-weight: 500;
}

.popup-diff-1, .popup-diff-2 { color: #3a9a4a; font-weight: 700; }
.popup-diff-3               { color: #c8a000; font-weight: 700; }
.popup-diff-4               { color: #d46800; font-weight: 700; }
.popup-diff-5               { color: #c42020; font-weight: 700; }

.map-popup-btn,
a.map-popup-btn,
.leaflet-popup-content a.map-popup-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  background: #4a7c3f;
  color: #fff !important;             /* override browser's link color */
  text-decoration: none !important;   /* override default link underline */
  text-align: center;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: calc(13px * var(--text-scale));
  margin-top: 8px;
  transition: background 0.15s, transform 0.08s;
}
.map-popup-btn:hover,
a.map-popup-btn:hover  { background: #3a6231; color: #fff !important; }
.map-popup-btn:active,
a.map-popup-btn:active { transform: scale(0.97); }
.map-popup-btn:visited,
a.map-popup-btn:visited { color: #fff !important; }
.map-popup-btn-tower  { background: #1f4f9e; }
.map-popup-btn-tower:hover { background: #163b78; }
.map-popup-btn-done   { background: #5d9550; }

/* ── Marker cluster bubbles (custom-styled) ── */
.mk-cluster { background: none !important; border: none !important; }
.mk-cluster-inner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: calc(15px * var(--text-scale));
  border: 2.5px solid rgba(255,255,255,0.96);
  /* Layered depth: inset top-highlight + inset bottom-shade for a glossy
     dome, soft drop shadow, and a thin dark ring for contrast on light terrain */
  box-shadow:
    inset 0 3px 5px rgba(255,255,255,0.35),
    inset 0 -4px 6px rgba(0,0,0,0.22),
    0 4px 12px rgba(0,0,0,0.45),
    0 0 0 1px rgba(0,0,0,0.30);
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  position: relative;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mk-cluster:hover .mk-cluster-inner { transform: scale(1.08); }
.mk-cluster-done {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #22a94b;
  color: #fff;
  font-size: calc(10px * var(--text-scale));
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 6px;
  border: 2px solid #fff;
  min-width: 16px;
  line-height: 1.1;
}

/* Override default Leaflet.markercluster styles we don't want */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
  transition: transform 0.25s ease-out, opacity 0.25s ease-in;
}

/* Map marker label — scales with the text size setting */
.mk-wrap {
  position: relative;
  display: inline-block;
}

.mk-label {
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  font-size: calc(10px * var(--text-scale));
  font-weight: 800;
  color: #111;
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0.2px;
  pointer-events: none;
  text-shadow:
    1px 1px 0 #fff, -1px 1px 0 #fff, 1px -1px 0 #fff, -1px -1px 0 #fff,
    0 1px 0 #fff,  0 -1px 0 #fff,  2px 0 0 #fff,  -2px 0 0 #fff;
}

/* Trailhead parking pins */
.trailhead-marker { background: transparent !important; border: none !important; }
.trailhead-pin {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: #fff;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.trailhead-pin.curated {
  width: 22px; height: 22px;
  background: #1e4d8b;       /* deep blue for the named, curated 46er trailheads */
  font-size: calc(11px * var(--text-scale));
  border-radius: 4px;
}
.trailhead-pin.tower {
  width: 20px; height: 20px;
  background: #4a70a8;             /* slightly lighter blue — distinguishes towers from 46er trailheads */
  font-size: calc(10px * var(--text-scale));
  border-radius: 50%;
}
/* Popup body — Leaflet popups always have white bg, so hard-code dark text */
.popup-th-row {
  font-size: calc(13px * var(--text-scale));
  margin-top: 5px;
  color: #1a1a1a;
  line-height: 1.4;
}
.popup-th-row strong {
  color: #5a5a5a;
  font-weight: 700;
  margin-right: 4px;
}
.popup-th-note {
  font-size: calc(12px * var(--text-scale));
  color: #555;
  font-style: italic;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #e5e5e5;
  line-height: 1.45;
}
.popup-th-peak {
  color: #1e4d8b;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dotted #1e4d8b;
}
.popup-th-peak:hover { background: rgba(30,77,139,0.1); }

/* "Wrong location? Report it" link — small footer on popups */
.popup-report-link {
  display: block;
  text-align: center;
  font-size: calc(11px * var(--text-scale));
  color: #888 !important;
  text-decoration: none !important;
  margin-top: 8px;
  padding: 4px;
}
.popup-report-link:hover { color: #555 !important; text-decoration: underline !important; }

/* Smaller "Wrong?" link next to the Directions button in the peak/tower modal */
.report-loc-link {
  display: inline-block;
  font-size: calc(11px * var(--text-scale));
  color: var(--text-muted);
  text-decoration: underline;
  margin-left: 8px;
  padding: 4px 6px;
  white-space: nowrap;
}
.report-loc-link:hover { color: var(--danger); }

/* Lean-to / campsite shelter pins */
.shelter-marker { background: transparent !important; border: none !important; }
.shelter-pin {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(11px * var(--text-scale));
  border-radius: 50%;
  background: rgba(180,120,40,0.85);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.7);
}
.shelter-pin.campsite {
  background: rgba(120,90,50,0.7);
  width: 8px; height: 8px;
  font-size: 0;
}

/* Hide completed markers when the "Remaining" toggle is on */
#map.dim-completed .leaflet-marker-icon:has(.mk-done),
#map.dim-completed .leaflet-marker-icon.mk-done {
  display: none !important;
}
/* Fallback for browsers without :has() — fade them */
@supports not selector(:has(*)) {
  #map.dim-completed .mk-done {
    opacity: 0.15;
    filter: grayscale(0.85);
    pointer-events: none;
  }
}

/* 46er number input */
.adk46-input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: calc(14px * var(--text-scale));
  font-weight: 600;
  width: 80px;
  text-align: center;
  outline: none;
  font-family: inherit;
}
.adk46-input:focus { border-color: var(--accent); }

/* Install banner */
#install-banner {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1400;
  animation: slide-up 0.35s ease;
  max-width: 480px;
  margin: 0 auto;
}
#install-banner.hidden { display: none; }

.install-icon { font-size: calc(28px * var(--text-scale)); flex-shrink: 0; }
.install-text { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.install-text strong { font-size: calc(14px * var(--text-scale)); color: var(--text); }
.install-text small  { font-size: calc(12px * var(--text-scale)); color: var(--text-muted); line-height: 1.3; }

.install-cta {
  width: auto !important;
  padding: 8px 14px !important;
  font-size: calc(13px * var(--text-scale)) !important;
  margin: 0 !important;
  flex-shrink: 0;
}

.install-x {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: calc(18px * var(--text-scale));
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}

/* ── Trail map service buttons ───────────── */
.trail-links-meta-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.trail-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.trail-svc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 8px;
  color: #fff;
  font-size: calc(11px * var(--text-scale));
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.2px;
  transition: opacity 0.15s, transform 0.1s;
  border: 1px solid rgba(255,255,255,0.15);
}
.trail-svc-btn:hover  { opacity: 0.88; }
.trail-svc-btn:active { transform: scale(0.95); }

.trail-svc-icon { font-size: calc(13px * var(--text-scale)); line-height: 1; }
/* Hide icon spans that are empty after the emoji cleanup, so they don't leave gaps */
.trail-svc-icon:empty, .milestone-emoji:empty, .peak-banner-icon:empty, .we-ico:empty { display: none; }
.trail-svc-name { line-height: 1; }

/* ── Photo fullscreen ────────────────────── */
#photo-fs {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.2s ease;
}
#photo-fs.hidden { display: none; }

#photo-fs-img {
  max-width: 100%;
  max-height: 100dvh;
  object-fit: contain;
  border-radius: 4px;
}

#photo-fs-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: calc(22px * var(--text-scale));
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hint that photo is tappable */
.modal-hero-img { cursor: zoom-in; }

/* ── Milestone toast ─────────────────────── */
#milestone-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  z-index: 1500;
  animation: slide-up 0.3s ease;
  cursor: pointer;
  max-width: 90vw;
}
#milestone-toast.hidden   { display: none; }
#milestone-toast.hiding   { animation: slide-down 0.4s ease forwards; }
@keyframes slide-down { to { transform: translateX(-50%) translateY(80px); opacity: 0; } }

.milestone-emoji { font-size: calc(26px * var(--text-scale)); line-height: 1; }
.milestone-msg   { font-size: calc(14px * var(--text-scale)); font-weight: 600; color: var(--text); }

/* ── Hiker selector in header ────────────── */
.hiker-selector {
  background: rgba(255,255,255,0.22);
  color: var(--header-text);
  border: 1px solid rgba(255,255,255,0.35);
  font-size: calc(12px * var(--text-scale));
  font-weight: 700;
  padding: 4px 22px 4px 9px;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  max-width: 110px;
  text-overflow: ellipsis;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: background-color 0.15s;
}
.hiker-selector:hover  { background-color: rgba(255,255,255,0.32); }
.hiker-selector:focus  { border-color: #fff; }
.hiker-selector option { color: #111; }

/* ── Visits log in modal ─────────────────── */
.visit-count-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: calc(11px * var(--text-scale));
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 4px;
  vertical-align: middle;
}

.visits-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.visit-empty {
  font-size: calc(13px * var(--text-scale));
  color: var(--text-muted);
  font-style: italic;
  padding: 12px;
  text-align: center;
  background: var(--bg2);
  border-radius: 10px;
}

.visit-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: calc(13px * var(--text-scale));
}

.visit-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.visit-date {
  font-weight: 700;
  color: var(--text);
  font-size: calc(14px * var(--text-scale));
}

.visit-actions { display: flex; gap: 4px; }

.visit-edit, .visit-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: calc(14px * var(--text-scale));
  padding: 2px 6px;
  border-radius: 5px;
}
.visit-edit:hover, .visit-delete:hover { background: var(--bg); }

.visit-people {
  font-size: calc(12px * var(--text-scale));
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 2px;
}

.visit-cond, .visit-notes {
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
  line-height: 1.4;
}

.visit-notes {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
  color: var(--text);
}

/* ── Visit form ───────────────────────────── */
.visit-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.visit-form-header {
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.hiker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.add-hiker-mini {
  display: inline-block;
  margin-top: 8px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: calc(12px * var(--text-scale));
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.add-hiker-mini:hover { color: var(--accent); border-color: var(--accent); }

/* Hike time-of-day (from / to) inputs */
.field-optional { color: var(--text-muted); font-weight: 400; font-size: calc(11px * var(--text-scale)); }
.time-range { display: inline-flex; align-items: center; gap: 6px; }
.time-range input[type="time"] {
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  padding: 6px 8px;
}
.time-sep { color: var(--text-muted); font-size: calc(12px * var(--text-scale)); }
.visit-time { color: var(--text-muted); font-weight: 400; font-size: calc(12px * var(--text-scale)); }

/* ── Ski lift confirmation ───────────────── */
.lift-confirm {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: #fff5e0;
  border: 1px solid #e8c080;
  border-radius: 10px;
  font-size: calc(12px * var(--text-scale));
  color: #6b4a10;
  cursor: pointer;
  line-height: 1.4;
}
[data-theme="dark"] .lift-confirm {
  background: #2a2010;
  border-color: #5a4010;
  color: #f0c060;
}
.lift-confirm input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: #d46800;
}

.visit-lift-badge {
  display: inline-block;
  margin-left: 8px;
  font-size: calc(10px * var(--text-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #b35a00;
  background: #fff0dd;
  border: 1px solid #e8c080;
  padding: 1px 6px;
  border-radius: 6px;
  vertical-align: middle;
}
[data-theme="dark"] .visit-lift-badge {
  color: #f0a030;
  background: #2a2010;
  border-color: #5a4010;
}

.visit-lift { opacity: 0.7; }

/* ── Hiker roster in Settings ─────────────── */
.hiker-roster {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hiker-roster-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

/* Force [hidden] to actually hide buttons/inputs whose .btn rules set display */
[hidden] { display: none !important; }

.hiker-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: calc(14px * var(--text-scale));
}
.hiker-name-display {
  color: var(--text);
  padding: 4px 0;
}
.hiker-name-input {
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: calc(14px * var(--text-scale));
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  width: 160px;
  outline: none;
}
.hiker-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hiker-edit-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: calc(14px * var(--text-scale));
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.hiker-edit-btn:hover {
  background: var(--bg);
  color: var(--accent);
}
.hiker-name-input:focus {
  background: var(--bg);
  outline: 1px solid var(--accent);
}

.hiker-self-badge {
  font-size: calc(10px * var(--text-scale));
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.hiker-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: calc(16px * var(--text-scale));
  cursor: pointer;
  padding: 2px 6px;
}

/* Challenge toggles */
.challenge-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.challenge-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.challenge-toggle:hover { border-color: var(--accent); }
.challenge-toggle input { margin-top: 3px; accent-color: var(--accent); }
.challenge-toggle-label { font-size: calc(14px * var(--text-scale)); line-height: 1.4; color: var(--text); }
.challenge-toggle-sub { color: var(--text-muted); font-weight: 400; font-size: calc(13px * var(--text-scale)); }
.challenge-toggle input:not(:checked) ~ .challenge-toggle-label { opacity: 0.55; }
/* Colored challenge glyph (matches the Stats progress-ring colors) */
.challenge-ico { width: 22px; height: 22px; flex-shrink: 0; margin-top: 1px; }
.challenge-toggle input:not(:checked) ~ .challenge-ico { opacity: 0.4; }

.hiker-add-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.hiker-add-row .btn { padding: 6px 10px; font-size: calc(13px * var(--text-scale)); }

/* ── Quick-log FAB (auto-log nearest summit) ─ */
.quick-log-fab {
  position: absolute;
  bottom: 24px;
  right: 16px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  border: 3px solid #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.40), inset 0 2px 4px rgba(255,255,255,0.25);
  z-index: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  /* Pulse a few times to draw the eye on load, then settle — not forever */
  animation: log-pulse 2.6s ease-in-out 3;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0;
}
.quick-log-fab:active { transform: scale(0.92); }
@keyframes log-pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(0,0,0,0.45), 0 0 0 0 rgba(120, 187, 101, 0.5); }
  50%      { box-shadow: 0 4px 14px rgba(0,0,0,0.45), 0 0 0 14px rgba(120, 187, 101, 0); }
}
.quick-log-fab:active { transform: scale(0.94); }
.quick-log-fab.locating { animation: pulse-loc 0.9s infinite; }

.quick-log-icon { font-size: calc(19px * var(--text-scale)); line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); }
.quick-log-text { font-size: calc(10px * var(--text-scale)); line-height: 1.05; letter-spacing: 0.6px; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,0.35); }

/* ── Quick-log picker list ───────────────── */
.quick-log-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 60dvh;
  overflow-y: auto;
}

.quick-log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.quick-log-item:active { background: var(--surface); }

.quick-log-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(18px * var(--text-scale));
  flex-shrink: 0;
}

.quick-log-info { flex: 1; min-width: 0; }
.quick-log-name { font-size: calc(15px * var(--text-scale)); font-weight: 600; color: var(--text); }
.quick-log-meta { font-size: calc(12px * var(--text-scale)); color: var(--text-muted); margin-top: 2px; }

.quick-log-dist {
  font-size: calc(14px * var(--text-scale));
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Clickable stat links ────────────────── */
.stat-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px dotted var(--accent);
  cursor: pointer;
}
.stat-link:hover { opacity: 0.8; }
.stat-link:active { opacity: 0.6; }

/* Year rows in the "By year" card — clickable to filter heatmap */
.year-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: calc(14px * var(--text-scale));
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  margin: 1px 0;
}
.year-row:hover { background: var(--bg2); }
.year-row-active {
  background: rgba(120, 187, 101, 0.18);
  border-left: 3px solid var(--accent);
  padding-left: 7px;
}
.year-row span:first-child { font-weight: 600; }
.year-count {
  font-weight: 700;
  color: var(--accent);
  background: var(--bg2);
  padding: 2px 9px;
  border-radius: 10px;
  font-size: calc(12px * var(--text-scale));
}

/* ── Activity heatmap ────────────────────── */
.heatmap-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.heatmap-title {
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  color: var(--text);
}

.heatmap-stats {
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
}

.heatmap-year-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 700;
  font-size: calc(13px * var(--text-scale));
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  margin-left: 4px;
}

.heatmap-year-static {
  color: var(--accent);
  font-weight: 700;
}

.heatmap-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.heatmap-months {
  display: grid;
  grid-template-columns: repeat(53, 11px);
  gap: 2px;
  margin-bottom: 4px;
  font-size: calc(10px * var(--text-scale));
  color: var(--text-muted);
  height: 12px;
}

.heatmap-months span {
  grid-row: 1;
  white-space: nowrap;
}

.heatmap-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 11px);
  gap: 2px;
}

.heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: calc(10px * var(--text-scale));
  color: var(--text-muted);
  margin-top: 8px;
  justify-content: flex-end;
}

.heatmap-legend .heatmap-cell {
  display: inline-block;
}

/* ── Share Trophy Card button ────────────── */
.share-trophy-btn {
  margin-top: 12px;
  width: 100%;
  font-size: calc(16px * var(--text-scale)) !important;
  padding: 14px !important;
}

/* ── Summit weather forecast ─────────────── */
.weather-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 16px;
  min-height: 60px;
}

.weather-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  color: var(--text-muted);
  font-size: calc(13px * var(--text-scale));
}

.weather-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: weather-spin 0.8s linear infinite;
}
@keyframes weather-spin { to { transform: rotate(360deg); } }

.weather-error {
  text-align: center;
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
  padding: 12px;
}

.weather-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.weather-current {
  display: flex;
  align-items: center;
  gap: 12px;
}

.weather-icon-big {
  font-size: calc(40px * var(--text-scale));
  line-height: 1;
}
.weather-icon-big svg {
  width: calc(42px * var(--text-scale));
  height: calc(42px * var(--text-scale));
  color: var(--accent);
  display: block;
}

.weather-cur-temp {
  font-size: calc(26px * var(--text-scale));
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.weather-cur-cond {
  font-size: calc(12px * var(--text-scale));
  color: var(--text);
  font-weight: 600;
  margin-top: 2px;
}

.weather-cur-meta {
  font-size: calc(11px * var(--text-scale));
  color: var(--text-muted);
  margin-top: 2px;
}

.weather-summit-badge {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: calc(10px * var(--text-scale));
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.weather-summit-badge > div:last-child {
  font-size: calc(14px * var(--text-scale));
  color: var(--accent);
  margin-top: 1px;
  letter-spacing: 0;
}

.weather-days {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.weather-day {
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  font-size: calc(11px * var(--text-scale));
  color: var(--text);
}

.weather-day-name {
  font-size: calc(11px * var(--text-scale));
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.weather-day-icon {
  font-size: calc(22px * var(--text-scale));
  line-height: 1;
  margin: 4px 0;
}
.weather-day-icon svg {
  width: calc(24px * var(--text-scale));
  height: calc(24px * var(--text-scale));
  color: var(--text);
  margin: 0 auto;
}

.weather-day-temp {
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
}
.weather-day-temp .hi { color: var(--text); }
.weather-day-temp .lo { color: var(--text-muted); margin-left: 4px; }

.weather-day-rain,
.weather-day-wind {
  font-size: calc(10px * var(--text-scale));
  margin-top: 3px;
  color: var(--text-muted);
}
.weather-day-rain { color: #4a7cb0; }
.weather-day-wind { color: #b35a00; }

.weather-footnote {
  font-size: calc(10px * var(--text-scale));
  color: var(--text-muted);
  text-align: right;
  margin-top: 8px;
}

/* Extra current-conditions row */
.weather-extras {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 10px;
  padding: 8px;
  background: var(--surface);
  border-radius: 8px;
}

.weather-extra {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  color: var(--text);
  text-align: center;
  gap: 1px;
}

.we-val { font-weight: 700; color: var(--text); }
.we-lbl { font-size: calc(9px * var(--text-scale)); color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }

/* Sunrise / sunset bar */
.weather-sun {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: calc(12px * var(--text-scale));
  color: var(--text);
  margin-top: 8px;
  padding: 8px 10px;
  background: linear-gradient(90deg, rgba(255,180,80,0.15), rgba(120,160,200,0.05), rgba(120,80,160,0.15));
  border-radius: 8px;
}
.weather-sun strong { color: var(--text); font-weight: 800; }
.weather-daylight { font-size: calc(11px * var(--text-scale)); color: var(--text-muted); font-weight: 600; }

/* Per-day UV warning */
.weather-day-uv {
  font-size: calc(10px * var(--text-scale));
  margin-top: 3px;
  color: #d4a000;
}

/* Pre-fill button */
.weather-actions {
  margin-top: 10px;
}
.weather-prefill-btn {
  width: 100%;
  font-size: calc(12px * var(--text-scale)) !important;
  padding: 8px !important;
  background: var(--bg) !important;
  color: var(--accent) !important;
  border: 1px dashed var(--accent) !important;
}
.weather-prefill-btn:active { background: var(--bg2) !important; }

/* Brief highlight when chips are auto-selected */
.chips-flash {
  animation: chip-flash 0.5s ease;
}
@keyframes chip-flash {
  0%   { background: rgba(120, 187, 101, 0.25); }
  100% { background: transparent; }
}

/* ── Rich trailhead info card ────────────── */
.trailhead-card {
  margin-top: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.trailhead-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}

.trailhead-card-title {
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  color: var(--text);
}

.trailhead-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: calc(18px * var(--text-scale));
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}

.trailhead-card-body {
  padding: 4px 12px 12px;
  border-top: 1px solid var(--border);
}

.trailhead-address {
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
  font-style: italic;
  margin: 8px 0;
  line-height: 1.4;
}

.trailhead-rows {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trailhead-rows li {
  display: flex;
  gap: 8px;
  font-size: calc(12px * var(--text-scale));
  line-height: 1.45;
  padding: 3px 0;
  border-bottom: 1px dotted var(--border);
}
.trailhead-rows li:last-child { border-bottom: none; }

.trailhead-row-key {
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 92px;
}

.trailhead-row-val {
  color: var(--text);
  flex: 1;
}

.trailhead-notes {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(120, 187, 101, 0.12);
  border: 1px solid rgba(120, 187, 101, 0.3);
  border-radius: 8px;
  font-size: calc(12px * var(--text-scale));
  line-height: 1.45;
  color: var(--text);
}
[data-theme="dark"] .trailhead-notes,
[data-theme="oled"] .trailhead-notes {
  background: rgba(120, 187, 101, 0.08);
}

/* ── Peak modal banners (winter rule, AMR, etc.) ─ */
.peak-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid;
  margin-bottom: 8px;
  text-decoration: none;
  cursor: default;
}

.peak-banner-icon {
  font-size: calc(22px * var(--text-scale));
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.peak-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.4;
}

.peak-banner-text strong {
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
}

.peak-banner-text span {
  font-size: calc(12px * var(--text-scale));
  opacity: 0.85;
}

.peak-banner-text em {
  font-style: italic;
  font-weight: 600;
}

.peak-banner-arrow {
  font-size: calc(18px * var(--text-scale));
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* AMR reservation — tappable, blue */
.peak-banner-amr {
  background: #e7f0fa;
  border-color: #4a7cb0;
  color: #1d3a5d;
  cursor: pointer;
}
.peak-banner-amr:active { background: #d0e0f0; }
[data-theme="dark"] .peak-banner-amr {
  background: #1a2a44;
  border-color: #4a7cb0;
  color: #b0d0ee;
}

/* AMR off-season — neutral info */
.peak-banner-info {
  background: var(--bg2);
  border-color: var(--border);
  color: var(--text-muted);
}

/* Winter law — amber */
.peak-banner-winter {
  background: #fff4dc;
  border-color: #d8a040;
  color: #6b4a10;
}
[data-theme="dark"] .peak-banner-winter {
  background: #2a2010;
  border-color: #6a4810;
  color: #f0c060;
}

/* Seasonal closure — red */
.peak-banner-closure {
  background: #fbe0e0;
  border-color: #c84030;
  color: #802020;
}
[data-theme="dark"] .peak-banner-closure {
  background: #3a1a1a;
  border-color: #803030;
  color: #f0a0a0;
}

/* ── Emergency SOS ───────────────────────── */
.sos-fab {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #d32020;
  color: #fff;
  border: 3px solid #fff;
  font-size: calc(13px * var(--text-scale));
  font-weight: 900;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0,0,0,0.55);
  z-index: 800;
  animation: sos-pulse 3.2s ease-in-out infinite;
  transition: transform 0.12s ease;
}
.sos-fab:active { transform: scale(0.92); }
@keyframes sos-pulse {
  0%, 100% { box-shadow: 0 3px 12px rgba(0,0,0,0.55), 0 0 0 0 rgba(211, 32, 32, 0.4); }
  50%      { box-shadow: 0 3px 12px rgba(0,0,0,0.55), 0 0 0 12px rgba(211, 32, 32, 0); }
}
.sos-fab:active { transform: scale(0.92); }

#sos-overlay {
  position: fixed;
  inset: 0;
  /* Structured dark gradient with a faint red top-glow — calmer than flat black */
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(211,32,32,0.18), transparent 60%),
    linear-gradient(180deg, #16110f 0%, #0a0a0c 100%);
  color: #fff;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
#sos-overlay.hidden { display: none; }

#sos-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  font-size: calc(22px * var(--text-scale));
  cursor: pointer;
}

.sos-content {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sos-title {
  font-size: calc(30px * var(--text-scale));
  font-weight: 900;
  color: #ff4242;
  letter-spacing: 1px;
  text-align: center;
  margin-top: 26px;
  text-shadow: 0 0 24px rgba(255,48,48,0.45);
}

.sos-subtitle {
  font-size: calc(14px * var(--text-scale));
  text-align: center;
  color: #b8b8b8;
  margin-top: -10px;
}

/* GPS status pill */
.sos-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
}
.sos-status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0; background: #888;
}
.sos-status[data-state="acquiring"] { color: #ffc14d; }
.sos-status[data-state="acquiring"] .sos-status-dot {
  background: #ffc14d; animation: sos-dot-pulse 1.1s ease-in-out infinite;
}
.sos-status[data-state="locked"] { color: #4ade80; }
.sos-status[data-state="locked"] .sos-status-dot {
  background: #4ade80; box-shadow: 0 0 8px rgba(74,222,128,0.7);
}
.sos-status[data-state="error"] { color: #ff7a7a; }
.sos-status[data-state="error"] .sos-status-dot { background: #ff5050; }
@keyframes sos-dot-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.sos-coords {
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(255,66,66,0.55);
  border-radius: 16px;
  padding: 18px;
  width: 100%;
  display: block;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.sos-coords:hover { border-color: rgba(255,66,66,0.85); }
.sos-coords:active { transform: scale(0.99); background: rgba(255,255,255,0.07); }

.sos-coords-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 0;
}

.sos-coords-label {
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  color: #888;
  letter-spacing: 1px;
}

.sos-coords-val {
  font-size: calc(32px * var(--text-scale));
  font-weight: 800;
  color: #fff;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  letter-spacing: 0.5px;
}

.sos-coords-accuracy {
  text-align: center;
  font-size: calc(12px * var(--text-scale));
  color: #888;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid #333;
}

.sos-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sos-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 14px;
  text-align: center;
  font-size: calc(17px * var(--text-scale));
  font-weight: 800;
  text-decoration: none;
  border: none;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  transition: transform 0.1s, filter 0.15s;
}
.sos-btn:active { transform: scale(0.98); filter: brightness(0.9); }
.sos-btn-main { font-size: calc(17px * var(--text-scale)); font-weight: 800; }
.sos-btn-sub  { font-size: calc(11.5px * var(--text-scale)); font-weight: 500; opacity: 0.82; letter-spacing: 0.2px; }

/* Primary calls get a subtle gradient for depth */
.sos-btn-call    { background: linear-gradient(180deg, #2fa02f, #228222); }
.sos-btn-911     { background: linear-gradient(180deg, #e23636, #c01818); }

/* Secondary utilities sit side-by-side */
.sos-actions-row { display: flex; gap: 10px; }
.sos-actions-row .sos-btn { flex: 1; font-size: calc(15px * var(--text-scale)); padding: 13px; box-shadow: none; }
.sos-btn-copy    { background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.16); }
.sos-btn-refresh { background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.16); }

.sos-info {
  background: #1a1a1a;
  border-radius: 10px;
  padding: 14px;
  font-size: calc(13px * var(--text-scale));
  line-height: 1.6;
  color: #ccc;
  border-left: 4px solid #ff3030;
}

/* ── Fire Tower rules banner (top of towers list) ─ */
.ft-rules-banner {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  color: var(--text);
  gap: 8px;
  text-align: center;
  flex-wrap: wrap;
}
.ft-rules-banner strong { font-size: calc(14px * var(--text-scale)); font-weight: 800; }

/* ── Range section headers (list By Range) ─ */
.range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  font-size: calc(13px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.range-name  { font-weight: 700; color: var(--text); }
.range-count { font-weight: 700; color: var(--accent); font-size: calc(12px * var(--text-scale)); }

/* ── Submission modal ────────────────────── */
.sub-hiker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

.sub-hiker-label {
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.sub-hiker-select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: calc(14px * var(--text-scale));
  font-weight: 600;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}
.sub-hiker-select:focus { border-color: var(--accent); }


.sub-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.sub-stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.sub-stat-num {
  font-size: calc(26px * var(--text-scale));
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.sub-stat-lbl {
  font-size: calc(11px * var(--text-scale));
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.sub-first-last {
  font-size: calc(12px * var(--text-scale));
  color: var(--text-muted);
  padding: 4px 0;
}
.sub-first-last strong { color: var(--text); }

.sub-ready {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 10px;
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  text-align: center;
  margin-top: 8px;
}

.sub-progress-note {
  background: var(--bg2);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 8px;
  font-size: calc(12px * var(--text-scale));
  text-align: center;
  margin-top: 6px;
}

.sub-tabs {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  border-bottom: 1px solid var(--border);
}

.sub-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  font-size: calc(13px * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.sub-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.sub-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: calc(11px * var(--text-scale));
  line-height: 1.5;
  max-height: 280px;
  overflow: auto;
  white-space: pre;
  color: var(--text);
  margin: 0;
}

/* ── Global error toast (top of screen) ──── */
.global-error-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-200%);
  background: #c0392b;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: calc(13px * var(--text-scale));
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 4000;
  max-width: 90vw;
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.25s;
  pointer-events: none;
}
.global-error-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
/* Success variant — green instead of error red */
.global-error-toast.toast-success {
  background: #2c7a44;
}

/* ── Empty state ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: calc(14px * var(--text-scale));
}

/* ─────────────────────────────────────────────────────────────────────────────
   Reduced-motion: honor the OS "reduce motion" accessibility setting.
   Near-instantly collapses animations/transitions instead of removing them
   entirely (keeps focus/scroll behavior intact). Recommended by WCAG 2.3.3
   and a Google Play / iOS accessibility quality signal.
   ───────────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Keyboard focus rings — visible only for keyboard navigation (:focus-visible),
   never on mouse/touch. Improves accessibility without affecting pointer users.
   ───────────────────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Buttons/links already rounded — keep the ring snug to their shape */
button:focus-visible,
a:focus-visible,
.tab:focus-visible,
.chip:focus-visible,
.btn:focus-visible,
.layer-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
/* Remove the default ring for pointer users (focus, not focus-visible) */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   First-launch onboarding overlay
   ───────────────────────────────────────────────────────────────────────── */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(10, 24, 16, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  animation: fade-in 0.3s ease;
}
.onboarding-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 18px;
  max-width: 420px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
  animation: slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.onboarding-icon { width: 76px; height: 76px; margin: 0 auto 8px; display: block; }
.onboarding-title { margin: 4px 0 6px; font-size: calc(22px * var(--text-scale)); color: var(--accent); }
.onboarding-sub { margin: 0 0 20px; color: var(--text-muted); font-size: calc(14px * var(--text-scale)); line-height: 1.5; }
.onboarding-list { list-style: none; padding: 0; margin: 0 0 22px; text-align: left; }
.onboarding-list li {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: calc(14px * var(--text-scale)); line-height: 1.45;
}
.onboarding-list li:last-child { border-bottom: none; }
.ob-ico { flex-shrink: 0; width: 28px; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.ob-ico svg { width: calc(22px * var(--text-scale)); height: calc(22px * var(--text-scale)); }
.onboarding-cta { width: 100%; padding: 13px; font-size: calc(15px * var(--text-scale)); font-weight: 700; border-radius: 10px; }
.onboarding-link {
  display: block; width: 100%; margin-top: 10px;
  background: none; border: none; color: var(--text-muted);
  font-size: calc(13px * var(--text-scale)); cursor: pointer; text-decoration: underline; font-family: inherit;
}
.onboarding-link:hover { color: var(--accent); }

/* ─────────────────────────────────────────────────────────────────────────────
   Photo timeline / memories
   ───────────────────────────────────────────────────────────────────────── */
.photo-memories-card { cursor: pointer; transition: background 0.15s; }
.photo-memories-card:hover { background: var(--bg2); }

.pt-sheet { max-height: 88vh; display: flex; flex-direction: column; }
.photo-timeline-grid {
  overflow-y: auto;
  padding: 4px 16px 24px;
  -webkit-overflow-scrolling: touch;
}
.pt-loading, .pt-empty {
  text-align: center; color: var(--text-muted);
  padding: 40px 20px; font-size: calc(14px * var(--text-scale));
}
.pt-month { margin-top: 18px; }
.pt-month-label {
  font-size: calc(14px * var(--text-scale)); font-weight: 700; color: var(--accent);
  margin: 0 0 10px; position: sticky; top: 0;
  background: var(--surface); padding: 6px 0; z-index: 1;
}
.pt-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.pt-thumb {
  position: relative; aspect-ratio: 1; border: none; padding: 0;
  border-radius: 10px; overflow: hidden; cursor: pointer;
  background: var(--bg2); display: block;
}
.pt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pt-thumb .pt-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.78));
  color: #fff; font-size: calc(10.5px * var(--text-scale)); font-weight: 600;
  padding: 14px 6px 5px; text-align: left; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pt-missing {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; font-size: calc(10px * var(--text-scale)); color: var(--text-muted);
  text-align: center;
}

/* ─────────────────────────────────────────────────────────────────────────────
   The Grid (552 challenge) matrix
   ───────────────────────────────────────────────────────────────────────── */
.grid-card { cursor: pointer; transition: background 0.15s; }
.grid-card:hover { background: var(--bg2); }

.grid-sheet { max-height: 90vh; display: flex; flex-direction: column; }
.grid-intro {
  font-size: calc(12.5px * var(--text-scale)); color: var(--text-muted); line-height: 1.45;
  margin: 0 16px 10px; flex-shrink: 0;
}
.grid-modal-body {
  overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 0 12px 20px;
}
.grid-table {
  border-collapse: collapse;
  font-size: calc(11px * var(--text-scale));
  width: 100%;
  /* Keep month cells tappable on narrow phones — scroll horizontally
     inside .grid-modal-body rather than squishing 12 columns to fit. */
  min-width: 380px;
}
.grid-table th, .grid-table td { text-align: center; padding: 0; }
.grid-peak-head, .grid-peak-name {
  text-align: left !important;
  position: sticky; left: 0; z-index: 2;
  background: var(--surface);
  padding: 4px 8px 4px 2px !important;
  white-space: nowrap;
  font-weight: 600;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis;
}
.grid-mo-head, .grid-tot-head {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface);
  color: var(--text-muted); font-weight: 700;
  width: 20px; height: 26px;
}
.grid-cell {
  width: 20px; height: 22px;
  border: 1px solid var(--border);
  color: transparent;
  font-size: calc(9px * var(--text-scale));
}
.grid-cell.on {
  background: #7a4d8e; color: #fff;
  border-color: #7a4d8e;
}
.grid-peak-tot, .grid-mo-tot { font-weight: 700; color: var(--accent); width: 24px; }
.grid-row-complete .grid-peak-name { color: #7a4d8e; }
.grid-row-complete .grid-peak-tot { color: #7a4d8e; }
.grid-foot td {
  border-top: 2px solid var(--border);
  font-weight: 700; color: var(--text-muted);
  padding-top: 4px !important; font-size: calc(10px * var(--text-scale));
}
.grid-foot td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }

/* ─────────────────────────────────────────────────────────────────────────────
   Stats hero — circular progress rings
   ───────────────────────────────────────────────────────────────────────── */
.rings-hero {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  padding: 18px 12px;
}
.ring {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.ring-svg { width: 84px; height: 84px; display: block; }
.ring-track { stroke: var(--border); opacity: 0.45; }
.ring-fill {
  transition: stroke-dasharray 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-center {
  position: absolute;
  top: 42px;                 /* center of the 84px ring */
  left: 0; right: 0;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.ring-num {
  font-size: calc(22px * var(--text-scale));
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ring-den {
  font-size: calc(11px * var(--text-scale));
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ring-label {
  margin-top: 6px;
  font-size: calc(11px * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Tactile press feedback — tappable surfaces "give" slightly when pressed.
   (Respects prefers-reduced-motion via the global rule.)
   ───────────────────────────────────────────────────────────────────────── */
.grid-card:active,
.photo-memories-card:active,
.stat-card[role="button"]:active,
.peak-item:active,
.year-row:active,
.hiker-roster-item:active { transform: scale(0.985); }
.btn:active,
.filter-chip:active,
.type-btn:active,
.layer-btn:active,
.theme-btn:active,
.text-size-btn:active { transform: scale(0.95); }
.grid-card, .photo-memories-card, .peak-item, .btn,
.filter-chip, .type-btn, .layer-btn {
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Skeleton shimmer — modern loading placeholder (replaces spinners)
   ───────────────────────────────────────────────────────────────────────── */
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton {
  background: linear-gradient(90deg,
    var(--bg2) 25%, var(--surface) 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 8px;
}
.weather-skeleton { padding: 4px 0 2px; }
.weather-skeleton .sk-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.weather-skeleton .sk-circle { width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0; }
.weather-skeleton .sk-lines { flex: 1; }
.weather-skeleton .sk-line { height: 12px; margin-bottom: 7px; }
.weather-skeleton .sk-line.w70 { width: 70%; }
.weather-skeleton .sk-line.w45 { width: 45%; }
.weather-skeleton .sk-days { display: flex; gap: 6px; }
.weather-skeleton .sk-day { flex: 1; height: 64px; border-radius: 10px; }

/* ─────────────────────────────────────────────────────────────────────────────
   Empty states — faint brand mark above the message so it feels designed
   ───────────────────────────────────────────────────────────────────────── */
.empty-state, .pt-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: calc(14px * var(--text-scale));
  line-height: 1.5;
  padding: 48px 28px;
}
.empty-state::before, .pt-empty::before {
  content: "";
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  background: url('../icon.svg') no-repeat center / contain;
  opacity: 0.22;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Tabular figures everywhere numbers are compared/stacked — keeps columns aligned
   ───────────────────────────────────────────────────────────────────────── */
.stat-value, .stat-detail, .progress-cell-val, .year-count,
.ring-num, .ring-den, .grid-peak-tot, .grid-mo-tot {
  font-variant-numeric: tabular-nums;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Inline SVG chrome icons — sized in em so they scale with the text-size setting,
   inherit color via currentColor, and align with their labels.
   ───────────────────────────────────────────────────────────────────────── */
.tab-ico {
  width: 1.25em; height: 1.25em;
  vertical-align: -0.18em;
  margin-right: 5px;
}
.cell-ico {
  width: 1.05em; height: 1.05em;
  vertical-align: -0.15em;
}
.sos-ico {
  width: 1.05em; height: 1.05em;
  vertical-align: -0.14em;
  margin-right: 4px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Weather — planning extras (precip, freezing level) + climb profile
   ───────────────────────────────────────────────────────────────────────── */
.weather-extra.we-alert { color: #d35400; font-weight: 700; }
.weather-extra.we-alert .we-lbl { color: #d35400; opacity: 0.8; }

.weather-plan {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  font-size: calc(12.5px * var(--text-scale)); color: var(--text-muted);
  padding: 8px 2px 2px;
}
.weather-plan-warn { color: #2a6cb0; font-weight: 600; }
[data-theme="dark"] .weather-plan-warn,
[data-theme="oled"] .weather-plan-warn { color: #7fb3e8; }

.weather-day-rain.high { color: #2a6cb0; font-weight: 700; }
[data-theme="dark"] .weather-day-rain.high,
[data-theme="oled"] .weather-day-rain.high { color: #7fb3e8; }

/* Trip planning card (avg grade + est. calories) */
.trip-plan {
  display: flex;
  gap: 10px;
  margin: 10px 0 4px;
}
.trip-plan-stat {
  flex: 1;
  background: var(--bg2);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}
.trip-plan-stat .tp-val {
  font-size: calc(22px * var(--text-scale)); font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.trip-plan-stat .tp-lbl {
  font-size: calc(11px * var(--text-scale)); text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-top: 3px;
}
.trip-plan-stat .tp-sub { font-size: calc(11px * var(--text-scale)); color: var(--text-muted); opacity: 0.85; margin-top: 1px; }

/* ── Custom date picker popover ───────────────────────────────────────── */
input.has-cal { cursor: pointer; }
.cal-pop {
  position: fixed; z-index: 1300; visibility: hidden;
  width: 280px; max-width: calc(100vw - 16px);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg, 14px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.28);
  padding: 10px; opacity: 0; transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.cal-pop.show { visibility: visible; opacity: 1; transform: translateY(0); }
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: 8px;
}
.cal-title {
  flex: 1; background: transparent; border: none; cursor: pointer;
  font-size: calc(15px * var(--text-scale)); font-weight: 700; color: var(--text);
  padding: 8px 6px; border-radius: 8px; text-align: center;
}
.cal-title:hover { background: var(--bg2); }
.cal-nav {
  width: 36px; height: 36px; flex: 0 0 auto;
  background: transparent; border: none; cursor: pointer;
  font-size: calc(22px * var(--text-scale)); line-height: 1; color: var(--text-muted);
  border-radius: 8px;
}
.cal-nav:hover { background: var(--bg2); color: var(--text); }
.cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px;
}
.cal-dow span {
  text-align: center; font-size: calc(11px * var(--text-scale));
  font-weight: 600; color: var(--text-muted); padding: 4px 0;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer; color: var(--text);
  font-size: calc(14px * var(--text-scale)); border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.cal-day:hover:not(.muted) { background: var(--bg2); }
.cal-day.muted { cursor: default; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent, #3a6231); font-weight: 700; }
.cal-day.sel { background: var(--accent, #3a6231); color: #fff; font-weight: 700; }
.cal-day.sel:hover { background: var(--accent, #3a6231); }
.cal-months, .cal-years { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cal-month, .cal-year {
  padding: 12px 4px; background: var(--bg2); border: none; cursor: pointer;
  color: var(--text); font-size: calc(14px * var(--text-scale)); border-radius: 8px;
}
.cal-month:hover, .cal-year:hover { background: var(--border); }
.cal-month.today, .cal-year.today { box-shadow: inset 0 0 0 1.5px var(--accent, #3a6231); font-weight: 700; }
.cal-month.sel, .cal-year.sel { background: var(--accent, #3a6231); color: #fff; font-weight: 700; }
.cal-foot {
  display: flex; gap: 8px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.cal-today-btn, .cal-clear-btn {
  flex: 1; padding: 8px; background: var(--bg2); border: none; cursor: pointer;
  color: var(--text); font-size: calc(13px * var(--text-scale)); font-weight: 600;
  border-radius: 8px;
}
.cal-today-btn:hover, .cal-clear-btn:hover { background: var(--border); }
.cal-clear-btn { color: var(--danger, #c0392b); }
