:root {
  --paper: #fcf7f2;
  --ink: #29201c;
  --orange: #a6340b;
  --line: #e4d7cf;
  --muted: #64544c;
  --panel: #f3eae3;
  --green: #315d49;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  color: var(--ink);
  background: var(--paper);
  font: 100%/1.55 system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button, a { touch-action: manipulation; }
a { color: inherit; }
button { cursor: pointer; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.skip:focus { position: fixed; z-index: 3; background: white; padding: 12px; }
.wrap { width: min(1080px, calc(100% - 56px)); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--line); }
.bar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.logo { display: block; width: 208px; height: auto; mix-blend-mode: multiply; }
.bar nav { display: flex; align-items: center; gap: 22px; }
.bar nav a, .bar nav button { display: inline-flex; align-items: center; min-height: 44px; background: none; border: 0; text-decoration: none; font-weight: 650; padding: 0; }
.bar nav a[aria-current] { color: var(--orange); }
.library span { margin-left: 7px; border: 1px solid var(--line); border-radius: 99px; padding: 0 7px; color: var(--orange); font-size: .8rem; }
.intro { padding: 32px 0 22px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; color: var(--orange); font-weight: 750; font-size: .82rem; margin: 0 0 8px; }
h1, h2, h3 { text-wrap: balance; }
h1 { font: italic clamp(2.8rem,6vw,5.1rem)/1 var(--serif); letter-spacing: -.055em; margin: 0; }
.intro > p:last-child { margin: .7rem 0 0; color: var(--muted); }
#catalog { scroll-margin-top: 16px; }
.catalog-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filters button, .secondary, .dialog-bar button, .reader-toolbar summary {
  min-height: 44px; border: 1px solid var(--line); background: transparent; border-radius: 5px; padding: 8px 13px; font-weight: 650;
}
.filters button[aria-pressed=true] { color: white; background: var(--orange); border-color: var(--orange); }
.search input { width: 240px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: #fffaf7; }
.spotlight { display: flex; justify-content: center; align-items: center; gap: clamp(16px,5vw,64px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin: 16px 0 26px; padding: 18px 22px; }
.spotlight .cover { width: clamp(68px,13vw,144px); flex: 0 0 auto; }
.spotlight h2, .shelf-heading h2 { font: clamp(1.65rem,3.6vw,2.85rem)/1.03 var(--serif); margin: 0; letter-spacing: -.045em; }
.spotlight p:not(.eyebrow) { margin: 4px 0; color: var(--muted); }
.spotlight .secondary { margin-top: 8px; }
.shelf-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 22px 0 12px; }
#result-count { color: var(--muted); font-size: .875rem; flex-shrink: 0; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 24px 18px; }
.card { display: block; width: 100%; text-align: start; padding: 0; border: 0; background: transparent; }
.cover-slot { display: block; background: var(--panel); padding: clamp(8px,2.4vw,22px); border-radius: 7px; }
.cover {
  display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto auto minmax(0,1fr) auto; gap: 5%; aspect-ratio: .72;
  padding: 8%; overflow: hidden; border-radius: 2px 5px 5px 2px; position: relative;
  background: var(--cover); color: var(--cover-ink); box-shadow: 4px 7px 12px #33221736, inset 4px 0 #211a1633;
}
.cover-title { font: clamp(1.05rem,3vw,2.1rem)/1.02 var(--serif); letter-spacing: -.045em; }
.cover-small { font-size: clamp(.57rem,1.1vw,.72rem); text-transform: uppercase; letter-spacing: .055em; font-weight: 700; }
.cover-art { align-self: center; justify-self: center; width: 60%; aspect-ratio: 1; border-radius: 50%; background: repeating-radial-gradient(circle at 35% 65%, transparent 0 7px,currentColor 8px 9px); opacity: .65; }
.cover[data-art="rays"] .cover-art { background: repeating-linear-gradient(75deg,currentColor 0 2px,transparent 3px 11px); }
.cover[data-art="moon"] .cover-art { background: currentColor; border-radius: 0; transform: rotate(35deg) scale(.7); }
.cover[data-art="river"] .cover-art { width: 80%; background: repeating-radial-gradient(ellipse at 0 67%,transparent 0 13px,currentColor 14px 15px); }
.card-meta { display: grid; gap: 1px; padding: 8px 0 0; }
.card-meta strong { font: 1.25rem/1.14 var(--serif); }
.card:hover strong { text-decoration: underline; }
.author { color: var(--muted); font-size: .9rem; }
.price { font-size: .875rem; font-weight: 750; color: var(--orange); }
.price.free { color: var(--green); }
.empty { grid-column: 1/-1; display: grid; justify-items: start; }
footer { margin-top: 40px; padding: 20px 0; border-top: 1px solid var(--line); }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
footer span, .notice { color: var(--muted); }

dialog { width: min(710px,calc(100% - 24px)); max-height: 92dvh; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 8px; padding: 18px clamp(16px,5vw,42px) 26px; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: #291b1678; }
body:has(dialog[open]) { overflow: hidden; }
.dialog-bar { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.dialog-bar button { min-width: 60px; }
dialog h2 { font: clamp(2rem,6.4vw,3.2rem)/1.02 var(--serif); letter-spacing: -.045em; margin: 4px 0 8px; }
dialog h3 { font: 1.55rem/1.15 var(--serif); }
.dialog-actions, .reader-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.primary { min-height: 44px; border: 1px solid var(--orange); border-radius: 5px; padding: 9px 14px; background: var(--orange); color: white; font-weight: 700; }
.primary:hover { background: #832605; }
.secondary:hover, .dialog-bar button:hover, .reader-toolbar summary:hover { background: var(--panel); }
.book-row, .resume, .order { display: flex; align-items: center; gap: 14px; margin: 14px 0; padding: 12px; border-radius: 7px; background: var(--panel); }
.book-row .cover, .order .cover { width: 71px; flex: 0 0 auto; }
.book-row .cover-title, .order .cover-title { font-size: .75rem; }
.book-row .cover-small, .order .cover-small { font-size: .42rem; }
.spotlight .cover-title { font-size: clamp(.8rem,2vw,1.5rem); }
.spotlight .cover-small { font-size: clamp(.48rem,1vw,.67rem); }
.book-row p, .order p, .resume p { margin: 0; }
.resume .cover { width: 95px; flex: 0 0 auto; }
.resume .cover-title { font-size: .95rem; }
.resume .cover-small { font-size: .49rem; }
.resume .primary { margin-top: 9px; }
.shelf-list { list-style: none; padding: 0; }
.shelf-list li { border-top: 1px solid var(--line); }
.shelf-title { background: none; border: 0; width: 100%; padding: 8px 0; text-align: start; font-weight: 700; display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 44px; }
.shelf-title span { color: var(--orange); font-size: .875rem; }
.reader-toolbar { display: flex; align-items: start; justify-content: space-between; gap: 8px; margin-top: 16px; }
.reader-toolbar details { flex: 1; }
.reader-toolbar summary { cursor: pointer; }
.reader-toolbar .settings { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 0; }
.reader-toolbar .settings [aria-pressed=true] { background: var(--panel); }
.reader-toolbar select { max-width: 100%; margin-top: 8px; min-height: 44px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.reading { max-width: 58ch; margin: 20px auto; font: var(--reader-size,1.2rem)/1.7 var(--serif); overflow-wrap: anywhere; }
.reading p { margin: 0 0 1.3em; }
.reading .verse-line { display: block; padding-inline-start: var(--verse-indent,1.15em); text-indent: -1.15em; }
.reading p:first-child::first-letter, .reading .verse-line:first-child::first-letter { color: var(--orange); }
.reader-nav { border-top: 1px solid var(--line); padding-top: 12px; justify-content: space-between; }
.reader-nav button:disabled { cursor: default; opacity: .55; }
dialog.night { --paper: #271f1c; --ink: #f7ece2; --muted: #e1c8b6; --line: #836b60; --panel: #47362d; --orange: #f6a67f; --green: #acdec3; color-scheme: dark; }
dialog.night .primary { background: #a6340b; border-color: #a6340b; }
dialog.night .secondary { color: var(--ink); }
@media (max-width: 720px) {
  .wrap { width: calc(100% - 32px); }
  .bar { min-height: 62px; }
  .logo { width: 158px; }
  .bar nav { position: fixed; z-index: 2; bottom: 0; left: 0; right: 0; justify-content: space-around; gap: 6px; background: var(--paper); border-top: 1px solid var(--line); padding: 4px 10px max(4px,env(safe-area-inset-bottom)); }
  .bar nav a, .bar nav button { padding: 0 12px; }
  body { padding-bottom: calc(52px + env(safe-area-inset-bottom)); }
  .intro { padding: 24px 0 15px; }
  .search { width: 100%; }
  .search input { width: 100%; }
  .spotlight { justify-content: flex-start; padding: 12px; }
  .grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px 12px; }
  .cover-title { font-size: clamp(1.1rem,4.3vw,1.8rem); }
}
.cover[data-art="rain"] {
  background: linear-gradient(100deg,#d5c2a8 0,#eee2ce 6%,#f3eadb 100%);
}
.cover[data-art="rain"] .cover-art {
  width: 87%;
  border-radius: 0;
  opacity: .85;
  background:
    radial-gradient(ellipse at 79% 72%,#263659 0 3%,transparent 4%),
    radial-gradient(ellipse at 59% 45%,#354f75 0 3%,transparent 4%),
    radial-gradient(ellipse at 73% 25%,#354f75 0 2%,transparent 3%),
    radial-gradient(ellipse at 41% 67%,#657b98 0 3%,transparent 4%),
    radial-gradient(ellipse at 65% 52%,#8796aa 0 10%,transparent 52%);
  transform: skew(-12deg);
}
.confirmation #dialog-content { text-align: center; }
.confirmation .book-row, .confirmation .dialog-actions { justify-content: center; }
@media (max-width: 720px) {
  dialog.reader-view {
    margin: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    padding: max(16px,env(safe-area-inset-top)) 20px max(20px,env(safe-area-inset-bottom));
  }
}
.cover.cover-image { display: block; padding: 0; }
.cover-image img { display: block; width: 100%; height: 100%; object-fit: contain; background: #21170e; }
.guide-page > img { display: block; width: min(100%,650px); height: auto; margin: 20px auto 12px; }
.guide-text { margin-bottom: 18px; }
.guide-text summary { cursor: pointer; min-height: 44px; padding-block: 8px; font-weight: 650; }
.guide-text .reading { white-space: pre-wrap; }
