:root {
  --bg: #f6f1e9; --fg: #2a2118; --muted: #7a6a58; --card: #fffdf8; --line: #ded3c2;
  --accent: #8a4b2a; --plank: #8b5a34; --plank-dark: #5e3a1f; --back: #e9dfcf;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1914; --fg: #efe6d8; --muted: #a8998a; --card: #272119; --line: #3b3226;
    --accent: #e0a070; --plank: #6b4426; --plank-dark: #44290f; --back: #14110d; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 Georgia, "Iowan Old Style", serif; }
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 3rem; }
.site-header { display: flex; justify-content: space-between; align-items: center; padding: .75rem 16px; border-bottom: 1px solid var(--line); }
.brand { font-size: 1.25rem; font-weight: bold; text-decoration: none; color: var(--fg); }
.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 16px; }

/* controls */
.controls { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; margin-bottom: 1.5rem; display: grid; gap: .75rem; }
.controls input[type=search] { width: 100%; padding: .55rem .75rem; font: inherit; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.facets, .row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.controls label { display: grid; gap: .15rem; font: .75rem system-ui, sans-serif; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.controls select, .controls button { font: .9rem system-ui, sans-serif; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); max-width: 100%; }
.controls button { cursor: pointer; }
#count { margin-left: auto; font: .85rem system-ui, sans-serif; color: var(--muted); }

/* shelf */
.shelf-group h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
.shelf-row {
  --cw: 120px; --ch: 180px; --row: 212px;
  display: grid; grid-template-columns: repeat(auto-fill, 136px); grid-auto-rows: var(--row);
  gap: 0; padding: 0 8px; align-items: start;
  background: repeating-linear-gradient(to bottom, transparent 0 calc(var(--row) - 14px), var(--plank) calc(var(--row) - 14px) calc(var(--row) - 4px), var(--plank-dark) calc(var(--row) - 4px) var(--row));
  border-radius: 3px;
}
.book { display: flex; align-items: flex-end; justify-content: center; height: calc(var(--row) - 14px); text-decoration: none; color: inherit; position: relative; }
.book .cover { transition: transform .15s; transform-origin: bottom center; }
.book:hover .cover, .book:focus-visible .cover { transform: translateY(-6px) scale(1.04); }
.cover { position: relative; width: var(--cw, 120px); height: var(--ch, 180px); border-radius: 2px 4px 4px 2px; overflow: hidden; box-shadow: 2px 2px 6px rgba(0,0,0,.35); background: hsl(var(--h, 20) 35% 35%); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .ph { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: .4rem; padding: .6rem; color: #fff; text-align: center; font-size: .8rem; border-left: 6px solid rgba(0,0,0,.25); }
.cover .ph strong { font-size: .95rem; line-height: 1.2; }
.cover .ph em { opacity: .8; font-size: .75rem; }
.badge { position: absolute; top: 4px; right: 12px; z-index: 1; background: var(--accent); color: #fff; font: .65rem system-ui, sans-serif; padding: 1px 6px; border-radius: 3px; }
.empty { color: var(--muted); padding: 2rem 0; }

/* book page */
.book-page { display: grid; grid-template-columns: minmax(0, 260px) 1fr; gap: 2rem; }
.book-cover .cover { --cw: 240px; --ch: 360px; width: 240px; height: 360px; }
.book-meta h1 { margin: 0; }
.by { margin-top: .25rem; color: var(--muted); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
dt { color: var(--muted); } dd { margin: 0; }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 99px; padding: 0 .6rem; margin: 0 .25rem .25rem 0; text-decoration: none; font-size: .85rem; }
.notes { background: var(--card); border-left: 3px solid var(--accent); padding: .75rem 1rem; }
@media (max-width: 640px) {
  .book-page { grid-template-columns: 1fr; }
  .shelf-row { grid-template-columns: repeat(auto-fill, 128px); justify-content: center; }
}
