/* ============================================================
   Тавда: история и жители — светлый дизайн v4
   Двухколоночный layout: левое меню + лента контента
   ============================================================ */

:root {
    --bg: #f5f7fa;              /* светло-серо-голубой фон */
    --bg-card: #ffffff;         /* белые карточки */
    --text: #2c3e50;            /* тёмно-синий текст */
    --muted: #5d6b7a;           /* приглушённый (контраст ~5:1 на фоне) */
    --accent: #2f6f8f;          /* спокойный синий */
    --accent-dark: #24536d;
    --green: #3e7c4f;           /* мягкий зелёный для таблиц */
    --green-dark: #2f5c3c;
    --border: #e3e8ee;
    --shadow: 0 1px 4px rgba(30, 60, 90, .07);
    --radius: 8px;
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: Georgia, "Times New Roman", "PT Serif", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

img { max-width: 100%; height: auto; }
a { color: var(--accent); }

.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ===== Шапка (с фото) ===== */
.site-header {
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 6px rgba(30, 60, 90, .08);
}

.header-photo {
    background-image: linear-gradient(rgba(20, 35, 50, .45), rgba(20, 35, 50, .55)),
        url('/assets/img/header-tavda.jpg');
    background-size: cover;
    background-position: center 60%;
}

.header-inner {
    display: flex;
    align-items: center;
    padding-top: 18px;
    padding-bottom: 18px;
    min-height: 110px;
}

.logo {
    font-family: var(--font-serif);
    font-size: 28px;
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: .4px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}

.logo span {
    display: block;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    color: #dce8f2;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}

/* ===== Трёхколоночный layout (главная: меню | контент | changelog) ===== */
.layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
    padding-top: 20px;
    padding-bottom: 40px;
    align-items: start;
}

.layout.with-right {
    grid-template-columns: 250px 1fr 260px;
}

/* ===== Левая колонка ===== */
.sidebar {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.side-nav {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    box-shadow: var(--shadow);
}

.side-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: background .12s, color .12s;
}

.side-nav a:hover { background: #eef4f8; color: var(--accent); }

.side-nav a.active {
    background: var(--accent);
    color: #fff;
}

.side-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.side-box h3 {
    font-family: var(--font-serif);
    font-size: 16px;
    color: var(--accent-dark);
    margin-bottom: 8px;
}

.side-box p { margin-bottom: 4px; }

/* ===== Контент ===== */
.content { min-width: 0; }

/* ===== Правая колонка: история изменений ===== */
.right-col {
    position: sticky;
    top: 16px;
    min-width: 0;
}

.changelog-box { max-height: 80vh; overflow-y: auto; }

.changelog-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.changelog-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-left: 3px solid #ccc;
    border-radius: 0 6px 6px 0;
    background: #fbfcfd;
    font-size: 13px;
}

.changelog-added   { border-left-color: #4caf50; }
.changelog-changed { border-left-color: #ff9800; }
.changelog-removed { border-left-color: #e53935; }

.changelog-date {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
}

.changelog-title { font-weight: 600; color: var(--text); }

.changelog-desc {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

h1 {
    font-family: var(--font-serif);
    font-size: 30px;
    color: var(--accent-dark);
    margin-bottom: 14px;
    line-height: 1.25;
}

h2 {
    font-family: var(--font-serif);
    font-size: 21px;
    color: var(--accent-dark);
    margin-bottom: 10px;
    line-height: 1.3;
}

h3 { font-size: 17px; margin-bottom: 8px; }

p { margin-bottom: 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #c0392b; font-weight: 600; }

/* ===== Hero ===== */
.hero {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent);
    border-radius: var(--radius);
    padding: 26px 26px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.hero h1 { font-size: 32px; margin-bottom: 8px; }
.hero-sub { color: var(--muted); font-size: 15.5px; max-width: 640px; margin: 0; }

/* ===== Лента (как в соцсетях) ===== */
.feed { margin-bottom: 26px; }

.feed-title {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-dark);
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 7px;
    margin-bottom: 12px;
}

.feed-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.feed-item:hover { border-color: #c3d4e0; }

.feed-head { margin-bottom: 6px; }

.feed-head a {
    font-size: 16.5px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    line-height: 1.35;
}

.feed-head a:hover { color: var(--accent); }

.feed-date {
    display: inline-block;
    font-family: var(--font-serif);
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
    margin-right: 10px;
}

.feed-excerpt { color: var(--muted); font-size: 14.5px; margin-bottom: 8px; }

.feed-meta a, .feed-more a {
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.feed-meta a:hover, .feed-more a:hover { text-decoration: underline; }

.feed-more { margin-top: 10px; }

/* Фото на главной */
.home-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}

.home-photo {
    display: block;
    aspect-ratio: 4/3;
    border-radius: 6px;
    overflow: hidden;
    background: #eef1f4;
    border: 1px solid var(--border);
}

.home-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s;
}

.home-photo:hover img { transform: scale(1.05); }

/* ===== Таблицы ===== */
.people-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 14.5px;
    box-shadow: var(--shadow);
}

.people-table th {
    background: var(--accent);
    color: #fff;
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 13.5px;
}

.people-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.people-table tr:last-child td { border-bottom: none; }
.people-table tr:nth-child(even) td { background: #f8fafc; }
.people-table tr:hover td { background: #eef4f8; }

.people-table a { color: var(--accent); text-decoration: none; font-weight: 500; }
.people-table a:hover { text-decoration: underline; }

.detail-table {
    width: 100%;
    max-width: 780px;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 14.5px;
    box-shadow: var(--shadow);
}

.detail-table th {
    text-align: left;
    width: 230px;
    padding: 10px 13px;
    background: #f0f4f7;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    font-weight: 600;
}

.detail-table td { padding: 10px 13px; border-bottom: 1px solid var(--border); }
.detail-table tr:last-child th, .detail-table tr:last-child td { border-bottom: none; }

/* Семья на карточке жителя */
.family-block { margin-top: 26px; }
.family-block h2 {
    border-bottom: 2px solid var(--border);
    padding-bottom: 7px;
    margin-bottom: 14px;
}
.people-table tr.row-current td {
    background: #e8f0e8 !important;
    font-weight: 600;
}

/* Нечёткий поиск */
.fuzzy-block {
    background: #f0f6f0;
    border: 1px solid #cfe0cf;
    border-radius: var(--radius);
    padding: 16px 18px;
    margin: 14px 0;
}
.fuzzy-list {
    margin: 10px 0 6px;
    padding-left: 22px;
    line-height: 1.7;
}
.fuzzy-list a { font-weight: 600; }

.stat-big {
    font-family: var(--font-serif);
    font-size: 34px;
    font-weight: 700;
    color: var(--accent-dark);
    margin: 0;
}

/* ===== Визуальный редактор (WYSIWYG) ===== */
.field { margin-bottom: 18px; }

.field-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 6px;
}

.wysiwyg-wrap { display: flex; flex-direction: column; }

.wysiwyg-tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #f7f9fb;
    padding: 6px 8px;
}

.wysiwyg-tab {
    border: 1px solid #d5dde4;
    background: #fff;
    border-radius: 5px;
    padding: 5px 14px;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.4;
    margin-right: 6px;
    color: var(--muted);
}

.wysiwyg-tab:hover { background: #eef2f6; border-color: #b9c6d1; }

.wysiwyg-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

.wysiwyg-codearea {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    padding: 12px 14px;
    background: #fbfcfe;
    min-height: 320px;
}

.wysiwyg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    border: 1px solid var(--border);
    border-top: none;
    border-bottom: none;
    border-radius: 0;
    background: #f7f9fb;
    padding: 6px 8px;
}

.wysiwyg-toolbar button {
    border: 1px solid #d5dde4;
    background: #fff;
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.4;
}

.wysiwyg-toolbar button:hover { background: #eef2f6; border-color: #b9c6d1; }

.wysiwyg-sep {
    color: #c2ccd5;
    margin: 0 3px;
    user-select: none;
}

.wysiwyg-editor {
    min-height: 320px;
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    padding: 14px 16px;
    background: #fff;
    font-size: 15px;
    line-height: 1.65;
    overflow-y: auto;
    outline: none;
}

.wysiwyg-editor:focus { border-color: var(--accent); }

.wysiwyg-editor h2 { font-size: 22px; margin: 14px 0 8px; }
.wysiwyg-editor h3 { font-size: 18px; margin: 12px 0 6px; }
.wysiwyg-editor blockquote {
    border-left: 4px solid var(--accent);
    margin: 10px 0;
    padding: 6px 14px;
    color: var(--muted);
    background: #f7fafc;
}
.wysiwyg-editor img { max-width: 100%; border-radius: 6px; }

/* Обтекание изображений в редакторе и на публичных страницах статей */
.wysiwyg-editor img.img-float-left,
.wysiwyg-editor img[style*="float:left"],
.article-body img.img-float-left,
.article-body img[style*="float:left"] {
    float: left;
    margin: 4px 18px 10px 0;
    max-width: 55%;
}

.wysiwyg-editor img.img-float-right,
.wysiwyg-editor img[style*="float:right"],
.article-body img.img-float-right,
.article-body img[style*="float:right"] {
    float: right;
    margin: 4px 0 10px 18px;
    max-width: 55%;
}

/* Показ обтекания в редакторе: прозрачная рамка вокруг float-картинки */
.wysiwyg-editor img.img-float-left,
.wysiwyg-editor img.img-float-right {
    box-shadow: 0 0 0 1px rgba(47, 111, 143, .35);
}

/* ===== Модальное окно вставки изображения ===== */
.wysiwyg-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.wysiwyg-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(20, 30, 40, .55);
}

.wysiwyg-modal-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.wysiwyg-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 15px;
    color: var(--accent-dark);
}

.wysiwyg-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    padding: 0 4px;
}

.wysiwyg-modal-close:hover { color: var(--text); }

.wysiwyg-modal-body { padding: 16px 18px; }

.wysiwyg-modal-foot {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
    border-radius: 0 0 12px 12px;
}

.wysiwyg-picker-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.wysiwyg-picker-tabs .wysiwyg-tab { margin-right: 0; }

.wysiwyg-picker-body { margin-bottom: 10px; }
.wysiwyg-picker-body input[type="file"],
.wysiwyg-picker-body input[type="url"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
}

.wysiwyg-upload-state {
    margin-top: 8px;
    font-size: 13px;
    color: var(--accent-dark);
}
.wysiwyg-upload-state em { color: var(--muted); font-style: normal; }

.wysiwyg-picker-opts {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 12px;
    font-size: 13px;
    align-items: center;
}
.wysiwyg-picker-opts label { display: flex; align-items: center; gap: 6px; }
.wysiwyg-picker-opts input[type="number"] { width: 90px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; }
.wysiwyg-picker-opts select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }

.wysiwyg-picker-caption { margin-bottom: 8px; }
.wysiwyg-picker-caption label { display: block; font-size: 13px; margin-bottom: 4px; }
.wysiwyg-picker-caption input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
}

/* ===== Формы / фильтры ===== */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px;
    box-shadow: var(--shadow);
}

.filters input[type="text"],
.filters select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 14.5px;
    font-family: inherit;
    flex: 1;
    min-width: 150px;
    color: var(--text);
}

.filters button {
    padding: 9px 22px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}

.filters button:hover { background: var(--accent-dark); }

/* ===== Пагинация ===== */
.pagination {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.pagination a, .pagination .current {
    display: inline-block;
    min-width: 36px;
    text-align: center;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--accent);
    background: var(--bg-card);
    font-weight: 500;
    font-size: 14px;
}

.pagination a:hover { background: #eef4f8; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== Хроника ===== */
.chronicle-year { margin-bottom: 28px; }
.chronicle-year h2 {
    border-bottom: 2px solid var(--border);
    padding-bottom: 6px;
    margin-bottom: 12px;
}

.chronicle-item {
    display: flex;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.chronicle-date {
    min-width: 100px;
    font-family: var(--font-serif);
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
}

.chronicle-ref { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

/* ===== Статьи, источники ===== */
.article-body {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px 28px;
    font-size: 16px;
    box-shadow: var(--shadow);
    line-height: 1.75;
}

.article-body p { margin-bottom: 13px; }
.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    cursor: zoom-in;
}

/* Подпись под фото (figure/figcaption) — в редакторе и в статьях */
.wysiwyg-editor figure,
.article-body figure {
    margin: 14px auto;
    text-align: center;
    max-width: 100%;
}

.wysiwyg-editor figure img,
.article-body figure img {
    display: block;
    margin: 0 auto;
    border-radius: 6px;
}

.wysiwyg-editor figure figcaption,
.article-body figure figcaption {
    font-size: 13px;
    color: var(--muted);
    margin-top: 7px;
    font-style: italic;
    line-height: 1.4;
}

/* Обтекание фигуры с подписью */
.wysiwyg-editor figure.img-float-left,
.article-body figure.img-float-left {
    float: left;
    margin: 4px 18px 10px 0;
    max-width: 55%;
    text-align: left;
}

.wysiwyg-editor figure.img-float-right,
.article-body figure.img-float-right {
    float: right;
    margin: 4px 0 10px 18px;
    max-width: 55%;
    text-align: right;
}

.article-body h2 { margin-top: 22px; }
.article-body blockquote {
    border-left: 4px solid var(--accent);
    background: #f0f6fa;
    padding: 13px 17px;
    margin: 15px 0;
    color: #44566a;
    font-style: italic;
    border-radius: 0 8px 8px 0;
}
.article-body ul, .article-body ol { margin: 0 0 13px 22px; }
.article-body li { margin-bottom: 6px; }
.article-body img { border-radius: 6px; margin: 13px 0; }

.source-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 13px;
    box-shadow: var(--shadow);
}

.breadcrumbs { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.breadcrumbs a { color: var(--accent); text-decoration: none; }

/* ===== Галерея ===== */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}

.photo-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin: 0;
}

.photo-card a { display: block; aspect-ratio: 4/3; overflow: hidden; background: #eef1f4; }
.photo-card img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.photo-card a:hover img { transform: scale(1.04); }

.photo-card figcaption { padding: 10px 12px; }
.photo-card figcaption strong { display: block; font-size: 14px; margin-bottom: 3px; }
.photo-card figcaption span { display: block; }

/* ============================================================
   АДМИНКА
   ============================================================ */

.admin-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(160deg, #e8eef4, #f5f7fa);
}

.admin-login {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 36px;
    width: 380px;
    max-width: 94vw;
    box-shadow: 0 10px 30px rgba(30, 60, 90, .12);
}

.admin-login h1 { font-size: 23px; margin-bottom: 6px; }
.admin-login form { display: flex; flex-direction: column; gap: 13px; margin-top: 15px; }
.admin-login label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 500; }
.admin-login input {
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
}
.admin-login button {
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}
.admin-login button:hover { background: var(--accent-dark); }
.admin-login p { margin-top: 13px; font-size: 14px; }

.admin-page { background: var(--bg); }

.admin-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
}

.admin-header .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-header .main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-header .main-nav a {
    color: var(--text);
    text-decoration: none;
    padding: 8px 13px;
    border-radius: 8px;
    font-size: 14px;
    transition: background .15s;
}
.admin-header .main-nav a:hover { background: #eef4f8; }

.admin-main { padding: 24px 0 50px; }
.admin-main h1 { font-size: 26px; }

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 14.5px;
}
.flash.success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.flash.error { background: #fdecea; color: #c0392b; border: 1px solid #f5c6c0; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--accent);
    color: #fff !important;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s;
}
.btn:hover { background: var(--accent-dark); }

.btn-ghost {
    background: transparent;
    color: var(--accent) !important;
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: #eef4f8; color: var(--accent-dark) !important; }

.btn-danger {
    background: transparent;
    border: none;
    color: #c0392b;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 6px;
}
.btn-danger:hover { background: #fdecea; }

.admin-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    max-width: 860px;
}

.admin-form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; font-weight: 500; font-size: 14px; }
.admin-form input[type="text"], .admin-form input[type="password"],
.admin-form textarea, .admin-form select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14.5px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
}
.admin-form textarea { line-height: 1.6; resize: vertical; }
.admin-form .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.admin-form .checkbox { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
.admin-form .checkbox input { width: 17px; height: 17px; }

.form-row { display: flex; gap: 15px; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 200px; }

.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.upload-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    max-width: 860px;
}
.upload-form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; font-weight: 500; font-size: 14px; }
.upload-form input[type="text"], .upload-form input[type="file"] {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14.5px;
    background: #fff;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}

.media-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.media-thumb { display: block; aspect-ratio: 4/3; background: #eef1f4; overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.media-thumb:hover img { transform: scale(1.04); }

.media-pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.media-info { padding: 11px; }
.media-title { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.media-path { word-break: break-all; margin-bottom: 7px; }

.media-desc { font-size: 12px; color: var(--muted); margin-bottom: 5px; }

.media-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.btn-ghost-small {
    display: inline-block;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}

.btn-ghost-small:hover { background: #eef2f6; }

.media-edit[open] summary { margin-bottom: 8px; }

.media-edit-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: #fafcfd;
    margin-bottom: 6px;
    min-width: 220px;
}

.media-edit-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; }
.media-edit-form input {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 13px;
    background: #fff;
}

.actions { white-space: nowrap; }
.actions .inline { display: inline; }
.inline { display: inline; }

/* Выбор медиа в форме статьи */
.media-pick {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
}

.media-pick legend {
    padding: 0 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--accent-dark);
}

.media-pick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px;
}

.media-pick-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    transition: border-color .12s, background .12s;
    background: #fff;
}

.media-pick-item img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: 5px;
    background: #eef1f4;
}

.media-pick-pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4/3;
    background: #f0f4f7;
    border-radius: 5px;
    font-size: 15px;
    color: var(--accent);
    font-weight: 700;
}

.media-pick-title {
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1.3;
    word-break: break-word;
}

.media-pick-item input { display: none; }

.media-pick-item.picked {
    border-color: var(--accent);
    background: #eef4f8;
}

.media-pick-item.picked .media-pick-title { color: var(--accent-dark); font-weight: 600; }

/* Галерея в статье */
.article-gallery { margin-top: 26px; }
.article-gallery h2 {
    border-bottom: 2px solid var(--border);
    padding-bottom: 7px;
    margin-bottom: 14px;
}

/* ===== Подвал (светлый) ===== */
.site-footer {
    background: #ffffff;
    border-top: 1px solid var(--border);
    color: var(--muted);
    padding: 22px 0;
    font-size: 13.5px;
}

.site-footer p { margin-bottom: 4px; }
.footer-note { color: #6b7a8a; font-size: 12.5px; }

/* ===== Адаптив ===== */
@media (max-width: 820px) {
    .layout { grid-template-columns: 1fr; }
    .layout.with-right { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .right-col { position: static; }
    .side-nav { display: flex; flex-wrap: wrap; gap: 4px; }
    .side-nav a { flex: 1; min-width: 100px; text-align: center; padding: 9px 8px; font-size: 14px; }
    .side-box { display: none; }
    h1 { font-size: 24px; }
    .hero { padding: 22px 18px; }
    .hero h1 { font-size: 26px; }
    .hero-sub { font-size: 15px; }
    .article-body { padding: 18px 16px; font-size: 15px; }
    .chronicle-item { flex-direction: column; gap: 5px; }
    .chronicle-date { min-width: 0; }
    .detail-table th { width: 130px; }
    .people-table { font-size: 13px; }
    .people-table th, .people-table td { padding: 8px 9px; }
    .admin-form { padding: 16px; }
}

/* ===== Исправления аудита 2026-08: карточки, доступность, мобильные ===== */

/* Skip-link для клавиатурной навигации */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--accent);
    color: #fff;
    padding: 8px 14px;
    border-radius: 0 0 8px 0;
    z-index: 1000;
    font-weight: 600;
}
.skip-link:focus {
    left: 0;
    color: #fff;
}

/* Горизонтальная прокрутка таблиц на узких экранах */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .people-table { min-width: 640px; }

/* Карточки (использовались в шаблонах, но не были описаны в CSS) */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin: 16px 0;
}
.card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.card:hover {
    border-color: var(--accent);
    box-shadow: 0 3px 10px rgba(30, 60, 90, .12);
    color: var(--text);
}
.card h2 { font-size: 17px; margin-bottom: 6px; color: var(--accent-dark); }
.card p { margin: 0; font-size: 14px; color: var(--muted); }

/* Список статей/легенд */
.legends-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin: 16px 0;
}
.legend-card { padding: 20px; }

/* Кнопки 404/403/500 в ряд */
.notfound-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

/* Видимый фокус для доступности */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
