/* Рабочий стол прихода: неделя — как разворот богослужебного календаря.
   Слева число и день, справа места для постов по рубрикатору. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --sunk: #eceef3;
  --ink: #18233a;
  --muted: #5d6679;
  --line: #d9dce5;
  --azure: #1d3a6e;      /* лазурь — основной цвет действий */
  --azure-soft: #e3e9f5;
  --gold: #a87a1f;       /* золото — праздники */
  --gold-soft: #f6ecd6;
  --ok: #2c7a4b;  --ok-soft: #e1f1e7;
  --warn: #9a5b00; --warn-soft: #fbeed9;
  --bad: #b3261e; --bad-soft: #fbe4e2;
  --display: "Prata", Georgia, "Times New Roman", serif;
  --body: "Golos Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151d; --surface: #1a2029; --sunk: #232a35; --ink: #e8ebf1; --muted: #9aa3b4; --line: #2f3746;
    --azure: #8fb0ea; --azure-soft: #22324f; --gold: #e2b85a; --gold-soft: #3a3020;
    --ok: #74c793; --ok-soft: #1d3326; --warn: #f0b25a; --warn-soft: #3a2c17; --bad: #f28b82; --bad-soft: #3c1f1d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151d; --surface: #1a2029; --sunk: #232a35; --ink: #e8ebf1; --muted: #9aa3b4; --line: #2f3746;
  --azure: #8fb0ea; --azure-soft: #22324f; --gold: #e2b85a; --gold-soft: #3a3020;
  --ok: #74c793; --ok-soft: #1d3326; --warn: #f0b25a; --warn-soft: #3a2c17; --bad: #f28b82; --bad-soft: #3c1f1d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--display); font-weight: 400; text-wrap: balance; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--azure); }
:focus-visible { outline: 2px solid var(--azure); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* шапка */
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-size: 20px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand i { width: 26px; height: 26px; border-radius: 6px; background: var(--azure); display: inline-grid; place-items: center; color: var(--gold-soft); font-style: normal; font-size: 15px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs button[aria-current="page"] { background: var(--azure-soft); color: var(--azure); }
.credits { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

main { padding-block: 24px 80px; }

/* кнопки и поля */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--azure); }
.btn.primary { background: var(--azure); border-color: var(--azure); color: var(--surface); }
.btn.gold { background: var(--gold-soft); border-color: transparent; color: var(--gold); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 11px; color: var(--ink); font-size: 15px; font-weight: 400;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }

/* неделя */
.weekhead { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.weekhead h1 { font-size: 30px; line-height: 1.15; }
.weekhead .eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.job { background: var(--azure-soft); color: var(--azure); border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px; display: grid; gap: 8px; }
.job.fail { background: var(--bad-soft); color: var(--bad); }
.job.done { background: var(--ok-soft); color: var(--ok); }
.bar { height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: currentColor; transition: width .4s; }
.lastyear { background: var(--gold-soft); border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.lastyear b { color: var(--gold); }
.lastyear a { cursor: pointer; }

.day { display: grid; grid-template-columns: 150px 1fr; gap: 18px; padding-block: 18px; border-top: 1px solid var(--line); }
.day.today .num { color: var(--azure); }
.dayside .num { font-family: var(--display); font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.dayside .wd { font-weight: 600; margin-top: 4px; }
.dayside .mon { font-size: 13px; color: var(--muted); }
.cal { font-size: 13px; color: var(--muted); margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.cal .feast { color: var(--gold); font-weight: 600; }
.cal .fast { color: var(--ok); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 6px; cursor: pointer; text-align: left; align-content: start; min-width: 0; position: relative; }
.card:hover { border-color: var(--azure); }
.card .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); font-weight: 500; }
.card .meta .time { font-variant-numeric: tabular-nums; }
.card .title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.card .brief { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card.empty { border-style: dashed; background: none; color: var(--muted); }
.card .thumb { position: absolute; right: 10px; bottom: 10px; width: 38px; height: 48px; border-radius: 4px; object-fit: cover; }
.card.has-thumb { padding-right: 58px; }
.dayadd { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-plan { background: var(--sunk); color: var(--muted); }
.s-draft { background: var(--warn-soft); color: var(--warn); }
.s-ready { background: var(--azure-soft); color: var(--azure); }
.s-published { background: var(--ok-soft); color: var(--ok); }
.s-busy { background: var(--azure-soft); color: var(--azure); }
.s-busy::before { animation: pulse 1s infinite alternate; }
.s-err { background: var(--bad-soft); color: var(--bad); }
@keyframes pulse { to { opacity: .25; } }

/* редактор поста */
.sheet-bg { position: fixed; inset: 0; background: rgb(10 15 25 / .45); z-index: 40; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--bg); z-index: 41; overflow-y: auto; box-shadow: -10px 0 40px rgb(0 0 0 / .18); padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.sheet header { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 2; padding-block: 10px; }
.sheet header .in { display: flex; gap: 10px; align-items: center; padding-inline: max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-right)); }
.sheet .body { padding: 18px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); display: grid; gap: 22px; }
.sec { display: grid; gap: 10px; }
.sec h3 { font-size: 18px; }
.statuses { display: flex; gap: 6px; flex-wrap: wrap; }
.statuses button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; font-weight: 500; }
.statuses button[aria-pressed="true"] { border-color: currentColor; font-weight: 700; }
.posttext { min-height: 360px; font-size: 15px; }
.count { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.count.over { color: var(--bad); font-weight: 600; }
.err { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.working { background: var(--azure-soft); color: var(--azure); padding: 10px 12px; border-radius: 8px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: grid; }
.gallery img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; background: var(--sunk); }
.gallery .wait { aspect-ratio: 4 / 5; display: grid; place-items: center; background: var(--sunk); color: var(--muted); font-size: 13px; text-align: center; padding: 10px; gap: 8px; align-content: center; justify-items: center; }
.gallery figcaption { display: flex; gap: 4px; padding: 6px; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos figure { margin: 0; position: relative; }
.photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; display: block; }
.photos button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); cursor: pointer; font-size: 13px; line-height: 1; }
.calbox { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.calbox .feast { color: var(--gold); font-weight: 600; }

/* новый пост */
.kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 22px; }
.kind { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; cursor: pointer; text-align: left; display: grid; gap: 6px; }
.kind[aria-pressed="true"] { border-color: var(--azure); box-shadow: inset 0 0 0 1px var(--azure); }
.kind b { font-family: var(--display); font-weight: 400; font-size: 19px; }
.kind span { font-size: 14px; color: var(--muted); }
.form { display: grid; gap: 14px; max-width: 720px; }

/* архив */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--r); overflow: hidden; }
.table td, .table th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--sunk); }
.table tr[data-open] { cursor: pointer; }
.table tr[data-open]:hover td { background: var(--azure-soft); }
.table td.d { white-space: nowrap; font-variant-numeric: tabular-nums; }
.scrollx { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }

/* настройки */
.setgrid { display: grid; gap: 26px; }
.rub-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 8px; }
.rub-day h3 { font-size: 17px; }
.rub-slot { display: grid; grid-template-columns: 80px 1fr 2fr auto auto; gap: 8px; align-items: center; }
.rub-slot input[type=checkbox] { width: 18px; height: 18px; }
.rubs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 12px; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(380px, 100%); display: grid; gap: 14px; }
.login h1 { font-size: 26px; }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 60; font-size: 14px; max-width: calc(100% - 32px); }

@media (max-width: 720px) {
  .day { grid-template-columns: 1fr; gap: 8px; }
  .dayside { display: flex; align-items: baseline; gap: 10px; }
  .dayside .num { font-size: 28px; }
  .weekhead h1 { font-size: 24px; }
  .rub-slot { grid-template-columns: 70px 1fr auto auto; }
  .rub-slot .about { grid-column: 1 / -1; }
  .top .wrap { gap: 8px; padding-block: 8px; }
  .credits { display: none; }
  .brand span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
