.home-link { text-decoration: none; }
nav [aria-current="page"] { color: var(--accent); text-decoration: underline; }
.library-controls { border-block: 1px solid var(--line); }
.control-bottom { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.control-bottom { padding: 17px 0; flex-wrap: wrap; }
.library-controls button, .library-controls input, .library-controls select, .empty-library button { font: 11px var(--mono); }
.surprise-button { background: none; border: 1px solid var(--accent); border-radius: 3px; color: var(--accent); padding: 11px 15px; white-space: nowrap; min-height: 40px; }
.surprise-button span { margin-right: 5px; font-size: 17px; vertical-align: middle; }
.surprise-button:hover { background: var(--wash); }
.surprise-button:disabled { opacity: .5; cursor: default; }
.search-label { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 220px; color: var(--muted); }
.search-label input { width: 100%; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 0; background: transparent; color: var(--ink); min-width: 0; }
.search-label input::placeholder { color: var(--muted); opacity: 1; }
.select-label { display: flex; gap: 7px; align-items: center; font: 9px var(--mono); color: var(--muted); }
.select-label select { max-width: 160px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 3px; padding: 10px 6px; min-height: 40px; }
.view-toggle { display: flex; border: 1px solid var(--line); border-radius: 3px; padding: 3px; }
.view-toggle button { border: none; background: transparent; color: var(--muted); padding: 8px; min-height: 32px; }
.view-toggle button[aria-pressed="true"] { background: var(--wash); color: var(--ink); }
.results-heading { display: flex; justify-content: space-between; gap: 15px; padding: 19px 0 25px; font: 10px var(--mono); color: var(--muted); }
.results-heading p { margin: 0; }
.books-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 33px 24px; }
.book-card { min-width: 0; }
.book-open { display: block; text-decoration: none; }
.cover-stage { display: block; position: relative; width: 100%; aspect-ratio: 2 / 3; perspective: 500px; background: transparent; }
.cover-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(3px 5px 3px #0002); transition: transform 180ms ease, filter 180ms ease; }
.cover-fallback { display: flex; flex-direction: column; justify-content: center; position: absolute; inset: 0; padding: 18px 12px; color: var(--book-ink); background: var(--book-color); box-shadow: inset 4px 0 #0002; overflow: hidden; }
.cover-stage:has(img) .cover-fallback { visibility: hidden; }
.cover-fallback > span { font-size: 18px; line-height: 1.3; overflow: hidden; }
.cover-fallback small { margin-top: 15px; font-size: 11px; }
.book-open:hover .cover-stage img, .book-open:focus-visible .cover-stage img { transform: translateY(-7px) rotate(-2deg); filter: drop-shadow(5px 9px 5px #0003); }
.book-caption { display: block; padding-top: 14px; }
.book-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 15px; line-height: 1.35; }
.book-author { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.book-meta { display: flex; gap: 7px; align-items: center; justify-content: space-between; margin-top: 10px; font: 8px var(--mono); color: var(--muted); }
.book-rating { color: var(--accent); font-family: Georgia,serif; font-size: 10px; white-space: nowrap; letter-spacing: 1px; }
.clay { --book-color: #934f3c; --book-ink: #fff0db; }
.moss { --book-color: #53674b; --book-ink: #f0eed7; }
.ink { --book-color: #344d53; --book-ink: #f4eada; }
.ochre { --book-color: #c2a169; --book-ink: #302f23; }
.slate { --book-color: #6c7781; --book-ink: #fff5e3; }
.berry { --book-color: #795454; --book-ink: #fcecdc; }
.book-spine { display: none; }
.books-grid.spines { grid-template-columns: repeat(auto-fill,minmax(53px,1fr)); gap: 28px 7px; padding-bottom: 15px; }
.spines .book-card { display: flex; flex-direction: column; justify-content: flex-end; border-bottom: 6px solid var(--line); padding-bottom: 3px; }
.spines .book-open { height: 250px; display: flex; align-items: flex-end; }
.spines .cover-stage, .spines .book-caption { display: none; }
.spines .book-spine { display: flex; flex-direction: column; gap: 10px; writing-mode: vertical-rl; width: 100%; height: 230px; padding: 14px 8px; color: var(--book-ink); background: var(--book-color); border-radius: 3px 3px 0 0; box-shadow: inset 3px 0 #fff2, inset -3px 0 #0002, 2px 0 2px #0002; transition: transform 180ms ease; }
.spines .book-card:nth-child(3n) .book-spine { height: 245px; }
.spines .book-card:nth-child(4n) .book-spine { height: 210px; }
.book-spine > span { font-size: 14px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-spine small { font-size: 9px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spines .book-open:hover .book-spine, .spines .book-open:focus-visible .book-spine { transform: translateY(-12px) rotate(-3deg); }
.empty-library { text-align: center; padding: 60px 15px; color: var(--muted); }
.empty-library h2 { color: var(--ink); }
.library-source { display: flex; justify-content: space-between; align-items: center; gap: 25px; padding: 26px 0; border-top: 1px solid var(--line); }
.library-source > span { color: var(--muted); font: 9px/1.9 var(--mono); text-align: left; }
.library-source time { font: inherit; }
.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; }
#book-dialog { width: min(690px,calc(100% - 32px)); max-height: calc(100dvh - 40px); overflow-y: auto; background: var(--paper); color: var(--ink); border: 1px solid var(--line); padding: 40px; border-radius: 5px; box-shadow: 0 20px 80px #0003; }
#book-dialog::backdrop { background: #131a15a6; }
body:has(#book-dialog[open]) { overflow: hidden; }
.dialog-close { position: absolute; top: 8px; right: 10px; background: none; color: var(--muted); border: none; width: 40px; height: 40px; font-size: 28px; }
.dialog-layout { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 32px; align-items: start; padding-top: 13px; }
.dialog-cover { aspect-ratio: 2 / 3; position: relative; }
.dialog-cover img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(4px 5px 4px #0003); }
.dialog-copy h2 { font-size: 29px; line-height: 1.2; overflow-wrap: anywhere; }
#dialog-author { color: var(--muted); font-size: 17px; }
#dialog-rating { font: 11px/1.6 var(--mono); color: var(--accent); }
#dialog-facts { display: grid; grid-template-columns: auto 1fr; gap: 9px 15px; font: 10px/1.5 var(--mono); margin: 23px 0; }
#dialog-facts dt { color: var(--muted); }
#dialog-facts dd { margin: 0; }
.goodreads-link { display: inline-block; color: var(--accent); font-size: 14px; padding: 8px 0; }
@media (max-width: 1000px) { .books-grid { grid-template-columns: repeat(5,minmax(0,1fr)); } .control-bottom { gap: 12px; } .search-label { flex-basis: 100%; } }
@media (max-width: 750px) { .books-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 28px 18px; } .library-totals { min-width: 160px; gap: 20px; } .library-totals strong { font-size: 35px; } .library-dek br { display: none; } }
@media (max-width: 600px) {
  .surprise-button { padding: 8px 12px; }
  .control-bottom { justify-content: flex-start; gap: 12px; }
  .select-label { flex-direction: column; align-items: flex-start; gap: 5px; }
  .select-label select { max-width: 145px; }
  .view-toggle { align-self: flex-end; }
  .books-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 25px 14px; }
  .book-title { font-size: 14px; }
  .book-meta { flex-direction: column; align-items: flex-start; gap: 5px; }
  .book-author { font-size: 11px; }
  .results-heading { font-size: 9px; gap: 10px; }
  .library-source { display: block; }
  .library-source > span { display: block; text-align: left; margin-top: 12px; }
  #book-dialog { padding: 28px 22px; }
  .dialog-layout { grid-template-columns: 95px minmax(0,1fr); gap: 18px; }
  .dialog-copy h2 { font-size: 23px; }
  #dialog-facts { grid-template-columns: 1fr; gap: 4px; }
  #dialog-facts dd { margin-bottom: 8px; }
}
@media (max-width: 400px) { .books-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 26px 20px; } .view-toggle { margin-top: 5px; } .book-meta { flex-direction: row; } }
@media (prefers-reduced-motion: reduce) { .cover-stage img, .book-spine { transition: none; } .book-open:hover .cover-stage img, .spines .book-open:hover .book-spine { transform: none; } }

.library-intro { display: flex; align-items: baseline; gap: 24px; padding: 28px 0 22px; }
.library-intro h1 { font-size: 36px; margin: 0; white-space: nowrap; }
.library-intro p { margin: 0; font-size: 15px; color: var(--muted); }
.reading-patterns { border: 1px solid var(--line); padding: 22px 24px 14px; margin-bottom: 22px; background: linear-gradient(120deg,var(--wash),transparent); }
.pattern-header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.pattern-header h2 { font-size: 20px; margin: 0; }
.pattern-header > span { font: 9px var(--mono); color: var(--muted); }
.pattern-layout { display: grid; grid-template-columns: 1.65fr 1fr; gap: 28px; align-items: center; }
.book-map { display: grid; grid-template-columns: repeat(31,minmax(0,1fr)); gap: 3px; }
.book-mark { height: 19px; background: var(--book-color); border-radius: 1px; box-shadow: inset 2px 0 #ffffff20; transition: opacity .15s; }
.book-mark.dimmed { opacity: .16; }
.pattern-insight p { margin: 0; font-size: 15px; line-height: 1.55; }
.pattern-insight p + p { margin-top: 7px; color: var(--muted); }
.pattern-insight strong { font-size: 42px; line-height: 1; font-weight: 400; color: var(--accent); margin-right: 5px; }
.pattern-insight b { color: var(--ink); font-weight: 500; }
.theme-legend { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px 16px; margin-top: 18px; }
.theme-key { display: flex; align-items: center; gap: 8px; padding: 7px 4px; color: var(--ink); border: 1px solid transparent; border-radius: 2px; background: transparent; text-align: left; font: 10px var(--mono); min-height: 36px; }
.theme-key i { width: 7px; height: 14px; background: var(--book-color); flex-shrink: 0; }
.theme-key strong { margin-left: auto; font-weight: 400; color: var(--muted); }
.theme-key:hover:not(:disabled), .theme-key[aria-pressed="true"] { border-color: var(--line); background: var(--paper); }
.theme-key:disabled { cursor: default; }
.pattern-footer { display: flex; justify-content: space-between; align-items: baseline; gap: 15px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font: 10px/1.6 var(--mono); color: var(--muted); }
.pattern-footer > p { margin: 0; }
.pattern-footer strong { font-weight: 400; color: var(--ink); }
.pattern-footer details { max-width: 320px; }
.pattern-footer summary { cursor: pointer; white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; }
.results-heading { align-items: center; padding: 14px 0 22px; }
.results-heading .surprise-button { margin-left: auto; font: 10px var(--mono); }
#clear-filters { font: 10px var(--mono); background: none; color: var(--accent); border: 0; padding: 10px 0; text-decoration: underline; }
.empty-library button { font: 11px var(--mono); background: transparent; border: 1px solid var(--ink); color: var(--ink); border-radius: 3px; padding: 13px 26px; }
.library-source { margin-top: 35px; }
.unclassified { --book-color: #89867f; --book-ink: #fff; }
@media (max-width: 750px) {
  .library-intro { display: block; padding: 24px 0 20px; }
  .library-intro h1 { font-size: 32px; margin-bottom: 6px; }
  .reading-patterns { padding: 16px; }
  .pattern-header { align-items: center; }
  .pattern-header h2 { font-size: 18px; }
  .pattern-layout { grid-template-columns: 1fr; gap: 14px; }
  .book-mark { height: 12px; }
  .pattern-insight { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
  .pattern-insight p { font-size: 13px; }
  .pattern-insight strong { display: block; font-size: 32px; }
  .pattern-insight p + p { margin: 0; }
  .theme-legend { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 2px 10px; margin-top: 12px; }
  .theme-key { font-size: 9px; gap: 5px; }
  .pattern-footer { display: block; font-size: 9px; }
  .pattern-footer details { margin-top: 5px; }
}
@media (prefers-reduced-motion: reduce) { .book-mark { transition: none; } }
