:root {
  --primary: #176b78;
  --primary-hover: #125966;
  --primary-soft: #e8f4f5;
  --bg: #ffffff;
  --paper: #f7f4ed;
  --paper-deep: #efe9dd;
  --fg: #0d0f14;
  --muted: #626570;
  --border: #e5e9f2;
  --border-warm: #d9d1c3;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-reader: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  line-height: 1.6;
}
a { color: inherit; }
button, input { font: inherit; }
.shell { width: min(1180px, calc(100% - 64px)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-name { font-weight: 700; letter-spacing: -.02em; font-size: 1.08rem; }
.brand-mark { position: relative; width: 28px; height: 28px; display: inline-block; }
.brand-mark span { position: absolute; width: 8px; height: 8px; border: 2px solid var(--primary); border-radius: 50%; background: #fff; }
.brand-mark span:nth-child(1) { left: 2px; top: 10px; }
.brand-mark span:nth-child(2) { right: 2px; top: 2px; }
.brand-mark span:nth-child(3) { right: 2px; bottom: 2px; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 9px; width: 12px; height: 1px; background: var(--primary); transform-origin: left center; }
.brand-mark::before { top: 12px; transform: rotate(-34deg); }
.brand-mark::after { top: 15px; transform: rotate(34deg); }
.section-name { color: var(--muted); font-size: .92rem; }

.library-hero { padding: 72px 0 52px; }
.eyebrow { margin: 0 0 14px; color: var(--primary); font-size: .76rem; font-weight: 750; text-transform: uppercase; letter-spacing: .14em; }
.library-hero h1 { margin: 0; font-size: clamp(40px, 6vw, 66px); letter-spacing: -.055em; line-height: 1.02; font-weight: 650; }
.hero-copy { margin: 22px 0 0; max-width: 58ch; color: var(--muted); font-size: clamp(17px, 2vw, 20px); }
.method { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 8px 11px; align-items: center; color: var(--muted); font-size: .85rem; }
.method b { color: var(--primary); font-weight: 600; }

.library { display: grid; grid-template-columns: minmax(290px, .7fr) minmax(0, 1.55fr); min-height: 700px; border: 1px solid var(--border-warm); background: var(--paper); }
.catalogue { padding: 26px; border-right: 1px solid var(--border-warm); background: #fbfaf7; }
.catalogue-tools { display: grid; gap: 14px; margin-bottom: 24px; }
.search input { width: 100%; border: 1px solid var(--border-warm); background: #fff; color: var(--fg); padding: 11px 13px; border-radius: 9px; outline: none; }
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filter { border: 0; background: transparent; color: var(--muted); padding: 5px 8px; cursor: pointer; font-size: .78rem; border-radius: 999px; }
.filter:hover, .filter.active { color: var(--primary); background: var(--primary-soft); }
.manuscript-list { display: grid; gap: 12px; }
.manuscript-card { width: 100%; text-align: left; display: grid; grid-template-columns: 90px 1fr; gap: 14px; padding: 13px; border: 1px solid var(--border-warm); background: #fff; cursor: pointer; transition: border-color .18s ease, transform .18s ease, background .18s ease; }
.manuscript-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.manuscript-card.active { border-color: var(--primary); background: var(--primary-soft); }
.card-art { width: 90px; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-deep); border: 1px solid var(--border-warm); }
.card-meta { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.card-id { color: var(--primary); font-size: .68rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.card-title { margin-top: 4px; font-family: var(--font-reader); font-size: 1.02rem; line-height: 1.22; }
.card-doctrine { margin-top: 7px; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.catalogue-note { margin: 26px 2px 0; color: var(--muted); font-size: .76rem; line-height: 1.55; }

.preview { min-width: 0; padding: clamp(40px, 5.5vw, 76px); display: flex; align-items: flex-start; justify-content: center; }
.preview-empty { color: var(--muted); }
.preview-sheet { width: min(100%, 730px); }
.preview-art { display: block; width: min(100%, 600px); height: 245px; object-fit: cover; margin: 0 auto 44px; border: 1px solid var(--border-warm); background: var(--paper-deep); }
.preview-kicker { color: var(--primary); font-size: .72rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.preview h2 { margin: 11px 0 0; font-family: var(--font-reader); font-size: clamp(34px, 4.2vw, 48px); line-height: 1.06; font-weight: 500; letter-spacing: -.028em; }
.preview-status { display: inline-flex; margin-top: 15px; color: var(--muted); font-size: .75rem; gap: 7px; align-items: center; }
.preview-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.preview-question { margin: 34px 0 0; padding-top: 26px; border-top: 1px solid var(--border-warm); }
.preview-label { margin: 0 0 8px; color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .06em; }
.preview-question p:last-child { margin: 0; font-family: var(--font-reader); font-size: 1.18rem; line-height: 1.55; font-style: italic; }
.preview-excerpt { margin: 25px 0 0; color: #35383f; font-family: var(--font-reader); font-size: 1.05rem; line-height: 1.78; }
.passages { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 7px; }
.passages span { border: 1px solid var(--border-warm); background: rgba(255,255,255,.55); border-radius: 999px; padding: 5px 9px; color: var(--muted); font-size: .72rem; }
.preview-actions { margin-top: 32px; }
.read-button { display: inline-flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 9px; background: var(--primary); color: #fff; text-decoration: none; font-weight: 700; font-size: .9rem; }
.read-button:hover { background: var(--primary-hover); }

.footer { margin-top: 64px; padding: 28px 0 42px; border-top: 1px solid var(--border); color: var(--muted); font-size: .78rem; display: flex; justify-content: space-between; gap: 20px; }

/* Reader */
.reader-page { background: #fbfaf7; }
.reader-shell { width: min(860px, calc(100% - 48px)); margin-inline: auto; }
.reader-topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--border); }
.back-link { text-decoration: none; color: var(--muted); font-size: .85rem; }
.back-link:hover { color: var(--primary); }
.reader-meta { color: var(--muted); font-size: .75rem; }
.reader-hero { padding: 64px 0 36px; text-align: center; }
.reader-hero img { width: min(100%, 600px); height: 245px; object-fit: cover; border: 1px solid var(--border-warm); background: var(--paper-deep); margin-bottom: 36px; }
.reader-hero .code { color: var(--primary); font-size: .72rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.reader-hero h1 { margin: 10px auto 0; max-width: 18ch; font-family: var(--font-reader); font-size: clamp(38px, 6vw, 58px); font-weight: 500; line-height: 1.05; letter-spacing: -.035em; }
.reader-document { max-width: 720px; margin: 0 auto; padding-bottom: 80px; font-family: var(--font-reader); font-size: clamp(1.03rem, 2vw, 1.12rem); line-height: 1.82; }
.reader-document > h1:first-child, .reader-document > p.meta-line { display: none; }
.reader-document h2 { margin: 56px 0 15px; font-family: var(--font-ui); font-size: 1.22rem; line-height: 1.3; letter-spacing: -.02em; }
.reader-document p { margin: 0 0 20px; }
.reader-document .question { margin: 0 0 34px; text-align: center; color: #363941; font-style: italic; font-size: 1.12em; }
.reader-document .intro { margin-bottom: 38px; }
.reader-document .reference { margin: 0 0 10px; font-family: var(--font-ui); color: var(--primary); font-size: .8rem; font-weight: 750; letter-spacing: .04em; }
.reader-document blockquote { margin: 0 0 26px; padding: 15px 20px; border-left: 2px solid rgba(23, 107, 120, .45); background: #faf8f3; font-size: 1.02em; }
.reader-document blockquote p { margin: 0; }
.reader-document strong { font-weight: 700; }
.reader-document .complementary { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border-warm); color: var(--muted); font-family: var(--font-ui); font-size: .82rem; }
.reader-note { max-width: 720px; margin: 0 auto 72px; padding: 18px 20px; border: 1px solid var(--border-warm); background: var(--paper); color: var(--muted); font-size: .82rem; }

@media (max-width: 820px) {
  .shell { width: min(100% - 40px, 1180px); }
  .library { grid-template-columns: 1fr; }
  .catalogue { border-right: 0; border-bottom: 1px solid var(--border-warm); }
  .preview { padding: 38px 24px 46px; }
  .preview-art { height: 210px; }
}

@media (max-width: 520px) {
  .shell { width: min(100% - 28px, 1180px); }
  .site-header { min-height: 72px; }
  .library-hero { padding: 52px 0 36px; }
  .library { border-left: 0; border-right: 0; }
  .catalogue { padding: 18px 14px; }
  .manuscript-card { grid-template-columns: 82px 1fr; padding: 10px; }
  .card-art { width: 82px; }
  .preview { padding-left: 14px; padding-right: 14px; }
  .preview-art { height: 185px; margin-bottom: 32px; }
  .footer { flex-direction: column; }
  .reader-shell { width: min(calc(100% - 36px), 860px); }
  .reader-document,
  .reader-note { width: min(calc(100% - 36px), 720px); }
  .reader-document blockquote { padding: 14px 15px; }
  .reader-topbar { min-height: 68px; }
  .reader-hero { padding-top: 42px; }
  .reader-hero img { height: 185px; }
}
