/* ============================================================
   «Родословная» — оформление приложения.
   Палитра: пергамент, глубокий хвойный зелёный, старое золото.
   ============================================================ */

:root {
    --paper: #faf7f1;
    --paper-2: #f3ede3;
    --surface: #ffffff;
    --ink: #1f2320;
    --ink-soft: #4a524c;
    --muted: #837b6f;
    --line: #e2dacd;

    --brand: #2f5d50;
    --brand-dark: #1d3c33;
    --brand-light: #4d8574;
    --accent: #b8873c;
    --accent-light: #e2c48c;

    --danger: #a63636;
    --success: #3d7a52;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(31, 35, 32, .05), 0 8px 24px rgba(31, 35, 32, .07);
    --shadow-lg: 0 2px 6px rgba(31, 35, 32, .08), 0 22px 48px rgba(31, 35, 32, .14);

    --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
    --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html, body {
    font-family: var(--sans);
    background: var(--paper);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.6;
    scroll-behavior: smooth;
}

h1, h2, h3, h4, .serif {
    font-family: var(--serif);
    color: var(--brand-dark);
    letter-spacing: -.01em;
    font-weight: 700;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: var(--brand-dark);
    text-decoration: underline;
}

.text-muted-2 { color: var(--muted); }

/* ---------- Кнопки ---------- */

.btn {
    border-radius: 999px;
    font-weight: 600;
    padding: .55rem 1.35rem;
    border: 1px solid transparent;
    transition: transform .12s ease, box-shadow .2s ease, background-color .2s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary,
.btn-primary:focus {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-accent:hover {
    background: #a3762f;
    border-color: #a3762f;
    color: #fff;
}

.btn-outline-brand {
    border-color: var(--brand);
    color: var(--brand);
    background: transparent;
}

.btn-outline-brand:hover {
    background: var(--brand);
    color: #fff;
}

.btn-ghost {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink-soft);
}

.btn-ghost:hover {
    border-color: var(--brand-light);
    color: var(--brand-dark);
}

.btn-danger-soft {
    border-color: #eec7c7;
    background: #fbeaea;
    color: var(--danger);
}

.btn-danger-soft:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-sm { padding: .3rem .85rem; font-size: .85rem; }

/* ---------- Формы ---------- */

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    padding: .6rem .85rem;
    background: var(--surface);
    color: var(--ink);
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(77, 133, 116, .18);
}

.form-floating > label { color: var(--muted); }

label, .form-label { font-weight: 600; color: var(--ink-soft); font-size: .92rem; }

.validation-message, .text-danger { color: var(--danger); font-size: .875rem; }

/* ---------- Карточки и панели ---------- */

.card, .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel { padding: 1.5rem; }

.panel-title {
    font-family: var(--serif);
    font-size: 1.15rem;
    color: var(--brand-dark);
    margin: 0 0 1rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--line);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: var(--paper-2);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    border-radius: 999px;
    padding: .15rem .7rem;
    font-size: .8rem;
    font-weight: 600;
}

.chip-accent { background: #fdf4e4; border-color: var(--accent-light); color: #8a5f1c; }
.chip-danger { background: #fbeaea; border-color: #eec7c7; color: var(--danger); }
.chip-success { background: #e9f4ed; border-color: #c3e0cf; color: var(--success); }

.alert { border-radius: var(--radius-sm); border: 1px solid var(--line); }

/* ---------- Аватары ---------- */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
    color: #fff;
    font-family: var(--serif);
    font-weight: 700;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-female { background: linear-gradient(135deg, #b98c76, #8a5c46); }
.avatar-unknown { background: linear-gradient(135deg, #9c9a94, #6c6a64); }

.avatar-xs { width: 32px; height: 32px; font-size: .75rem; }
.avatar-sm { width: 44px; height: 44px; font-size: .9rem; }
.avatar-md { width: 64px; height: 64px; font-size: 1.15rem; }
.avatar-lg { width: 132px; height: 132px; font-size: 2.4rem; }

/* ============================================================
   Лендинг
   ============================================================ */

.landing { background: var(--paper); }

.landing-header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
    background: rgba(250, 247, 241, .88);
    border-bottom: 1px solid var(--line);
}

.landing-header .inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: .85rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-dark);
    text-decoration: none;
}

.brand:hover { text-decoration: none; color: var(--brand); }

.brand-mark { width: 34px; height: 34px; flex: none; }

.landing-nav {
    display: flex;
    gap: 1.6rem;
    margin-left: auto;
    font-size: .95rem;
    font-weight: 600;
}

.landing-nav a { color: var(--ink-soft); }
.landing-nav a:hover { color: var(--brand); text-decoration: none; }

.landing-actions { display: flex; gap: .6rem; align-items: center; }

.hero {
    position: relative;
    overflow: hidden;
    padding: 5.5rem 1.5rem 4.5rem;
    background:
        radial-gradient(1000px 420px at 78% -10%, rgba(184, 135, 60, .16), transparent 65%),
        radial-gradient(760px 420px at 8% 0%, rgba(47, 93, 80, .14), transparent 60%);
}

.hero-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 3.5rem;
    align-items: center;
}

.hero h1 {
    font-size: clamp(2.4rem, 5vw, 3.9rem);
    line-height: 1.08;
    margin-bottom: 1.2rem;
}

.hero h1 em { font-style: italic; color: var(--accent); }

.hero-lead {
    font-size: 1.15rem;
    color: var(--ink-soft);
    max-width: 34rem;
    margin-bottom: 2rem;
}

.hero-cta { display: flex; flex-wrap: wrap; gap: .8rem; }

.eyebrow {
    display: inline-block;
    font-size: .78rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1rem;
}

.hero-art {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
}

.hero-art svg { width: 100%; height: auto; display: block; }

.stats-band {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--paper-2);
}

.stats-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 2.2rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    text-align: center;
}

.stat-value {
    font-family: var(--serif);
    font-size: 2.3rem;
    font-weight: 700;
    color: var(--brand-dark);
    line-height: 1;
}

.stat-label {
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin-top: .45rem;
    font-weight: 600;
}

.section { max-width: 1180px; margin: 0 auto; padding: 5rem 1.5rem; }

.section-head { max-width: 46rem; margin-bottom: 3rem; }
.section-head h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); margin-bottom: .8rem; }
.section-head p { color: var(--ink-soft); font-size: 1.05rem; margin: 0; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

.feature {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem 1.75rem;
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease;
}

.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.feature-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(47, 93, 80, .12), rgba(184, 135, 60, .18));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand);
    margin-bottom: 1.1rem;
}

.feature h3 { font-size: 1.2rem; margin-bottom: .55rem; }
.feature p { color: var(--ink-soft); margin: 0; font-size: .97rem; }

.steps { counter-reset: step; display: grid; gap: 1.2rem; }

.step {
    display: flex;
    gap: 1.2rem;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.35rem 1.5rem;
}

.step-num {
    counter-increment: step;
    font-family: var(--serif);
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    background: var(--brand);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex: none;
}

.step-num::before { content: counter(step); }
.step h3 { font-size: 1.05rem; margin: 0 0 .25rem; }
.step p { margin: 0; color: var(--ink-soft); font-size: .95rem; }

.cta-band {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: #fff;
    border-radius: 24px;
    padding: 3.5rem 2.5rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.cta-band h2 { color: #fff; font-size: clamp(1.8rem, 3.4vw, 2.4rem); margin-bottom: .8rem; }
.cta-band p { color: rgba(255, 255, 255, .82); max-width: 38rem; margin: 0 auto 2rem; }

.landing-footer { border-top: 1px solid var(--line); margin-top: 4rem; background: var(--paper-2); }

.landing-footer .inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    color: var(--muted);
    font-size: .9rem;
}

/* ============================================================
   Внутренние страницы
   ============================================================ */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header { background: var(--brand-dark); color: #fff; position: sticky; top: 0; z-index: 40; }

.app-header .inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: .7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.4rem;
}

.app-header .brand { color: #fff; font-size: 1.1rem; }
.app-header .brand:hover { color: var(--accent-light); }

.app-nav { display: flex; gap: .3rem; margin-left: 1rem; flex-wrap: wrap; }

.app-nav a {
    color: rgba(255, 255, 255, .78);
    padding: .4rem .9rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: .93rem;
}

.app-nav a:hover { color: #fff; background: rgba(255, 255, 255, .1); text-decoration: none; }
.app-nav a.active { color: var(--brand-dark); background: var(--accent-light); }

.app-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.app-user .name { color: #fff; font-size: .9rem; font-weight: 600; }

.app-user .logout {
    background: none;
    border: 1px solid rgba(255, 255, 255, .3);
    color: rgba(255, 255, 255, .85);
    border-radius: 999px;
    padding: .3rem .9rem;
    font-size: .85rem;
    cursor: pointer;
}

.app-user .logout:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.app-body { flex: 1; max-width: 1320px; width: 100%; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.page-title { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.page-title h1 { font-size: 1.9rem; margin: 0; }
.page-title .spacer { margin-left: auto; }

/* ---------- Таблицы ---------- */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

table.data { width: 100%; border-collapse: collapse; }

table.data th {
    text-align: left;
    font-size: .78rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--paper-2);
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

table.data td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fbf9f5; }

/* ---------- Список людей ---------- */

.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 1rem; }

.person-card {
    display: flex;
    gap: .9rem;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    color: inherit;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.person-card:hover {
    text-decoration: none;
    color: inherit;
    border-color: var(--brand-light);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.person-card .name { font-weight: 600; line-height: 1.3; }
.person-card .years { font-size: .84rem; color: var(--muted); }

/* ---------- Карточка человека ---------- */

.person-hero {
    display: flex;
    gap: 1.75rem;
    align-items: flex-start;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.person-hero h1 { font-size: 2rem; margin: 0 0 .4rem; }
.person-hero .subtitle { color: var(--muted); margin-bottom: 1rem; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 2rem; }
.fact-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.fact-value { font-size: .98rem; }

.relations-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }

.relation-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }

.relation-list a {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .45rem .55rem;
    border-radius: var(--radius-sm);
    color: inherit;
}

.relation-list a:hover { background: var(--paper-2); text-decoration: none; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }

.gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.gallery img { width: 100%; height: 150px; object-fit: cover; display: block; }
.gallery figcaption { padding: .5rem .65rem; font-size: .82rem; color: var(--muted); }

/* ---------- Дерево ---------- */

.tree-toolbar {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    margin-bottom: 1.25rem;
}

.tree-scroll {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    overflow-x: auto;
}

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }

.tree ul { margin-left: 1.35rem; padding-left: 1.35rem; border-left: 2px solid var(--line); }

.tree li { position: relative; padding: .3rem 0; }

.tree li::before {
    content: "";
    position: absolute;
    left: -1.35rem;
    top: 1.55rem;
    width: 1.15rem;
    height: 2px;
    background: var(--line);
}

.tree > li::before { display: none; }

.node {
    display: flex;
    align-items: center;
    gap: .7rem;
    flex-wrap: wrap;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .35rem .9rem .35rem .4rem;
    width: fit-content;
    max-width: 100%;
}

.node.is-focus { border-color: var(--accent); background: #fdf6e9; box-shadow: 0 0 0 3px rgba(184, 135, 60, .18); }
.node .person-link { display: flex; align-items: center; gap: .55rem; color: inherit; }
.node .person-link:hover { text-decoration: none; color: var(--brand-dark); }
.node .name { font-weight: 600; font-size: .95rem; }
.node .years { font-size: .82rem; color: var(--muted); }

.node .spouse {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding-left: .7rem;
    margin-left: .3rem;
    border-left: 1px solid var(--line);
    font-size: .88rem;
    color: var(--ink-soft);
}

.node .spouse::before { content: "⚭"; color: var(--accent); font-size: 1rem; }

.toggle {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--muted);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: .7rem;
    cursor: pointer;
    flex: none;
    padding: 0;
    line-height: 1;
}

.toggle:hover { border-color: var(--brand-light); color: var(--brand); }

.ancestors { display: flex; gap: 1.25rem; overflow-x: auto; padding-bottom: .5rem; }
.ancestor-col { display: flex; flex-direction: column; justify-content: space-around; gap: .5rem; min-width: 190px; }

.ancestor-cell {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: .5rem .7rem;
    font-size: .88rem;
    color: inherit;
    display: block;
}

.ancestor-cell:hover { text-decoration: none; border-color: var(--brand-light); }
.ancestor-cell.empty { opacity: .35; font-style: italic; }
.ancestor-cell .years { color: var(--muted); font-size: .8rem; }

/* Пустой слот, который можно заполнить */
.ancestor-cell-add {
    width: 100%;
    text-align: left;
    border-style: dashed;
    background: transparent;
    color: var(--brand);
    font-weight: 600;
    cursor: pointer;
}

.ancestor-cell-add:hover {
    background: #f2f7f4;
    border-color: var(--brand);
    border-style: solid;
}

.ancestor-cell-add .years { font-weight: 400; }

/* ---------- Формы Identity ---------- */

.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--paper); }

.auth-aside {
    background: linear-gradient(150deg, var(--brand-dark), var(--brand) 65%, #3d7a68);
    color: #fff;
    padding: 3.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-aside h2 { color: #fff; font-size: 2.1rem; line-height: 1.2; }
.auth-aside p { color: rgba(255, 255, 255, .8); max-width: 28rem; }
.auth-aside .brand { color: #fff; }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 3rem 1.5rem; }
.auth-card { width: 100%; max-width: 27rem; }
.auth-card h1 { font-size: 1.9rem; margin-bottom: .4rem; }
.auth-card .lead-sm { color: var(--muted); margin-bottom: 1.8rem; }
.auth-card .form-floating { margin-bottom: 1rem; }
.auth-links { margin-top: 1.5rem; display: grid; gap: .5rem; font-size: .92rem; }

/* ---------- Настройки профиля ---------- */

.manage-layout { display: grid; grid-template-columns: 240px 1fr; gap: 2rem; align-items: start; }

.manage-nav { display: grid; gap: .2rem; }

.manage-nav a { padding: .55rem .85rem; border-radius: var(--radius-sm); color: var(--ink-soft); font-weight: 600; font-size: .93rem; }
.manage-nav a:hover { background: var(--paper-2); text-decoration: none; }
.manage-nav a.active { background: var(--brand); color: #fff; }

/* ---------- Служебное ---------- */

.empty-state { text-align: center; padding: 3.5rem 1.5rem; color: var(--muted); }
.empty-state h3 { color: var(--ink-soft); }

#blazor-error-ui {
    color: #fff;
    background: var(--danger);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none;
    left: 0;
    padding: .8rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .75rem; }
#blazor-error-ui a { color: #fff; text-decoration: underline; }

.loading-dots { color: var(--muted); font-style: italic; }

@media (max-width: 1024px) {
    .hero-inner { grid-template-columns: 1fr; }
    .hero-art { order: -1; }
    .feature-grid { grid-template-columns: 1fr 1fr; }
    .stats-inner { grid-template-columns: repeat(3, 1fr); row-gap: 1.75rem; }
    .auth-page { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .manage-layout { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    .landing-nav { display: none; }
    .feature-grid { grid-template-columns: 1fr; }
    .stats-inner { grid-template-columns: repeat(2, 1fr); }
    .section { padding: 3.5rem 1.25rem; }
    .app-header .inner { flex-wrap: wrap; }
    .app-nav { order: 3; width: 100%; margin-left: 0; }
    .table-wrap { overflow-x: auto; }
}
