:root {
  font: 16px/1.6 var(--rb-sans);
  color: var(--rb-ink);
  background: var(--rb-bg);
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-underline-offset: 4px; }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--rb-accent);
  outline-offset: 5px;
}

.site-head {
  display: flex;
  max-width: 1120px;
  min-height: 80px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: auto;
  padding: 20px 32px;
  border-bottom: 1px solid var(--rb-line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--rb-accent-deep);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.4px;
  text-decoration: none;
  white-space: nowrap;
}
.brand svg { flex: none; color: var(--rb-accent); }
nav { display: flex; gap: 24px; font-size: 13px; color: var(--rb-muted); }
nav a { text-decoration: none; }
nav a:hover { color: var(--rb-accent); text-decoration: underline; }

main { max-width: 1056px; margin: 56px auto 100px; padding: 0 32px; }
main.reader-view { max-width: 1080px; margin-top: 30px; }
h1, h2 { font-family: var(--rb-serif); font-weight: 600; text-wrap: balance; }
h1 { margin: 0 0 12px; font-size: clamp(30px, 4vw, 42px); line-height: 1.25; letter-spacing: -.8px; }
h2 { line-height: 1.35; letter-spacing: -.35px; }
.byline, .meta { color: var(--rb-muted); }
.byline { margin: 0; font-size: 14px; }
.library-top { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 46px; }
.search { width: 100%; max-width: 300px; }
.search input {
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  border: 1px solid var(--rb-line);
  border-radius: 11px;
  background: var(--rb-surface);
  font-size: 14px;
}
.search input::placeholder { color: var(--rb-muted); opacity: 1; }

/* Illustrations stay flat, with the book details beneath them. */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 42px 32px; }
.book-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  padding: 0 8px 16px;
  border-radius: 4px;
  text-decoration: none;
}
.book-card-artwork {
  position: relative;
  display: block;
  width: min(100%, 184px);
  aspect-ratio: 2 / 3;
  margin: 0 0 24px;
  overflow: hidden;
  border-radius: 2px;
  background: #294c3f;
}
.book-card-body { display: flex; flex: 1; flex-direction: column; align-items: flex-start; }
.book-card h2 { max-width: 24ch; margin: 0 0 8px; font-size: 22px; overflow-wrap: break-word; }
.book-card .meta { margin-top: 14px; font-size: 11px; letter-spacing: .02em; }
.book-card:hover h2 { color: var(--rb-accent); }
.book-mark { display: grid; width: 48px; height: 48px; margin-bottom: 24px; place-items: center; color: var(--rb-accent); }
.empty { padding: 64px 20px; color: var(--rb-muted); text-align: center; }
.error { color: #a63d2e; }

.back { display: inline-block; margin-bottom: 8px; color: var(--rb-muted); font-size: 12px; text-decoration: none; }
.back:hover { color: var(--rb-accent); text-decoration: underline; }

/* The original artwork is presented straight-on, without book mockup effects. */
.book-intro {
  display: grid;
  grid-template-columns: minmax(220px, .78fr) minmax(0, 1.42fr);
  align-items: center;
  gap: clamp(40px, 6vw, 88px);
  min-height: 370px;
  padding: 34px 6% 48px;
}
.book-artwork {
  position: relative;
  justify-self: center;
  width: 215px;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 2px;
  background: #294c3f;
}
.book-artwork-image { display: block; width: 100%; height: 100%; object-fit: cover; }
.book-artwork-title {
  position: absolute;
  top: 8%;
  right: 14px;
  left: 14px;
  max-width: 9ch;
  margin: 0 auto;
  color: #ead49a;
  font: 600 25px/1.08 var(--rb-serif);
  letter-spacing: -.4px;
  text-align: center;
  text-wrap: balance;
  text-shadow: 0 1px 7px rgba(10, 30, 20, .6);
  pointer-events: none;
}
.book-card-artwork .book-artwork-title { font-size: 21px; }
.book-artwork-fallback { display: grid; width: 100%; height: 100%; place-items: center; color: #d4bc7a; background: #294c3f; font: 400 78px/1 var(--rb-serif); }
.book-details { min-width: 0; overflow-wrap: anywhere; }
.book-eyebrow { margin: 0 0 16px; color: var(--rb-accent); font: 600 10px/1.6 var(--rb-sans); letter-spacing: .2em; text-transform: uppercase; }
.book-details h1 { max-width: 21ch; margin-bottom: 16px; font-size: clamp(31px, 3.6vw, 44px); font-weight: 400; line-height: 1.16; letter-spacing: -1.1px; }
.book-details .byline { font-size: 15px; }
.book-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 16px; margin-top: 26px; color: var(--rb-muted); font-size: 11px; }
.book-meta > span + span { position: relative; }
.book-meta > span + span::before { position: absolute; top: .7em; left: -9px; width: 2px; height: 2px; border-radius: 50%; background: #8e9a8e; content: ''; }
.edition-note { margin: 13px 0 0; color: var(--rb-muted); font-size: 11px; line-height: 1.7; }
.reader-title { margin-bottom: 28px; }
.reader-title h1 { max-width: 32ch; font-size: clamp(28px, 3.6vw, 38px); line-height: 1.3; }
.reader-title .byline { font-size: 15px; }

.player { max-width: 940px; margin: 0 auto 44px; padding: 16px 22px; border: 1px solid var(--rb-line); border-radius: 13px; background: rgba(253, 251, 247, .78); box-shadow: 0 2px 10px rgba(30, 60, 52, .025); }
.book-details .player { width: 100%; margin: 24px 0 0; padding: 13px; border-radius: 11px; text-align: left; }
audio { display: block; width: 100%; min-width: 0; color-scheme: light; }
.player-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.book-details .player-tools { gap: 8px; }
.book-details .resume-note { flex: 1 0 100%; margin-left: 0; font-size: 10px; }
button, .player-tools select { min-height: 40px; padding: 8px 12px; border: 1px solid var(--rb-line); border-radius: 8px; background: var(--rb-surface); font-size: 13px; }
button:not(:disabled):hover { border-color: var(--rb-accent); background: var(--rb-soft); }
.player-tools label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.resume-note { margin-left: auto; color: var(--rb-muted); font-size: 11px; }
.chapter-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 38px; }
.chapter-nav label { flex: 1; min-width: 0; }
.chapter-nav select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--rb-line); border-radius: 8px; background: var(--rb-surface); font-size: 13px; text-overflow: ellipsis; }
.chapter-nav button { width: 44px; min-height: 44px; padding: 8px; }

/* Paper grain lives beneath the ink; the text stays sharp and high-contrast. */
.reading-paper {
  position: relative;
  isolation: isolate;
  max-width: 950px;
  margin: 0 auto;
  padding: 38px clamp(34px, 7vw, 88px) 44px;
  border: 1px solid #e4ddcc;
  border-radius: 3px 4px 3px 3px;
  background: linear-gradient(90deg, rgba(218, 205, 173, .1), transparent 9%, transparent 93%, rgba(218, 205, 173, .08)), #fffdf5;
  box-shadow: 0 2px 3px rgba(68, 61, 41, .04), 0 14px 36px rgba(68, 61, 41, .07), 0 38px 90px -48px rgba(35, 47, 31, .2);
}
.reading-paper::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' opacity='.24' filter='url(%23n?rbui=611a0714e901105b64108f915832f925b2be43f7178d093c7ff3b7951d42b54d)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  opacity: .2;
  content: '';
  pointer-events: none;
}
.reading-paper::after {
  position: absolute;
  z-index: -2;
  right: 5px;
  bottom: -7px;
  left: 5px;
  height: 6px;
  border: 1px solid #ded5c0;
  border-top: 0;
  border-radius: 0 0 3px 3px;
  background: repeating-linear-gradient(0deg, #f8f2e4 0 1px, #e7deca 1px 2px);
  box-shadow: 0 4px 6px rgba(68, 61, 41, .04);
  content: '';
  pointer-events: none;
}
.paper-topline { display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #657262; font: 500 9px/1.6 var(--rb-sans); letter-spacing: .16em; text-transform: uppercase; }
.paper-topline > :last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reading-paper .chapter-nav { margin: 20px 0 36px; padding: 11px 0; border-top: 1px solid #e8e2d4; border-bottom: 1px solid #e8e2d4; }
.reading-paper .chapter-nav button { border-color: transparent; background: transparent; }
.reading-paper .chapter-nav select { border-color: transparent; background: transparent; text-align: center; }
.reading-paper .chapter-nav button:not(:disabled):hover, .reading-paper .chapter-nav select:hover { border-color: #d2d4c2; background: rgba(229, 228, 211, .25); }
.manuscript { max-width: 40rem; margin: auto; color: #2c382f; font-family: var(--rb-serif); font-size: clamp(19px, 1.8vw, 21px); line-height: 1.9; font-kerning: normal; overflow-wrap: break-word; }
.manuscript h2 { margin: 0 0 34px; font-size: 26px; font-weight: 400; line-height: 1.4; text-align: center; }
.manuscript p { margin: 0 0 1.3em; white-space: pre-wrap; }
.reading-paper .manuscript p:first-of-type { display: flow-root; }
.reading-paper .manuscript p:first-of-type::first-letter { float: left; margin: .08em .13em -.02em 0; color: #345541; font-size: 3.25em; line-height: .88; }
.reader-footer { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 38px 0 0; color: var(--rb-muted); font: 11px/1.6 var(--rb-sans); }
.reader-footer::before, .reader-footer::after { width: 32px; height: 1px; background: #ded6c1; content: ''; }
[hidden] { display: none !important; }
.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; }

@media (max-width: 760px) {
  .book-intro { grid-template-columns: minmax(170px, .8fr) minmax(0, 1.2fr); gap: 30px; min-height: 300px; padding: 26px 14px 38px; }
  .book-artwork { width: 176px; }
  .book-artwork-title { font-size: 22px; }
  .book-details h1 { font-size: 33px; }
  .book-meta { margin-top: 18px; }
  .reading-paper { padding-right: 40px; padding-left: 40px; }
}

@media (max-width: 600px) {
  .site-head { min-height: 72px; align-items: center; gap: 16px; padding: 16px 20px; }
  .brand { gap: 8px; font-size: 15px; }
  nav { flex-direction: column; align-items: end; gap: 5px; font-size: 11px; white-space: nowrap; }
  main { margin-top: 30px; padding: 0 20px; }
  main.reader-view { margin-top: 24px; padding: 0 18px; }
  .library-top { flex-direction: column; align-items: stretch; gap: 22px; margin-bottom: 34px; }
  .search { max-width: none; }
  .search input { font-size: 16px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 36px 22px; }
  .book-card { align-items: center; padding: 0 6px 16px; }
  .book-card-artwork { width: 174px; }
  .book-card-body { width: 100%; max-width: 270px; }
  .back { margin-bottom: 15px; }
  .book-intro { grid-template-columns: minmax(0, 1fr); gap: 24px; min-height: 0; padding: 12px 12px 28px; }
  .book-artwork { width: 160px; }
  .book-artwork-title { font-size: 20px; }
  .book-details { width: 100%; text-align: center; }
  .book-details h1 { max-width: 23ch; margin-right: auto; margin-left: auto; font-size: 30px; }
  .book-eyebrow { margin-bottom: 12px; font-size: 9px; }
  .book-meta { justify-content: center; margin-top: 18px; }
  .edition-note { max-width: 32ch; margin-right: auto; margin-left: auto; }
  .player { margin-bottom: 30px; padding: 12px; }
  .book-details .player { margin-top: 22px; margin-bottom: 0; padding: 12px; }
  .player-tools { gap: 8px; }
  .player-tools button, .player-tools select { min-height: 44px; }
  .player-tools select { font-size: 16px; }
  .resume-note { width: 100%; margin: 2px 0 0; }
  .reading-paper { padding: 25px 24px 30px; }
  .paper-topline { gap: 12px; font-size: 8px; letter-spacing: .11em; }
  .paper-topline > :last-child { max-width: 65%; }
  .chapter-nav { gap: 6px; margin-bottom: 30px; }
  .chapter-nav select { font-size: 16px; }
  .reading-paper .chapter-nav { margin-top: 15px; margin-bottom: 30px; }
  .manuscript { font-size: 19px; line-height: 1.85; }
  .manuscript h2 { margin-bottom: 28px; font-size: 22px; }
  .reader-footer { gap: 10px; margin-top: 30px; font-size: 10px; }
  .reader-footer::before, .reader-footer::after { width: 21px; }
}
