:root {
  --library-bg: #181416;
  --library-surface: #211c1e;
  --library-surface-2: #2a2325;
  --library-text: #fcf5f1;
  --library-muted: rgba(252, 245, 241, .68);
  --library-border: rgba(175, 142, 119, .28);
  --library-accent: #d6b9a5;
  --library-accent-soft: rgba(175, 142, 119, .13);
  --library-shelf: #5a382c;
}

* { box-sizing: border-box; }
body.page-timeline,
body.page-publication {
  margin: 0;
  min-width: 320px;
  color: var(--library-text);
  background:
    radial-gradient(circle at 12% 0%, rgba(113, 61, 49, .16), transparent 35rem),
    radial-gradient(circle at 92% 92%, rgba(35, 91, 60, .09), transparent 32rem),
    var(--library-bg);
}

.library-page {
  width: min(1280px, calc(100% - 36px));
  min-height: calc(100vh - var(--global-header-height, 68px));
  margin: 0 auto;
  padding: 56px 0 110px;
}

.library-kicker {
  display: block;
  margin: 0 0 10px;
  color: var(--library-accent);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.library-hero,
.library-topic-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--library-border);
  border-radius: 20px;
  background:
    linear-gradient(115deg, rgba(99, 55, 43, .32), rgba(33, 28, 30, .96) 58%),
    var(--library-surface);
  box-shadow: 0 24px 54px rgba(0, 0, 0, .24);
}

.library-hero::after,
.library-topic-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .035), transparent 32%);
}

.library-hero {
  max-width: 820px;
  margin-inline: auto;
  padding: 26px 24px;
  text-align: center;
}

.library-hero h1,
.library-topic-hero h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  line-height: .9;
  letter-spacing: -.055em;
}

.library-hero > p:last-child {
  max-width: 700px;
  margin: 14px auto 0;
  color: var(--library-muted);
  font-size: clamp(1rem, 1.7vw, 1.15rem);
  line-height: 1.7;
}

.library-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.library-card {
  --card-color: #4d3430;
  --card-accent: #d6b9a5;
  position: relative;
  display: flex;
  min-height: 270px;
  flex-direction: column;
  padding: 28px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--card-accent) 38%, transparent);
  border-radius: 18px;
  color: var(--library-text);
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--card-accent) 17%, transparent), transparent 45%),
    linear-gradient(140deg, color-mix(in srgb, var(--card-color) 64%, #211c1e), var(--library-surface) 78%);
  box-shadow: 0 18px 34px rgba(0, 0, 0, .18);
  text-decoration: none;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.library-card::after {
  content: "";
  position: absolute;
  right: -42px;
  bottom: -56px;
  width: 150px;
  height: 150px;
  border: 1px solid color-mix(in srgb, var(--card-accent) 32%, transparent);
  border-radius: 50%;
}

.library-card:hover,
.library-card:focus-visible {
  transform: translateY(-7px);
  border-color: color-mix(in srgb, var(--card-accent) 75%, transparent);
  box-shadow: 0 28px 46px rgba(0, 0, 0, .28);
  outline: none;
}

.library-card-index,
.library-card-meta {
  color: color-mix(in srgb, var(--card-accent) 84%, white);
  font-size: .7rem;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.library-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  text-align: center;
}

.library-card p {
  margin: 16px 0 24px;
  color: var(--library-muted);
  line-height: 1.65;
  text-align: center;
}

.library-card-meta { margin-top: auto; }
.library-card-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--library-text);
  font-size: .82rem;
  font-weight: 800;
}

.library-topic { min-width: 0; }
.library-back {
  display: inline-flex;
  margin: 0 0 18px;
  color: var(--library-muted);
  font-size: .82rem;
  font-weight: 800;
  text-decoration: none;
}
.library-back:hover { color: var(--library-text); }

.library-topic-hero {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.library-topic-hero > div { min-width: 0; }
.library-topic-hero h1 { font-size: clamp(3rem, 7vw, 6.2rem); }
.library-topic-hero > div > p:last-child {
  max-width: 700px;
  margin: 18px 0 0;
  color: var(--library-muted);
  line-height: 1.65;
}

.library-search {
  position: relative;
  z-index: 1;
  display: grid;
  flex: 0 1 350px;
  gap: 8px;
  color: var(--library-accent);
  font-size: .69rem;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.library-search input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--library-border);
  border-radius: 10px;
  color: var(--library-text);
  background: rgba(18, 15, 16, .58);
  font: 500 .88rem/1.2 inherit;
  letter-spacing: 0;
  text-transform: none;
}
.library-search input:focus { border-color: var(--library-accent); outline: 2px solid rgba(214, 185, 165, .28); outline-offset: 2px; }

.library-shelves {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: clamp(42px, 5vw, 64px) clamp(22px, 3vw, 38px);
  padding: clamp(58px, 8vw, 94px) 0 28px;
}

.library-shelf {
  --book-count: 1;
  --shelf-width: 100%;
  width: var(--shelf-width);
  max-width: 100%;
  flex: 0 1 var(--shelf-width);
  min-width: 0;
  scroll-margin-top: calc(var(--global-header-height, 68px) + 20px);
}
.library-shelf.is-targeted .library-shelf-heading h2 { color: var(--library-accent); }

.library-shelf-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 0 8px 14px;
}
.library-shelf-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 3vw, 2.65rem);
  line-height: 1;
}
.library-shelf.is-loose .library-shelf-heading h2 { font-size: clamp(2rem, 2.65vw, 2.35rem); }
.library-shelf-heading p {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--library-muted);
  line-height: 1.55;
}
.library-shelf-symbol {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  place-items: center;
  border: 1px solid var(--library-border);
  border-radius: 50%;
  color: var(--library-text);
  background: color-mix(in srgb, var(--library-shelf) 72%, var(--library-bg));
  font: 700 1.25rem/1 Georgia, "Times New Roman", serif;
}

.library-shelf-frame {
  position: relative;
  width: 100%;
  min-height: 365px;
  padding: 8px 38px 43px;
  overflow: hidden;
  border: 1px solid rgba(175, 142, 119, .17);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(0, 0, 0, .08));
  box-shadow: 0 20px 36px rgba(0, 0, 0, .14);
}
.library-shelf-frame::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 16px;
  left: 12px;
  height: 28px;
  border: 1px solid color-mix(in srgb, var(--library-shelf) 78%, #000);
  border-radius: 4px;
  background: linear-gradient(#8a6047, var(--library-shelf) 45%, color-mix(in srgb, var(--library-shelf) 46%, #000));
  box-shadow: 0 16px 22px rgba(0, 0, 0, .34), inset 0 2px rgba(255, 255, 255, .12);
}

.library-shelf-viewport {
  position: relative;
  z-index: 2;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.library-shelf-viewport::-webkit-scrollbar { display: none; }
.library-shelf-track {
  display: flex;
  width: max-content;
  min-width: 100%;
  min-height: 314px;
  align-items: end;
  gap: 16px;
  padding: 22px 3px 5px;
}

.library-shelf-arrow {
  position: absolute;
  z-index: 4;
  top: 45%;
  width: 30px;
  height: 50px;
  border: 1px solid var(--library-border);
  border-radius: 999px;
  color: var(--library-text);
  background: rgba(24, 20, 22, .9);
  font-size: 1.5rem;
  cursor: pointer;
}
.library-shelf-arrow[data-direction="previous"] { left: 5px; }
.library-shelf-arrow[data-direction="next"] { right: 5px; }
.library-shelf-arrow:disabled { opacity: .34; cursor: default; }
.library-shelf-arrow[hidden] { display: none; }

.library-book {
  --book-color: #1d6a55;
  --book-accent: #d6c179;
  --book-height: 258px;
  position: relative;
  display: block;
  width: 78px;
  height: var(--book-height);
  flex: 0 0 78px;
  padding: 38px 8px 40px;
  overflow: hidden;
  scroll-snap-align: start;
  border: 1px solid color-mix(in srgb, var(--book-color) 72%, #000);
  border-radius: 5px 7px 3px 3px;
  color: white;
  background: linear-gradient(90deg, rgba(255, 255, 255, .14), transparent 13%, rgba(0, 0, 0, .18) 88%), var(--book-color);
  box-shadow: 8px 8px 14px rgba(0, 0, 0, .34), inset -3px 0 rgba(0, 0, 0, .2);
  text-decoration: none;
  transform-origin: center bottom;
  transition: transform .18s ease, filter .18s ease;
}
.library-book::before,
.library-book::after {
  content: "";
  position: absolute;
  right: 4px;
  left: 4px;
  height: 2px;
  background: var(--book-accent);
  opacity: .8;
}
.library-book::before { top: 30px; }
.library-book::after { bottom: 30px; }
.library-book:hover,
.library-book:focus-visible {
  z-index: 3;
  filter: brightness(1.09);
  transform: translateY(-10px) rotate(-.6deg);
  outline: 3px solid color-mix(in srgb, var(--book-accent) 68%, transparent);
  outline-offset: 3px;
}
.library-book-mark {
  position: absolute;
  top: 10px;
  right: 7px;
  left: 7px;
  color: var(--book-accent);
  font: 900 .53rem/1.1 Arial, sans-serif;
  letter-spacing: .06em;
  text-align: center;
  text-transform: none;
}
.library-book-title {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: calc(100% - 18px);
  max-height: calc(100% - 84px);
  overflow: hidden;
  color: white;
  font: 700 .86rem/1.08 Georgia, "Times New Roman", serif;
  text-align: center;
  text-shadow: 0 1px 3px #000;
  transform: translate(-50%, -50%) rotate(180deg);
  writing-mode: vertical-rl;
}
.library-book-meta {
  position: absolute;
  right: 7px;
  bottom: 10px;
  left: 7px;
  color: color-mix(in srgb, var(--book-accent) 88%, white);
  font: 800 .54rem/1.15 Arial, sans-serif;
  text-align: center;
  text-transform: uppercase;
}
.library-book-tooltip {
  position: fixed;
  z-index: 1000;
  display: flex;
  max-width: min(420px, calc(100vw - 24px));
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid var(--library-border);
  border-radius: 8px;
  color: var(--library-text);
  background: rgba(24, 20, 22, .96);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .34);
  font: 700 .8rem/1.25 Arial, sans-serif;
  pointer-events: none;
  white-space: nowrap;
}
.library-book-tooltip[hidden] { display: none; }
.library-book-tooltip strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.library-book-tooltip span { flex: 0 0 auto; color: var(--library-muted); font-size: .68rem; font-weight: 600; }
.library-shelf-empty {
  width: 100%;
  margin: auto;
  color: var(--library-muted);
  text-align: center;
}

.library-empty,
.library-loading {
  display: grid;
  min-height: 190px;
  place-items: center;
  padding: 34px;
  border: 1px dashed var(--library-border);
  border-radius: 14px;
  color: var(--library-muted);
  text-align: center;
}
.library-empty[hidden],
.library-loading[hidden] { display: none; }
.library-empty { min-height: 150px; }
.library-empty strong { color: var(--library-text); }
.library-empty span { margin-top: 7px; }
.library-card-grid > .library-empty { grid-column: 1 / -1; }

.page-publication .global-brand,
.page-timeline .global-brand { color: var(--library-text); text-decoration: none; }
.publication-page { width: min(860px, calc(100% - 36px)); margin: 0 auto; padding: 64px 0 110px; }
.publication-back { display: inline-flex; margin-bottom: 34px; color: var(--library-muted); font-size: .82rem; font-weight: 750; text-decoration: none; }
.publication-back:hover { color: var(--library-text); }
.publication-header { margin-bottom: 36px; padding-bottom: 28px; border-bottom: 1px solid var(--library-border); }
.publication-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--library-muted); font-size: .76rem; }
.publication-meta a { color: var(--library-accent); font-weight: 820; letter-spacing: .06em; text-decoration: none; text-transform: uppercase; }
.publication-header h1 { margin: 13px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.2rem, 6vw, 4.6rem); line-height: 1.02; letter-spacing: -.045em; text-align: center; overflow-wrap: anywhere; }
.publication-project { margin: 15px 0 0; color: var(--library-muted); font-size: .82rem; }
.publication-project a { color: var(--library-accent); }
.publication-content { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.publication-content > * { min-width: 0; }
.publication-author { margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--library-border); color: var(--library-muted); font-size: .72rem; line-height: 1.5; }
.publication-author a { color: inherit; text-underline-offset: 2px; }
.publication-author a:hover { color: var(--library-text); }
.publication-rich-text { color: rgba(252, 245, 241, .9); font-size: 1.04rem; line-height: 1.82; hyphens: auto; overflow-wrap: anywhere; text-align: justify; text-justify: inter-word; }
.publication-rich-text :is(p, ul, ol, li, blockquote) { text-align: justify; text-justify: inter-word; }
.publication-rich-text blockquote { margin: 1.2em clamp(12px, 3vw, 32px); padding-inline-start: clamp(12px, 2vw, 22px); border-inline-start: 2px solid var(--library-border); font-style: italic; }
.publication-rich-text blockquote > :first-child { margin-top: 0; }
.publication-rich-text blockquote > :last-child { margin-bottom: 0; }
.publication-rich-text > :first-child { margin-top: 0; }
.publication-rich-text > :last-child { margin-bottom: 0; }
.publication-rich-text h2 { margin-top: 2.2em; font-size: 1.65rem; text-align: center; }
.publication-rich-text h3 { margin-top: 1.8em; font-size: 1.3rem; text-align: center; }
.publication-rich-text a { color: var(--library-accent); }
.publication-image figure,
.publication-gallery figure { margin: 0; }
.publication-image img,
.publication-gallery img { display: block; width: 100%; max-height: 760px; border-radius: 11px; object-fit: contain; background: #0d0b0c; }
.publication-image figcaption,
.publication-gallery figcaption { margin-top: 7px; color: var(--library-muted); font-size: .8rem; }
.publication-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.publication-video { position: relative; width: 100%; overflow: hidden; border-radius: 11px; aspect-ratio: 16 / 9; background: #000; }
.publication-video iframe { width: 100%; height: 100%; border: 0; }

@media (max-width: 900px) {
  .library-page { width: min(100% - 24px, 760px); padding-top: 38px; }
  .library-card-grid { grid-template-columns: 1fr; }
  .library-card { min-height: 230px; }
  .library-topic-hero { align-items: stretch; flex-direction: column; }
  .library-search { flex-basis: auto; }
}

@media (max-width: 600px) {
  .library-page,
  .publication-page { width: min(100% - 20px, 560px); }
  .library-hero { padding: 24px 18px; }
  .library-card { min-height: 215px; padding: 23px; }
  .library-topic-hero { padding: 0; }
  .library-shelves { gap: 48px 0; padding-top: 54px; }
  .library-shelf-heading { align-items: flex-start; }
  .library-shelf-symbol { width: 42px; height: 42px; flex-basis: 42px; }
  .library-shelf { width: 100%; flex-basis: 100%; }
  .library-shelf-frame { padding-inline: 12px; }
  .library-shelf-viewport { overflow: visible; scroll-snap-type: none; }
  .library-shelf-track {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 28px;
  }
  .library-shelf-arrow { display: none; }
  .library-book { width: 74px; flex-basis: 74px; }
  .publication-page { padding-top: 42px; }
  .publication-gallery { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .library-card,
  .library-book { transition: none; }
  .library-shelf-viewport { scroll-behavior: auto !important; }
}
