:root {
  color-scheme: light;
  --desk: #ffffff;
  --paper: #ffffff;
  --ink: #121714;
  --green: #245746;
  --signal: #b22d2d;
  --rule: #d2d6d0;
  --muted: #404a43;
  font: 17px/1.7 Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
}

a {
  color: var(--green);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

a,
button,
summary {
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, text-decoration-color 140ms ease;
}

button {
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, text-decoration-color 140ms ease, transform 140ms ease;
}

button:active { transform: translateY(1px); }

.masthead {
  width: 100%;
  min-height: 68px;
  margin: 0;
  padding: 10px clamp(16px, 4vw, 48px);
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.title-masthead { justify-content: flex-start; }
.title-masthead > a:last-child { margin-left: auto; font: 650 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
.title-sheet { min-height: calc(100vh - 140px); }
.title-page-arabic { max-width: 38ch; margin: 14px 0 20px; font-size: clamp(28px, 4vw, 38px); line-height: 1.8; }

.brand {
  display: grid;
  gap: 5px;
  color: var(--ink);
  text-decoration: none;
}

.brand span {
  font: 700 25px/1 Georgia, "Iowan Old Style", serif;
  letter-spacing: -.045em;
}

nav a,
.eyebrow,
.search label,
.segment-kind {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(14px, 2.4vw, 30px);
}

nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

nav a:hover { color: var(--green); border-color: var(--green); }

.mobile-nav { display: none; }

.sheet {
  width: min(calc(100% - 32px), 1240px);
  margin: 16px auto 30px;
  padding: 18px clamp(0px, 3vw, 32px) 42px;
  border: 0;
  background: var(--paper);
  box-shadow: none;
}

.sheet::before,
.sheet::after {
  display: none;
}

.hero {
  max-width: 900px;
  margin: 0 0 28px;
}

.eyebrow {
  margin: 0;
  color: var(--signal);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .14em;
  line-height: 1.5;
  text-transform: uppercase;
}

h1 {
  max-width: 20ch;
  margin: 10px 0 14px;
  font: 700 clamp(36px, 5vw, 58px)/1.05 Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  letter-spacing: -.04em;
}

.hero h1 span { color: var(--ink); }

h2 {
  margin: 0 0 12px;
  font: 400 26px/1.2 Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  letter-spacing: -.025em;
}

h3 {
  margin: 0 0 14px;
  font: 400 23px/1.3 Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

p { margin: 0 0 1em; }

.dek,
.topic-intro > p:not(.eyebrow):not(.editor-note) {
  max-width: 58ch;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.5;
}

.search {
  max-width: 740px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.search label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.search div {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.search input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 2px;
  border: 0;
  border-bottom: 1px solid #858d82;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 17px/1.4 Georgia, "Iowan Old Style", serif;
}

.search input:focus { border-bottom-color: var(--green); }

.search button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--green);
  border-radius: 0;
  background: var(--green);
  color: #fff;
  font: 700 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}

.search button:hover { background: #173f31; }

.empty {
  max-width: 850px;
  padding: 18px 0 6px;
  border-top: 1px solid var(--ink);
  color: var(--muted);
}

.empty h2 { color: var(--ink); }
.empty p { max-width: 60ch; }

.home-catalog {
  margin-top: 36px;
  padding-top: 13px;
  border-top: 2px solid var(--ink);
}

.home-catalog > h2 {
  margin-bottom: 4px;
  font: 700 28px/1.15 Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

.catalog-count {
  margin: 0 0 20px;
  color: var(--muted);
  font: 12px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.catalog-group { margin-top: 24px; }

.catalog-group > h2 {
  margin: 0;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--ink);
  color: var(--muted);
  font: 750 11px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.catalog-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.catalog-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .75fr);
  align-items: start;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}

.catalog-item h3 {
  margin: 0 0 4px;
  font: 700 25px/1.2 Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  letter-spacing: -.02em;
}

.catalog-item h3 a {
  color: var(--ink);
  text-decoration: none;
}

.catalog-item h3 a:hover { color: var(--green); text-decoration: underline; }

.catalog-arabic {
  margin: 0;
  font: 22px/1.55 "Noto Naskh Arabic", "Amiri", "Geeza Pro", serif;
}

.catalog-summary {
  max-width: 58ch;
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}

.catalog-byline {
  margin: 5px 0 0;
  color: var(--muted);
  font: 12px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.catalog-status {
  margin: 6px 0 0;
  color: var(--muted);
  font: 12px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.catalog-status { color: var(--green); font-weight: 700; }
.catalog-note,
.catalog-source-note {
  max-width: 75ch;
  color: var(--muted);
  font: 13px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.catalog-source-note { margin: 20px 0 0; padding-top: 10px; border-top: 1px solid var(--rule); }
.request-book { margin: 0 0 20px; font: 700 13px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.catalog-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 10px 0 16px; font: 12px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
.catalog-pagination span { margin-right: 6px; color: var(--muted); }
.catalog-pagination a { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.catalog-pagination a[aria-current="page"] { color: var(--ink); font-weight: 750; text-decoration-thickness: 2px; }
.planned-subheading { margin: 18px 0 0; font: 400 20px/1.25 Georgia, "Iowan Old Style", serif; }

.search-result-title,
.search-result-arabic,
.search-result-status { display: block; }
.search-result-title { font-weight: 700; }
.search-result-arabic { margin-top: 3px; font: 21px/1.5 "Noto Naskh Arabic", "Amiri", "Geeza Pro", serif; }
.search-result-status { margin-top: 4px; color: var(--muted); font: 11px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
.search-result-limit { color: var(--muted); font: 12px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.search-result-heading { margin: 20px 0 0; padding-bottom: 6px; border-bottom: 1px solid var(--ink); font: 750 11px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.search-result-heading:first-child { margin-top: 0; }

.catalog-sections {
  margin: 0;
  padding-left: 1.7em;
  list-style: decimal-leading-zero;
}

.catalog-sections li { padding-left: 4px; }

.catalog-sections li::marker {
  color: var(--green);
  font: 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

.catalog-sections a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-size: 15px;
  text-decoration: none;
}

.catalog-sections a:hover { color: var(--green); text-decoration: underline; }

#results { max-width: 760px; margin-top: 18px; }

#results a {
  display: block;
  padding: 13px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  font-size: 18px;
  animation: reveal 160ms ease-out both;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.reading-layout {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 48px);
}

.contents {
  align-self: start;
  padding-right: 14px;
  border-right: 1px solid var(--rule);
}

.contents h2 {
  margin: 0 0 14px;
  color: var(--muted);
  font: 750 10px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.toc-list,
.contents-list {
  margin: 0;
  padding-left: 1.8em;
  list-style: decimal-leading-zero;
}

.toc-list li,
.contents-list li { padding-left: 4px; }

.toc-list li::marker,
.contents-list li::marker {
  color: var(--green);
  font: 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

.toc-list a,
.contents-list a {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
  text-decoration: none;
}

.toc-list a:hover,
.contents-list a:hover { color: var(--green); text-decoration: underline; }

.toc-mobile { display: none; }

.reading-content {
  min-width: 0;
  max-width: 940px;
}

.chapter-heading {
  margin-bottom: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.reading-content h1 { max-width: 22ch; font-size: clamp(36px, 4.5vw, 48px); font-weight: 700; }

.source-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 18px;
  max-width: 740px;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
  color: var(--muted);
  font: 13px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.source-notes p { margin: 0; }
.source-notes p + p::before { content: none; }

article.segment {
  max-width: 940px;
  padding: 19px 0 24px;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 24px;
}

.chapter-heading + article.segment { border-top: 0; padding-top: 8px; }

.segment-kind {
  display: flex;
  align-items: center;
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.arabic {
  margin: 6px 0 10px;
  color: #18271f;
  font-family: "Noto Naskh Arabic", "Amiri", "Geeza Pro", serif;
  font-size: clamp(30px, 3.5vw, 38px);
  line-height: 1.85;
  text-align: right;
}

.segment > p[lang="id"],
.segment blockquote p[lang="id"] {
  max-width: 65ch;
  margin: 0;
  font-size: 19px;
  line-height: 1.7;
}

.segment blockquote {
  margin: 0;
  padding: 0;
  border: 0;
}

.segment-source {
  width: fit-content;
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  color: var(--muted);
  font: 12px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.topic-intro {
  max-width: 760px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ink);
}

.topic-intro h1 { max-width: 15ch; }
.editor-note {
  max-width: 70ch;
  margin: 10px 0 0;
  padding: 0;
  border: 0;
  color: var(--muted);
  font: 12px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.topic-references { max-width: 850px; }
.topic-references > h2 { margin-bottom: 8px; }

.reference-list {
  margin: 0;
  padding-left: 2em;
  list-style: decimal-leading-zero;
}

.reference-entry {
  padding: 16px 0 18px 4px;
  border-top: 1px solid var(--rule);
}

.reference-entry::marker {
  color: var(--green);
  font: 13px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.reference-metadata {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 18px;
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  color: var(--muted);
  font: 13px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.reference-metadata p { margin: 0 0 4px; }
.segment-links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 17px 0 0; padding: 0; list-style: none; }
.segment-links a { min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; }

.colophon {
  width: min(calc(100% - 40px), 1160px);
  margin: 0 auto 30px;
  padding: 14px clamp(22px, 5vw, 68px) 0;
  border-top: 1px solid var(--ink);
  color: var(--muted);
  font: 12px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.skip {
  position: absolute;
  z-index: 5;
  top: 6px;
  left: -10000px;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
}

.skip:focus { left: 8px; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid #8a5a17;
  outline-offset: 3px;
}

.consent {
  position: fixed;
  z-index: 5;
  inset: auto 16px 16px;
  max-width: 480px;
  margin: auto;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  background: var(--paper);
  box-shadow: 0 5px 25px rgb(32 39 32 / 20%);
}

.consent p {
  max-width: none;
  margin: 0 0 8px;
  color: var(--muted);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.consent button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.consent button {
  min-height: 44px;
  margin: 0 6px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--green);
  border-radius: 0;
  background: var(--paper);
  color: var(--green);
  font: 650 13px system-ui, -apple-system, "Segoe UI", sans-serif;
}

.consent button:first-of-type { background: var(--green); color: #fff; }

@media (max-width: 760px) {
  .masthead {
    width: 100%;
    min-height: 56px;
    align-items: center;
    flex-direction: row;
    gap: 12px;
    padding: 4px 12px;
  }

  .brand { display: block; }
  .brand span { font-size: 24px; }
  .desktop-nav { display: none; }
  .mobile-nav { position: relative; display: block; margin-left: auto; }
  .mobile-nav summary {
    min-width: 48px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    text-decoration: underline;
    text-underline-offset: 4px;
    color: var(--ink);
    font: 700 11px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
    letter-spacing: .1em;
    text-transform: uppercase;
    cursor: pointer;
    list-style: none;
  }
  .mobile-nav summary::-webkit-details-marker { display: none; }
  .mobile-nav[open] summary { color: var(--green); }
  .mobile-nav nav {
    position: absolute;
    z-index: 6;
    top: calc(100% + 8px);
    right: 0;
    width: min(220px, calc(100vw - 40px));
    display: grid;
    gap: 0;
    padding: 5px 14px;
    border: 1px solid var(--ink);
    background: #fff;
    box-shadow: 0 3px 0 rgb(18 23 20 / 10%);
  }
  .mobile-nav[open] nav { animation: reveal 160ms ease-out both; }
  .mobile-nav nav a { width: 100%; border-bottom: 1px solid var(--rule); }
  .mobile-nav nav a:last-child { border-bottom: 0; }

  .sheet {
    width: calc(100% - 24px);
    margin: 8px auto 18px;
    padding: 12px 0 30px;
  }

  .hero { margin-bottom: 24px; }
  .hero h1 { font-size: clamp(36px, 9vw, 48px); }
  .dek { font-size: 16px; }
  .catalog-item { display: block; }
  .catalog-sections { margin-top: 10px; }
  .reading-layout { display: block; }
  .contents { margin-bottom: 8px; padding: 0 0 4px; border: 0; border-bottom: 1px solid var(--rule); }
  .toc-desktop { display: none; }
  .toc-mobile { display: block; }
  .toc-mobile summary { min-height: 44px; display: flex; align-items: center; color: var(--green); font: 700 12px system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .09em; text-transform: uppercase; cursor: pointer; }
  .toc-mobile .toc-list { columns: 1; }
  .reading-content h1 { font-size: clamp(36px, 8vw, 46px); }
  .source-notes { grid-template-columns: 1fr; gap: 3px; }
  .segment > p[lang="id"],
  .segment blockquote p[lang="id"] { font-size: 18px; }
  .colophon { width: calc(100% - 20px); padding: 12px 18px 0; }
}

@media (max-width: 420px) {
  .masthead { padding-right: 12px; padding-left: 12px; }
  .sheet { width: calc(100% - 24px); }
  .search button { padding-right: 14px; padding-left: 14px; }
  .reference-list { padding-left: 1.8em; }
  .reference-metadata { grid-template-columns: 1fr; }
}

@media (min-width: 1500px) {
  .sheet { width: min(calc(100% - 96px), 1400px); }
  .colophon { width: min(calc(100% - 96px), 1400px); }
}

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

@media print {
  @page { margin: 18mm; }
  body { background: #fff; color: #111; font-size: 11pt; }
  .masthead nav,
  .contents,
  .search,
  .skip,
  .consent,
  .colophon { display: none !important; }
  .masthead { width: auto; min-height: 0; margin: 0 0 12mm; padding: 0 0 5mm; border-color: #888; }
  .sheet { width: auto; min-height: 0; margin: 0; padding: 0; border: 0; background: #fff; box-shadow: none; }
  .sheet::before,
  .sheet::after { display: none; }
  a { color: inherit; }
  article.segment,
  .reference-entry { break-inside: avoid; }
  h1,
  h2,
  h3 { break-after: avoid; }
}
