@keyframes reveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

:root {
  --ink: #1b1b19;
  --muted: #6d6a64;
  --paper: #f4f0e7;
  --white: #fffdf8;
  --line: #d6d0c4;
  --red: #a43b2b;
  --blue: #285c79;
  --blue-soft: #d6e5ea;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "Manrope", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
svg { width: 17px; height: 17px; stroke-width: 1.7; }

.library-header {
  min-height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 240, 231, .95);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}
.brand, nav, nav a, .research-note a { display: flex; align-items: center; }
.brand { gap: 12px; font-weight: 700; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; background: var(--red); color: white; font: 500 11px "DM Mono", monospace; }
.edition { padding-left: 12px; border-left: 1px solid var(--line); color: var(--muted); font: 400 10px "DM Mono", monospace; text-transform: uppercase; }
nav { gap: 26px; font-size: 13px; font-weight: 600; }
nav a { gap: 6px; }

.masthead {
  min-height: 290px;
  padding: 48px clamp(20px, 6vw, 96px) 42px;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  align-items: end;
  gap: 90px;
  background-image: radial-gradient(#c6bfb2 0.7px, transparent 0.7px);
  background-size: 18px 18px;
}
.eyebrow { color: var(--red); font: 500 11px "DM Mono", monospace; text-transform: uppercase; }
h1, h2 { font-family: "Newsreader", serif; letter-spacing: 0; }
h1 { margin: 14px 0 0; font-size: clamp(36px, 4vw, 58px); line-height: 1.06; font-weight: 600; }
h1 em { display: inline-block; margin-top: .14em; color: var(--red); font-weight: 500; }
.masthead-note p { margin: 0 0 28px; max-width: 560px; color: #44413d; font: 500 clamp(16px, 1.5vw, 20px)/1.65 "Newsreader", serif; }
.masthead-note span { color: var(--muted); font: 400 10px "DM Mono", monospace; text-transform: uppercase; }

.library-shell { min-height: 850px; display: grid; grid-template-columns: 340px minmax(0, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.catalog-panel { border-right: 1px solid var(--line); background: var(--white); }
.search-wrap { height: 60px; padding: 0 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.search-wrap svg { color: var(--muted); }
.search-wrap input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.topic-filters { padding: 14px 16px; display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.topic-filters button { border: 1px solid var(--line); padding: 7px 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; text-transform: uppercase; }
.topic-filters button.active { border-color: var(--ink); background: var(--ink); color: white; }
.catalog-meta { padding: 13px 20px; display: flex; justify-content: space-between; color: var(--muted); font: 400 9px "DM Mono", monospace; text-transform: uppercase; }
.paper-row { width: 100%; min-height: 92px; padding: 16px 18px; display: grid; grid-template-columns: 25px 1fr 18px; gap: 9px; align-items: start; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.paper-row:last-child { border-bottom: 1px solid var(--line); }
.paper-row:hover, .paper-row.active { background: var(--blue-soft); }
.paper-row.active { box-shadow: inset 3px 0 var(--blue); }
.paper-row > span:first-child { color: var(--red); font: 500 10px "DM Mono", monospace; }
.paper-row strong, .paper-row small { display: block; }
.paper-row strong { font: 600 16px/1.2 "Newsreader", serif; }
.paper-row small { margin-top: 8px; color: var(--muted); font: 400 8px "DM Mono", monospace; text-transform: uppercase; }
.paper-row svg { width: 14px; margin-top: 1px; opacity: 0; }
.paper-row.active svg { opacity: 1; }
.empty-state { padding: 24px 20px; color: var(--muted); font-size: 12px; }

.reader-panel { min-width: 0; display: grid; grid-template-columns: minmax(360px, .85fr) minmax(520px, 1.15fr); background: #ebe6dc; }
.paper-detail { padding: clamp(30px, 4vw, 64px); border-right: 1px solid var(--line); background: var(--paper); }
.detail-enter > * { animation: reveal .3s both; }
.detail-enter > *:nth-child(3) { animation-delay: 40ms; }
.detail-enter > *:nth-child(5) { animation-delay: 80ms; }
.paper-number { color: var(--red); font: 500 10px "DM Mono", monospace; text-transform: uppercase; }
.paper-topics { display: flex; gap: 6px; margin: 20px 0; }
.paper-topics span { border: 1px solid #b9b3a9; padding: 6px 8px; color: var(--muted); font: 400 8px "DM Mono", monospace; text-transform: uppercase; }
.paper-detail h2 { margin: 0; max-width: 13ch; font-size: clamp(32px, 3vw, 46px); line-height: 1.02; font-weight: 600; text-wrap: balance; }
.paper-full-title { margin: 18px 0 0; max-width: 52ch; color: var(--muted); font: 500 11px/1.5 "DM Mono", monospace; }
.paper-author { margin: 22px 0 0; font-size: 12px; font-weight: 700; }
.paper-author span { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.paper-abstract { margin: 34px 0; color: #4d4944; font: 500 17px/1.65 "Newsreader", serif; }
.paper-metrics { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.paper-metrics div { min-width: 0; padding: 13px 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.paper-metrics strong, .paper-metrics span { display: block; }
.paper-metrics strong { font-size: 16px; color: var(--blue); }
.paper-metrics span { margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.3; text-transform: uppercase; }
.rights-notice { margin-top: 28px; padding: 13px; display: grid; grid-template-columns: 22px 1fr; gap: 9px; border: 1px solid var(--line); color: var(--muted); font-size: 9px; line-height: 1.5; }
.rights-notice svg { color: var(--red); }
.rights-notice strong { display: block; color: var(--ink); font-size: 10px; }

.pdf-reader { min-width: 0; align-self: start; margin: 32px; border: 1px solid #c7c1b7; background: #3c3d3d; box-shadow: 12px 12px 0 #d5cec1; }
.pdf-toolbar { height: 46px; padding: 0 14px; display: flex; justify-content: space-between; align-items: center; color: #d9dddb; background: #282a29; font: 400 9px "DM Mono", monospace; }
.pdf-toolbar span { display: flex; align-items: center; gap: 7px; }
.pdf-controls { display: flex; align-items: center; gap: 5px; }
.pdf-controls button { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid #4c504e; background: transparent; color: #d9dddb; cursor: pointer; }
.pdf-controls button:hover:not(:disabled) { background: #464a48; }
.pdf-controls button:disabled { opacity: .35; cursor: default; }
.pdf-controls svg { width: 14px; height: 14px; }
.pdf-controls span { min-width: 48px; justify-content: center; color: #aeb3b0; }
.pdf-viewport { min-height: 720px; padding: 22px; display: flex; align-items: flex-start; justify-content: center; position: relative; overflow: auto; background: #555755; user-select: none; }
.pdf-viewport img { display: none; max-width: none; height: auto; background: white; box-shadow: 0 2px 12px rgba(0, 0, 0, .35); pointer-events: none; }
.pdf-viewport img.ready { display: block; }
.pdf-loading { min-height: 620px; display: flex; align-items: center; gap: 10px; color: #e1e4e2; font: 400 9px "DM Mono", monospace; text-transform: uppercase; }
.pdf-loading span { width: 10px; height: 10px; border: 2px solid #8c918e; border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
.pdf-loading.hidden { display: none; }
.viewer-watermark { position: absolute; right: 28px; bottom: 28px; padding: 6px 9px; background: rgba(255, 255, 255, .78); color: rgba(91, 50, 43, .65); font: 500 8px "DM Mono", monospace; text-transform: uppercase; pointer-events: none; }

@keyframes spin { to { transform: rotate(360deg); } }

.research-note { padding: 70px clamp(20px, 6vw, 96px); display: grid; grid-template-columns: .45fr 1.1fr .45fr; gap: 50px; align-items: start; background: var(--blue); color: white; }
.research-note .eyebrow { color: #bad6df; }
.research-note p { margin: 0; max-width: 760px; font: 500 clamp(24px, 3vw, 42px)/1.2 "Newsreader", serif; }
.research-note a { gap: 8px; justify-self: end; padding-bottom: 6px; border-bottom: 1px solid #bad6df; font-size: 11px; font-weight: 700; }
footer { min-height: 76px; padding: 0 clamp(20px, 6vw, 96px); display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 10px; }

@media (max-width: 1180px) {
  .reader-panel { grid-template-columns: 1fr; }
  .paper-detail { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 800px) {
  .edition, nav a:first-child { display: none; }
  .library-header { min-height: 62px; }
  .masthead { min-height: 450px; grid-template-columns: 1fr; gap: 38px; align-content: end; }
  .library-shell { display: block; }
  .catalog-panel { border-right: 0; }
  .paper-list { display: flex; overflow-x: auto; scrollbar-width: none; }
  .paper-row { min-width: 230px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .reader-panel { display: block; }
  .paper-detail h2 { max-width: 16ch; }
  .pdf-reader { margin: 12px; box-shadow: 6px 6px 0 #d5cec1; }
  .pdf-toolbar { height: auto; min-height: 50px; padding: 8px 10px; gap: 8px; }
  .pdf-toolbar > span:first-child { display: none; }
  .pdf-controls { width: 100%; justify-content: center; }
  .pdf-viewport { min-height: 490px; padding: 10px; }
  .pdf-loading { min-height: 440px; }
  .viewer-watermark { right: 16px; bottom: 16px; }
  .research-note { grid-template-columns: 1fr; gap: 25px; }
  .research-note a { justify-self: start; }
  footer { padding: 22px 20px; flex-direction: column; align-items: start; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; }
}