/* Контент-завод · Библиотека катхи */

:root {
  --paper: #f6f0e1;
  --paper-2: #fbf7ea;
  --card: #fffdf6;
  --ink: #1d2b24;
  --ink-soft: #4f5b53;
  --green: #1c4a38;
  --green-deep: #123226;
  --green-wash: #e8efe3;
  --gold: #b38b2e;
  --gold-soft: rgba(179, 139, 46, 0.42);
  --gold-ink: #7b5b12;
  --line: rgba(28, 74, 56, 0.16);
  --line-strong: rgba(28, 74, 56, 0.34);
  --danger: #8f2d1f;
  --danger-wash: #f8e6df;
  --ok-wash: #e3efe2;
  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 5px;
  --gutter: 16px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 12px;
}

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  background:
    radial-gradient(900px 420px at 8% -8%, rgba(179, 139, 46, 0.12), transparent 62%),
    linear-gradient(180deg, var(--paper-2), var(--paper) 520px);
  background-color: var(--paper);
  overflow-x: hidden;
}

img, svg { max-width: 100%; }

h1, h2, h3, p, ul, dl, dd, figure, fieldset { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }

a { color: var(--green); }

:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
  border-radius: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 50;
  padding: 10px 14px;
  background: var(--green);
  color: #fffaf0;
  border-radius: var(--radius);
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* Шапка */

.site-header {
  border-bottom: 1px solid var(--gold-soft);
  box-shadow: 0 3px 0 -2px rgba(179, 139, 46, 0.22);
}
.header-inner { padding-top: 18px; padding-bottom: 16px; }

.brand {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 14px;
  text-decoration: none;
  color: var(--green-deep);
}
.brand-name {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.005em;
}
.brand-sub {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-ink);
}

/* Вступление */

.hero { padding: 44px 0 30px; }
.hero-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px 40px;
}
.hero-copy { flex: 1 1 24rem; min-width: 0; }
.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.35rem, 7.4vw, 4.2rem);
  line-height: 1.04;
  letter-spacing: -0.012em;
  color: var(--green-deep);
  overflow-wrap: break-word;
}
.hero h1 em {
  display: block;
  font-style: italic;
  color: var(--green);
}
.hero-lead {
  margin-top: 20px;
  max-width: 38rem;
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.hero-lead::before {
  content: "";
  display: block;
  width: 64px;
  height: 0;
  margin-bottom: 18px;
  border-top: 2px solid var(--gold);
}
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 32px;
  padding-bottom: 4px;
}
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat strong {
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 400;
  line-height: 1.1;
  color: var(--green-deep);
}
.stat span {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-ink);
}

/* Последний выпуск */

.latest {
  background: var(--green-deep);
  color: #f7f0dc;
  border-top: 2px solid var(--gold);
  border-bottom: 1px solid rgba(0, 0, 0, 0.3);
}
.latest-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px 28px;
  align-items: center;
  padding-top: 16px;
  padding-bottom: 16px;
}
.latest-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #e6c877;
}
.latest-body { min-width: 0; }
.latest-meta {
  font-size: 0.875rem;
  color: #d8d2bd;
  overflow-wrap: anywhere;
}
.latest-sep { margin: 0 0.5em; color: #e6c877; }
.latest-title {
  margin-top: 2px;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.3;
  color: #fffaf0;
  overflow-wrap: anywhere;
}
.latest-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.latest-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: var(--radius);
  background: #f7f0dc;
  color: var(--green-deep);
  font-weight: 650;
  text-decoration: none;
}
.latest-link:hover { background: #fffaf0; }
.latest-filter {
  min-height: 42px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: #f0dca0;
  font: inherit;
  font-size: 0.875rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.latest :focus-visible { outline-color: #f0d98c; }

/* Рабочая область */

.library { padding-top: 36px; padding-bottom: 56px; outline: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label,
.kinds legend {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-ink);
}

input[type="search"],
input[type="date"],
select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-color: #fffefa;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.3;
}
input[type="date"] { -webkit-appearance: none; appearance: none; }
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--green) 50%),
    linear-gradient(135deg, var(--green) 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}
input::placeholder { color: #6b7469; }

.finder {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px 20px;
  padding: 22px 20px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 10px 28px -22px rgba(18, 50, 38, 0.5);
}
.finder > * { min-width: 0; }

.kinds legend { padding: 0; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; }
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.chip-face {
  display: inline-flex;
  gap: 8px;
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fffefa;
  color: var(--green-deep);
  font-weight: 600;
  line-height: 1.2;
  align-items: center;
}
.chip-count {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.chip:hover .chip-face { border-color: var(--green); }
.chip input:checked + .chip-face {
  background: var(--green);
  border-color: var(--green);
  color: #fffaf0;
}
.chip input:checked + .chip-face .chip-count { color: #e6dcb9; }
.chip input:focus-visible + .chip-face {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

.finder-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-top: 4px;
}
.copy-status {
  min-height: 1.4em;
  font-size: 0.875rem;
  font-weight: 600;
}
#copy-link[data-state="ok"] { background: var(--ok-wash); border-color: #1c5a3a; color: #1c5a3a; }
#copy-link[data-state="error"] { background: var(--danger-wash); border-color: var(--danger); color: var(--danger); }
.copy-status[data-state="ok"] { color: #1c5a3a; }
.copy-status[data-state="error"] { color: var(--danger); }
.copy-status:empty { display: none; }

.more {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 16px 20px;
  padding-top: 18px;
  border-top: 1px dashed var(--gold-soft);
}

@media (min-width: 720px) {
  .finder { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 26px 26px 22px; }
  .field-search, .kinds, .finder-bar, .more { grid-column: 1 / -1; }
  .field-topic { grid-column: span 2; }
}

/* Кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn .icon { width: 1.15em; height: 1.15em; }
.btn-primary { background: var(--green); color: #fffaf0; border-color: var(--green); }
.btn-primary:hover { background: var(--green-deep); }
.btn-secondary { background: #fffefa; color: var(--green-deep); border-color: var(--green); }
.btn-secondary:hover { background: var(--green-wash); }
.btn-quiet { background: transparent; color: var(--green-deep); border-color: var(--line-strong); }
.btn-quiet:hover { background: var(--green-wash); border-color: var(--green); }
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-primary:disabled { background: #d8d7c6; color: #4f5b53; border-color: #d8d7c6; opacity: 0.8; }
.btn-fmt { font-weight: 500; font-size: 0.78rem; opacity: 0.85; letter-spacing: 0.04em; }
.btn[aria-expanded] .chev { transition: transform 0.15s; }
.btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
#more-toggle[aria-expanded="true"] { background: var(--green-wash); border-color: var(--green); }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--green);
  color: #fffaf0;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Результаты */

.results { margin-top: 40px; }
.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
  padding-bottom: 14px;
}
.section-title {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1.15;
  color: var(--green-deep);
}
.result-count { margin-top: 4px; color: var(--ink-soft); font-size: 0.95rem; }
.field-sort { flex: 0 1 240px; min-width: min(100%, 200px); }
.view-note {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-left: 3px solid var(--gold);
  background: #f4ecd2;
  font-size: 0.9rem;
}

/* Панель выбора */

.selection {
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
}
.selection-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}
.selection-summary { flex: 1 1 260px; min-width: 0; }
.sel-summary { font-weight: 650; color: var(--green-deep); overflow-wrap: anywhere; }
.sel-hidden, .sel-warn { margin-top: 2px; font-size: 0.875rem; color: var(--ink-soft); }
.sel-warn { color: var(--danger); font-weight: 600; }
.selection-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.zip-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 14px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--gold-soft);
}
.zip-progress progress { grid-column: 1 / -1; width: 100%; height: 10px; accent-color: var(--green); }
.zip-progress p { font-size: 0.9rem; font-weight: 600; }

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--green);
  background: var(--ok-wash);
  font-size: 0.925rem;
}
.notice p { min-width: 0; overflow-wrap: anywhere; }
.notice-info { background: #f4ecd2; border-left-color: var(--gold); }
.notice-error { background: var(--danger-wash); border-left-color: var(--danger); }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notice-actions:empty { display: none; }
noscript .notice { margin-top: 0; }

@media (min-width: 720px) {
  .selection {
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 12px 24px -16px rgba(18, 50, 38, 0.4);
  }
}

/* Строки */

.rows {
  border-top: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 0 0 var(--radius) var(--radius);
}
.row {
  position: relative;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.row:last-child { border-bottom: 1px solid var(--line-strong); }
.row.is-selected { background: #f1f5e9; box-shadow: inset 3px 0 0 var(--green); }

.row-main {
  display: grid;
  grid-template-columns: 44px 56px minmax(0, 1fr) auto;
  column-gap: 12px;
  row-gap: 8px;
  align-items: start;
  padding: 14px 16px 14px 8px;
}

.check {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
}
.check input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.check input:disabled { cursor: not-allowed; }
.check-box {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--green);
  border-radius: 4px;
  background: #fffefa;
  color: transparent;
}
.check-box .icon { width: 16px; height: 16px; stroke-width: 2.6; }
.check input:checked + .check-box { background: var(--green); color: #fffaf0; }
.check input:disabled + .check-box { opacity: 0.55; }
.check input:focus-visible + .check-box { outline: 3px solid var(--green); outline-offset: 2px; }

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.thumb {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ece4cd;
  color: var(--green);
}
.thumb .icon { width: 26px; height: 26px; }
.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.info { min-width: 0; }
.row-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--green-deep);
  overflow-wrap: anywhere;
}
.row-speaker { margin-top: 2px; font-size: 0.925rem; color: var(--ink); overflow-wrap: anywhere; }
.row-topics {
  margin-top: 2px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
.facts li { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
.facts li + li::before {
  content: "·";
  margin: 0 0.55em;
  color: var(--gold-ink);
  font-weight: 700;
}
.facts .icon { width: 15px; height: 15px; color: var(--green); }
.facts .fact-kind { font-weight: 650; color: var(--green-deep); }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 12px;
  max-width: 300px;
  align-self: center;
}
.text-link {
  font-size: 0.875rem;
  font-weight: 600;
  text-underline-offset: 3px;
  padding: 10px 2px;
}

/* Раскрытая область */

.panel {
  margin: 0 16px 16px 72px;
  padding: 16px 0 0;
  border-top: 1px dashed var(--gold-soft);
}
.media { margin-bottom: 14px; }
.media audio { display: block; width: 100%; max-width: 560px; }
.media .note { font-size: 0.9rem; color: var(--ink-soft); }
.media .note-error { color: var(--danger); font-weight: 600; }
.media .btn { margin-top: 8px; }

.reading {
  max-height: 22rem;
  overflow: auto;
  margin: 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefa;
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 20px; }
.preview-img {
  display: block;
  max-width: 100%;
  max-height: 440px;
  width: auto;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ece4cd;
}
.preview figcaption { flex: 1 1 220px; min-width: 0; font-size: 0.925rem; overflow-wrap: anywhere; }
.preview figcaption strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--green-deep);
}

.details {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  gap: 8px 16px;
  font-size: 0.925rem;
}
.details dt {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-ink);
  padding-top: 3px;
}
.details dd { min-width: 0; overflow-wrap: anywhere; }
.topic-list li { padding: 1px 0; }
.topic-list li::before { content: "— "; color: var(--gold-ink); }

/* Состояния */

.state {
  margin-top: 24px;
  padding: 36px 24px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
}
.state .btn { margin-top: 16px; }
.state-title {
  margin-bottom: 6px;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--green-deep);
}
.state-error { border-left: 3px solid var(--danger); background: var(--danger-wash); }
.state-empty { margin-top: 0; border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }

.skeleton { display: grid; gap: 10px; max-width: 520px; margin: 0 auto 16px; }
.skeleton span {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #e9e0c8, #f4ecd6, #e9e0c8);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton span:nth-child(2) { width: 80%; }
.skeleton span:nth-child(3) { width: 55%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.load-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 0 4px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.925rem;
}

/* Подвал */

.site-footer {
  margin-top: 8px;
  padding: 30px 0 44px;
  border-top: 1px solid var(--gold-soft);
  box-shadow: 0 -3px 0 -2px rgba(179, 139, 46, 0.22);
  background: rgba(232, 239, 227, 0.4);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.footer-inner { display: grid; gap: 10px; }
.footer-note { max-width: 46rem; color: var(--ink); }
.footer-meta { overflow-wrap: anywhere; }
.footer-sep { margin: 0 0.5em; color: var(--gold-ink); }
.footer-brand { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-ink); }
.footer-brand span { font-family: var(--serif); font-weight: 700; letter-spacing: 0.02em; text-transform: none; font-size: 0.95rem; }

/* Узкие экраны */

@media (max-width: 899px) {
  .latest-inner { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 719px) {
  :root { --gutter: 14px; }
  .hero { padding: 32px 0 22px; }
  .library { padding-top: 26px; }
  .finder { padding: 18px 14px 16px; }
  .section-title { font-size: 1.55rem; }
  .selection-actions .btn { flex: 1 1 auto; }
  .selection-actions #sel-zip { flex-basis: 100%; }
}

@media (max-width: 759px) {
  .row-main {
    grid-template-columns: 44px 52px minmax(0, 1fr);
    padding: 14px 12px 14px 4px;
  }
  .thumb { width: 52px; height: 52px; }
  .row-actions {
    grid-column: 1 / -1;
    max-width: none;
    justify-content: flex-start;
    padding-left: 8px;
  }
  .row-actions .btn { flex: 1 1 auto; }
  .panel { margin: 0 12px 16px 12px; }
  .details { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .details dt { padding-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
