* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; color: #1c2b2d; }

#topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding: 10px 16px;
  background: #123a63;
  color: white;
  min-height: 56px;
}
#topbar h1 { font-size: 16px; margin: 0; font-weight: 600; flex: 1 1 auto; min-width: 200px; }
.campus-tabs { display: flex; gap: 8px; }
.campus-tab {
  background: transparent;
  border: 2px solid #f6f4ee;
  color: #f6f4ee;
  padding: 7px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.campus-tab:hover { background: #f6f4ee; color: #12312b; }
.campus-tab.active { background: #ffd93d; border-color: #ffd93d; color: #12312b; }
.campus-tab.active:hover { background: #ffd93d; border-color: #ffd93d; color: #12312b; }
.campus-tab[data-campus="Chilliwack"] { background: #6fa8ff; border-color: #6fa8ff; color: #0d2b52; }
.campus-tab[data-campus="Chilliwack"]:hover { background: #4a8ce0; border-color: #4a8ce0; color: #0d2b52; }
.campus-tab.active[data-campus="Chilliwack"] { background: #6fa8ff; border-color: #6fa8ff; color: #0d2b52; }
.campus-tab.active[data-campus="Chilliwack"]:hover { background: #6fa8ff; border-color: #6fa8ff; color: #0d2b52; }
#aboutBtn {
  background: #ff7a1a;
  border: 2px solid #ff7a1a;
  color: #2b1400;
  padding: 7px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
#aboutBtn:hover { background: #e0650c; border-color: #e0650c; }
#editModeBtn {
  background: transparent;
  border: 2px solid #f6f4ee;
  color: #f6f4ee;
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
#editModeBtn:hover { background: #f6f4ee; color: #12312b; }
#editModeBtn.active { background: #b23a2e; border-color: #b23a2e; color: #fff8f0; }
#editModeBtn.active:hover { background: #92301f; border-color: #92301f; }

#editBanner {
  background: #d9a441;
  color: #12312b;
  padding: 8px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
}
#editBanner button { padding: 4px 10px; border: none; border-radius: 4px; cursor: pointer; font-weight: 600; }
.hidden { display: none !important; }

main { display: flex; height: calc(100% - 56px); }
#sidebar {
  width: 260px;
  padding: 14px;
  overflow-y: auto;
  background: #f6f4ee;
  border-right: 1px solid #ddd;
}
#map { flex: 1; }

.stats { background: white; border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.stats b { font-size: 20px; }
.stats-main { line-height: 1.5; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid #eee; }
.stats-block { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid #eee; }
.stats-block-last { padding-bottom: 0; margin-bottom: 0; }
.stats-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: #889; margin-bottom: 5px; }
.stat-chip {
  display: inline-block; background: #f6f4ee; color: #444; font-size: 12px;
  padding: 3px 8px; border-radius: 10px; margin: 0 4px 4px 0;
}
.stat-chip.mix-halq { background: #d7f2e0; color: #1f9e59; }
.stat-chip.mix-bilingual { background: #dbe7fb; color: #1a56db; }
.stat-chip.mix-multilingual { background: #eaddfa; color: #7c3aed; }
.stat-chip.mix-unspecified { background: #f0eee6; color: #667; }
.stat-chip.extent-single { background: #f8e6bd; color: #c98a1f; }
.stat-chip.extent-multiple { background: #f7d9c9; color: #c1440e; }
.stat-chip.extent-phrase { background: #cdf0ea; color: #0e9488; }
.stat-chip.extent-proper { background: #dbe7fb; color: #1a56db; }
.stat-chip.extent-other { background: #f0eee6; color: #667; }
.stat-chip.cp-halq { background: #d7f2e0; color: #1f9e59; }
.stat-chip.cp-english { background: #dbe7fb; color: #1a56db; }
.stat-chip.cp-balanced { background: #eaddfa; color: #7c3aed; }
.stat-chip.cp-mixed { background: #f8e6bd; color: #c98a1f; }
.stat-chip.cp-halqonly { background: #cdf0ea; color: #0e9488; }
.stats-sub { color: #667; font-size: 12px; line-height: 1.5; }
.stats-link-btn {
  background: none; border: none; color: #12312b; font-weight: 600;
  font-size: 13px; padding: 0; margin-top: 10px; cursor: pointer; text-decoration: underline;
}
.stats-link-btn:hover { color: #d9a441; }
.glossary-item { font-size: 13px; margin-bottom: 6px; }
.glossary-item summary { cursor: pointer; color: #12312b; font-weight: 500; }
.glossary-item summary:hover { color: #d9a441; }
.glossary-item p { margin: 6px 0 4px; color: #556; font-size: 12px; line-height: 1.5; }
.glossary-item ul { margin: 4px 0; padding-left: 18px; color: #556; font-size: 12px; line-height: 1.5; }
.glossary-item li { margin-bottom: 3px; }
.info-icon {
  cursor: help; display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; border-radius: 50%; border: 1px solid #99a;
  color: #778; font-size: 10px; font-style: italic; font-weight: 700;
  font-family: Georgia, "Times New Roman", serif; text-transform: none;
  letter-spacing: normal; vertical-align: middle;
}

.filter-group { margin-bottom: 18px; }
.filter-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: #667; margin: 0 0 8px; }
.filter-group label { display: block; font-size: 13px; margin-bottom: 4px; cursor: pointer; }
.filter-subgroup-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: #889; margin-bottom: 4px; }
#glossaryToggle > summary { cursor: pointer; list-style: revert; margin-bottom: 8px; }
#glossaryToggle > summary:hover h3 { color: #d9a441; }
#glossaryToggle > summary h3 { display: inline; margin: 0; }
#glossaryToggle[open] > summary { margin-bottom: 10px; }
#searchBox { width: 100%; padding: 6px 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; }

.legend-item { font-size: 12px; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: #444; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.legend-dot-unlogged { width: 12px; height: 12px; border-radius: 50%; display: inline-block; background: repeating-linear-gradient(45deg, #3f6b4f, #3f6b4f 2px, white 2px, white 4px); border: 1px solid #3f6b4f; }

.building-marker {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.building-marker.editable { cursor: grab; outline: 2px dashed #b23a2e; outline-offset: 2px; }
.building-marker.dimmed { opacity: 0.28; }

#welcomeOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 3000;
}
#welcomeOverlay.hidden { display: none; }
#welcomeContent {
  position: relative; background: #ffffff; color: #1c2b2d; max-width: 560px;
  width: 90vw; max-height: 85vh; overflow-y: auto; padding: 28px 32px;
  border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
#welcomeContent h2 { margin-top: 0; font-size: 20px; color: #12312b; }
#welcomeContent h3 { margin: 22px 0 8px; font-size: 15px; color: #12312b; }
#welcomeContent p { font-size: 14px; line-height: 1.5; }
#welcomeContent hr { border: none; border-top: 1px solid #ddd; margin: 20px 0; }
#welcomeClose { position: absolute; top: 10px; right: 14px; background: none; border: none; font-size: 24px; cursor: pointer; }
#welcomeGotIt {
  background: transparent; color: #12312b; border: 1.5px solid #12312b;
  padding: 9px 20px; border-radius: 2px; cursor: pointer; font-size: 12.5px;
  font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; margin-top: 8px;
}
#welcomeGotIt:hover { background: #12312b; color: white; }

#lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.88);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
#lightboxContent { position: relative; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; }
#lightboxImgWrap { max-width: 80vw; max-height: 70vh; overflow: auto; border-radius: 6px; cursor: zoom-in; }
#lightboxImgWrap.zoomed { cursor: grab; }
#lightboxImgWrap.zoomed:active { cursor: grabbing; }
#lightboxImg { max-width: 80vw; max-height: 70vh; border-radius: 6px; display: block; transition: max-width 0.15s, max-height 0.15s; }
#lightboxImgWrap.zoomed #lightboxImg { max-width: none; max-height: none; width: 220%; }
#lightboxZoomHint { color: rgba(255,255,255,0.6); font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 10px; }
#lightboxBrightenBtn {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.3); color: white;
  font-size: 11px; padding: 3px 9px; border-radius: 10px; cursor: pointer;
}
#lightboxBrightenBtn.active { background: #d9a441; border-color: #d9a441; color: #12312b; font-weight: 600; }
#lightboxImg.brightened { filter: brightness(1.55) contrast(1.08); }
#lightboxMeta { color: white; max-width: 600px; margin-top: 12px; font-size: 13px; background: rgba(255,255,255,0.06); padding: 10px 14px; border-radius: 6px; }
#lightboxMeta div { margin-bottom: 4px; }
#lightboxMeta b { color: #d9a441; }
.tier-badge {
  display: inline-block; background: rgba(217,164,65,0.18); color: #d9a441;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 1px 6px; border-radius: 8px; margin-left: 4px; vertical-align: middle;
}
#lightboxClose { position: absolute; top: -36px; right: -6px; background: none; border: none; color: white; font-size: 28px; cursor: pointer; }
.lightbox-nav { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.15); border: none; color: white; font-size: 32px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; z-index: 2001; }
#lightboxPrev { left: 16px; }
#lightboxNext { right: 16px; }

#buildingPanel {
  position: fixed; top: 56px; right: 0; width: 380px; height: calc(100% - 56px);
  background: white; box-shadow: -2px 0 8px rgba(0,0,0,0.15); padding: 16px; overflow-y: auto; z-index: 1000;
}
#buildingPanelClose { position: absolute; top: 10px; right: 12px; background: none; border: none; font-size: 24px; cursor: pointer; }
#buildingPanelTitle { margin: 0 0 4px; font-size: 18px; }
#buildingPanelStats { font-size: 13px; color: #555; margin-bottom: 12px; }
#buildingPanelGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#buildingPanelGrid img { width: 100%; height: 80px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; }
#buildingPanelGrid img.no-halq { opacity: 0.55; }
#buildingPanelGrid img:hover { border-color: #d9a441; }

#statsPanel {
  position: fixed; top: 56px; right: 0; width: 380px; height: calc(100% - 56px);
  background: white; box-shadow: -2px 0 8px rgba(0,0,0,0.15); padding: 16px; overflow-y: auto; z-index: 1000;
}
#statsPanelClose { position: absolute; top: 10px; right: 12px; background: none; border: none; font-size: 24px; cursor: pointer; }
#statsPanelTitle { margin: 0 0 12px; font-size: 18px; color: #12312b; }
#statsPanel .stats-block:first-of-type { padding-top: 0; }
