/* Лекторий «Реплика». Бордовая музейная шапка, рубрики слева, статьи справа. */
:root {
  --bg: #f6ecd6;
  --veil: rgba(246, 236, 214, 0.35);   /* дымка поверх карты на фоне */
  --panel: rgba(251, 245, 231, 0.9);  /* подложка под текстом */
  --paper: #fbf5e7;
  --ink: #2a1a16;
  --muted: #6e5a4c;
  --rule: #dcc9a6;
  --brand: #8e2226;
  --brand-ink: #fff7ef;
  --brand-deep: #6d171b;
  --focus: #c4572b;
  --ok: #3f6b3a;
  --warn: #8a5a00;
  --danger: #a3241f;
  --f-display: "Oswald", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "PT Serif", Georgia, "Times New Roman", serif;
  --f-ui: "PT Sans", "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1513; --veil: rgba(29, 21, 19, 0.82); --panel: rgba(39, 28, 25, 0.93); --paper: #271c19; --ink: #f0e4d2; --muted: #b9a593; --rule: #4a3832;
    --brand: #9e2b2f; --brand-ink: #fff4ea; --brand-deep: #7c1f23; --focus: #e2875a;
    --ok: #8cc083; --warn: #e0b45c; --danger: #ef7b72; color-scheme: dark;
  }
  .nav a, .h-list, .h-page, .crumbs a, .rubrics a:hover, .rubrics a[aria-current="true"], .btn.ghost, .article .body h3, .gal-head h2 { color: #f2a59f; }
  .nav a { border-color: #b8484c; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--f-ui); }
img { max-width: 100%; height: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
code { background: color-mix(in srgb, var(--brand) 10%, transparent); padding: 1px 5px; border-radius: 3px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Шапка */
.mast { background: #8e2321; color: #fff7ef; }  /* цвет совпадает с фоном баннера */
.mast .banner { display: block; flex: 0 1 600px; min-width: 0; line-height: 0; }
.mast .banner img { display: block; width: 100%; max-width: 600px; height: auto; }
.mast .wrap { padding-block: 6px; display: flex; gap: 12px 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.logo { font: 700 clamp(44px, 9vw, 84px)/0.9 var(--f-display); letter-spacing: 0.04em; text-transform: uppercase; }
.logo a { text-decoration: none; color: var(--brand-ink); }
.mast p { margin: 8px 0 0; font: 500 clamp(13px, 1.8vw, 17px)/1.3 var(--f-display); letter-spacing: 0.08em; text-transform: uppercase; max-width: 38ch; opacity: 0.92; }
.mast-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search input { width: min(260px, 70vw); padding: 8px 12px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.35); background: rgba(0,0,0,0.18); color: var(--brand-ink); }
.search input::placeholder { color: rgba(255,247,239,0.7); }
.btn-admin { padding: 8px 12px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.5); color: var(--brand-ink); text-decoration: none; font-weight: 700; }
.btn-admin:hover, .btn-admin.on { background: var(--brand-ink); color: var(--brand-deep); }

/* Меню разделов */
.nav { border-bottom: 1px solid var(--rule); background: var(--paper); }
.nav .wrap { display: flex; gap: 6px 10px; flex-wrap: wrap; padding-block: 12px; align-items: center; }
.nav a, .nav-logout button { text-decoration: none; padding: 7px 14px; border-radius: 4px; font: 500 14px/1.2 var(--f-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand); border: 1px solid var(--brand); background: transparent; cursor: pointer; }
.nav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
.nav a:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.nav a[aria-current="page"]:hover { background: var(--brand-deep); }
.nav-logout { margin: 0 0 0 auto; }
.nav-logout button { border-color: var(--rule); color: var(--muted); }
.is-admin .nav { background: color-mix(in srgb, var(--brand) 8%, var(--paper)); }

main.wrap { padding-block: 28px 64px; }

/* Фон — старинная карта Енисейской губернии. Слой закреплён и не прокручивается вместе со страницей. */
body { position: relative; }
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(var(--veil), var(--veil)), url("map-bg.jpg") center / cover no-repeat;
}
main.wrap { position: relative; z-index: 0; }
main.wrap::before {
  content: ""; position: absolute; inset: 12px max(0px, calc(env(safe-area-inset-right, 0px) - 16px)) 24px max(0px, calc(env(safe-area-inset-left, 0px) - 16px));
  z-index: -1; background: var(--panel); border-radius: 8px; box-shadow: 0 2px 18px rgba(60, 30, 20, 0.12);
}
footer { background: var(--panel); }
.eyebrow { margin: 0 0 10px; font: 500 13px/1.2 var(--f-display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.h-list { margin: 0 0 14px; font: 700 clamp(24px, 3.4vw, 32px)/1.15 var(--f-display); text-wrap: balance; color: var(--brand); }
.h-page { margin: 0 0 18px; font: 700 clamp(28px, 4vw, 40px)/1.1 var(--f-display); color: var(--brand); }
.empty { padding: 22px; border: 1px dashed var(--rule); border-radius: 6px; color: var(--muted); }
.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; border: 1px solid; }
.flash.ok { color: var(--ok); border-color: currentColor; background: color-mix(in srgb, var(--ok) 8%, transparent); }
.flash.err { color: var(--danger); border-color: currentColor; background: color-mix(in srgb, var(--danger) 8%, transparent); }
.flash.warn { color: var(--warn); border-color: currentColor; background: color-mix(in srgb, var(--warn) 8%, transparent); }

/* Раздел */
.cols { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 36px; align-items: start; }
@media (max-width: 760px) { .cols { grid-template-columns: minmax(0, 1fr); gap: 22px; } }
.rubrics { display: flex; flex-direction: column; gap: 2px; }
.rubrics a { text-decoration: none; padding: 9px 10px; border-left: 3px solid transparent; font-weight: 700; line-height: 1.25; text-wrap: balance; }
.rubrics a:hover { color: var(--brand); }
.rubrics a[aria-current="true"] { color: var(--brand); border-left-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, transparent); }
.count { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 4px; font-variant-numeric: tabular-nums; }
ol.articles { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
ol.articles li { border-bottom: 1px solid var(--rule); display: flex; gap: 10px; align-items: center; }
ol.articles li a { flex: 1; min-width: 0; display: block; padding: 12px 2px; text-decoration: none; font: 17px/1.4 var(--f-body); }
ol.articles li a:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
ol.articles .sub { display: block; font: 13px var(--f-ui); color: var(--muted); }
.tag { display: inline-block; font: 12px/1.6 var(--f-ui); color: var(--muted); border: 1px solid var(--rule); border-radius: 10px; padding: 0 8px; white-space: nowrap; }
.tag.ok { color: var(--ok); border-color: currentColor; }
.tag.warn { color: var(--warn); border-color: currentColor; }
.admin-hint { margin-top: 14px; }

/* Статья */
.article { max-width: 70ch; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--brand); }
.article h1 { margin: 0 0 22px; font: 700 clamp(28px, 4.6vw, 44px)/1.12 var(--f-display); text-wrap: balance; }
.article .body { font: 18px/1.7 var(--f-body); }
.article .body p { margin: 0 0 1em; }
.article .body h3 { font: 700 22px/1.3 var(--f-display); margin: 1.4em 0 0.5em; color: var(--brand); }
.article .body a { color: var(--brand); }
.article figure { margin: 26px 0; }
.article figure img { display: block; width: 100%; border-radius: 3px; cursor: zoom-in; }
.article figcaption { font: italic 14px/1.4 var(--f-body); color: var(--muted); margin-top: 6px; }
.article .meta { margin-top: 30px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 10px; }

.files { margin: 26px 0 0; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
.files ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.files a { color: var(--brand); font-weight: 700; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.pager a, .pager span { padding: 4px 10px; border: 1px solid var(--rule); border-radius: 4px; text-decoration: none; font-variant-numeric: tabular-nums; }
.pager span.cur { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
form.filters-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
form.filters-form select, form.filters-form input[type=search] { width: auto; max-width: 100%; padding: 7px 9px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); }
form.filters-form input[type=search] { min-width: 220px; flex: 1; }
.import-box { border: 1px dashed var(--brand); border-radius: 6px; padding: 16px; margin-bottom: 22px; display: grid; gap: 10px; }
.import-box p { margin: 0; }

/* Кнопки и формы */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 4px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); cursor: pointer; font-weight: 700; text-decoration: none; }
.btn:hover { background: var(--brand-deep); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ghost:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.iconbtn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 4px; font-size: 13px; text-decoration: none; }
.iconbtn:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.narrow { max-width: 460px; }
form.editor { display: grid; gap: 16px; max-width: 800px; }
.field { display: grid; gap: 6px; align-content: start; }
.field > label, .field .label { font-weight: 700; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); }
input[type=number] { max-width: 110px; }
textarea { min-height: 360px; font: 16px/1.6 var(--f-body); resize: vertical; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; font-size: 14px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1.4fr; gap: 14px; }
@media (max-width: 680px) { .row3 { grid-template-columns: 1fr; } }
.thumbs { display: flex; flex-wrap: wrap; gap: 12px; }
.thumb { width: 170px; display: grid; gap: 5px; }
.thumb img { width: 170px; height: 120px; object-fit: cover; border-radius: 3px; border: 1px solid var(--rule); }
.thumb input[type=text] { padding: 5px 7px; font-size: 13px; }
.thumb-row { display: flex; gap: 8px; align-items: center; }
.thumb-row input[type=number] { width: 64px; padding: 4px 6px; font-size: 13px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.actions a { color: var(--muted); }
.danger-zone { margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--rule); }
.sticky-save { position: sticky; bottom: 0; padding-block: 12px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg); border-top: 1px solid var(--rule); margin-top: 18px; }

/* Админка: таблицы и блоки */
.admin-block { margin-bottom: 32px; }
.admin-block h2 { font: 700 22px/1.2 var(--f-display); margin: 0 0 12px; }
.admin-block h3 { font: 700 17px/1.2 var(--f-display); margin: 22px 0 10px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font: 500 12px/1.2 var(--f-display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td a { text-decoration: none; }
.tbl td a:hover { color: var(--brand); text-decoration: underline; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl form { margin: 0; }
.tbl input[type=text] { min-width: 220px; }
.inline-add { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inline-add input { flex: 1; min-width: 200px; }
.filters { display: flex; gap: 6px 14px; flex-wrap: wrap; margin-bottom: 16px; }
.filters a { color: var(--muted); text-decoration: none; padding-bottom: 2px; border-bottom: 2px solid transparent; }
.filters a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); font-weight: 700; }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 32px; }
ul.users { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
ul.users li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }
ul.users form { margin-left: auto; }

/* Галерея */
.gal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.gal-head .h-page { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 18px; }
.tile { margin: 0; background: var(--paper); border: 1px solid var(--rule); padding: 8px 8px 10px; display: grid; gap: 8px; align-content: start; }
.tile img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.tile a { cursor: zoom-in; }
.tile figcaption { font: 14px/1.4 var(--f-body); }
.tile form { margin: 0; }
.drop { border: 2px dashed var(--brand); border-radius: 6px; padding: 18px; margin-bottom: 22px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.drop p { margin: 0; width: 100%; color: var(--muted); }
.drop.over { background: color-mix(in srgb, var(--brand) 10%, transparent); }

/* Просмотр фотографий */
.lb { position: fixed; inset: 0; z-index: 50; background: rgba(15,8,6,0.94); display: grid; grid-template-rows: 1fr auto; padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.lb .imgbox { display: flex; min-height: 0; }
.lb img { max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; }
.lb .bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; color: #f3e6d6; padding-top: 12px; flex-wrap: wrap; }
.lb .bar p { margin: 0; font: italic 16px/1.4 var(--f-body); flex: 1; min-width: 0; }
.lb button { background: transparent; border: 1px solid rgba(243,230,214,0.5); color: #f3e6d6; border-radius: 4px; padding: 6px 12px; cursor: pointer; }

footer { border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px; }
footer .wrap { padding-block: 18px; display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.login-link { color: var(--muted); }
