/* ── 1. Reset + Tokens ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f4f2ec;
  --bg-deep:     #e8e5dd;
  --surface:     #ffffff;
  --ink:         #0a0a0a;
  --ink-2:       #2a2a2a;
  --muted:       #7a7772;
  --dim:         #b8b5af;
  --line:        #dfdcd3;
  --line-soft:   #ebe8df;
  --accent:      #f5e642;
  --accent-deep: #e6d82e;
  --accent-ink:  #0a0a0a;
  --strava:      #fc4c02;
  --font:        'Space Grotesk', system-ui, sans-serif;
  --mono:        'Space Mono', ui-monospace, monospace;
  --r-pill:      999px;
  --r-panel:     16px;
  --r-card:      10px;
  --r-input:     8px;
  --r-poster:    6px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}


/* ── 2. Screen layout ────────────────────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.screen[hidden] { display: none !important; }


/* ── 3. Top bar ──────────────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  flex-shrink: 0;
  gap: 12px;
}

/* Logo */
.logo-mark {
  display: flex;
  align-items: baseline;
  text-decoration: none;
  letter-spacing: -0.04em;
  user-select: none;
  gap: 0;
}
.logo-mara { font-size: 18px; font-weight: 800; color: var(--ink); font-family: var(--font); }
.logo-maps { font-size: 18px; font-weight: 400; color: var(--ink); font-family: var(--font); font-style: italic; }

/* Editor filename info */
.editor-file-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 8px;
  min-width: 0;
  overflow: hidden;
}
.editor-filename {
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dot { color: var(--dim); }

/* Icon button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 6px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--ink); background: var(--line-soft); }

/* Link button (inline text) */
.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { color: var(--ink); }


/* ── 4. Landing screen ───────────────────────────────────────────────────────── */
.screen-landing {
  background: var(--bg);
}

.landing-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 80px;
  padding: 40px 48px 60px;
  overflow: hidden;
}

.landing-copy {
  flex: 0 0 auto;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.landing-hero {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}
.hero-bold   { font-weight: 800; color: var(--ink); }
.hero-italic { font-weight: 400; font-style: italic; color: var(--ink); }

.landing-sub {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 28px;
}

/* Strava CTA */
.btn-strava {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--strava);
  color: #fff;
  border: none;
  border-radius: var(--r-pill);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
  margin-bottom: 10px;
  width: 100%;
  justify-content: center;
}
.btn-strava:hover { opacity: 0.9; }
.btn-strava:disabled {
  background: var(--dim);
  color: var(--muted);
  cursor: default;
  opacity: 1;
}
.btn-strava .chevron { margin-left: auto; }

/* Upload zone */
.upload-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-input);
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 12px;
}
.upload-zone:hover { border-color: var(--ink); background: var(--line-soft); }
.upload-zone.drag-over { border-color: var(--ink); background: var(--line-soft); }

.sample-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0;
}
.sample-link:hover { color: var(--ink); }

/* Poster stack */
.landing-poster-stack {
  flex: 0 0 auto;
  position: relative;
  width: 260px;
  height: 364px;
}

.sample-card {
  position: absolute;
  border-radius: var(--r-poster);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(26,24,20,0.18);
}
.sample-card svg { display: block; width: 100%; height: 100%; }

.sample-card--back {
  width: 220px;
  height: 308px;
  top: 20px;
  right: 0;
  transform: rotate(4deg);
  z-index: 1;
}
.sample-card--front {
  width: 230px;
  height: 322px;
  top: 0;
  left: 0;
  z-index: 2;
  transform: rotate(-2deg);
}


/* ── 5. Editor screen ────────────────────────────────────────────────────────── */
.screen-editor {
  background: var(--bg);
}

.screen-editor .top-bar {
  padding: 18px 28px;
}

.editor-main {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 40px 120px;
  overflow: hidden;
}


/* ── 6. Poster area ──────────────────────────────────────────────────────────── */
.poster-wrap {
  width: min(420px, 42vw);
  aspect-ratio: 1 / 1.4;
  max-height: 78vh;
  flex-shrink: 0;
}

.poster {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-poster);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(26,24,20,0.2);
  background: var(--surface);
  position: relative; /* positioning context for logo-overlay, routeCanvas, bg-photo-layer */
}

#map {
  flex: 1;
  min-height: 0;
  position: relative;
}

/* keep canvas overlay filling the map area */
#routeCanvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
#routeCanvas[hidden] { display: none; }

.bg-photo-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  pointer-events: none;
}

.logo-overlay {
  position: absolute;
  z-index: 15;
  cursor: move;
  user-select: none;
}
.logo-overlay[hidden] { display: none; }

.logo-resize-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  cursor: se-resize;
}


/* ── 7. Poster ribbon strip ──────────────────────────────────────────────────── */
.poster-ribbon {
  --ribbon-scale: 1;
  flex-shrink: 0;
  padding: 18px 22px 22px;
  background: var(--surface);
  color: var(--ink);
  transition: background 0.2s, color 0.2s;
}
.poster-ribbon.dark {
  background: var(--ink);
  color: #fff;
}

.poster-ribbon-title {
  font-size: calc(22px * var(--ribbon-scale));
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: var(--font);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poster-ribbon-sub {
  font-size: calc(10px * var(--ribbon-scale));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
.poster-ribbon.dark .poster-ribbon-sub { color: rgba(255,255,255,0.55); }
.poster-ribbon-sub[hidden] { display: none; }

.poster-ribbon-stats {
  display: flex;
  gap: 18px;
  margin-top: 14px;
  font-family: var(--mono);
}

.stat-item { display: flex; flex-direction: column; }
.stat-item[hidden] { display: none !important; }

/* Vertical separator between visible stat items */
.stat-item + .stat-item:not([hidden]) {
  border-left: 1px solid var(--line);
  padding-left: 18px;
  margin-left: 0;
}
.poster-ribbon.dark .stat-item + .stat-item:not([hidden]) {
  border-color: rgba(255,255,255,0.15);
}

.stat-value {
  font-size: calc(18px * var(--ribbon-scale));
  font-weight: 700;
  line-height: 1;
}
.stat-key {
  font-size: calc(9px * var(--ribbon-scale));
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
.poster-ribbon.dark .stat-key { color: rgba(255,255,255,0.5); }


/* ── 8. Floating action bar ──────────────────────────────────────────────────── */
.action-bar-wrap {
  position: fixed;
  bottom: 28px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 30;
}

.action-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border-radius: var(--r-pill);
  padding: 5px;
  box-shadow: 0 8px 32px rgba(26,24,20,0.14), 0 2px 6px rgba(26,24,20,0.08);
  border: 1px solid var(--line);
  pointer-events: auto;
}

.tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--ink-2);
  border: none;
  border-radius: var(--r-pill);
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tab-pill:hover { background: var(--line-soft); }
.tab-pill[aria-pressed="true"],
.tab-pill.active {
  background: var(--ink);
  color: #fff;
}

.tab-pill--accent {
  background: var(--accent);
  color: var(--accent-ink);
}
.tab-pill--accent:hover { background: var(--accent-deep); }
.tab-pill--accent[aria-pressed="true"],
.tab-pill--accent.active {
  background: var(--accent-deep);
  color: var(--accent-ink);
}

.action-bar-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 3px;
  flex-shrink: 0;
}


/* ── 9. Panel (desktop side panel + mobile bottom sheet) ─────────────────────── */
.panel {
  position: fixed;   /* fixed = viewport-relative; immune to parent overflow:hidden */
  z-index: 50;
}
.panel[hidden] { display: none !important; }

/* Desktop: right-docked panel */
@media (min-width: 780px) {
  .panel {
    right: 28px;
    top: calc(var(--topbar-h, 64px) + 16px);
    bottom: 110px;
    width: 360px;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 10px 40px rgba(26,24,20,0.12);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInRight 0.22s cubic-bezier(.2,.8,.2,1);
  }
  .panel[hidden] { display: none !important; }
  .sheet-handle  { display: none; }
  .panel-done    { display: none; }
  .panel-close   { display: flex; }
}

/* Mobile: bottom sheet */
@media (max-width: 779px) {
  .panel {
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: var(--panel-h, 82svh);
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 40px rgba(26,24,20,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.24s cubic-bezier(.2,.8,.2,1);
  }
  .panel[hidden] { display: none !important; }
  .panel-close   { display: none !important; }
  .panel-done    { display: flex !important; }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  align-self: center;
  flex-shrink: 0;
  margin: 10px 0 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px 10px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-done {
  display: none;
  align-items: center;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--r-pill);
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.panel-section { }
.panel-section[hidden] { display: none !important; }

.panel-section-inner {
  padding: 18px 22px 40px;
  display: block;
}


/* ── 10. Scrim ───────────────────────────────────────────────────────────────── */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(26,24,20,0.35);
  z-index: 40;
  animation: fadeIn 0.2s;
}
.scrim[hidden] { display: none !important; }


/* ── 11. Panel content — shared primitives ───────────────────────────────────── */

/* Section label */
.sec-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* Text input */
.text-input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-input);
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.text-input:focus { border-color: var(--ink); }
.text-input::placeholder { color: var(--dim); }

/* Segment group (line / ribbon-bg) */
.seg-group {
  display: flex;
  gap: 6px;
}
.seg-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: var(--r-input);
  border: none;
  background: var(--line-soft);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-transform: capitalize;
}
.seg-btn:hover { background: var(--line); }
.seg-btn.active {
  background: var(--ink);
  color: #fff;
}

/* Chip row (charities) */
.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  background: var(--surface);
  color: var(--ink-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--ink); }
.chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}


/* ── 11a. Style panel ────────────────────────────────────────────────────────── */

/* Map style grid */
.mapstyle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mapstyle-tile {
  background: none;
  border: 2px solid transparent;
  border-radius: var(--r-card);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: center;
  transition: border-color 0.15s;
}
.mapstyle-tile.active { border-color: var(--ink); }
.mapstyle-tile:hover:not(.active) { border-color: var(--line); }

.tile-preview {
  height: 50px;
  overflow: hidden;
}
.tile-preview svg {
  width: 100%;
  height: 100%;
  display: block;
}

.tile-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 0 5px;
  transition: color 0.15s;
}
.mapstyle-tile.active .tile-label { color: var(--ink); }

/* Route colour row */
.colour-row-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.colour-row {
  display: contents; /* its swatches participate in the wrapper's flex layout */
}

.colour-swatch,
.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px var(--line);
  transition: box-shadow 0.15s;
}
.colour-swatch.active,
.color-swatch.active {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}
.swatch-white { box-shadow: 0 0 0 1.5px var(--line); }

.swatch-custom {
  background: conic-gradient(from 0deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.swatch-custom svg { color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
.swatch-custom input[type="color"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}


/* ── Size grid (in Style panel) ──────────────────────────────────────────────── */
.size-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.size-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.size-btn:hover:not(:disabled) { border-color: var(--ink-2); }
.size-btn.active {
  border-color: var(--ink);
  background: var(--line-soft);
}
.size-btn:disabled { cursor: default; }

/* Tiny aspect-ratio icons */
.size-icon {
  background: var(--line);
  border-radius: 2px;
  transition: background 0.15s;
}
.size-btn.active .size-icon { background: var(--ink); }
.size-icon--sq    { width: 18px; height: 18px; }
.size-icon--story { width: 11px; height: 20px; }
.size-icon--land  { width: 22px; height: 16px; }

.size-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: center;
  line-height: 1.2;
}
.size-dim {
  font-size: 9px;
  color: var(--muted);
  font-family: var(--mono);
  text-align: center;
}

/* ── 11b. Brand panel ────────────────────────────────────────────────────────── */

.logo-upload-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-input);
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.logo-upload-btn:hover { border-color: var(--ink); background: var(--line-soft); }
.logo-upload-hint { margin-left: auto; font-size: 11px; color: var(--dim); }

.logo-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.logo-preview-row[hidden] { display: none; }
.logo-preview-thumb {
  height: 36px;
  width: auto;
  max-width: 120px;
  border-radius: 4px;
  object-fit: contain;
  border: 1px solid var(--line);
  padding: 3px;
  background: var(--surface);
}


/* ── 11c. Stats panel ────────────────────────────────────────────────────────── */

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line-soft);
  border-radius: var(--r-card);
  overflow: hidden;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  cursor: pointer;
}

.toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: var(--line);
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s;
}
/* checked state driven by sibling selector */
.toggle-track:has(input:checked) { background: var(--ink); }

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #fff;
  transition: left 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-track:has(input:checked) .toggle-knob { left: 18px; }

.toggle-info { flex: 1; }
.toggle-label { font-size: 13px; font-weight: 600; color: var(--ink); text-transform: capitalize; }
.toggle-sub   { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 1px; }

/* Range slider */
.range-slider {
  width: 100%;
  accent-color: var(--ink);
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 4px;
}


/* ── 11d. Export panel ───────────────────────────────────────────────────────── */

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-card);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.preset-card:hover:not(:disabled) { border-color: var(--ink-2); }
.preset-card.active {
  border-color: var(--ink);
  background: var(--line-soft);
}
.preset-card--locked {
  opacity: 0.55;
  cursor: default;
}

.preset-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.preset-card.active .preset-radio {
  background: var(--ink);
  border-color: var(--ink);
}

.preset-name { font-size: 13px; font-weight: 600; }
.preset-dim  { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 1px; }

.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--r-pill);
  padding: 14px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}
.btn-download:hover { background: var(--accent-deep); }

.export-privacy {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}


/* ── 12. Settings modal ──────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none !important; }

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(26,24,20,0.45);
}

.modal-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--r-panel);
  padding: 24px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.token-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-sm-ink {
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--r-pill);
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-sm-ink:hover { opacity: 0.8; }

.token-stored {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.token-stored[hidden] { display: none; }

.token-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
}
.token-hint-link { color: var(--ink); text-decoration: underline; }

.privacy-card {
  padding: 14px;
  background: var(--line-soft);
  border-radius: var(--r-card);
}
.privacy-title { font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.privacy-body  { font-size: 12px; color: var(--muted); line-height: 1.5; }


/* ── 13. Loading overlay + Toast ─────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,24,20,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-overlay[hidden] { display: none !important; }

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-msg {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  z-index: 150;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  pointer-events: none;
  white-space: nowrap;
}
.toast[hidden] { display: none; }


/* ── 14. Animations ──────────────────────────────────────────────────────────── */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ── 15. Mobile breakpoint ───────────────────────────────────────────────────── */
@media (max-width: 779px) {

  .top-bar {
    padding: 14px 16px 8px;
  }

  .editor-main {
    padding: 4px 16px 120px;
    align-items: flex-start;
    padding-top: 16px;
  }

  .poster-wrap {
    width: min(92%, 360px);
    max-height: 72vh;
    margin: 0 auto;
  }

  .poster-ribbon-title { font-size: calc(14px * var(--ribbon-scale)); }
  .poster-ribbon { padding: 10px 14px 12px; }
  .poster-ribbon-stats { gap: 10px; margin-top: 8px; }
  .stat-value { font-size: calc(12px * var(--ribbon-scale)); }
  .stat-key   { font-size: calc(7px  * var(--ribbon-scale)); }

  .action-bar-wrap { bottom: 20px; }
  .tab-pill { padding: 8px 12px; font-size: 12px; }

  .landing-main {
    flex-direction: column;
    padding: 24px 24px 48px;
    gap: 40px;
    align-items: flex-start;
    overflow-y: auto;
  }

  .landing-hero { font-size: clamp(30px, 8vw, 44px); }

  .landing-poster-stack {
    width: 200px;
    height: 280px;
    align-self: center;
  }

  .sample-card--back  { width: 170px; height: 238px; }
  .sample-card--front { width: 176px; height: 246px; }

  .editor-file-info { display: none; }
}


/* ── Scrollbar styling ───────────────────────────────────────────────────────── */
*::-webkit-scrollbar        { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb  { background: var(--line); border-radius: 4px; }
*::-webkit-scrollbar-track  { background: transparent; }


/* ── Mapbox GL overrides ──────────────────────────────────────────────────────── */
.mapboxgl-ctrl-logo,
.mapboxgl-ctrl-attrib { display: none !important; }


/* ── Strava connected state ───────────────────────────────────────────────────── */
.strava-connected-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  width: 100%;
}
.strava-connected-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-deep);
  border-radius: var(--r-pill);
  padding: 4px 10px;
}
.btn-strava--pick {
  background: var(--strava);
  color: #fff;
  margin-bottom: 0;
  width: 100%;
  padding: 12px 20px;
  font-size: 14px;
  justify-content: center;
}
.btn-strava--pick .chevron { margin-left: auto; }
.strava-disconnect-btn {
  font-size: 11px;
  color: var(--muted);
}
.strava-disconnect-btn:hover { color: var(--ink); }


/* ── Strava activity picker modal ─────────────────────────────────────────────── */
.strava-modal-card {
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  width: min(480px, 92vw);
  padding: 0;
  overflow: hidden;
}
.strava-modal-card .modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.activity-list {
  overflow-y: auto;
  flex: 1;
}
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  transition: background 0.1s;
}
.activity-item:hover  { background: var(--bg-deep); }
.activity-item:last-child { border-bottom: none; }
.activity-strava-link {
  flex-shrink: 0;
  padding: 6px;
  color: var(--dim);
  border-radius: 6px;
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.activity-strava-link:hover { color: var(--strava); background: var(--bg); }
.activity-type-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}
.activity-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.activity-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}
.activity-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ── Landing legal link ──────────────────────────────────────────────────────── */
.landing-legal {
  margin-top: 16px;
  font-size: 11px;
  color: var(--dim);
}
.landing-legal a {
  color: var(--muted);
  text-decoration: none;
}
.landing-legal a:hover { text-decoration: underline; }

/* ── Beta badge ───────────────────────────────────────────────────────────────── */
.beta-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 4px;
  padding: 2px 5px;
  margin-left: 4px;
  font-family: var(--font);
  align-self: center;
}

/* ── Strava API credit (landing page) ────────────────────────────────────────── */
.strava-api-credit {
  margin: 8px 0 0;
}
.strava-api-credit a {
  display: inline-block;
  text-decoration: none;
  line-height: 0;
}
.strava-api-credit a:hover { opacity: 0.8; }
.strava-logo-badge {
  height: 18px;
  width: auto;
  display: block;
}

/* ── Strava credit in ribbon ─────────────────────────────────────────────────── */
.ribbon-strava-credit {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.ribbon-strava-credit:hover { opacity: 0.8; }
.strava-logo-img {
  height: calc(10px * var(--ribbon-scale));
  width: auto;
  display: block;
}
/* Light ribbon → orange logo; dark ribbon → white logo */
.poster-ribbon:not(.dark) .strava-logo--dark  { display: none; }
.poster-ribbon.dark       .strava-logo--light { display: none; }

/* ── Poster title link (active when Strava data loaded) ──────────────────────── */
.poster-ribbon-title-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

/* ── Panel privacy warning ───────────────────────────────────────────────────── */
.strava-privacy-warning {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 12px 16px 0;
  padding: 8px 12px;
  background: #fff8f0;
  border: 1px solid #fcd9b8;
  border-radius: var(--r-input);
  font-size: 11px;
  font-weight: 500;
  color: #7a4a1a;
  line-height: 1.4;
}
.strava-privacy-warning svg { flex-shrink: 0; color: #e07020; }
.strava-privacy-warning a { color: #e07020; font-weight: 600; text-underline-offset: 2px; white-space: nowrap; }
.strava-privacy-warning[hidden] { display: none !important; }
