*, *::before, *::after { box-sizing: border-box; }
:root {
    --bg: #f6f4ef; --fg: #2b2b2b; --muted: #7a7366;
    --accent: #8b5e3c; --accent-2: #c9a97a; --card: #fff; --border: #e5dfd3;
    --danger: #b0413e;
}
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, "PT Sans", sans-serif;
       background: var(--bg); color: var(--fg); line-height: 1.5; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

.site-header { background: var(--fg); color: #fff; }
.header-inner { display: flex; align-items: center; gap: 24px; padding: 14px 20px; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.main-nav { display: flex; gap: 16px; flex: 1; }
.main-nav a { color: #e8e2d4; text-decoration: none; }
.main-nav a:hover { color: #fff; }
.user-nav { display: flex; align-items: center; gap: 12px; }
.user-nav a { color: #e8e2d4; text-decoration: none; }
.inline { display: inline; margin: 0; }
.link-btn { background: none; border: 0; color: #e8e2d4; cursor: pointer;
            padding: 0; font: inherit; }

main.container { padding: 32px 20px; min-height: 60vh; }
h1 { font-size: 1.7rem; margin: 0 0 20px; }
h2 { font-size: 1.25rem; margin: 28px 0 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px;
        padding: 20px; text-align: center; }
.card .num { font-size: 2rem; font-weight: 700; color: var(--accent); }
.card .lbl { color: var(--muted); font-size: .9rem; }

.birthday-list { list-style: none; padding: 0; }
.birthday-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.birthday-list a { color: var(--accent); text-decoration: none; }

.search-form { display: flex; gap: 8px; margin-bottom: 24px; }
.search-form input { flex: 1; padding: 10px 14px; border: 1px solid var(--border);
                     border-radius: 8px; font-size: 1rem; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 8px;
         padding: 10px 18px; font: inherit; cursor: pointer; }
button:hover { background: #6f4930; }

.people-grid { list-style: none; padding: 0; display: grid;
               grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.person-card { background: var(--card); border: 1px solid var(--border);
               border-radius: 10px; overflow: hidden; }
.person-card a { color: inherit; text-decoration: none; display: block; padding: 16px; }
.person-card:hover { border-color: var(--accent-2); }
.avatar { width: 60px; height: 60px; border-radius: 50%; background: var(--accent-2);
          color: #fff; display: flex; align-items: center; justify-content: center;
          font-size: 1.6rem; font-weight: 700; margin-bottom: 10px; }
.avatar-lg { width: 110px; height: 110px; border-radius: 50%; background: var(--accent-2);
             color: #fff; display: flex; align-items: center; justify-content: center;
             font-size: 3rem; font-weight: 700; flex-shrink: 0; }
.person-card .name { font-weight: 600; }
.person-card .dates { color: var(--muted); font-size: .9rem; margin-top: 4px; }

.person-header { display: flex; gap: 24px; align-items: center;
                 background: var(--card); border: 1px solid var(--border);
                 border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.person-header h1 { margin: 0; }
.dates { color: var(--muted); }
.muted { color: var(--muted); }

section { background: var(--card); border: 1px solid var(--border);
          border-radius: 12px; padding: 20px; margin-bottom: 16px; }
section h2:first-child { margin-top: 0; }
section ul { padding-left: 20px; margin: 0; }
section ul li { padding: 4px 0; }
section a { color: var(--accent); text-decoration: none; }
section a:hover { text-decoration: underline; }

.login-box { max-width: 380px; margin: 40px auto; background: var(--card);
             border: 1px solid var(--border); border-radius: 12px; padding: 28px; }
.login-box label { display: block; margin-bottom: 14px; font-size: .95rem; }
.login-box input { width: 100%; padding: 10px 14px; border: 1px solid var(--border);
                   border-radius: 8px; margin-top: 6px; font: inherit; }
.login-box button { width: 100%; }
.error { background: #fdeaea; color: var(--danger); padding: 10px 14px;
         border-radius: 8px; margin-bottom: 14px; }

.site-footer { color: var(--muted); text-align: center; padding: 32px 20px;
               border-top: 1px solid var(--border); font-size: .9rem; }


/* Админка */
.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.admin-table th, .admin-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { background: #f0ece1; font-weight: 600; }
.admin-table a { color: var(--accent); text-decoration: none; }
.admin-table a:hover { text-decoration: underline; }

.admin-form { background: var(--card); padding: 24px; border: 1px solid var(--border); border-radius: 8px; max-width: 800px; }
.form-row { display: flex; gap: 20px; margin-bottom: 16px; }
.form-row label { flex: 1; }
.admin-form input[type="text"], .admin-form input[type="date"], .admin-form select, .admin-form textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font: inherit; margin-top: 4px;
}
.admin-form textarea { resize: vertical; }
.btn { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; padding: 10px 18px; border-radius: 8px; border: none; cursor: pointer; font: inherit; }
.btn:hover { background: #6f4930; }    

.relation-box { background: var(--card); padding: 20px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 20px; }
.relation-box h3 { margin-top: 0; margin-bottom: 15px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.relation-box ul { list-style: none; padding: 0; margin: 0; }

/* Галерея */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.gallery-item {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

a.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.gallery-item img {
    width: 100%;
    height: 200px; /* Фиксированная высота для ровной сетки */
    object-fit: cover; /* Обрезает края, сохраняя пропорции */
    display: block;
}

/* Лайтбокс */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 15, 15, 0.92);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
    z-index: 10; /* Картинка ниже кнопок */
    position: relative;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 45px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10000;
    line-height: 1;
}

.lightbox-close {
    color: #c9a97a;
    z-index: 9999; /* Крестик тоже наверху */
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 50px;
    cursor: pointer;
    padding: 20px;
    user-select: none;
    transition: color 0.2s, background 0.2s;
    border-radius: 50%;
    z-index: 9999; /* Кнопки строго наверху */
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-nav:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

@media (max-width: 768px) {
    .lightbox-nav { font-size: 30px; padding: 10px; }
    .lightbox-prev { left: 5px; }
    .lightbox-next { right: 5px; }
    .lightbox-close { top: 10px; right: 20px; font-size: 35px; }
}


