/* =========================================
   /public/css/styles.css — Генеалогическое древо
   Оформление: градиентный фон, светлые карточки, фиолетовые акценты
   ========================================= */

:root {
  /* Цветовая палитра */
  --bg-page: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --bg-surface: rgba(255, 255, 255, 0.95);
  --bg-card: #ffffff;
  --bg-dark: #1e293b;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-accent: #6366f1;
  --text-accent-light: #818cf8;
  --photo-active: #6366f1;
  --photo-active-light: #818cf8;
  --photo-deactive: #64748b;
  --photo-deactive-light: #979faa;
  
  /* Линии */
  --line-color: #94a3b8;
  --line-marriage: #ec4899;
  --line-width: 3px;
  
  /* Размеры */
  --generation-gap: 140px;
  --sibling-gap: 40px;
  --couple-gap: 20px;
  --card-width: 180px;
  --card-padding: 16px;
  --photo-size: 80px;
  --border-radius-base: 12px;
  --border-radius-small: 8px;
  
  /* Эффекты */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --card-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Базовые стили --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1 0 auto; /* занимает всё свободное пространство, не ломая panZoom */
  position: relative;
  min-height: 0; /* важно для корректной работы flex-контейнера */
}

/* --- Шапка --- */
header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  color: white;
  font-size: 1.5rem;
  margin: 0;
}

/* --- Панель авторизации --- */
.auth-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.3rem 1rem;
  border-radius: var(--border-radius-base);
}

.user-info span {
  color: white;
  font-weight: 500;
}

.auth-buttons {
  display: flex;
  gap: 0.8rem;
}

/* --- Кнопки в шапке (светлые на прозрачном фоне) --- */
.auth-buttons .button-small,
.user-info .button-small {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.auth-buttons .button-small:hover,
.user-info .button-small:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ========== НОВАЯ КОМПАКТНАЯ ПАНЕЛЬ ========== */
.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

/* Правая часть шапки — прижимаем к правому краю */
.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: auto;
}

.controls-group {
    display: flex;
    align-items: flex-end;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.control-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.7);
}

.control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Селекторы — сохраняем прежнее оформление */
.tree-select,
#tree-select,
.root-select,
#root-person-select {
    padding: 6px 12px;
    border-radius: var(--border-radius-base);
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
}

.tree-select option,
#tree-select option,
.root-select option,
#root-person-select option {
    background: #1e293b;
    color: white;
}

/* Кнопка редактирования дерева */
.edit-tree-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius-base);
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.edit-tree-btn img {
    width: 18px;
    height: 18px;
}

.edit-tree-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Переключатели режима */
.mode-buttons {
    display: flex;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
}

.mode-radio {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
}

.mode-radio input {
    accent-color: #6366f1;
    margin: 0;
}

.mode-radio:has(input:checked) {
    color: white;
    font-weight: 500;
}

/* скрываем старый editor-link */
.editor-link {
    display: none !important;
}

/* --- Селектор дерева --- */
.branch-selector {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.branch-selector label {
  font-weight: 500;
  color: white;
}

.branch-selector select {
  padding: 6px 12px;
  border-radius: var(--border-radius-base);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
}

.branch-selector select option {
  background: #1e293b;
  color: white;
}

/* --- Режим отображения --- */
.mode-selector {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.3rem 1rem;
  border-radius: var(--border-radius-base);
}

.mode-label {
  font-weight: 500;
  color: white;
}

.mode-selector label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8);
}

.mode-selector input[type="radio"] {
  accent-color: #6366f1;
}

.mode-selector label:has(input:checked) {
  color: white;
}

/* Селектор корневого человека */
#root-person-select {
    padding: 6px 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
}

#root-person-select option {
    background: #1e293b;
    color: white;
}

/* --- Ссылка на редактор --- */
.editor-link {
  margin-left: 0.5rem;
}

.editor-link a {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  text-decoration: none;
  padding: 0.3rem 1rem;
  border-radius: var(--border-radius-base);
  transition: all 0.2s;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.editor-link a:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* =========================================
   МОБИЛЬНОЕ МЕНЮ (ГАМБУРГЕР)
   ========================================= */
/* Оверлей для мобильного меню */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    display: none;
}

.mobile-menu-overlay.active {
    display: block;
}

/* Кнопка гамбургера */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
}

.hamburger-btn span {
    display: block;
    width: 100%;
    height: 3px;
    background: white;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.hamburger-btn.active span:nth-child(1) {
    transform: translateY(10px) rotate(45deg);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: translateY(-11px) rotate(-45deg);
}


/* Мобильное меню (выезжающее) */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: linear-gradient(145deg, #1e1b4b 0%, #2e1065 100%);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.4);
    z-index: 1002;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    border-radius: 0;
}
.mobile-menu.open {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(139, 92, 246, 0.3);
    background: rgba(0, 0, 0, 0.3);
}

.mobile-menu-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #c4b5fd;
    letter-spacing: 0.5px;
}

.mobile-menu-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #a78bfa;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.mobile-menu-close:hover {
    background: rgba(139, 92, 246, 0.3);
    color: white;
}

.mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.2);
}

/* Стили для контролов внутри мобильного меню */
.mobile-menu-content .controls-group {
    display: flex !important;
    flex-direction: column;
    gap: 1.5rem;
    align-items: stretch;
}

.mobile-menu-content .control-item {
    margin-bottom: 0;
    width: 100%;
    margin-top: 1.5rem;
}
.mobile-menu-content .control-item:first-child {
  margin-top: 0;
}

.mobile-menu-content .control-label {
    color: #a78bfa;
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.mobile-menu-content .tree-select,
.mobile-menu-content .root-select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(139, 92, 246, 0.5);
    color: #e2e8f0;
    width: 100%;
    padding: 12px 12px;
    font-size: 0.9rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-menu-content .tree-select:hover,
.mobile-menu-content .root-select:hover {
    border-color: #8b5cf6;
    background: rgba(0, 0, 0, 0.6);
}

.mobile-menu-content .tree-select option,
.mobile-menu-content .root-select option {
    background: #1e1b4b;
    color: #e2e8f0;
}

.mobile-menu-content .edit-tree-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(139, 92, 246, 0.5);
    padding: 10px 12px;
    border-radius: 12px;
    transition: all 0.2s;
}

.mobile-menu-content .edit-tree-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: #8b5cf6;
}

.mobile-menu-content .edit-tree-btn img {
    filter: brightness(0) invert(1);
}

.mobile-menu-content .mode-buttons {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.75rem;
    gap: 1rem;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    border: 1px solid rgba(139, 92, 246, 0.5);
}

.mobile-menu-content .mode-radio {
    color: #cbd5e1;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 20px;
    transition: all 0.2s;
}

.mobile-menu-content .mode-radio input {
    accent-color: #8b5cf6;
    margin-right: 6px;
}

.mobile-menu-content .mode-radio:has(input:checked) {
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.2);
    font-weight: 500;
}

.mobile-menu-footer {
    padding: 1rem;
    border-top: 1px solid rgba(139, 92, 246, 0.3);
    background: rgba(0, 0, 0, 0.3);
}

.apply-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    border: none;
    border-radius: 40px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

.apply-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.5);
}

.apply-btn:active {
    transform: translateY(0);
}

/* Адаптивность меню */
@media (max-width: 768px) {
    /* Показываем кнопку гамбургера */
    .hamburger-btn {
        display: flex;
    }
    
    /* Скрываем оригинальные контролы в шапке */
    .header-right > .controls-group {
        display: none !important;
    }
    
    /* Упрощаем шапку */
    header {
        flex-direction: row !important;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
    }
    
    .header-right {
        margin-left: 0;
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
    }
    
    .logo-area h1 {
        font-size: 1.1rem;
    }
    
    .logo-icon {
        width: 28px;
        height: 28px;
    }
    
    /* Уменьшаем аватар */
    .user-avatar {
        width: 36px;
        height: 36px;
    }
    
    .user-avatar img {
        width: 28px;
        height: 28px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .logo-area h1 {
        font-size: 0.9rem;
    }
    
    .mobile-menu {
        width: 100%;
        max-width: 100%;
    }
}

/* ========== ПРИВЕТСТВЕННЫЙ ЭКРАН ========== */
.welcome-screen {
  text-align: center;
  padding: 3rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  margin: 2rem auto;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.welcome-screen h2 {
  color: var(--text-accent);
  margin-bottom: 1rem;
}

.welcome-screen p {
  color: var(--text-secondary);
}

/* ========== МЕНЮ ПОЛЬЗОВАТЕЛЯ (АВАТАР С ДРОПДАУНОМ) ========== */
.auth-container {
    display: flex;
    align-items: center;
}

.user-menu {
    position: relative;
}

.user-avatar {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.user-avatar:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.6);
}

.user-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.user-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: white;
    border-radius: var(--border-radius-base);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.dropdown-user-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.dropdown-user-email {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 4px;
}

.dropdown-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.dropdown-item:hover {
    background: #f1f5f9;
}

.dropdown-item:active {
    background: #e2e8f0;
}

/* Оверлей для закрытия дропдауна при клике вне */
.dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    display: none;
}

.dropdown-overlay.active {
    display: block;
}

/* Лоадер над блоком дерева */
.tree-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(153, 109, 255, 0.75);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 16px;
}

.tree-loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: tree-spinner-rotate 0.8s linear infinite;
}

.tree-loader-message {
    margin-top: 12px;
    font-size: 0.875rem;
    color: #475569;
    text-align: center;
}

.tree-loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 20px 28px;
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

@keyframes tree-spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

/* --- Контейнер древа --- */
#tree-container {
  position: relative;
  width: 100%;
  height: calc(100vh - 85px); /* фиксированная высота */
  min-height: 400px;
  overflow: hidden; /* важно: скрываем overflow здесь */
  padding: 0; /* убираем padding, чтобы viewport занимал всё место */
}

@media (max-height: 600px) {
    main {
        min-height: 400px;
    }
    
    #tree-container {
        height: 400px;
    }
}

/* --- Viewport для Pan/Zoom --- */
.tree-viewport {
  width: 100%;
  height: 100%; /* ← КЛЮЧЕВОЙ МОМЕНТ: занимаем всю высоту родителя */
  overflow: hidden; /* скрываем скролл, т.к. panZoom управляет трансформацией */
  cursor: grab;
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 24px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.2s ease;
}

.tree-viewport:active {
  cursor: grabbing;
}

.tree-viewport::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.tree-viewport::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.tree-viewport::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.tree-pan-wrapper {
  transform-origin: 0 0;
  transition: transform 0.1s ease-out;
  padding: 2rem;
  position: relative;
  min-width: max-content;
}

/* --- Основное дерево --- */
.tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--generation-gap);
  padding: 2rem 0;
  min-width: max-content;
  width: max-content;
}

/* --- Семейная ячейка --- */
.family-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  animation: fadeInUp 0.5s ease-out forwards;
  opacity: 0;
  min-width: min-content;
}

.family-unit:nth-child(1) { animation-delay: 0.05s; }
.family-unit:nth-child(2) { animation-delay: 0.1s; }
.family-unit:nth-child(3) { animation-delay: 0.15s; }
.family-unit:nth-child(4) { animation-delay: 0.2s; }
.family-unit:nth-child(5) { animation-delay: 0.25s; }
.family-unit:nth-child(6) { animation-delay: 0.3s; }

/* --- Пара супругов --- */
.couple {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--couple-gap);
  position: relative;
  margin-bottom: 30px;
}

.single-parent {
  position: relative;
  margin-bottom: 30px;
  display: flex;
  justify-content: center;
}

/* --- Группа детей --- */
.children-group {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: var(--sibling-gap);
  position: relative;
  margin-top: 20px;
  flex-wrap: nowrap;
  min-width: min-content;
}

/* --- Карточка человека --- */
.person-card {
  background: var(--bg-card);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  width: var(--card-width);
  text-align: center;
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  z-index: 1;
  border: 2px solid transparent;
}

.person-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-xl);
  border-color: var(--text-accent);
}

.person-card.active {
  border-color: var(--text-accent);
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
  transform: translateY(-4px);
}

.person-card.dimmed {
  opacity: 0.3;
  filter: grayscale(0.8);
}

/* --- Особые состояния --- */
.person-card.deceased .person-photo {
  border: 4px solid var(--photo-deactive);
}

.person-card.deceased .person-name {
  color: var(--text-secondary);
}

.person-card.living {
  border-bottom: 3px solid #10b981;
}

/* --- Фотография --- */
.person-photo {
  width: var(--photo-size);
  height: var(--photo-size);
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--photo-active);
  box-shadow: var(--shadow-md);
  margin: 0 auto 12px;
  display: block;
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
}

.person-photo-placeholder {
  width: var(--photo-size);
  height: var(--photo-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--photo-active) 0%, var(--photo-active-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 2rem;
  color: white;
  box-shadow: var(--shadow-md);
}

/* --- Информация в карточке --- */
.person-firstname {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-accent);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.person-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
}

.person-dates {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.person-role {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-accent);
  background: #eef2ff;
  padding: 4px 12px;
  border-radius: 20px;
  margin-top: 8px;
}

.person-address {
  font-size: 0.75rem;
  color: var(--text-accent);
  margin-top: 6px;
  background: #f1f5f9;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
}

/* --- Линия брака --- */
.marriage-line {
  width: 50px;
  height: 4px;
  background: linear-gradient(90deg, var(--line-marriage) 0%, #f472b6 100%);
  border-radius: 2px;
  position: relative;
  box-shadow: 0 2px 4px rgba(236, 72, 153, 0.3);
}

.marriage-line::after {
  content: '♥';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--line-marriage);
  font-size: 14px;
  background: var(--bg-card);
  padding: 0 6px;
  border-radius: 50%;
  font-weight: bold;
}

/* --- Блок партнёров в карточке --- */
.partners-block {
  margin-top: 12px;
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
}

.partners-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-accent);
  margin-bottom: 8px;
}

.partner-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.partner-nav button {
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.partner-nav button:hover:not(:disabled) {
  background: #e2e8f0;
}

.partner-nav button:disabled {
  opacity: 0.3;
  cursor: default;
}

.partner-details {
  flex: 1;
  text-align: center;
}

.partner-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.partner-photo img, .partner-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #c7d2fe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.partner-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.partner-role {
  font-size: 0.7rem;
  color: var(--text-accent);
}

.partner-dates {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.no-partner {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 8px;
  font-style: italic;
}

/* --- Информационная панель --- */
.info-panel {
  position: fixed;
  right: -480px;
  top: 50%;
  transform: translateY(-50%);
  width: 480px;
  max-width: 90vw;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: 24px 0 0 24px;
  padding: 24px;
  overflow-y: auto;
  max-height: 90vh;
  box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

.info-panel.visible {
  right: 0;
}

.close-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-panel:hover {
  background: #e2e8f0;
  transform: rotate(90deg);
}

/* --- Анимации --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.person-card:hover .person-photo {
  animation: pulse 0.6s ease-in-out;
}

/* --- Адаптивность --- */
@media (max-width: 1024px) {
  :root {
    --generation-gap: 120px;
    --sibling-gap: 30px;
    --couple-gap: 16px;
    --card-width: 160px;
    --photo-size: 70px;
  }
}

@media (max-width: 480px) {
  :root {
    --generation-gap: 90px;
    --card-width: 120px;
    --photo-size: 50px;
  }

  .person-name {
    font-size: 0.8rem;
  }
  .person-dates {
    font-size: 0.7rem;
  }
  .partner-name {
    font-size: 0.7rem;
  }
  .person-address {
    font-size: 0.7rem;
    padding: 2px 4px;
  }
  .person-role {
    font-size: 0.65rem;
    padding: 3px 8px;
  }
  .partner-role {
    font-size: 0.65rem;
  }

  .branch-selector label,
  .branch-info {
    font-size: 0.75rem;
  }
}

/* ========== УВЕЛИЧЕННЫЙ ПРИВЕТСТВЕННЫЙ ЭКРАН >>>>>>>>> ========== */
.welcome-screen {
    max-width: 700px;
    padding: 2.5rem;
    margin: 2rem auto;
}

.welcome-tree-icon {
    width: 120px;
    height: 120px;
    margin-bottom: 1.5rem;
}

.welcome-screen h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.welcome-greeting {
    font-size: 1.1rem;
    color: #4f46e5;
    font-weight: 500;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
    display: inline-block;
}

.welcome-description {
    text-align: left;
    color: #334155;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
}

.features-list {
    text-align: left;
    margin: 1.5rem 0;
    padding: 0;
    list-style: none;
}

.features-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.features-list li:last-child {
    border-bottom: none;
}

.feature-icon {
    font-size: 1.5rem;
    min-width: 40px;
    text-align: center;
}

.feature-text {
    flex: 1;
}

.feature-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.feature-desc {
    font-size: 0.85rem;
    color: #64748b;
}

.author-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e2e8f0;
    text-align: center;
}

.author-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.author-contact {
    font-size: 0.8rem;
    color: #64748b;
}

.author-contact a {
    color: #4f46e5;
    text-decoration: none;
}

.author-contact a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .welcome-screen {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .welcome-tree-icon {
        width: 80px;
        height: 80px;
    }
    
    .welcome-screen h1 {
        font-size: 1.5rem;
    }
    
    .features-list li {
        flex-direction: column;
        text-align: center;
    }
    
    .feature-icon {
        font-size: 2rem;
    }
}

/* ========== <<<<<<<< УВЕЛИЧЕННЫЙ ПРИВЕТСТВЕННЫЙ ЭКРАН ========== */

/* ========== ФУТЕР ========== */
footer {
  background: var(--bg-dark);
  text-align: center;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  width: 100%;
  margin-top: auto;
}
@media (max-width: 640px) {
    footer {
      padding: 0.25rem 1rem;
      font-size: 0.7rem;
    }
}
/* ========== <<<<<<<< ФУТЕР ========== */

/* ========== СООБЩЕНИЯ О ПУСТОМ ДЕРЕВЕ И ОШИБКАХ ========== */
.empty-tree-message,
.error-message {
    max-width: 600px;
    margin: 3rem auto;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    text-align: center;
    animation: fadeInUp 0.5s ease-out;
}

.empty-tree-icon,
.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-tree-message h3,
.error-message h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.empty-tree-message p,
.error-message p {
    font-size: 1rem;
    color: #475569;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.empty-tree-message .button-link {
    display: inline-block;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 40px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.empty-tree-message .button-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.empty-tree-features {
    text-align: left;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.empty-tree-features h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.empty-tree-features ul {
    list-style: none;
    padding: 0;
}

.empty-tree-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.85rem;
    color: #475569;
}

.error-message .button-link {
    display: inline-block;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 40px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
    cursor: pointer;
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
}

.error-message .button-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* ========== <<<<<<<< СООБЩЕНИЯ О ПУСТОМ ДЕРЕВЕ И ОШИБКАХ ========== */


/* ========== КАСТОМНОЕ МОДАЛЬНОЕ ОКНО ========== */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.custom-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.custom-modal-container {
    position: relative;
    background: white;
    border-radius: 24px;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.custom-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.custom-modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.custom-modal-close:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.custom-modal-body {
    padding: 1.5rem;
    color: #334155;
    line-height: 1.5;
}

.custom-modal-body p {
    margin: 0;
}

.custom-modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    border-top: 1px solid #f1f5f9;
}

/* Типы окон */
.custom-modal-error .custom-modal-header {
    background: #fef2f2;
    border-bottom-color: #fecaca;
}

.custom-modal-error .custom-modal-header h3 {
    color: #dc2626;
}

.custom-modal-success .custom-modal-header {
    background: #f0fdf4;
    border-bottom-color: #bbf7d0;
}

.custom-modal-success .custom-modal-header h3 {
    color: #16a34a;
}

.custom-modal-warning .custom-modal-header {
    background: #fffbeb;
    border-bottom-color: #fde68a;
}

.custom-modal-warning .custom-modal-header h3 {
    color: #d97706;
}

/* Кнопки */
.custom-modal-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.custom-modal-btn-primary {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
}

.custom-modal-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.custom-modal-btn-secondary {
    background: #f1f5f9;
    color: var(--text-primary);
    border: 1px solid #e2e8f0;
}

.custom-modal-btn-secondary:hover {
    background: #e2e8f0;
}

.custom-modal-btn-danger {
    background: #dc2626;
    color: white;
}

.custom-modal-btn-danger:hover {
    background: #b91c1c;
}

@media (max-width: 640px) {
    .custom-modal-footer {
        flex-direction: column;
    }
    
    .custom-modal-btn {
        width: 100%;
        text-align: center;
    }
}

/* ========== <<<<<<<< КАСТОМНОЕ МОДАЛЬНОЕ ОКНО ========== */

/* ========== МОДАЛЬНОЕ ОКНО ОБРЕЗКИ ФОТО (CROP) ========== */
.crop-modal .modal-content {
    max-width: 550px;
    padding: 0;
    overflow: hidden;
}

.crop-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.crop-modal .modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.crop-modal .close-crop {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
    margin: 0;
    float: none;
}

.crop-modal .close-crop:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.crop-modal .modal-body {
    padding: 1.5rem;
}

.crop-modal .crop-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1e293b;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.crop-modal .crop-container canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    cursor: crosshair;
}

.crop-modal .crop-help-text {
    text-align: center;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 1rem;
}

.crop-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

.crop-modal .modal-footer .button-std {
    width: auto;
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
}

.crop-modal .modal-footer .cancel-crop-btn {
    background: #f1f5f9;
    color: var(--text-primary);
}

.crop-modal .modal-footer .cancel-crop-btn:hover {
    background: #e2e8f0;
}

/* ========== <<<<<<<<<< МОДАЛЬНОЕ ОКНО ОБРЕЗКИ ФОТО (CROP) ========== */

/* --- Печать --- */
@media print {
  body {
    background: white;
  }

  header {
    display: none;
  }

  .tree-viewport {
    cursor: default;
    box-shadow: none;
    backdrop-filter: none;
  }

  .info-panel {
    display: none;
  }
}
/* селекторы на панели */
@media (max-width: 1024px) {
    .controls-group {
        gap: 1rem;
    }
    
    .control-item {
        min-width: 130px;
    }
}