:root {
    --bg: #1a1a2e;
    --bg-panel: #16213e;
    --bg-card: #1a1a3e;
    --text: #e0e0e0;
    --text-dim: #8a8a9a;
    --accent: #e94560;
    --accent2: #16c79a;
    --gold: #f5a623;
    --border: #30475e;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

/* ===== 左侧面板 ===== */
#control-panel {
    width: 300px;
    min-width: 300px;
    height: 100vh;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    position: sticky;
    top: 0;
    z-index: 100;
}
#control-panel .inner { padding: 20px; }
#control-panel h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 4px;
    letter-spacing: 2px;
}
#control-panel .subtitle {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 16px;
    line-height: 1.6;
}

/* 搜索栏 — sticky */
#search-section {
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    z-index: 10;
    padding: 12px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
#search-section label {
    display: block;
    font-size: 12px;
    color: var(--accent2);
    margin-bottom: 6px;
    font-weight: 600;
    letter-spacing: 1px;
}
#search-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
#search-input:focus { border-color: var(--accent2); outline: none; }
#search-btn {
    margin-top: 8px;
    width: 100%;
    padding: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background .2s;
}
#search-btn:hover { background: #c73852; }
#search-btn:disabled { opacity: .5; cursor: wait; }
#search-results {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.6;
}
#search-results .loading { color: var(--accent2); }
#search-results .success { color: var(--accent2); }
#search-results .error { color: var(--accent); }

/* 控件组 */
.control-group { margin-bottom: 16px; }
.control-group label {
    display: block;
    font-size: 12px;
    color: var(--accent2);
    margin-bottom: 6px;
    font-weight: 600;
    letter-spacing: 1px;
}
.control-group select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}
.control-group select:focus { border-color: var(--accent2); outline: none; }
.control-group select option { background: var(--bg-panel); }

/* 缩放 */
#zoom-control { display: flex; align-items: center; gap: 8px; }
#zoom-control input[type=range] { flex: 1; }
#zoom-value { font-size: 12px; color: var(--gold); min-width: 36px; text-align: right; }

/* 时间轴方向切换 */
.dir-btn {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    color: var(--accent2);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all .2s;
}
.dir-btn:hover { border-color: var(--accent2); background: rgba(95,158,184,.1); }
.dir-btn:active { transform: scale(.97); }

/* 人物信息卡 */
#figure-info {
    margin-top: 16px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
    display: none;
}
#figure-info.visible { display: block; }
#figure-info .fig-name { font-size: 17px; font-weight: 700; color: var(--gold); margin-bottom: 4px; }
#figure-info .fig-years { font-size: 12px; color: var(--accent2); margin-bottom: 6px; }
#figure-info .fig-title { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
#figure-info .fig-era { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 11px; color: var(--text-dim); }
#figure-info .fig-era b { color: var(--gold); }

/* 统计 */
#stats {
    margin-top: 16px;
    padding: 10px 12px;
    background: rgba(255,255,255,.03);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.8;
}
#stats span { color: var(--gold); font-weight: 600; }

/* 图例 */
.legend { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.legend h3 { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ===== 时间轴区域 ===== */
#timeline-area {
    flex: 1;
    height: 100vh;
    overflow: auto;
    padding: 20px;
    position: relative;
}
#timeline-area h2 { font-size: 15px; color: var(--text-dim); margin-bottom: 12px; letter-spacing: 1px; }
#timeline-container { position: relative; }
#timeline-container svg { display: block; }

/* SVG 元素样式 */
.era-bar { transition: opacity .2s; cursor: pointer; }
.era-bar:hover { opacity: 1 !important; }
.fig-bar { transition: opacity .2s, stroke .2s, stroke-width .2s, filter .2s; cursor: pointer; }
.fig-bar:hover { opacity: 1 !important; stroke: #fff; stroke-width: 2; }
.fig-bar.highlighted { opacity: 1 !important; stroke: var(--gold); stroke-width: 3; filter: drop-shadow(0 0 6px #f5a623); }
.fig-bar.contemporary { opacity: 0.9 !important; stroke: var(--accent2); stroke-width: 2; filter: drop-shadow(0 0 4px #5f9ea0); }
.fig-label { cursor: pointer; }
.fig-label.highlighted { fill: var(--gold) !important; font-weight: bold !important; }
.fig-label.contemporary { fill: var(--accent2) !important; font-weight: 600; }
.era-label, .fig-label { pointer-events: none; }

/* 滚动条 */
#timeline-area::-webkit-scrollbar { width: 8px; height: 8px; }
#timeline-area::-webkit-scrollbar-track { background: var(--bg); }
#timeline-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#timeline-area::-webkit-scrollbar-thumb:hover { background: var(--accent); }
#control-panel::-webkit-scrollbar { width: 6px; }
#control-panel::-webkit-scrollbar-track { background: var(--bg-panel); }
#control-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== 移动端面板切换按钮（默认隐藏） ===== */
#panel-toggle {
    display: none;
}

/* ===== 移动端响应式 ===== */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    /* 切换按钮 */
    #panel-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        background: var(--accent);
        color: #fff;
        border: none;
        border-radius: 8px;
        font-size: 20px;
        cursor: pointer;
        z-index: 200;
        box-shadow: 0 2px 8px rgba(0,0,0,.4);
    }

    /* 控制面板 — 抽屉式，默认隐藏 */
    #control-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        min-width: 0;
        max-width: 320px;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform .3s ease;
        z-index: 150;
    }
    #control-panel.open {
        transform: translateX(0);
    }

    /* 遮罩层 */
    #panel-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 140;
    }
    #panel-overlay.visible {
        display: block;
    }

    /* 时间轴区域 — 全宽 */
    #timeline-area {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        padding: 50px 10px 20px 10px;
    }
    #timeline-area h2 {
        font-size: 14px;
    }

    /* 搜索栏输入适配 */
    #search-input {
        font-size: 16px; /* 防止 iOS 自动缩放 */
    }
    #search-btn {
        padding: 10px;
        font-size: 14px;
    }

    /* 控件间距收紧 */
    .control-group { margin-bottom: 12px; }
    .control-group select {
        padding: 10px;
        font-size: 14px;
    }

    /* 人物信息卡 */
    #figure-info {
        padding: 12px;
    }
    #figure-info .fig-name { font-size: 16px; }

    /* 缩放滑块加大触控区 */
    #zoom-control input[type=range] {
        height: 28px;
    }

    /* 方向按钮加大触控区 */
    .dir-btn {
        padding: 10px;
        font-size: 14px;
    }

    /* 移动端浮动方向切换按钮（面板关闭时可用） */
    #dir-float {
        display: flex;
        position: fixed;
        top: 10px;
        right: 60px;
        z-index: 200;
        padding: 8px 14px;
        background: var(--accent);
        color: #fff;
        border: none;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        font-family: inherit;
        box-shadow: 0 2px 8px rgba(0,0,0,.4);
    }
    #dir-float:active { transform: scale(.95); }
}
/* 桌面端隐藏浮动按钮 */
@media(min-width:769px) {
    #dir-float { display: none; }
}
