:root {
  /* PeakTrace brand palette (mirrors lib/core/theme/app_colors.dart) */
  --sage: #8EAFB4;
  --gray-teal: #748D92;
  --slate: #445F67;
  --petrol: #2A4550;
  --charcoal: #1D2B31;

  /* Default theme = dark, like the app */
  --bg: var(--charcoal);
  --surface: #243137;
  --border: #344148;
  --text: #E8ECF1;
  --text-dim: #A2B0B7;
  --accent: var(--sage);
  --activity-from: var(--petrol);
  --activity-to: var(--charcoal);
  --error: #FF6B6B;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #F4F6F8;
    --surface: #FFFFFF;
    --border: #DDE3E8;
    --text: var(--charcoal);
    --text-dim: var(--slate);
    --accent: var(--petrol);
    --error: #D63030;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.45;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 0 32px;
}

/* ── Status / error ── */
.status, .error {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-dim);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error h2 {
  color: var(--error);
  margin: 0 0 8px;
  font-size: 20px;
}

/* ── Map ── */
#map {
  height: 320px;
  background: var(--surface);
}

/* ── Activity gradient banner (mirrors _buildGradientBanner) ── */
.banner {
  background: linear-gradient(135deg, var(--activity-from) 0%, var(--activity-to) 100%);
  padding: 20px;
  color: #fff;
}

.activity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.activity-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-icon-wrap .material-icons {
  font-size: 18px;
  color: #fff;
}

.activity-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.track-name-row h1 {
  margin: 8px 0 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
}

.track-date {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 16px;
}

/* ── Stats grid (matches app _StatTile in gradient banner) ── */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 64px;
}

.stat-value {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 17px; }
}

/* ── CTA card ── */
.cta {
  margin: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.cta-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.cta-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.cta-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.cta-sub {
  font-size: 13px;
  color: var(--text-dim);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: opacity 0.15s, transform 0.1s;
  cursor: pointer;
  border: 0;
}

.btn:active { transform: scale(0.97); }
.btn:hover { opacity: 0.9; }

.btn-primary {
  background: var(--accent);
  color: var(--charcoal);
  width: 100%;
  font-size: 16px;
  margin-bottom: 12px;
}

.btn-primary .material-icons {
  font-size: 20px;
}

.store-buttons {
  display: flex;
  gap: 10px;
}

.btn-store {
  flex: 1;
  background: #000;
  color: #fff;
  padding: 10px 14px;
  font-weight: 500;
  gap: 10px;
  justify-content: flex-start;
}

.btn-store-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.btn-store-text span { font-size: 11px; opacity: 0.78; }
.btn-store-text strong { font-size: 15px; font-weight: 600; margin-top: 2px; }

@media (prefers-color-scheme: light) {
  .btn-primary { color: #fff; background: var(--petrol); }
}

/* ── Footer ── */
footer {
  margin-top: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 16px;
}

footer a {
  color: var(--text-dim);
  text-decoration: none;
}

footer a:hover { color: var(--text); }

/* ── Leaflet attribution dark theme ── */
.leaflet-container { background: var(--surface) !important; }
.leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.55) !important;
  color: rgba(255, 255, 255, 0.78) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--sage) !important; }
@media (prefers-color-scheme: light) {
  .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.85) !important;
    color: var(--slate) !important;
  }
  .leaflet-control-attribution a { color: var(--petrol) !important; }
}
