@font-face { font-family: 'Monomakh'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/monomakh.woff2) format('woff2'); }
@font-face { font-family: 'PT Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/ptserif-400i-cyrillic.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'PT Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/ptserif-400i-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'PT Serif'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ptserif-400-cyrillic.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'PT Serif'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ptserif-400-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'PT Serif'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/ptserif-700-cyrillic.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'PT Serif'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/ptserif-700-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Церковная Школа — как книга: одна тёплая бумага, тонкие линии, киноварь только для акцентов. */
:root {
  --paper: #faf6ec; --tint: #f2ebda; --field: #fffdf8;
  --ink: #2b2017; --soft: #6b5c48;
  --red: #9a2a1c; --red-dk: #741a10;
  --line: #e5dbc3; --line-2: #cfbf9b;
  --r: 4px;
  --title: "Monomakh", "PT Serif", Georgia, serif;
  --text: "PT Serif", "Noto Serif", Georgia, "Times New Roman", serif;
}
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; color: var(--ink); background: var(--paper); line-height: 1.6; font-family: var(--text); }
.sprite { position: absolute; }
.wrap { width: 100%; max-width: 64rem; margin: 0 auto; padding: 0 1.5rem; }
a, button, input, .ecard, .nl { transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* значки */
.i { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* украшение: линия — ромбик — линия */
.orn { display: flex; align-items: center; gap: .7rem; color: var(--red); margin: 1.4rem auto; max-width: 12rem; }
.orn::before, .orn::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }
.orn span { width: .4rem; height: .4rem; background: currentColor; transform: rotate(45deg); }

/* шапка */
.top { border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .3rem 1rem; min-height: 3.8rem; padding-top: .4rem; padding-bottom: .4rem; }
.brand { font-family: var(--title); font-size: 1.45rem; line-height: 1.2; color: var(--red); text-decoration: none; }
.brand:hover { color: var(--red-dk); }
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .3rem; }
.top form { margin: 0; }
.nl { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-size: .85rem; color: var(--soft); background: none; border: 0; border-radius: var(--r); padding: .45rem .6rem; min-height: 2.4rem; text-decoration: none; cursor: pointer; max-width: 14rem; }
.nl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl:hover { background: var(--tint); color: var(--ink); }
body.edit .btn-top { display: none; }

/* страница: без рамок, ширина по смыслу */
main:not(.edit-main) { flex: 1; width: 100%; max-width: 64rem; margin: 0 auto; padding: 2.6rem 1.5rem 3rem; }
main.mid { max-width: 46rem; }
main.read { max-width: 42rem; }
main.narrow { max-width: 25rem; }
@media (max-width: 700px) { .wrap { padding: 0 1rem; } .top nav { margin-left: -.6rem; } main:not(.edit-main) { padding: 1.6rem 1rem 2rem; } }

h1, h2, h3 { color: var(--red-dk); line-height: 1.25; }
h1 { font-family: var(--title); font-weight: 400; font-size: 2rem; margin: 0 0 1rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 .6rem; }
h3 { font-size: 1.1rem; margin: 1.2rem 0 .3rem; }
.narrow h1, .narrow > .lead, .narrow > .hint { text-align: center; }
a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red-dk); }
.lead { font-size: 1.05rem; color: var(--soft); margin-top: 0; }
.meta { color: var(--soft); font-size: .8rem; }
.hint { color: var(--soft); font-size: .85rem; }
.center { text-align: center; }
.empty { color: var(--soft); font-style: italic; padding: 1.4rem 0; }
.more { margin-top: 1.2rem; font-size: .9rem; }

/* поля */
input[type=search], input[type=text], input:not([type]), input[type=password], select {
  font: inherit; font-size: 1rem; color: var(--ink); background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r); padding: .5rem .75rem; width: 100%; min-height: 2.7rem;
}
input::placeholder { color: #9a8b73; }
input:hover { border-color: var(--soft); }
input:focus, select:focus { border-color: var(--red); }
select { cursor: pointer; }
input:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
input:focus, select:focus { outline: 2px solid transparent; box-shadow: 0 0 0 3px rgba(154,42,28,.18); } /* прозрачная рамка видна в режиме высокой контрастности */
.filter { position: relative; display: flex; align-items: center; gap: .5rem; margin: 0; flex: 0 1 18rem; width: 100%; }
.filter > .i { position: absolute; left: .75rem; color: var(--soft); pointer-events: none; }
.filter input { padding-left: 2.3rem; }
.filter.big { flex: none; margin: .6rem 0; }
.field-label { display: block; font-size: .9rem; margin: 1rem 0 .3rem; color: var(--ink); }
.check { display: flex; align-items: center; gap: .5rem; margin: .8rem 0; font-size: .9rem; color: var(--soft); cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--red); }
.card { margin: 1rem 0; }
.card .btn { margin-top: .8rem; }
.btn-wide { width: 100%; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-size: .88rem; text-decoration: none; cursor: pointer; color: #fff; background: var(--red); border: 1px solid var(--red); border-radius: var(--r); padding: .4rem 1rem; min-height: 2.4rem; }
.btn:hover { color: #fff; background: var(--red-dk); border-color: var(--red-dk); }
.btn-quiet { color: var(--ink); background: transparent; border-color: var(--line-2); }
.btn-quiet:hover { color: var(--red-dk); background: var(--tint); border-color: var(--line-2); }
.btn-danger { color: var(--red-dk); background: transparent; border-color: transparent; }
.btn-danger:hover { color: #fff; background: var(--red-dk); border-color: var(--red-dk); }
.actions form { margin: 0; }
.btn-top { font-size: .85rem; margin-left: .3rem; color: var(--red); background: transparent; border-color: var(--line-2); }
.btn-top:hover { color: #fff; background: var(--red); border-color: var(--red); }

/* уведомления: тонкая полоска слева */
.notice { background: var(--tint); border-left: 3px solid var(--line-2); border-radius: 0 var(--r) var(--r) 0; padding: .7rem 1rem; margin: 0 0 1.4rem; font-size: .95rem; }
.notice p { margin: .25rem 0; }
.notice .btn { margin: .4rem .4rem .2rem 0; }
.notice.err { background: #f9e6e0; border-color: var(--red); color: #5a130b; }
.notice.ok { background: #edf1dc; border-color: #7b9a35; }
.notice.warn { background: #f8efd2; border-color: #c9a94a; }
[hidden] { display: none !important; }

/* «✓ сохранено» в строке об авторе, тихо гаснет */
.saved-note { display: inline-flex; align-items: center; gap: .25rem; margin-left: .6rem; color: #56721f; font-style: italic; transition: opacity .8s; }
.saved-note .i { width: 1em; height: 1em; }
.saved-note.out { opacity: 0; }

/* каталог: список, как оглавление */
.catalog-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem 1.5rem; margin-bottom: 1.4rem; }
.catalog-head h1 { margin: 0; }
.list { border-top: 1px solid var(--line); }
.ecard { display: flex; align-items: flex-start; gap: 1.2rem; padding: 1.1rem .2rem; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); min-width: 0; }
.ecard:hover { background: linear-gradient(to right, transparent, var(--tint) 30%, var(--tint) 70%, transparent); color: var(--ink); }
.thumb { order: 2; width: 5rem; height: 5rem; flex: none; object-fit: cover; border-radius: var(--r); background: var(--tint); }
.thumb.ph { display: grid; place-items: center; font-family: var(--title); font-size: 2.6rem; line-height: 1; color: var(--red); }
.txt { flex: 1; display: flex; flex-direction: column; min-width: 0; gap: .2rem; }
.t { font-size: 1.15rem; color: var(--red-dk); line-height: 1.3; }
.ecard:hover .t { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ex { font-size: .92rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ecard .meta { margin-top: .2rem; }
.index { list-style: none; padding: 0; margin: 0 0 1rem; columns: 3 14rem; column-gap: 2rem; }
.index li { padding: .25rem 0; break-inside: avoid; }
.index a { text-decoration: none; }
.index a:hover { text-decoration: underline; }
.index.big { columns: 1; } .index.big li { font-size: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
h2.letter { font-family: var(--title); font-weight: 400; font-size: 1.6rem; color: var(--red); margin: 1.6rem 0 .3rem; }

/* памятная дата: строчка киноварью над названием */
.kicker { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-size: .78rem; letter-spacing: .03em; color: var(--red); }
.kicker .i { width: 1em; height: 1em; }
.kicker.soon { font-weight: 700; }
.entry-head .kicker { font-size: .85rem; margin-bottom: .2rem; }

/* метка «скрыта» в списках */
.tag { display: inline-flex; align-items: center; gap: .25rem; margin-left: .6rem; padding: 0 .45rem; font-size: .75rem; line-height: 1.5; color: var(--soft); border: 1px solid var(--line-2); border-radius: var(--r); vertical-align: .1em; }
.tag .i { width: 1em; height: 1em; }
.notice .i { vertical-align: -.15em; }

/* переключатель «По алфавиту / По дате» */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; }
.seg a { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .85rem; min-height: 2.3rem; font-size: .85rem; color: var(--soft); text-decoration: none; }
.seg a + a { border-left: 1px solid var(--line-2); }
.seg a:hover { background: var(--tint); color: var(--ink); }
.seg a[aria-current] { background: var(--red); color: #fff; }
.index.dated { columns: 2 16rem; }
.index.dated li { display: flex; gap: .7rem; align-items: baseline; }
.index.dated .day { flex: none; width: 1.6rem; text-align: right; font-family: var(--title); font-size: 1.15rem; color: var(--red); }

/* статья */
.entry-head h1 { margin: 0 0 .5rem; font-size: 2.4rem; line-height: 1.15; }
.entry-sub { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; }
.entry-sub .meta { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .3rem; }
.actions .btn { font-size: .82rem; min-height: 2.2rem; padding: .25rem .7rem; }
.entry .orn { margin: 1.3rem auto 1.6rem; }
.body { font-size: 1.1rem; line-height: 1.75; overflow-wrap: anywhere; -webkit-hyphens: auto; hyphens: auto; } /* переносы по-русски, как в книге (lang="ru") */
.body::after { content: ""; display: table; clear: both; }
.body p { margin: 0 0 .9em; }
.body h1 { font-size: 1.6rem; margin: 1.6rem 0 .4rem; clear: both; }
.body h2 { font-size: 1.35rem; margin: 1.5rem 0 .4rem; clear: both; }
.body h3 { font-size: 1.12rem; font-style: italic; margin: 1.2rem 0 .3rem; clear: both; }
.entry .body > p:first-child::first-letter { float: left; font-family: var(--title); font-size: 3.1em; line-height: .85; color: var(--red); padding: .06em .12em 0 0; }
/* картинки: умеренного размера, справа от текста (на телефоне — по центру) */
.body img { float: right; clear: right; max-width: min(45%, 18rem); max-height: 20rem; width: auto; height: auto; margin: .3rem 0 .8rem 1.4rem; border-radius: var(--r); }
@media (max-width: 700px) { .body img { float: none; display: block; max-width: 100%; margin: .8rem auto; } }

/* приглашения */
.card.invite { padding: .9rem 0; margin: 0; border-bottom: 1px solid var(--line); }
.card.invite p { margin: 0 0 .4rem; }
.card.invite .btn { margin-top: .5rem; }

/* редактор на всю страницу */
.edit-main { flex: 1; width: 100%; }
.docbar { position: sticky; top: 0; z-index: 5; background: rgba(250,246,236,.94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.docbar-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; padding: .4rem 1rem; }
.editor-bar { display: flex; flex-wrap: wrap; gap: .3rem; }
.editor-bar .grp { display: flex; flex-wrap: wrap; gap: .1rem; padding-right: .4rem; margin-right: .1rem; border-right: 1px solid var(--line); }
.editor-bar .grp:last-child { border-right: 0; }
.editor-bar button { display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-size: .8rem; color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: var(--r); padding: .3rem .55rem; min-height: 2.4rem; cursor: pointer; }
.editor-bar button:hover { background: var(--tint); }
.editor-bar button.on { background: var(--red); color: #fff; }
.editor-bar .b-img { color: var(--red); }
.editor-bar button.ib { padding: .3rem; width: 2.4rem; justify-content: center; }
.editor-bar button.ib .i { width: 1.2em; height: 1.2em; }
.editor-bar #btn-date.set { color: var(--red); background: var(--tint); border-color: var(--line-2); }
.docbar-actions { display: flex; gap: .4rem; }
.sheet { background: var(--field); max-width: 46rem; min-height: calc(100vh - 9rem); margin: 1.6rem auto 2rem; padding: 2.6rem 3.4rem 4rem; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 1px 2px rgba(43,32,23,.04), 0 8px 24px -12px rgba(43,32,23,.12); }
@media (max-width: 800px) { .sheet { margin: 0; padding: 1.2rem 1rem 3rem; border: 0; border-radius: 0; box-shadow: none; } }
input.title-input { display: block; width: 100%; border: 0; border-radius: 0; background: transparent; padding: 0; margin: 0 0 1rem; font-family: var(--title); font-size: 2.2rem; line-height: 1.2; color: var(--red-dk); min-height: 0; }
input.title-input:focus { outline: 0; border: 0; box-shadow: none; }
.title-input::placeholder { color: #bfae8c; }
.editor { min-height: 60vh; outline: 0; cursor: text; }
.editor:empty::before { content: "Начните писать здесь…"; color: #a99a7c; font-style: italic; }
.editor img { cursor: pointer; }
.editor img.sel { outline: 2px solid var(--red); outline-offset: 2px; }

/* окно поиска картинок */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(43,32,23,.45); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 1rem; }
.modal-box { background: var(--paper); border-radius: 6px; width: 100%; max-width: 60rem; padding: 1.2rem 1.5rem 1.4rem; margin: auto; box-shadow: 0 20px 50px -20px rgba(43,32,23,.45); }
.modal-box h2 { margin: .1rem 0 .3rem; font-family: var(--title); font-weight: 400; font-size: 1.6rem; }
.modal-box.small { max-width: 30rem; margin-top: 12vh; margin-bottom: auto; }
.modal-box.small .hint { margin: 0 0 .4rem; }
.date-row { display: flex; flex-wrap: wrap; gap: 0 .7rem; }
.date-row label { flex: 0 0 5.5rem; }
.date-row label.grow { flex: 1 1 9rem; }
.date-row .field-label { margin-top: .7rem; }
.date-row .opt { color: var(--soft); font-size: .8rem; }
.date-row label:last-child { flex: 1 1 100%; }
.date-row label:last-child input { max-width: 8rem; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; margin-top: 1.3rem; }
.imggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .8rem; margin: .8rem 0 1rem; }
.imggrid button { background: none; border: 1px solid transparent; border-radius: var(--r); padding: .3rem; cursor: pointer; font: inherit; font-size: .72rem; color: var(--soft); display: flex; flex-direction: column; gap: .3rem; align-items: stretch; text-align: left; }
.imggrid button:hover, .imggrid button:focus-visible { border-color: var(--red); background: var(--tint); }
.imggrid img { width: 100%; height: 7.5rem; object-fit: cover; border-radius: 3px; background: var(--tint); }
.imggrid span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media print { .top, .actions, form, .docbar { display: none; } body { background: #fff; } }
