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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  color: #1a1a1a;
  background: #f5f5f5;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 320px;
  background: #ffffff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 2px 0 8px rgba(0,0,0,0.08);
  transition: transform 0.3s ease;
}

body.sidebar-collapsed #sidebar {
  transform: translateX(-320px);
}

#map {
  position: absolute;
  top: 0; left: 320px; right: 0; bottom: 0;
  transition: left 0.3s ease;
}

body.sidebar-collapsed #map {
  left: 0;
}

#btn-sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 320px;
  z-index: 1002;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 0 4px 4px 0;
  width: 18px;
  height: 36px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: left 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#btn-sidebar-toggle:hover { background: #2d2d4e; }

body.sidebar-collapsed #btn-sidebar-toggle {
  left: 0;
}

/* ── Sidebar header ────────────────────────────────────────────────────────── */
#sidebar-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid #eee;
  background: #1a1a2e;
  color: #fff;
  flex-shrink: 0;
}

#title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

#subtitle {
  font-size: 15px;
  color: rgba(255,255,255,0.6);
  margin-top: 3px;
}

/* ── Panel sections ────────────────────────────────────────────────────────── */
.panel-section {
  padding: 12px 14px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.section-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #888;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-actions {
  display: flex;
  gap: 6px;
}

.link-btn {
  background: none;
  border: none;
  color: #0066cc;
  cursor: pointer;
  font-size: 15px;
  padding: 0;
  font-weight: 500;
  text-decoration: underline;
}

.link-btn:hover { color: #004499; }

/* ── Date navigation ───────────────────────────────────────────────────────── */
#date-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

#date-nav button {
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s;
}

#date-nav button:hover { background: #e0e0e0; }

#date-picker {
  flex: 1;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 6px;
  font-size: 16px;
  cursor: pointer;
}

#date-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 24px;
}

#tmax-badge {
  font-size: 16px;
  color: #555;
}

#btn-play {
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

#btn-play:hover { background: #2d2d4e; }
#btn-play.playing { background: #b00020; }

/* ── Category list ─────────────────────────────────────────────────────────── */
#cat-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 3px 0;
}

.cat-row input[type=checkbox] {
  width: 14px; height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.cat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-name {
  flex: 1;
  font-size: 16px;
}

.cat-thresh {
  font-size: 14px;
  color: #aaa;
  white-space: nowrap;
}

/* ── Legend ────────────────────────────────────────────────────────────────── */
#legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 16px;
}

.swatch {
  width: 18px; height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.legend-note {
  font-size: 14px;
  color: #999;
  line-height: 1.4;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
#sidebar-footer {
  margin-top: auto;
  padding: 10px 14px;
  font-size: 14px;
  color: #bbb;
  border-top: 1px solid #eee;
  line-height: 1.6;
  flex-shrink: 0;
}

/* ── Tooltip ───────────────────────────────────────────────────────────────── */
#tooltip {
  position: fixed;
  background: rgba(10, 10, 30, 0.92);
  color: #fff;
  padding: 10px 13px;
  border-radius: 6px;
  font-size: 15px;
  pointer-events: none;
  z-index: 9999;
  max-width: 280px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.3);
  line-height: 1.5;
}

#tooltip.hidden { display: none; }

.tt-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  padding-bottom: 4px;
}

.tt-score {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.tt-score-label { font-size: 14px; color: rgba(255,255,255,0.6); }

.tt-cats {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tt-cat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
}

.tt-cat-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tt-cat.inactive { opacity: 0.35; }

.tt-val { color: rgba(255,255,255,0.55); font-size: 13px; }

/* ── Loading overlay ───────────────────────────────────────────────────────── */
#loading {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,26,46,0.85);
  color: #fff;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 15px;
  z-index: 2000;
  transition: opacity 0.2s;
  white-space: nowrap;
}

#loading.hidden { opacity: 0; pointer-events: none; }

/* ── Timeline panel ────────────────────────────────────────────────────────── */
#timeline-panel {
  position: fixed;
  bottom: 0; left: 320px; right: 0;
  transition: left 0.3s ease;
  height: 210px;
  background: #fff;
  border-top: 1px solid #ddd;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.10);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  padding: 8px 14px 10px;
}

#timeline-panel.hidden { display: none; }

body.sidebar-collapsed #timeline-panel {
  left: 0;
}

#timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-shrink: 0;
}

#timeline-title {
  font-size: 16px;
  font-weight: 700;
  color: #222;
}

#timeline-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #888;
  line-height: 1;
  padding: 0 2px;
}

#timeline-close:hover { color: #333; }

#timeline-chart-wrap {
  flex: 1;
  min-height: 0;
}

/* ── Leaflet overrides ─────────────────────────────────────────────────────── */
.leaflet-control-attribution { font-size: 12px; }
