/* ===== 基础重置 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: #2c3e50;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

a { color: #1976d2; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 顶部标题栏 ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, #6a1b9a 0%, #283593 100%);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 1000;
}
.app-title h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 2px;
}
.app-subtitle {
    font-size: 12px;
    opacity: 0.85;
}
.current-year-display {
    display: flex;
    align-items: baseline;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    padding: 6px 14px;
    border-radius: 20px;
}
.year-label { font-size: 12px; opacity: 0.8; }
.year-value {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.dynasty-name {
    font-size: 14px;
    padding-left: 8px;
    border-left: 1px solid rgba(255,255,255,0.4);
    margin-left: 4px;
}

/* ===== 地图容器 ===== */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}
#map {
    width: 100%;
    height: 100%;
    background: #e8eef3;
    z-index: 1;
}
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 500;
}

/* ===== 图例 ===== */
.legend {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(255,255,255,0.95);
    padding: 10px 14px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-size: 12px;
    z-index: 400;
}
.legend-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: #555;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.legend-swatch {
    display: inline-block;
    width: 16px;
    height: 12px;
    border: 1px solid #333;
    border-radius: 2px;
    background: #888;
}

/* ===== 页脚 ===== */
.app-footer {
    padding: 6px 20px;
    background: #2c3e50;
    color: #bdc3c7;
    font-size: 11px;
    text-align: center;
    z-index: 1000;
}
.app-footer a { color: #90caf9; }

/* ===== 弹窗（Leaflet popup 内容） ===== */
.place-popup {
    max-width: 360px;
    font-size: 13px;
}
.place-popup-header {
    border-bottom: 2px solid #1976d2;
    padding-bottom: 8px;
    margin-bottom: 8px;
}
.place-popup-header h3 {
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 2px;
}
.place-popup-meta {
    font-size: 11px;
    color: #888;
}
.place-popup-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}
.tab-btn {
    flex: 1;
    padding: 6px 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.tab-btn:hover { background: #f0f0f0; }
.tab-btn.active {
    color: #1976d2;
    border-bottom-color: #1976d2;
    font-weight: 600;
}
.tab-content {
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}
.tab-content ul { list-style: none; }
.name-list li {
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
}
.name-list .name-year {
    color: #1976d2;
    font-weight: 600;
    white-space: nowrap;
}
.name-list .name-text { color: #2c3e50; }
.name-list .name-dynasty { color: #888; font-size: 11px; }

.event-list li, .person-list li {
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
    font-size: 12px;
}
.event-list .event-year,
.person-list .person-year {
    color: #1976d2;
    font-weight: 600;
    margin-right: 6px;
}
.event-list .event-title {
    color: #2c3e50;
    font-weight: 600;
}
.event-list .event-desc {
    color: #666;
    margin-top: 2px;
    font-size: 11px;
}
.person-list .person-name {
    color: #2c3e50;
    font-weight: 600;
    margin-right: 6px;
}
.person-list .person-role {
    color: #888;
    font-size: 11px;
}
.placeholder {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 12px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .app-header { flex-direction: column; gap: 6px; padding: 8px 12px; }
    .app-title h1 { font-size: 16px; }
    .current-year-display { padding: 4px 10px; }
    .year-value { font-size: 16px; }
    .legend { bottom: 8px; right: 8px; font-size: 11px; }
    .place-popup { max-width: 240px; }
}
