body {
    font-family: system-ui, sans-serif;
    margin: 0;
    font-size: 14px;
    background-size: 20px 20px;
    background-color: var(--bg-page);
    background-image: radial-gradient(var(--dot-color) 1px,
            transparent 1px);
    color: var(--text-main);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 10px;
    margin: 20px 20px 0 20px;
}

header>.title {
    display: flex;
    flex-direction: column;
}

header>.title>h1 {
    margin: 0;
    font-size: 24px;
    color: var(--color);
}

header>.title>span {
    color: var(--color);
    opacity: 0.7;
    margin: 3px 0;
    font-size: 12px;
}

header>.buttons {
    display: flex;
    gap: 8px;
}

header>.buttons>button,
header>.buttons>a {
    cursor: pointer;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-weight: 600;
    transition: opacity 0.2s;
    color: var(--color);
    background: var(--bg-card);
    text-decoration: none;
    font-size: 12px;
}

header>.buttons>a {
    background: var(--primary);
    color: var(--text-light);
    min-width: 70px;
    text-align: center;
}

@media (hover: hover) {

    header>.buttons>a:hover,
    header>.buttons>button:hover {
        opacity: 0.8;
    }
}

header>.buttons>.btn-save {
    background: var(--save);
    color: var(--text-light);
    margin-right: 10px;
}

@media(max-width: 750px) {
    header>.buttons {
        flex-direction: column;
        margin-left: 20px;
    }

    header>.buttons>button {
        width: 100%;
    }
}

/* Стили для легенды */
#legend {
    background: var(--bg-container);
    position: absolute;
    bottom: 20px;
    left: 20px;
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    opacity: 0.95;
    font-size: 13px;
    color: var(--color);
    z-index: 1000;
    border: 1px solid var(--border-light);
    gap: 10px;
    display: flex;
    flex-direction: column;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 12px;
}

.legend-color-box {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    margin-right: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    /* Легкая обводка */
}

/* Переиспользуем существующие цвета */
.legend-color-box.male {
    background-color: #90caf9;
    /* Глубокий синий */
}

.legend-color-box.female {
    background-color: #f48fb1;
    /* Насыщенный розовый */
}

.legend-color-box.nation {
    background-color: #ffd46e;
    /* Темно-зеленый */
}

/* Стили для линий в легенде */
.legend-link-parent {
    stroke: #444;
    stroke-width: 2px;
    stroke-opacity: 1;
}

.legend-link-marriage {
    stroke: #d81b60;
    stroke-width: 3px;
    stroke-dasharray: 4, 4;
    stroke-opacity: 1;
}

.legend-link-ancestor {
    stroke: #4caf50;
    stroke-width: 3px;
    stroke-dasharray: 4, 4;
    stroke-opacity: 1;
}

.legend-link-levirate {
    stroke: #7e22ce;
    stroke-width: 3px;
    stroke-dasharray: 4, 4;
    stroke-opacity: 1;
}

/* Область графа */
#tree-container {
    flex-grow: 1;
    cursor: grab;
    height: calc(100vh - 84px);
}

@media(max-width: 750px) {
    #tree-container {
        height: calc(100vh - 142px);
    }
}

#tree-container:active {
    cursor: grabbing;
}

/* Стили связей */
.node:hover circle {
    r: 15;
    filter: brightness(1.2);
}

/* Боковая панель */
#side-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    height: fit-content;
    width: 380px;
    overflow-y: auto;
    display: none;
    border-left: 1px solid #eee;
    padding: 20px;
    z-index: 1000;
    background: var(--bg-container);
    border-radius: 10px;
    box-shadow: var(--shadow);
    opacity: 0.95;
    font-size: 13px;
    color: var(--color);
    border: 1px solid var(--border-light);
}

@media (max-width: 500px) {
    #legend {
        bottom: 10px;
        left: 10px;
    }

    #side-panel {
        width: calc(100% - 20px - 40px);
        bottom: 10px;
        right: 10px;
    }
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    border: 0;
    background: var(--bg-secondary);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    justify-content: center;
}

.close-btn>svg {
    width: 16px;
    height: 16px;
    fill: var(--color);
}

.gender-tag {
    width: fit-content;
    display: flex;
    padding: 6px 12px;
    border-radius: 20px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 15px;
    align-items: center;
    justify-content: center;
}

.male {
    background-color: #2196f3;
}

.female {
    background-color: #e91e63;
}

.nation {
    background-color: #ffd46e;
}

.tag {
    background: var(--bg-secondary);
    color: var(--color);
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 12px;
    margin-right: 5px;
    margin-bottom: 5px;
    display: inline-block;
}

h2 {
    margin-top: 0;
    color: var(--color);
}

.info-label {
    font-weight: bold;
    color: var(--color);
    opacity: 1;
    display: block;
    margin-top: 15px;
    font-size: 14px;
}

.info-value {
    color: var(--color);
    opacity: 0.8;
    margin: 0;
    font-size: 12px;
}

hr {
    border: 0;
    border-top: 1px solid var(--color);
    margin: 20px 0;
}

/* Контрастные связи */
.link-parent {
    stroke: var(--color);
    /* Сделали темнее */
    stroke-opacity: 0.6;
    stroke-width: 2px;
}

.link-marriage {
    stroke: #d81b60;
    /* Насыщенный розовый */
    stroke-opacity: 0.9;
    stroke-width: 3px;
    stroke-dasharray: 8, 4;
}

.link-ancestor {
    stroke: #4caf50;
    /* Глубокий зеленый */
    stroke-opacity: 0.8;
    stroke-width: 3px;
    stroke-dasharray: 4, 4;
}

.link-levirate {
    stroke: #7e22ce;
    /* Насыщенный розовый */
    stroke-opacity: 0.9;
    stroke-width: 3px;
    stroke-dasharray: 8, 4;
}

/* Контрастные узлы */
.node circle {
    stroke: var(--color);
    stroke-width: 2.5px;
    filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.2));
}

.node text {
    font-size: 14px;
    font-weight: 600;
    fill: var(--color);
    paint-order: stroke;
    stroke: var(--bg-page);
    stroke-width: 4px;
    stroke-linecap: round;
    stroke-linejoin: round;
}