/* === 全局 & 布局 === */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* === 头部 === */
header {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    padding: 14px 24px;
    text-align: center;
    border-bottom: 1px solid #2a2a4a;
    flex-shrink: 0;
    z-index: 10;
}

header h1 {
    font-size: 1.6rem;
    color: #f0c040;
    letter-spacing: 2px;
    margin-bottom: 2px;
}

header .subtitle {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 4px;
}

header .hint {
    font-size: 0.7rem;
    color: #555;
    margin-bottom: 10px;
}

.controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.controls button,
.controls select {
    padding: 6px 14px;
    border: 1px solid #3a3a5a;
    background: #1e1e3a;
    color: #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.controls button:hover {
    background: #2e2e5a;
    border-color: #f0c040;
    color: #f0c040;
}

.controls select {
    cursor: pointer;
}

/* === 树容器 === */
#treeContainer {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background: radial-gradient(ellipse at center, #13132a 0%, #0a0a18 100%);
}

#treeContainer:active {
    cursor: grabbing;
}

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

/* === 节点样式 === */
g.node {
    cursor: pointer;
    transition: transform 0.15s ease;
}

g.node:hover rect.node-bg {
    filter: brightness(1.3);
}

rect.node-bg {
    rx: 8;
    ry: 8;
    stroke-width: 1.5;
    transition: fill 0.2s, stroke 0.2s;
}

text.node-label {
    font-size: 13px;
    font-weight: 700;
    fill: #fff;
    pointer-events: none;
    user-select: none;
    text-anchor: middle;
    dominant-baseline: central;
    text-shadow: 0 0 6px rgba(0,0,0,0.7);
}

/* === 连线 === */
path.edge {
    fill: none;
    stroke: #3a3a6a;
    stroke-width: 1.5;
    transition: stroke 0.2s;
}

path.edge:hover {
    stroke: #f0c040;
}

/* === 详情面板 === */
#detailPanel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 320px;
    max-height: 60%;
    background: rgba(20, 20, 45, 0.95);
    border: 1px solid #3a3a5a;
    border-radius: 12px;
    padding: 20px;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 20;
    transition: opacity 0.3s, transform 0.3s;
}

#detailPanel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(30px);
}

#closeDetail {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: #888;
    font-size: 1.2rem;
    cursor: pointer;
}

#closeDetail:hover {
    color: #f0c040;
}

#detailNumber {
    color: #f0c040;
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: 700;
}

#detailText {
    color: #ccc;
    font-size: 0.9rem;
    line-height: 1.7;
}

#detailText .zh-text {
    color: #e0e0e0;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

#detailText .en-text {
    color: #888;
    font-size: 0.8rem;
    font-style: italic;
    border-top: 1px solid #2a2a4a;
    padding-top: 8px;
    margin-top: 4px;
}

/* === 滚动条 === */
#detailPanel::-webkit-scrollbar {
    width: 4px;
}

#detailPanel::-webkit-scrollbar-thumb {
    background: #3a3a5a;
    border-radius: 2px;
}

/* === 响应式 === */
@media (max-width: 600px) {
    header { padding: 10px 12px; }
    header h1 { font-size: 1.2rem; }
    .controls { gap: 4px; }
    .controls button, .controls select {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    #detailPanel {
        width: 260px;
        right: 10px;
        top: 10px;
    }
}
