/* elph.ru — базовая дизайн-система.
   Без CSS-фреймворка: переменные + лёгкая типографика. */

:root {
    /* Палитра логотипа: тёмно-зелёный, зелёный, золотой; текст — чёрный. */
    --c-bg: #ffffff;
    --c-surface: #f6f8f6;
    --c-border: #e1e5e1;
    --c-text: #111111;
    --c-muted: #5f6b63;
    --c-accent: #144e3b;
    --c-accent-2: #72b393;
    --c-gold: #d3c15e;
    --c-accent-weak: #e7f0ec;
    --c-link: #144e3b;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
        "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas,
        monospace;

    --space: 1rem;
    --radius: 10px;
    --maxw: 960px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --c-bg: #16171a;
        --c-surface: #1e2024;
        --c-border: #2c2f35;
        --c-text: #ececee;
        --c-muted: #9aa6a0;
        --c-accent: #72b393;
        --c-accent-2: #9ad3b5;
        --c-gold: #d3c15e;
        --c-accent-weak: #16241d;
        --c-link: #8fd3ad;
    }
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--c-text);
    background: var(--c-bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--c-link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 600; line-height: 1.25; }

.container {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* --- Шапка --- */
.site-header {
    border-bottom: 1px solid var(--c-border);
    background: var(--c-bg);
}
.site-header .container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1.5rem;
    height: 60px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
    color: var(--c-text);
}
.brand:hover { text-decoration: none; }
.brand-logo { display: block; width: 32px; height: 32px; }

.site-nav {
    display: flex;
    gap: 0.8rem;
    justify-self: center;
    align-items: center;
}
.site-nav a:hover { text-decoration: none; }

.nav-auth { display: flex; gap: 0.75rem; align-items: center; justify-self: end; }
.nav-auth .btn { font-size: 1rem; }
.lang-switch { position: relative; }
.lang-switch .caret { font-size: 0.7em; color: var(--c-muted); }
.lang-menu {
    position: absolute; right: 0; top: calc(100% + 0.4rem);
    display: flex; flex-direction: column; min-width: 8.5rem;
    background: var(--c-bg); border: 1px solid var(--c-border);
    border-radius: var(--radius); padding: 0.3rem; z-index: 50;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}
.lang-menu button {
    background: none; border: none; cursor: pointer; text-align: left;
    padding: 0.45rem 0.7rem; border-radius: 6px;
    color: var(--c-text); font-size: 0.95rem;
}
.lang-menu button:hover { background: var(--c-accent-weak); }
.lang-menu button.is-active { font-weight: 600; color: var(--c-accent); }

.btn {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    font: inherit;      /* у <button> свои умолчания — ровняем с <a> */
    line-height: 1.5;
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: 0.9rem;
    cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--c-accent); }
.btn-primary { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn-primary:hover { color: #fff; }

/* --- Контент --- */
main { flex: 1 0 auto; padding: 2.5rem 0; }

.hero { text-align: center; padding: 3rem 0 2rem; }
.hero .logo {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin: 0;
    color: var(--c-accent);
}
.hero .logo span:nth-of-type(1) { color: var(--c-gold); }
.hero .logo span:nth-of-type(2) { color: var(--c-accent-2); }

/* Бэкроним ELPH */
.backronym {
    margin: 1.25rem 0 0;
    font-size: 1.15rem;
    color: var(--c-muted);
    min-height: 1.6em;
}
.backronym .word {
    display: inline-block;
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.backronym .word .lead { color: var(--c-accent); font-weight: 700; }
.backronym.is-fading .word { opacity: 0; transform: translateY(-4px); }

.lead-text { color: var(--c-muted); max-width: 38rem; margin: 1.5rem auto 0; }

/* Карточки разделов */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 2.5rem;
}
.card {
    display: block;
    padding: 1.25rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
}
.card:hover { text-decoration: none; border-color: var(--c-accent); }
.card h3 { margin: 0 0 0.4rem; }
.card p { margin: 0; color: var(--c-muted); font-size: 0.95rem; }

/* --- Формы аутентификации --- */
.auth {
    max-width: 26rem;
    margin: 1rem auto;
    padding: 1.75rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
}
.auth h1 { margin: 0 0 0.4rem; font-size: 1.4rem; }
.auth .sub { color: var(--c-muted); margin: 0 0 1.25rem; font-size: 0.95rem; }
.auth .field { margin-bottom: 1rem; }
.auth label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; color: var(--c-muted); }
.auth input[type=text],
.auth input[type=email],
.auth input[type=password],
.auth input[type=number],
.auth select,
.auth textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: var(--c-bg);
    color: var(--c-text);
    font: inherit;
    box-sizing: border-box;
}
.auth textarea { min-height: 6rem; resize: vertical; line-height: 1.5; }
.auth input:focus,
.auth select:focus,
.auth textarea:focus { outline: none; border-color: var(--c-accent); }
.auth .readonly { color: var(--c-text); font-weight: 600; }
.auth .btn-primary { width: 100%; padding: 0.6rem; font-size: 1rem; }
.auth .helptext { display: block; margin-top: 0.3rem; font-size: 0.82rem; color: var(--c-muted); }
.auth .errorlist { margin: 0.3rem 0 0; padding-left: 1.1rem; color: #c0392b; font-size: 0.85rem; }
.auth .form-error { margin-bottom: 1rem; color: #c0392b; font-size: 0.9rem; }
.auth .links { margin-top: 1.1rem; font-size: 0.9rem; display: flex; justify-content: space-between; }
.message-note { max-width: 26rem; margin: 1rem auto; text-align: center; }
.message-note p { color: var(--c-muted); }

/* --- Контент: ленты, дерево, статья --- */
.muted { color: var(--c-muted); }
.feed { list-style: none; padding: 0; }
.feed-item {
    position: relative;
    display: flex; gap: 1rem; align-items: flex-start;
    padding: 0.9rem 0; border-top: 1px solid var(--c-border);
}
.feed-item h3 { margin: 0 0 0.2rem; }
.feed-item a { color: var(--c-text); }
.feed-body { flex: 1; min-width: 0; }
.thumb { flex: 0 0 auto; }
.thumb img {
    display: block; width: 72px; height: 72px;
    object-fit: cover; border-radius: 8px; border: 1px solid var(--c-border);
}
.meta { color: var(--c-muted); font-size: 0.88rem; }
.ccount { color: var(--c-muted); font-size: 0.85rem; white-space: nowrap; }
.tree-node .ccount { margin-left: 0.4rem; }

.tree { list-style: none; padding: 0; }
/* Узел дерева — та же карточка, что элемент ленты новостей: обложка,
   заголовок, дата со временем, счётчик комментариев, отрывок. */
.tree-node {
    position: relative;
    padding: 0.9rem 0; display: flex; align-items: flex-start; gap: 1rem;
    border-top: 1px solid var(--c-border);
}
.tree-node a { color: var(--c-text); }
.tree-node h3 { margin: 0 0 0.2rem; }
/* Ссылка заголовка накрывает фрагмент целиком: материал открывается
   щелчком по любому месту карточки, а не только по названию. */
.feed-body > a::after {
    content: ""; position: absolute; inset: 0;
}

.breadcrumbs { font-size: 0.85rem; color: var(--c-muted); margin-bottom: 1rem; }
.draft-badge {
    display: inline-block; padding: 0.2rem 0.6rem; border-radius: 6px;
    background: var(--c-accent-weak); color: var(--c-accent); font-size: 0.8rem;
}

.article { max-width: 44rem; margin: 0 auto; }
.article > h1 { margin: 0.3rem 0; }
.prose { line-height: 1.7; }
.prose h2, .prose h3 { margin-top: 1.8rem; }
.prose img { max-width: 100%; height: auto; }
.prose pre {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: 8px; padding: 0.9rem 1rem; overflow-x: auto;
}
.prose code { font-family: var(--font-mono); font-size: 0.92em; }
.prose :not(pre) > code {
    background: var(--c-surface); padding: 0.1rem 0.35rem; border-radius: 5px;
}
.prose blockquote {
    margin: 1rem 0; padding: 0.2rem 1rem; border-left: 3px solid var(--c-border);
    color: var(--c-muted);
}
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--c-border); padding: 0.4rem 0.7rem; }

/* Вики-ссылки */
.wikilink.broken { color: #c0392b; border-bottom: 1px dashed #c0392b; cursor: help; }

/* Ненайденная картинка */
img.broken-img {
    display: inline-block; min-width: 8rem; min-height: 2rem; padding: 0.5rem;
    border: 1px dashed #c0392b; border-radius: 6px;
    color: #c0392b; font-size: 0.85rem;
}

/* Коллауты (Obsidian) */
.callout {
    margin: 1.2rem 0; padding: 0.8rem 1rem; border-radius: 8px;
    border: 1px solid var(--c-border); border-left: 4px solid var(--c-accent);
    background: var(--c-surface);
}
.callout-title { font-weight: 700; margin-bottom: 0.3rem; }
.callout-warning, .callout-caution { border-left-color: #d08700; }
.callout-danger, .callout-error, .callout-bug { border-left-color: #c0392b; }
.callout-tip, .callout-success, .callout-note { border-left-color: var(--c-accent); }

/* Теги */
.tags { margin-top: 1.5rem; }
.tag { font-size: 0.85rem; color: var(--c-muted); margin-right: 0.4rem; }
.tag:hover { color: var(--c-accent); }

.children { margin-top: 2rem; }
.children ul { padding-left: 1.2rem; }

/* Сообщения */
[x-cloak] { display: none !important; }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg {
    padding: 0.6rem 0.9rem; border-radius: 8px; margin-bottom: 0.5rem;
    background: var(--c-accent-weak); color: var(--c-text); font-size: 0.92rem;
}
.msg.error { background: #fbe6e6; color: #c0392b; }

/* Комментарии */
.comments { max-width: 44rem; margin: 2.5rem auto 0; }
.comment-form textarea {
    width: 100%; padding: 0.6rem 0.7rem; border: 1px solid var(--c-border);
    border-radius: 8px; background: var(--c-bg); color: var(--c-text);
    font-family: inherit; font-size: 0.95rem; resize: vertical;
}
.comment-form .btn-primary { margin-top: 0.5rem; }
.comment-list { list-style: none; padding: 0; margin-top: 1.5rem; }
.comment {
    padding: 0.7rem 0 0.7rem 0.9rem; border-left: 2px solid var(--c-border);
    margin-bottom: 0.6rem;
}
.comment-head { font-size: 0.85rem; color: var(--c-muted); display: flex; gap: 0.6rem; align-items: center; }
.comment-author { font-weight: 600; color: var(--c-text); }
.comment-body { margin: 0.3rem 0; }
.badge {
    font-size: 0.75rem; padding: 0.1rem 0.45rem; border-radius: 5px;
    background: var(--c-accent-weak); color: var(--c-accent);
}
.reply-toggle {
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--c-link); font-size: 0.85rem;
}
.comment-form.reply { margin-top: 0.5rem; }

/* Отрывок и отбивка */
.excerpt { color: var(--c-muted); font-style: italic; margin: 0.6rem 0 0; }
.feed-item .excerpt { margin-top: 0.3rem; }
.lede-rule { border: none; border-top: 1px solid var(--c-border); margin: 1.1rem 0 1.6rem; }
.recent { margin-top: 2.5rem; }

/* --- Чат --- */
.chat-log {
    height: 24rem; overflow-y: auto;
    border: 1px solid var(--c-border); border-radius: 8px;
    padding: 0.8rem 1rem; margin: 1rem 0 0.5rem;
    background: var(--c-surface);
}
.chat-msg { margin-bottom: 0.7rem; }
.chat-author { font-weight: 600; }
.chat-msg time { color: var(--c-muted); font-size: 0.8rem; margin-left: 0.4rem; }
.chat-text { white-space: pre-wrap; overflow-wrap: break-word; }
.chat-form { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-form textarea {
    flex: 1; padding: 0.5rem 0.7rem; resize: vertical;
    border: 1px solid var(--c-border); border-radius: 8px;
    background: var(--c-bg); color: var(--c-text);
    font-family: inherit; font-size: 0.95rem;
}
.chat-admin { margin-top: 1.2rem; }
.chat-admin summary { cursor: pointer; color: var(--c-muted); }
.chat-admin-form { margin: 0.7rem 0; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.chat-admin-form input, .chat-admin-form select {
    padding: 0.4rem 0.6rem; border: 1px solid var(--c-border);
    border-radius: 8px; background: var(--c-bg); color: var(--c-text);
}
.invite-actions { display: inline-block; margin: 0.4rem 0.4rem 0 0; }

/* --- Линии (генеалогический граф) --- */
.lines-canvas {
    /* Полная ширина экрана (вырывается из .container), высота — половина. */
    position: relative;
    width: 100vw;
    margin: 1rem 0 0.3rem calc(50% - 50vw);
    aspect-ratio: 2 / 1;
    border-top: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface);
    overflow: hidden;
}
.lines-canvas:fullscreen {
    width: 100%; height: 100%;
    margin: 0; aspect-ratio: auto; border: 0;
}
/* Псевдополный экран (iPhone: Fullscreen API у элементов нет) —
   холст растягивается поверх страницы средствами CSS. */
.lines-canvas.lines-pseudo-full {
    position: fixed; inset: 0; z-index: 900;
    width: auto; height: auto;
    margin: 0; aspect-ratio: auto; border: 0;
}
html.lines-noscroll, html.lines-noscroll body { overflow: hidden; }
.lines-tree.lines-active .lines-canvas {
    outline: 2px solid var(--c-accent);
    outline-offset: -2px;
}
.lines-menu {
    position: fixed;
    z-index: 1000;
    min-width: 190px;
    padding: 0.25rem;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    font-size: 0.9rem;
}
.lines-menu-item {
    display: block;
    width: 100%;
    padding: 0.4rem 0.7rem;
    color: var(--c-text);
    text-decoration: none;
    text-align: left;
    border: 0;
    border-radius: 4px;
    background: transparent;
    font: inherit;
    cursor: pointer;
}
.lines-menu-item:hover { background: var(--c-surface); }
/* Справка гостя древа: квадратная кнопка «i», по клику — всплывающее окно. */
.lines-help {
    display: inline-block;
    position: relative;
    vertical-align: middle;
}
.lines-help > summary { list-style: none; }
.lines-help > summary::-webkit-details-marker { display: none; }
.lines-help-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    font-family: Georgia, serif;
    font-size: 1rem;
    font-style: italic;
    font-weight: 600;
    user-select: none;
}
.lines-help[open] > .lines-help-toggle { border-color: var(--c-accent); }
.lines-help-body {
    position: absolute;
    left: 0;
    top: calc(100% + 0.4rem);
    z-index: 1000;
    width: min(34rem, 86vw);
    padding: 0.8rem 1rem;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    font-size: 0.85rem;
    font-weight: 400;
    text-align: left;
}
.lines-help-body p { margin: 0 0 0.5rem; }
.lines-help-body ul { margin: 0; padding-left: 1.2rem; }
.lines-help-body li { margin-bottom: 0.4rem; }
@media (max-width: 640px) {
    .lines-help-body {
        position: fixed;
        left: 50%;
        top: 18vh;
        transform: translateX(-50%);
    }
}
.lines-menu-head {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    color: var(--c-muted);
    border-bottom: 1px solid var(--c-border);
    margin-bottom: 0.2rem;
}
/* Ручка-коннектор на плашке и тянущаяся линия связи. */
.lines-connect {
    fill: var(--c-accent);
    stroke: var(--c-bg);
    stroke-width: 1.5;
    cursor: crosshair;
    opacity: 0.5;
}
.lines-connect:hover { opacity: 1; }
.lines-temp { stroke: var(--c-accent); stroke-width: 2; stroke-dasharray: 4 3; }
.lines-tree.lines-connecting { cursor: crosshair; }
/* Модалка редактирования личности поверх холста. */
.lines-modal-back {
    position: fixed; inset: 0; z-index: 1100;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 3vh 1rem; overflow: auto;
    background: rgba(0, 0, 0, 0.4);
}
.lines-modal {
    width: min(680px, 100%);
    padding: 1.2rem 1.4rem;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.lines-modal h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.lines-modal .field { margin-bottom: 0.9rem; }
.lines-modal label {
    display: block; margin-bottom: 0.3rem;
    font-size: 0.9rem; color: var(--c-muted);
}
.lines-modal input,
.lines-modal select,
.lines-modal textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: var(--c-bg);
    color: var(--c-text);
    font: inherit;
    box-sizing: border-box;
}
.lines-modal input:focus,
.lines-modal select:focus,
.lines-modal textarea:focus { outline: none; border-color: var(--c-accent); }
.lines-modal .helptext {
    display: block; margin-top: 0.25rem;
    font-size: 0.82rem; color: var(--c-muted);
}
.lines-modal .errorlist {
    margin: 0.3rem 0 0; padding-left: 1.1rem;
    color: #c0392b; font-size: 0.85rem;
}
.lines-modal-actions {
    display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem;
}
/* Кнопки формы личности: «Сохранить» и «…и вернуться» — в столбик, равной
   ширины; «Удалить» — меньше, красная, по центру. */
.lines-form-actions {
    display: flex; flex-direction: column; gap: 0.5rem;
    max-width: 340px; margin-top: 0.5rem;
}
.lines-form-actions .btn { width: 100%; text-align: center; }
.lines-delete-form { text-align: center; margin-top: 1rem; }
.btn-danger { background: #c0392b; border-color: #c0392b; color: #fff; }
.btn-danger:hover { background: #a93226; border-color: #a93226; color: #fff; }
.btn-small { padding: 0.05rem 0.6rem; font-size: 0.8rem; }
.lines-rail {
    /* Прозрачная полоса чуть шире кнопок, во всю высоту холста справа:
       перекрывает плашки (тап по ней не прожимается на холст), а свайп
       по ней листает страницу — интуитивный выход с активного холста
       на телефоне. */
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 3.6rem;
    touch-action: pan-y;
}
.lines-controls {
    position: absolute; top: 0.6rem; right: 0.8rem;
    display: flex; flex-direction: column; gap: 0.3rem;
}
.lines-controls .btn {
    width: 2rem; height: 2rem; padding: 0;
    font-size: 1.1rem; line-height: 1.9rem; text-align: center;
}
#lines-svg { display: block; width: 100%; height: 100%; }
.lines-node rect { fill: var(--c-bg); stroke: var(--c-border); }
.lines-node.sex-M rect { stroke: var(--c-accent-2); }
.lines-node.sex-F rect { stroke: var(--c-gold); }
.lines-node:hover rect { stroke: var(--c-accent); }
.lines-name { font-size: 13px; font-weight: 600; fill: var(--c-text); }
.lines-given { font-size: 12px; fill: var(--c-text); }
.lines-dates { font-size: 10.5px; fill: var(--c-muted); }
.lines-photo { fill: var(--c-surface); stroke: var(--c-border); }
.lines-photo-fig { fill: var(--c-border); }
/* Цвет линий наследуется от группы семьи (.lines-fam-N на <g>). */
/* Лента событий в карточке личности. Даты — колонкой слева, чтобы
   хронология читалась сверху вниз одним взглядом. Чужие события (где
   личность лишь свидетель) приглушены, дабы не спорить со своими. */
.lines-timeline .tl { list-style: none; margin: 0; padding: 0; }
.lines-timeline .tl-row {
    display: grid; grid-template-columns: 13.5rem 1fr; gap: 0 1rem;
    padding: 0.45rem 0; border-bottom: 1px solid var(--c-border);
}
.lines-timeline .tl-row:last-child { border-bottom: 0; }
.lines-timeline .tl-date {
    color: var(--c-muted); font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.lines-timeline .tl-type { font-weight: 600; }
.lines-timeline .tl-sep { color: var(--c-muted); margin: 0 0.35rem; }
.lines-timeline .tl-place::before { content: ' · '; color: var(--c-muted); }
.lines-timeline .tl-place { color: var(--c-muted); }
.lines-timeline .tl-att,
.lines-timeline .tl-note { display: block; font-size: 0.9em; color: var(--c-muted); }
.lines-timeline .tl-note { font-style: italic; }
.lines-timeline .tl-guest { opacity: 0.72; }
.lines-timeline .tl-guest .tl-type { font-weight: 500; font-style: italic; }
.lines-timeline .tl-empty { color: var(--c-muted); }

/* Правка на месте: ручка слева, карандаш справа — проступают при наведении,
   чтобы чтение оставалось чтением. */
.lines-toolbar {
    display: flex; gap: 0.5rem; align-items: center; margin: 0.25rem 0 1rem;
}
.lines-toolbar .lines-delete-form { display: inline; margin: 0; }
.lines-timeline .tl-editable .tl-row {
    grid-template-columns: 1.1rem 13.5rem 1fr auto;
}
.lines-timeline .tl-grip {
    cursor: grab; color: var(--c-border); user-select: none; line-height: 1.4;
}
.lines-timeline .tl-row:hover .tl-grip { color: var(--c-muted); }
.lines-timeline .tl-dragging { opacity: 0.5; }
.lines-timeline .tl-actions { opacity: 0; }
.lines-timeline .tl-row:hover .tl-actions,
.lines-timeline .tl-row:focus-within .tl-actions { opacity: 1; }
.lines-timeline .tl-edit {
    background: none; border: 0; cursor: pointer; color: var(--c-muted);
    font-size: 1rem; padding: 0 0.25rem;
}
.lines-timeline .tl-edit:hover { color: var(--c-accent); }
.lines-timeline .lines-event-add { margin-top: 0.75rem; }
.lines-form-hint { color: var(--c-muted); font-size: 0.9em; }

/* Строка связи: подпись, имя, и справа единообразная пара кнопок. */
.lines-relations .rel-row {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    padding: 0.3rem 0;
}
.lines-relations .rel-what { color: var(--c-muted); }
.lines-relations .rel-actions {
    display: inline-flex; gap: 0.35rem; align-items: center; margin-left: auto;
}
.lines-relations .rel-actions form { display: inline; margin: 0; }

@media (max-width: 620px) {
    .lines-timeline .tl-row,
    .lines-timeline .tl-editable .tl-row { grid-template-columns: 1fr; gap: 0; }
    .lines-timeline .tl-date { font-size: 0.9em; }
    .lines-timeline .tl-actions { opacity: 1; }
}

.lines-link { fill: none; stroke-width: 1.6; }
.lines-link.alt { stroke-dasharray: 5 4; }  /* усыновление/опека */
.lines-union { stroke-width: 1.6; fill: none; }
.lines-union.dashed { stroke-dasharray: 8 5; }  /* развод */
.lines-union.alt { stroke-dasharray: 5 4; }     /* усыновившая пара */
.lines-fam-0 { stroke: #d4a017; }  /* янтарный */
.lines-fam-1 { stroke: #2f6fd0; }  /* синий */
.lines-fam-2 { stroke: #3fae4f; }  /* зелёный */
.lines-fam-3 { stroke: #d23f3f; }  /* красный */
.lines-fam-4 { stroke: #9b4fca; }  /* фиолетовый */
.lines-fam-5 { stroke: #17a398; }  /* бирюзовый */
.lines-fam-6 { stroke: #e07b39; }  /* оранжевый */
.lines-fam-7 { stroke: #d24f9e; }  /* пурпурный */
.lines-relations ul { padding-left: 1.2rem; }
.lines-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin: 0 0 0.8rem;
}
.lines-media-item {
    margin: 0;
    max-width: 180px;
    font-size: 0.85rem;
}
.lines-media-item img {
    max-width: 180px;
    max-height: 180px;
    border: 1px solid var(--c-border);
    border-radius: 4px;
}
.lines-media-item figcaption { margin-top: 0.2rem; }
.lines-upload { margin: 0.6rem 0; }
.lines-upload-status { margin-left: 0.6rem; }

/* --- Подвал --- */
.site-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--c-border);
    color: var(--c-muted);
    font-size: 0.85rem;
    padding: 1.5rem 0;
}
.site-footer .container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
}
.site-footer .container > span:last-child { justify-self: end; }
.footer-nav { display: flex; gap: 0.8rem; justify-self: center; }
/* Меню шапки и подвала. Фон кнопок — цвет буквы H в ELPH, при наведении
   и у активного раздела — цвет буквы L. Текст фиксированно тёмный:
   в тёмной теме --c-accent светлеет и на этих фонах пропал бы. */
.footer-nav .btn, .site-nav .btn {
    font-size: 1rem;
    background: var(--c-accent-2);
    border-color: var(--c-accent-2);
    color: #144e3b;
}
.footer-nav .btn:hover, .site-nav .btn:hover,
.footer-nav .btn.is-active, .site-nav .btn.is-active {
    background: var(--c-gold);
    border-color: var(--c-gold);
    color: #144e3b;
}
/* Счётчик приглашений на пункте «Чаты» */
.nav-badge {
    display: inline-block; min-width: 1.2em; padding: 0 0.3em;
    border-radius: 999px; background: #c0392b; color: #fff;
    font-size: 0.78em; text-align: center; vertical-align: text-top;
}
@media (max-width: 640px) {
    .site-footer .container { grid-template-columns: 1fr; justify-items: center; }
    .site-footer .container > span:last-child { justify-self: center; }
}

/* Приглашение к меню подвала на главной */
.more-below {
    margin: 2.2rem 0 0.3rem; text-align: center;
    color: var(--c-muted); font-style: italic;
}
.more-below svg { display: block; margin: 0.5rem auto 0; }

@media (max-width: 640px) {
    .site-header .container {
        display: flex; flex-wrap: wrap; justify-content: space-between;
        height: auto; padding-top: 0.6rem; padding-bottom: 0.6rem;
        gap: 0.75rem;
    }
    .site-nav { order: 3; width: 100%; justify-content: center; }
    .hero .logo { font-size: 2.2rem; }
}
