/* ============================================================
   STRAVA BACKUP VIEWER — style.css
   ============================================================ */

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

/* ── Design tokens ────────────────────────────────────────── */
/*
   Nord Theme — IDE style
   Polar Night: #2e3440 #3b4252 #434c5e #4c566a
   Snow Storm:  #d8dee9 #e5e9f0 #eceff4
   Frost:       #8fbcbb #88c0d0 #81a1c1 #5e81ac
   Aurora:      #bf616a #d08770 #ebcb8b #a3be8c #b48ead
*/

/* LIGHT theme — chłodny, biuro-techniczny */
:root,
[data-theme="light"] {
  --bg:           #e5e9f0;   /* Snow Storm mid — chłodne tło */
  --bg2:          #eceff4;   /* Snow Storm bright — panele */
  --bg3:          #dde3ed;   /* uzupełnienie — hover */
  --bg4:          #d0d8e8;   /* uzupełnienie — aktywne */
  --border:       #c2ccdc;   /* uzupełnienie */
  --border2:      #a9b5cb;   /* uzupełnienie */
  --text:         #2e3440;   /* Polar Night 1 — główny tekst */
  --text2:        #434c5e;   /* Polar Night 3 — drugorzędny */
  --text3:        #8895aa;   /* uzupełnienie — placeholder */
  --accent:       #5e81ac;   /* Frost 4 — niebieski akcent */
  --accent2:      #81a1c1;   /* Frost 3 — hover */
  --accent-dim:   rgba(94,129,172,0.12);
  --accent-glow:  rgba(94,129,172,0.24);
  --yellow:       #8a6a00;
  --yellow-bg:    rgba(235,203,139,0.22);
  --yellow-border:rgba(235,203,139,0.55);
  --shadow-sm:    0 1px 2px rgba(46,52,64,0.12);
  --shadow-md:    0 4px 14px rgba(46,52,64,0.16);
}

/* DARK theme — głęboki Polar Night jak na screenshocie */
[data-theme="dark"] {
  --bg:           #242933;   /* ciemniejszy niż PN1 — tło aplikacji */
  --bg2:          #2e3440;   /* Polar Night 1 — panele/karty */
  --bg3:          #3b4252;   /* Polar Night 2 — hover, sidebar */
  --bg4:          #434c5e;   /* Polar Night 3 — aktywne elementy */
  --border:       #3b4252;   /* Polar Night 2 */
  --border2:      #4c566a;   /* Polar Night 4 */
  --text:         #eceff4;   /* Snow Storm bright */
  --text2:        #d8dee9;   /* Snow Storm dark */
  --text3:        #616e88;   /* uzupełnienie — wygaszone */
  --accent:       #88c0d0;   /* Frost 2 — główny akcent */
  --accent2:      #81a1c1;   /* Frost 3 — hover */
  --accent-dim:   rgba(136,192,208,0.12);
  --accent-glow:  rgba(136,192,208,0.22);
  --yellow:       #ebcb8b;   /* Aurora yellow */
  --yellow-bg:    rgba(235,203,139,0.10);
  --yellow-border:rgba(235,203,139,0.30);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.35);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.50);
}

/* ── Typography & base ────────────────────────────────────── */
:root {
  --sidebar-w:    340px;
  --header-h:     54px;
  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'Barlow', sans-serif;
  --radius:       8px;
  --radius-sm:    5px;
  --transition:   0.17s ease;
}

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

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar            { width: 5px; height: 5px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover{ background: var(--text3); }

/* ── App grid ─────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: var(--header-h) auto 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
#header {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.header-logo svg { width: 26px; height: 26px; }

.header-logo-svg {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.header-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--text);
  text-transform: uppercase;
  white-space: nowrap;
}
.header-title span { color: var(--accent); }

.header-sep {
  width: 1px;
  height: 26px;
  background: var(--border);
  flex-shrink: 0;
}

.header-search {
  flex: 1;
  max-width: 300px;
  position: relative;
}

.header-search input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px 6px 32px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.header-search input:focus { border-color: var(--border2); background: var(--bg2); }
.header-search input::placeholder { color: var(--text3); }

.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
}

/* Global stats (right side of header) */
.header-stats {
  display: flex;
  gap: 18px;
  margin-left: auto;
  align-items: center;
}

.hstat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.hstat-val {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.hstat-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Theme toggle button */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* Show sun icon in dark mode, moon in light mode */
[data-theme="light"] .icon-moon  { display: block; }
[data-theme="light"] .icon-sun   { display: none; }
[data-theme="dark"]  .icon-sun   { display: block; }
[data-theme="dark"]  .icon-moon  { display: none; }

/* ============================================================
   BACKUP BANNER
   ============================================================ */
#backup-banner {
  display: none;
  grid-column: 1 / -1;
  grid-row: 2;
  background: var(--yellow-bg);
  border-bottom: 1px solid var(--yellow-border);
  padding: 7px 18px;
  font-size: 12px;
  color: var(--yellow);
  align-items: center;
  gap: 8px;
}
#backup-banner.visible { display: flex; }

/* When banner is hidden, row 2 collapses to 0 */

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  grid-column: 1;
  grid-row: 3;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

/* Year tabs */
#year-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.year-tab {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
}
.year-tab:hover  { background: var(--bg3); color: var(--text); }
.year-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Year summary */
#year-summary {
  padding: 10px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.year-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.ystat {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 8px;
}
.ystat-val {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ystat-label {
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* Activity list */
#activity-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.activity-item:hover  { background: var(--bg3); }
.activity-item.active { background: var(--accent-dim); border-left-color: var(--accent); }

.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  margin-top: 1px;
}
.activity-item.active .activity-icon { background: var(--accent); border-color: var(--accent); }

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

.activity-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.activity-meta {
  display: flex;
  gap: 8px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.activity-meta-item {
  font-size: 11px;
  color: var(--text2);
}

.activity-date {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.empty-list {
  padding: 28px 16px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* Pending activity — greyed out, not clickable */
.activity-item.pending {
  opacity: 0.42;
  cursor: default;
  pointer-events: none;
}
.activity-item.pending:hover { background: transparent; }

.activity-pending-badge {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid var(--yellow-border);
  vertical-align: middle;
  margin-left: 4px;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Pending count in year summary */
.ystat-pending {
  font-size: 11px;
  color: var(--text3);
  font-weight: 400;
}

/* ============================================================
   MAIN PANEL
   ============================================================ */
#main {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Welcome */
#welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  color: var(--text3);
  text-align: center;
  padding: 40px;
}
#welcome-state svg { color: var(--border2); }
#welcome-state h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text2);
}
#welcome-state p  { font-size: 13px; max-width: 360px; color: var(--text2); }
#welcome-state code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  color: var(--accent);
}

#open-folder-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  padding: 12px 26px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: 0 4px 16px var(--accent-glow);
}
#open-folder-btn:hover  { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 6px 22px var(--accent-glow); }
#open-folder-btn:active { transform: none; }
#open-folder-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.folder-hint { font-size: 11px; color: var(--text3); margin-top: -6px; }

/* Activity detail */
#activity-detail {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
#activity-detail.visible { display: flex; }

/* ── Detail header ── */
.detail-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.detail-header-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-sport-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.detail-title-block { flex: 1; min-width: 0; }

.detail-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-subtitle {
  font-size: 12px;
  color: var(--text3);
  margin-top: 3px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.detail-subtitle-sep { color: var(--border2); }

.detail-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* Stats strip */
.stats-strip {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  padding: 8px 14px;
  border-right: 1px solid var(--border);
  min-width: 80px;
}
.stat-pill:last-child { border-right: none; }

.stat-val {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  color: var(--text);
}
.stat-unit {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  margin-left: 2px;
}
.stat-label {
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 2px;
}

/* ── Detail body — główny kontener pod headerem ── */
.detail-body {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}

/* Lewa kolumna — mapa + resizer + wykresy, elastyczna wysokość */
.detail-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Map */
#map-container {
  flex: 1;
  position: relative;
  min-height: 120px;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg3);
}

.map-no-gps {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 160px;
  gap: 8px;
  color: var(--text3);
  font-size: 13px;
}
.map-no-gps span { font-size: 28px; }

/* Resizer handle */
#chart-resizer {
  height: 6px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: ns-resize;
  flex-shrink: 0;
  z-index: 10;
}

/* Chart container */
#elevation-chart-container {
  background: var(--bg2);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 130px;
}

/* Gear bar — na dole lewej kolumny */
.detail-gear-bar {
  flex-shrink: 0;
  padding: 7px 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 12px;
  color: var(--text3);
}
.detail-gear-bar strong { color: var(--text2); font-weight: 500; }

/* Prawy panel — stała szerokość, niezależny scroll */
.detail-right {
  width: 300px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg2);
}

.chart-tabs {
  display: flex;
  gap: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.chart-tabs::-webkit-scrollbar { display: none; }

.chart-tabs-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  justify-content: space-between;
}

.chart-x-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.chart-x-btn {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition);
}
.chart-x-btn:hover  { color: var(--text2); }
.chart-x-btn.active { background: var(--bg4); color: var(--text); border-color: var(--border2); }

.chart-tab {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 6px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.chart-tab:hover  { color: var(--text2); }
.chart-tab.active { color: var(--text); border-bottom-color: var(--accent); }

#chart-canvas {
  width: 100%;
  height: 88px;
  display: block;
  flex: 1;
  cursor: crosshair;
}

.chart-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#chart-tooltip {
  position: absolute;
  top: 4px;
  left: 0;          /* pozycjonowany przez JS */
  width: 80px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 2px 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}
/* Niewidoczna polilinia do łapania zdarzeń myszy na trasie GPX */
.gpx-hit-line {
  stroke-opacity: 0 !important;
  cursor: crosshair;
}

#chart-tooltip.visible { opacity: 1; }

/* Right column */
.detail-right {
  grid-column: 2;
  grid-row: 1 / 3;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg2);
}

/* Sections inside right panel */
.detail-section {
  padding: 14px 14px 12px;
}

.detail-section-title {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.detail-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Extra stats grid */
.extra-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.extra-stat {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
}
.extra-stat-val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.1;
}
.extra-stat-label {
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1px;
}

/* Photos */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg3);
  border: 1px solid var(--border);
  transition: border-color var(--transition), transform var(--transition);
}
.photo-thumb:hover { border-color: var(--accent); transform: scale(1.02); }
.photo-thumb img  { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Comments */
.comment-item {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.comment-item:last-child { margin-bottom: 0; }

.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text3);
  overflow: hidden;
}
.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }

.comment-author { font-size: 12px; font-weight: 500; color: var(--text); }
.comment-text   { font-size: 12px; color: var(--text2); margin-top: 2px; line-height: 1.5; }
.comment-date   { font-size: 10px; color: var(--text3); margin-top: 2px; }

/* Gear/device bar */
.detail-gear-bar {
  grid-column: 1 / -1;
  padding: 9px 18px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 12px;
  color: var(--text3);
  flex-shrink: 0;
}
.detail-gear-bar strong { color: var(--text2); font-weight: 500; }

/* ============================================================
   LIGHTBOX
   ============================================================ */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
#lightbox.visible { display: flex; }

#lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: var(--radius);
  box-shadow: 0 20px 80px rgba(0,0,0,0.7);
}

#lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(28,25,23,0.7);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: background var(--transition);
}
#lightbox-close:hover { background: rgba(252,76,2,0.8); }

/* Prev / Next nav buttons */
#lightbox-prev,
#lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(28,25,23,0.65);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  transition: background var(--transition), transform var(--transition);
  z-index: 10001;
}
#lightbox-prev { left: 18px; }
#lightbox-next { right: 18px; }
#lightbox-prev:hover,
#lightbox-next:hover { background: rgba(252,76,2,0.75); transform: translateY(-50%) scale(1.08); }

/* Photo counter */
#lightbox-counter {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.45);
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(245,245,244,0.75);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(4px);
}
[data-theme="dark"] #loading-overlay {
  background: rgba(13,15,18,0.80);
}
#loading-overlay.visible { display: flex; }

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.loading-text {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text2);
}

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

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 960px) {
  :root { --sidebar-w: 280px; }
  .detail-body       { flex-direction: column; }
  .detail-right {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 340px;
    overflow-y: auto;
  }
  #map-container { min-height: 220px; }
  .year-summary-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  :root { --sidebar-w: 100vw; }
  #app { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  #main { grid-column: 1; }
  .header-stats { display: none; }
}
