:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4efe6;
  color: #2b241d;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f4efe6; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.site-header,
main { width: min(1100px, calc(100% - 32px)); margin-inline: auto; }
.site-header { display: flex; justify-content: space-between; gap: 24px; align-items: end; padding: 40px 0 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3.6rem); }
h2, h3 { margin-bottom: 0; font-family: Georgia, serif; }
.eyebrow { margin-bottom: 6px; text-transform: uppercase; letter-spacing: .14em; font-size: .76rem; font-weight: 700; color: #766653; }

.panel { background: #fffdf8; border: 1px solid #d8cdbd; border-radius: 18px; padding: 22px; box-shadow: 0 10px 28px rgb(56 43 28 / 8%); }
.section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 18px; }
.header-actions, .form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
button { border: 0; border-radius: 10px; padding: 10px 14px; background: #4f634f; color: white; font-weight: 700; }
button:hover { filter: brightness(.96); }
button.secondary { background: #eee7dc; color: #3c332a; }
button.secondary.active { outline: 2px solid #4f634f; }

.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
input, select, textarea { width: 100%; border: 1px solid #cfc2b0; border-radius: 9px; padding: 10px 12px; background: white; color: inherit; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid rgb(79 99 79 / 25%); outline-offset: 1px; }
.status { min-height: 1.4em; margin: 12px 0 0; color: #6a5d4d; }
.lookup-results { display: grid; gap: 10px; margin-top: 14px; }
.lookup-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 10px; border: 1px solid #e1d8cb; border-radius: 12px; }
.lookup-item img { width: 52px; height: 72px; object-fit: cover; border-radius: 5px; background: #e8e0d4; }
.lookup-item strong, .lookup-item span { display: block; }
.lookup-item span { color: #746758; font-size: .9rem; }

.manual-form { margin-top: 20px; padding-top: 20px; border-top: 1px solid #e2d9cd; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 6px; font-size: .9rem; font-weight: 700; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { margin-top: 14px; }
.hidden { display: none !important; }

.library-section { padding: 34px 0 60px; }
.library-tools { align-items: center; }
.library-search { width: min(360px, 100%); display: grid; gap: 6px; font-size: .85rem; font-weight: 700; color: #625646; }
#book-count { font-family: Inter, sans-serif; font-size: .9rem; vertical-align: middle; background: #e8e1d6; border-radius: 999px; padding: 4px 8px; }

.shelf-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 1px; margin-bottom: 18px; border-bottom: 1px solid #cabca9; scrollbar-width: thin; }
.shelf-tab { flex: 0 0 auto; border: 1px solid #cabca9; border-bottom: 0; border-radius: 10px 10px 0 0; padding: 9px 13px; background: #e9e0d3; color: #4d4236; }
.shelf-tab[aria-selected="true"] { background: #fffdf8; color: #2b241d; box-shadow: inset 0 -3px 0 #4f634f; }
.shelf-tab-count { display: inline-block; min-width: 1.5em; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: rgb(79 99 79 / 12%); font-size: .78rem; }

.shelf-toolbar { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 16px; padding: 16px 18px; background: #eee7dc; border: 1px solid #d8cdbd; border-radius: 12px; }
.shelf-summary { margin: 5px 0 0; color: #6f6253; font-size: .9rem; }
.sort-control { width: min(250px, 100%); display: grid; gap: 6px; font-size: .85rem; font-weight: 700; color: #625646; }

.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.library-grid.list-view { grid-template-columns: 1fr; }
.book-card { position: relative; background: #fffdf8; border: 1px solid #d9cebe; border-radius: 15px; overflow: hidden; box-shadow: 0 6px 18px rgb(62 48 32 / 7%); }
.book-card button.open-book { width: 100%; height: 100%; padding: 0; background: transparent; color: inherit; text-align: left; border-radius: 0; font-weight: 400; }
.book-cover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block; background: linear-gradient(145deg, #d7c7b1, #eee4d6); }
.book-copy { display: block; padding: 13px; }
.book-copy strong { display: block; font-family: Georgia, serif; font-size: 1.05rem; line-height: 1.25; }
.book-copy span { display: block; margin-top: 4px; color: #746758; font-size: .88rem; }
.genre { margin-top: 10px !important; font-size: .74rem !important; text-transform: uppercase; letter-spacing: .08em; }
.remove-book { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; padding: 0; border-radius: 999px; background: rgb(42 34 26 / 78%); z-index: 2; }
.list-view .book-card { min-height: 110px; }
.list-view .open-book { display: grid; grid-template-columns: 72px 1fr; }
.list-view .book-cover { width: 72px; height: 108px; aspect-ratio: auto; }
.empty-state { padding: 44px 20px; text-align: center; border: 1px dashed #cdbfae; border-radius: 14px; color: #746758; }

#book-dialog { width: min(620px, calc(100% - 30px)); border: 1px solid #cdbfae; border-radius: 18px; padding: 22px; color: inherit; }
#book-dialog::backdrop { background: rgb(30 24 18 / 45%); }
.detail-grid { display: grid; grid-template-columns: 150px 1fr; gap: 20px; }
.detail-grid img { width: 150px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 9px; background: #e8e0d4; }
.detail-meta { color: #6f6253; }
#book-dialog form { margin-top: 18px; text-align: right; }
.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: 680px) {
  .site-header, .section-heading, .shelf-toolbar { align-items: stretch; flex-direction: column; }
  .inline-form { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid img { width: 120px; }
  .sort-control { width: 100%; }
}
