/* z-index 修复 */
.leaflet-container { z-index: 1 !important; }

/* ========================================
   地球往事 - 样式表
   ======================================== */

/* 暗色主题 (默认) */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #78716c;
  --accent: #f59e0b;
  
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --border: #334155;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  
  --header-height: 56px;
  --timeline-height: 100px;
  
  /* 分类颜色 */
  --cat-war: #ef4444;
  --cat-politics: #3b82f6;
  --cat-discovery: #22c55e;
  --cat-culture: #a855f7;
  --cat-nature: #14b8a6;
  
  /* 主题标识 */
  --theme: dark;
}

/* 亮色主题 */
[data-theme="light"] {
  --bg-dark: #f8fafc;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .header {
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.8));
}

[data-theme="light"] .search-box {
  background: var(--bg-card);
  border-color: var(--border);
}

[data-theme="light"] .search-box input {
  background: transparent;
  color: var(--text-primary);
}

[data-theme="light"] .event-panel {
  background: var(--bg-card);
}

[data-theme="light"] .event-item {
  border-color: var(--border);
}

[data-theme="light"] .event-item:hover {
  background: var(--bg-hover);
}

[data-theme="light"] .timeline {
  background: linear-gradient(to top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.8));
}

[data-theme="light"] .year-indicator {
  background: var(--bg-card);
  border-color: var(--border);
}

[data-theme="light"] .category-filter {
  background: var(--bg-card);
  border-color: var(--border);
}

[data-theme="light"] .filter-btn {
  color: var(--text-secondary);
}

[data-theme="light"] .filter-btn.active {
  background: var(--primary);
  color: white;
}

[data-theme="light"] .modal-content {
  background: var(--bg-card);
  border-color: var(--border);
}

[data-theme="light"] .modal-header h2 {
  color: var(--text-primary);
}

[data-theme="light"] .modal-body p {
  color: var(--text-secondary);
}

[data-theme="light"] .keyboard-hint {
  background: var(--bg-card);
  border-color: var(--border);
}

[data-theme="light"] .stats-panel {
  background: var(--bg-card);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   顶部导航
   ======================================== */

.header {
  height: var(--header-height);
  background: linear-gradient(to bottom, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.8));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  position: relative;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.logo {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-en {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 300;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ========================================
   栏目导航
   ======================================== */

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.nav-item {
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 0;
  min-width: 160px;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 1000;
}

.nav-dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: block;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.search-box {
  display: flex;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.search-box input {
  background: transparent;
  border: none;
  padding: 8px 12px;
  color: var(--text-primary);
  width: 200px;
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box button {
  background: var(--bg-hover);
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.search-box button:hover {
  background: var(--primary);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ========================================
   地图区域
   ======================================== */

.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

/* Mapbox 覆盖样式 */
.mapboxgl-ctrl-group {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  overflow: hidden;
}

.mapboxgl-ctrl-group button {
  background: var(--bg-card) !important;
  border: none !important;
}

.mapboxgl-ctrl-group button:hover {
  background: var(--bg-hover) !important;
}

.mapboxgl-ctrl-icon {
  filter: invert(0.8) !important;
}

.mapboxgl-ctrl-attrib {
  background: rgba(15, 23, 42, 0.8) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}

.mapboxgl-popup-content {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-radius: 12px !important;
  padding: 16px !important;
  box-shadow: var(--shadow) !important;
  border: 1px solid var(--border) !important;
}

.mapboxgl-popup-tip {
  border-top-color: var(--bg-card) !important;
}

.mapboxgl-popup-close-button {
  color: var(--text-primary) !important;
  font-size: 18px !important;
}

/* ========================================
   年份指示器
   ======================================== */

.year-indicator {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 10px 20px;
  border-radius: 50px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  z-index: 10;
  transition: transform 0.3s, box-shadow 0.3s;
  min-width: 120px;
}

.year-indicator:hover {
  transform: translateX(-50%) scale(1.05);
  box-shadow: 0 6px 30px rgba(37, 99, 235, 0.5);
}

.year-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.8;
}

.year-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  white-space: nowrap;
}

.year-value.bc::before {
  content: 'BC ';
  font-size: 0.7rem;
  font-weight: 400;
}

/* 朝代指示器 */
.dynasty-indicator {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  white-space: nowrap;
}

[data-theme="light"] .dynasty-indicator {
  border-top-color: rgba(0, 0, 0, 0.2);
}

.year-value.ad::after {
  content: '';
}

/* 键盘快捷键提示 */
.keyboard-hint {
  position: absolute;
  top: 20px;
  left: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 10;
  cursor: pointer;
  transition: all 0.2s;
}

.keyboard-hint:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.keyboard-hint kbd {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 10px;
}

/* 数据统计面板 */
.stats-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  z-index: 2000;
  min-width: 300px;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.stats-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text-primary);
}

.stats-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.stats-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.stats-content {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.8;
}

.stats-content .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.stats-content .stat-row:last-child {
  border-bottom: none;
}

.stats-content .stat-label {
  color: var(--text-muted);
}

.stats-content .stat-value {
  color: var(--text-primary);
  font-weight: 500;
}

.stats-content .category-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.stats-content .category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-dark);
  border-radius: 6px;
}

/* ========================================
   分类筛选
   ======================================== */

.category-filter {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.filter-btn[data-category="war"].active { background: var(--cat-war); border-color: var(--cat-war); }
.filter-btn[data-category="politics"].active { background: var(--cat-politics); border-color: var(--cat-politics); }
.filter-btn[data-category="discovery"].active { background: var(--cat-discovery); border-color: var(--cat-discovery); }
.filter-btn[data-category="culture"].active { background: var(--cat-culture); border-color: var(--cat-culture); }
.filter-btn[data-category="nature"].active { background: var(--cat-nature); border-color: var(--cat-nature); }

/* ========================================
   事件面板
   ======================================== */

.event-panel {
  position: fixed;
  top: 80px;
  left: 20px;
  width: 320px;
  max-height: calc(100vh - var(--header-height) - var(--timeline-height) - 120px);
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  transform: translateX(-350px);
  transition: transform 0.3s ease;
  z-index: 99999 !important;
}

.event-panel.open {
  transform: translateX(0);
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h3 {
  font-size: 1rem;
  font-weight: 500;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.btn-close:hover {
  color: var(--text-primary);
}

.event-list {
  max-height: 400px;
  overflow-y: auto;
}

.event-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

.event-item:hover {
  background: var(--bg-hover);
}

.event-item:last-child {
  border-bottom: none;
}

.event-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.event-item-category {
  font-size: 1rem;
}

.event-item-title {
  font-weight: 500;
  font-size: 0.95rem;
}

.event-item-year {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.event-item-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========================================
   时间轴
   ======================================== */

.timeline {
  height: var(--timeline-height);
  background: linear-gradient(to top, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.9));
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 12px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 1001; /* 高于弹窗(1000)，确保可交互 */
  pointer-events: auto; /* 确保时间轴可以接收事件 */
}

.timeline-info {
  text-align: center;
  margin-bottom: 8px;
}

#timelineYear {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#timelineHint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.timeline-slider-container {
  display: flex;
  align-items: center;
  gap: 15px;
  position: relative;
}

/* 精度区域标签 */
.slider-zone-labels {
  position: absolute;
  left: 70px;
  right: 70px;
  bottom: 8px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.zone-label {
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.6;
  transition: opacity 0.2s;
}

.timeline-start,
.timeline-end {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.5);
  transition: transform 0.2s;
}

.timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.timeline-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.5);
}

.timeline-markers {
  position: absolute;
  bottom: 8px;
  left: 30px;
  right: 30px;
  height: 4px;
  pointer-events: none;
}

/* ========================================
   事件详情弹窗
   ======================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  pointer-events: none; /* 允许点击穿透到地图 */
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  /* backdrop-filter: blur(4px); 移除blur效果，允许地图交互 */
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: 16px;
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.3s;
  pointer-events: auto; /* 弹窗内容拦截点击 */
}

.modal.open .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 24px 24px 16px;
}

.modal-category {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.modal-category.war { background: var(--cat-war); }
.modal-category.politics { background: var(--cat-politics); }
.modal-category.discovery { background: var(--cat-discovery); }
.modal-category.culture { background: var(--cat-culture); }
.modal-category.nature { background: var(--cat-nature); }

.modal-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.modal-year {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.modal-body {
  padding: 0 24px 24px;
  overflow-y: auto;
  max-height: calc(85vh - 180px);
}

.modal-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 16px;
  background: var(--bg-hover);
  display: none;
}

.modal-image.loaded {
  display: block;
}

.modal-body p {
  line-height: 1.7;
  color: var(--text-secondary);
}

.modal-links {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-links a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 12px;
  background: rgba(37, 99, 235, 0.1);
  border-radius: 6px;
  transition: background 0.2s;
}

.modal-links a:hover {
  background: rgba(37, 99, 235, 0.2);
}

.modal-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.modal-location {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========================================
   加载动画
   ======================================== */

.loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.5s, visibility 0.5s;
}

.loading.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-earth {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 50%;
  position: relative;
  animation: rotate 2s linear infinite;
}

.loading-earth::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.2) 50%, transparent 70%);
  border-radius: 50%;
}

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

.loading p {
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ========================================
   标记点样式
   ======================================== */

/* Leaflet 自定义标记容器 */
.custom-marker {
  background: transparent !important;
  border: none !important;
}

.event-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.event-marker:hover {
  transform: scale(1.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.event-marker.war { background: var(--cat-war); }
.event-marker.politics { background: var(--cat-politics); }
.event-marker.discovery { background: var(--cat-discovery); }
.event-marker.culture { background: var(--cat-culture); }
.event-marker.nature { background: var(--cat-nature); }

/* Leaflet Tooltip 样式 */
.leaflet-tooltip {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 6px 10px !important;
  font-family: 'Noto Sans SC', sans-serif !important;
  font-size: 13px !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-tooltip-left::before,
.leaflet-tooltip-right::before {
  border-left-color: var(--bg-card) !important;
  border-right-color: var(--bg-card) !important;
}

/* Leaflet 控件样式 */
.leaflet-control-zoom {
  border: none !important;
  border-radius: 8px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-hover) !important;
}

.leaflet-control-zoom-in {
  border-radius: 8px 8px 0 0 !important;
}

.leaflet-control-zoom-out {
  border-radius: 0 0 8px 8px !important;
  border-top: none !important;
}

/* Leaflet 版权信息 */
.leaflet-control-attribution {
  background: rgba(15, 23, 42, 0.8) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
  border-radius: 4px 0 0 0 !important;
}

.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

/* ========================================
   响应式设计
   ======================================== */

@media (max-width: 768px) {
  .header {
    padding: 0 12px;
  }
  
  .logo {
    font-size: 1.1rem;
  }
  
  .logo-en {
    display: none;
  }
  
  .search-box input {
    width: 140px;
  }
  
  .event-panel {
    width: calc(100% - 24px);
    left: 12px;
    transform: translateY(100vh);
  }
  
  .event-panel.open {
    transform: translateY(0);
    top: auto;
    bottom: calc(var(--timeline-height) + 12px);
    max-height: 50vh;
  }
  
  .category-filter {
    top: auto;
    bottom: calc(var(--timeline-height) + 20px);
    right: 12px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  
  .filter-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
  
  .year-indicator {
    padding: 8px 16px;
  }
  
  .year-value {
    font-size: 1.4rem;
  }
  
  .timeline {
    padding: 10px 16px;
  }
  
  .timeline-start,
  .timeline-end {
    font-size: 0.6rem;
  }
  
  .modal-content {
    width: 95%;
    max-height: 90vh;
  }
}

@media (max-width: 480px) {
  .search-box {
    display: none;
  }
  
  .filter-btn {
    padding: 5px 8px;
    font-size: 0.7rem;
  }
  
  .modal-header h2 {
    font-size: 1.2rem;
  }
}

/* ========================================
   滚动条样式
   ======================================== */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ========================================
   动画工具类
   ======================================== */

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========================================
   底部版权信息
   ======================================== */

.footer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 8px;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-info .copyright {
  opacity: 0.9;
}

.footer-info .beian {
  opacity: 0.7;
}

.footer-info .beian a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-info .beian a:hover {
  color: var(--text-secondary);
}

.footer-info .map-credit {
  opacity: 0.7;
}

.footer-info .map-credit a {
  color: var(--primary);
  text-decoration: none;
}

.footer-info .map-credit a:hover {
  text-decoration: underline;
}

.footer-info .disclaimer {
  opacity: 0.6;
  font-size: 11px;
}

@media (max-width: 600px) {
  .footer-info {
    flex-direction: column;
    text-align: center;
    font-size: 11px;
    padding: 8px 12px;
  }
  
  .footer-left, .footer-right {
    justify-content: center;
    gap: 8px;
  }
}

/* 备案信息样式 */
.beian, .gongan-beian, .data-source, .privacy-link {
  margin-left: 15px;
  font-size: 12px;
}

.beian a, .gongan-beian a, .data-source a, .privacy-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.3s;
}

.beian a:hover, .gongan-beian a:hover, .data-source a:hover, .privacy-link:hover {
  color: var(--primary);
}

@media (max-width: 768px) {
  .footer-info {
    flex-direction: column;
    gap: 8px;
  }
  
  .beian, .gongan-beian, .data-source, .privacy-link {
    margin-left: 0;
    margin-right: 10px;
    display: inline-block;
  }
}

/* 联系链接样式 */
.contact-link {
  margin-left: 15px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.3s;
}

.contact-link:hover {
  color: var(--primary);
}

/* ========================================
   通知提示 Toast
   ======================================== */
.toast-notification {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 12px 24px;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3);
  font-size: 14px;
  color: var(--text-primary);
  animation: toastFadeIn 0.3s ease;
}

.toast-notification.warning {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
}

@keyframes toastFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast-notification.fade-out {
  animation: toastFadeOut 0.3s ease forwards;
}

@keyframes toastFadeOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* 分类筛选按钮 - 提高层级 */
.category-filter {
  z-index: 800 !important;
}

/* 键盘快捷键提示 */
.keyboard-hint {
  z-index: 800 !important;
}

/* 年份指示器 */
.year-indicator {
  z-index: 800 !important;
}

/* 搜索框 */
.search-box {
  z-index: 900 !important;
}

/* 按钮图标 */
.btn-icon {
  z-index: 900 !important;
}

/* 事件面板 */
.event-panel {
  z-index: 9999 !important;
}

/* 底部时间轴 */
.timeline {
  z-index: 700 !important;
}

/* 底部版权 */
.footer-info {
  z-index: 700 !important;
}

/* 统计面板 */
.stats-panel {
  z-index: 10000 !important;
}

/* 弹窗 */
.modal {
  z-index: 10001 !important;
}

/* Leaflet 控件 - 保持在所有地图元素上方 */
.leaflet-control {
  z-index: 1500 !important;
}

.leaflet-control-zoom {
  z-index: 1501 !important;
}

.leaflet-control-attribution {
  z-index: 1400 !important;
  margin-bottom: 120px !important;
}

/* Leaflet 图层控件 */
.leaflet-control-layers {
  z-index: 1500 !important;
}

.leaflet-control-layers-expanded {
  z-index: 1500 !important;
}

.leaflet-control-layers-list {
  z-index: 1500 !important;
}

/* 地图上的标注 */
.leaflet-marker-icon {
  z-index: 700 !important;
}

/* ========================================
   强制所有控件在地图上方
   ======================================== */

/* 所有可能的控件 */
.leaflet-top,
.leaflet-bottom,
.leaflet-left,
.leaflet-right {
  z-index: 2000 !important;
}

/* 所有 Leaflet 控件容器 */
.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom,
.leaflet-control-container .leaflet-left,
.leaflet-control-container .leaflet-right {
  z-index: 2000 !important;
}

/* 下拉选择框（如果有） */
.leaflet-control select,
.leaflet-control-layers select,
select.leaflet-control-layers-selector {
  z-index: 2001 !important;
  position: relative;
}

/* 覆盖所有可能的遮挡 */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-icon::before {
  z-index: auto !important;
}

/* 确保控件面板不被遮挡 */
.leaflet-control-layers-expanded {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 10px !important;
  max-height: 300px !important;
  overflow-y: auto !important;
}

/* 输入框 */
.leaflet-control input,
.leaflet-control-layers input {
  z-index: 2001 !important;
}

/* 事件面板 - 强制最高层级 */
#eventPanel {
  z-index: 99999 !important;
}

.event-panel {
  z-index: 99999 !important;
}

div.event-panel {
  z-index: 99999 !important;
}

/* 强制地图容器在所有UI元素下方 */
.leaflet-container {
  z-index: 1 !important;
}

.leaflet-pane {
  z-index: 1 !important;
}

.leaflet-tile-pane {
  z-index: 1 !important;
}

.leaflet-overlay-pane {
  z-index: 2 !important;
}

.leaflet-shadow-pane {
  z-index: 3 !important;
}

.leaflet-marker-pane {
  z-index: 4 !important;
}

.leaflet-popup-pane {
  z-index: 5 !important;
}

/* 地图容器本身 */
#map {
  z-index: 1 !important;
}

.map-container {
  z-index: 1 !important;
}

/* ========================================
   联系弹框样式
   ======================================== */

.contact-modal-content {
  max-width: 400px;
  text-align: center;
}

.contact-modal-content .modal-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.contact-modal-content .modal-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.5rem;
}

.contact-info {
  padding: 1rem 0;
}

.contact-label {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.contact-email {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--bg-hover);
  border-radius: 12px;
  margin: 1rem 0;
}

.email-icon {
  font-size: 1.5rem;
}

.email-link {
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s ease;
}

.email-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.contact-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 1rem;
}

/* 亮色主题适配 */
[data-theme="light"] .contact-email {
  background: #f1f5f9;
}

/* ============================================
   个人轨迹模块样式 - Track Module Styles
   ============================================ */

/* 轨迹标记样式 */
.track-marker {
  background: transparent !important;
  border: none !important;
}

.track-pin {
  width: 30px;
  height: 40px;
  background: #3498db;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}

.track-pin:hover {
  transform: rotate(-45deg) scale(1.1);
}

.track-icon {
  transform: rotate(45deg);
  font-size: 14px;
}

.temp-marker {
  background: transparent !important;
}

.temp-pin {
  width: 20px;
  height: 20px;
  background: #e74c3c;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

/* 轨迹弹窗样式 */
.track-popup {
  min-width: 200px;
  padding: 10px;
}

.track-popup h4 {
  margin: 0 0 8px 0;
  color: #2c3e50;
  font-size: 16px;
}

.track-date, .track-location {
  color: #7f8c8d;
  font-size: 13px;
  margin: 4px 0;
}

.track-note {
  color: #34495e;
  font-size: 14px;
  margin: 8px 0;
  padding: 8px;
  background: #ecf0f1;
  border-radius: 4px;
  max-height: 100px;
  overflow-y: auto;
}

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

.track-actions button {
  flex: 1;
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: opacity 0.2s;
}

.btn-edit {
  background: #3498db;
  color: white;
}

.btn-delete {
  background: #e74c3c;
  color: white;
}

.track-actions button:hover {
  opacity: 0.8;
}

/* 模态框样式 */
.track-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(3px);
}

.modal-content {
  background: white;
  padding: 25px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-content h3 {
  margin: 0 0 20px 0;
  color: #2c3e50;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: #555;
  font-size: 14px;
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3498db;
}

.color-picker {
  display: flex;
  gap: 10px;
}

.color-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.2s;
}

.color-option.active {
  border-color: #2c3e50;
  transform: scale(1.1);
}

.color-option:hover {
  transform: scale(1.1);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: #3498db;
  color: white;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-secondary {
  background: #ecf0f1;
  color: #555;
}

.btn-secondary:hover {
  background: #bdc3c7;
}

/* 轨迹面板样式 - 适配现有暗色主题 */
.track-panel {
  position: fixed;
  top: 80px;
  right: 20px;
  width: 280px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 9999;
  display: none;
}

.track-panel.open {
  display: block;
}

.track-panel-header {
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
}

.track-panel-header h3 {
  margin: 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.track-count {
  background: rgba(255,255,255,0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.track-panel-body {
  padding: 15px;
  max-height: 400px;
  overflow-y: auto;
}

.track-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.track-toolbar button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.track-toolbar button:hover {
  background: var(--bg-hover);
  border-color: #3498db;
}

.track-toolbar button.active {
  background: #3498db;
  color: white;
  border-color: #3498db;
}

.track-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.track-item {
  padding: 12px;
  background: var(--bg-hover);
  border-radius: 8px;
  border-left: 4px solid #3498db;
  cursor: pointer;
  transition: all 0.2s;
}

.track-item:hover {
  background: var(--border);
  transform: translateX(3px);
}

.track-item-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.track-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.track-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

.track-empty-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

/* Toast提示 */
.track-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #2c3e50;
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 14px;
  z-index: 10001;
  opacity: 0;
  transition: all 0.3s;
}

.track-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* 文件导入区域 */
.import-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  margin-top: 10px;
  transition: all 0.2s;
}

.import-area:hover {
  border-color: #3498db;
  background: var(--bg-hover);
}

.import-area input[type="file"] {
  display: none;
}

.import-label {
  cursor: pointer;
  color: #3498db;
  font-size: 14px;
}

/* 响应式优化 */
@media (max-width: 768px) {
  .track-panel {
    width: calc(100% - 40px);
    right: 20px;
    left: 20px;
    top: auto;
    bottom: 20px;
    max-height: 50vh;
  }
  
  .modal-content {
    width: 95%;
    margin: 20px;
  }
}

/* ============================================
   轨迹按钮高亮样式
   ============================================ */

#trackBtn {
  position: relative;
  overflow: hidden;
}

#trackBtn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.5s;
}

#trackBtn:hover::after {
  left: 100%;
}

#trackBtn.active {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

/* 轨迹面板默认显示优化 */
.track-panel.open {
  display: block;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 空状态优化 */
.track-empty {
  padding: 40px 20px;
}

.track-empty p {
  font-size: 14px;
  line-height: 1.6;
}
