:root {
  --ink: #071224;
  --navy: #031c32;
  --gold: #d5a153;
  --gold-2: #f0c979;
  --paper: #fffaf3;
  --line: rgba(42, 33, 24, .16);
  --muted: #667085;
  --shadow: 0 18px 42px rgba(31, 24, 16, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f8f2ea 0%, #fffaf3 76%);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.library-header {
  min-height: 78px;
  padding: 14px clamp(18px, 4vw, 58px);
  display: flex;
  align-items: center;
  gap: 28px;
  color: #fff8ec;
  background: linear-gradient(90deg, #03182b 0%, #062743 100%);
  border-bottom: 1px solid rgba(213, 161, 83, .28);
}

.brand {
  min-width: 270px;
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
}

.brand strong {
  display: block;
  font: 700 28px/1 Georgia, "Times New Roman", serif;
  color: #f3d38a;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--gold-2);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}

nav {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: clamp(16px, 3vw, 34px);
  flex-wrap: wrap;
}

nav a {
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .05em;
  text-transform: uppercase;
}

main {
  padding: 36px clamp(18px, 4vw, 58px) 60px;
}

.hero {
  max-width: 960px;
  margin-bottom: 24px;
}

.hero p {
  margin: 0 0 10px;
  color: #9a6b24;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 14px;
  font: 700 clamp(38px, 5vw, 66px)/.98 Georgia, "Times New Roman", serif;
}

#libraryMeta {
  color: var(--muted);
  font-weight: 750;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  gap: 12px;
  margin-bottom: 20px;
}

input,
select {
  min-height: 44px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
}

.research-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 16px;
}

.research-card {
  overflow: hidden;
  background: rgba(255, 252, 247, .96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.research-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #061a2d;
}

.research-body {
  padding: 18px;
}

.research-body span {
  display: block;
  margin-bottom: 8px;
  color: #9a6b24;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.research-body h2 {
  margin: 0 0 8px;
  font: 700 24px/1.12 Georgia, "Times New Roman", serif;
}

.research-body p {
  color: #303a49;
  line-height: 1.55;
}

.research-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.research-meta b {
  padding: 4px 8px;
  color: #082a45;
  background: rgba(213, 161, 83, .15);
  border-radius: 999px;
  font-size: 12px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag-row em,
.tags span {
  padding: 4px 8px;
  color: #684410;
  background: rgba(213, 161, 83, .14);
  border: 1px solid rgba(213, 161, 83, .22);
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.research-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.research-actions a {
  min-height: 34px;
  padding: 8px 12px;
  color: #071827;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border-radius: 7px;
  text-decoration: none;
  font-weight: 900;
  font-size: 13px;
}

.empty {
  grid-column: 1 / -1;
  padding: 30px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.paper {
  max-width: 1160px;
}

.paper-hero {
  display: grid;
  grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
  gap: clamp(22px, 4vw, 48px);
  align-items: center;
  margin-bottom: 26px;
}

.paper-hero img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: #061a2d;
}

.kicker {
  margin: 0 0 8px;
  color: #9a6b24;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.paper h1 {
  margin: 0 0 10px;
  font: 700 clamp(38px, 6vw, 72px)/.96 Georgia, "Times New Roman", serif;
}

.subtitle {
  margin: 0 0 12px;
  color: #9a6b24;
  font-size: 22px;
  font-weight: 800;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0;
}

.paper-section,
.toc {
  margin: 16px 0;
  padding: clamp(18px, 3vw, 28px);
  background: rgba(255, 252, 247, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.paper-section h2 {
  margin: 0 0 10px;
  font: 700 32px/1.08 Georgia, "Times New Roman", serif;
}

.paper-section p,
.paper-section li {
  color: #303a49;
  line-height: 1.65;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toc .kicker {
  width: 100%;
}

.toc a {
  padding: 7px 10px;
  color: #082a45;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  text-decoration: none;
  font-weight: 800;
}

.claim-list {
  display: grid;
  gap: 10px;
}

.claim-list article,
.lesson {
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.claim-list strong,
.claim-list span,
.claim-list small,
.source-list span {
  display: block;
}

.claim-list span,
.claim-list small,
.source-list span,
.image-credit {
  color: var(--muted);
  font-size: 13px;
}

.source-list {
  display: grid;
  gap: 9px;
  padding-left: 18px;
}

@media (max-width: 1000px) {
  .library-header {
    display: grid;
  }

  nav {
    justify-content: flex-start;
  }

  .research-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 620px) {
  .toolbar,
  .research-grid,
  .paper-hero {
    grid-template-columns: 1fr;
  }

  .brand {
    min-width: 0;
  }
}
