:root {
    --bg-color: #f6f8fc;
    --panel: #ffffff;
    --node-fill: #ffffff;
    --node-stroke: #1f6bff;
    --link-stroke: #c2cfe4;
    --text-color: #0b1b33;
    --ink-soft: #46566f;
    --mut: #8390a6;
    --line: #e4eaf3;
    --blue-soft: #e9f1ff;
    --blue-deep: #0a3fb0;
    --highlight: #1f6bff;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Archivo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

#scene {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.35;
    transition: opacity 1.6s ease;
}

#main-header,
#chart-container svg {
    transition: opacity 1.1s ease 0.15s;
}

body.booting #main-header,
body.leaving #main-header {
    opacity: 0;
}

body.leaving #chart-container svg {
    opacity: 0 !important;
}

#chart-container {
    position: relative;
    z-index: 1;
    width: 100vw;
    height: 100vh;
}

svg {
    width: 100%;
    height: 100%;
    cursor: grab;
}

svg:active {
    cursor: grabbing;
}

.link {
    fill: none;
    stroke: var(--link-stroke);
    stroke-width: 1.5px;
    transition: stroke 0.3s, stroke-width 0.3s;
}

.link:hover {
    stroke: var(--node-stroke);
    stroke-width: 2.5px;
}

.node rect {
    fill: var(--node-fill);
    stroke: var(--node-stroke);
    stroke-width: 1px;
    transition: all 0.3s ease;
    rx: 4px;
}

.node:hover rect {
    stroke: var(--blue-deep);
    stroke-width: 3px;
    cursor: pointer;
}

.node:hover image {
    cursor: pointer;
    filter: brightness(1.05);
}

.node text {
    font-size: 13px;
    font-weight: 600;
    fill: var(--text-color);
    pointer-events: none;
}

#main-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(246, 248, 252, 0.9);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 0 20px;
    z-index: 100;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 10px rgba(11, 27, 51, 0.05);
    box-sizing: border-box;
}

#main-header h1 {
    margin: 0;
    font-size: 18px;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 800;
}

.home-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.home-button:hover {
    color: var(--node-stroke);
    border-color: var(--node-stroke);
    background: var(--blue-soft);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-button {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--blue-soft);
    border: 1px solid #d4e4ff;
    border-radius: 999px;
    color: var(--blue-deep);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.back-button:hover {
    background: #dbe8ff;
    color: var(--node-stroke);
}

.back-button.hidden {
    display: none;
}

.tooltip {
    position: fixed;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.97);
    color: var(--text-color);
    border-radius: 8px;
    border-left: 3px solid var(--node-stroke);
    font-size: 13px;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 101;
    max-width: 260px;
    line-height: 1.5;
    box-shadow: 0 8px 30px rgba(11, 27, 51, 0.15);
    backdrop-filter: blur(8px);
}

.tooltip.hidden {
    opacity: 0;
}

.info-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    border-left: 1px solid var(--line);
    box-shadow: -5px 0 24px rgba(11, 27, 51, 0.12);
    z-index: 200;
    transition: right 0.3s ease-in-out;
    padding: 240px 20px 20px 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    backdrop-filter: blur(10px);
}

.info-panel.open {
    right: 0;
}

#close-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--ink-soft);
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

#close-panel:hover {
    color: var(--highlight);
}

.panel-header-image {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 230px;
    height: 230px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: var(--bg-color);
    box-shadow: 0 4px 14px rgba(11, 27, 51, 0.1);
}

.panel-section {
    margin-bottom: 25px;
}

.panel-title {
    font-size: 24px;
    color: var(--text-color);
    margin-bottom: 10px;
    border-bottom: 1px solid var(--node-stroke);
    padding-bottom: 10px;
    font-weight: 800;
}

.panel-desc {
    font-size: 14px;
    color: var(--ink-soft);
    line-height: 1.5;
}

.panel-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-link {
    display: block;
    padding: 10px;
    background: var(--blue-soft);
    color: var(--blue-deep);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    border-left: 3px solid var(--node-stroke);
}

.panel-link:hover {
    background: #dbe8ff;
}

.no-links {
    font-style: italic;
    color: var(--mut);
    font-size: 13px;
}

.subtree-button {
    display: block;
    width: 100%;
    padding: 9px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 15px;
    transition: color 0.2s, border-color 0.2s;
}

.subtree-button:hover {
    color: var(--node-stroke);
    border-color: var(--node-stroke);
}

.panel-section-header {
    font-size: 14px;
    text-transform: uppercase;
    color: var(--node-stroke);
    margin-bottom: 12px;
    letter-spacing: 1px;
    border-left: 2px solid var(--highlight);
    padding-left: 10px;
    font-weight: 700;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 10px;
}

.stat-item {
    background: var(--bg-color);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    transition: transform 0.2s, border-color 0.2s;
}

.stat-item:hover {
    transform: translateY(-2px);
    border-color: var(--node-stroke);
}

.stat-label {
    font-size: 10px;
    color: var(--mut);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 13px;
    color: var(--text-color);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
