/* Athenaeum — library: hero, toolbar, bookcase & spines, grid, list, card catalogue, tome, editor */

/* every modal sits on paper */
.modal {
  --ink: var(--paper-ink); --ink-soft: var(--paper-ink); --muted: var(--paper-muted);
  --line: rgba(80, 55, 25, .18); --line-strong: rgba(80, 55, 25, .38); --input-bg: rgba(255, 255, 255, .62); --panel-2: rgba(255, 255, 255, .55);
  --accent: #7d5617; --accent-2: #9b2a2a;
}
html[data-theme="minimal"] .modal { --accent: #2f5d50; }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.6rem; margin: .4rem 0 1.4rem; }
.hero h1 { font-size: clamp(2.3rem, 5vw, 3.8rem); margin: 0 0 .2rem; letter-spacing: .03em; }
.hero-stats { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: .2rem 0 .4rem; color: var(--ink-soft); font-size: .92rem; }
.hero-stats b { font-family: var(--display); font-size: 1.15rem; color: var(--accent); margin-right: .2rem; }
.hero-stats .od b, .hero-stats .od { color: var(--accent-2); }
.quip { font-style: italic; color: var(--muted); margin: 0; min-height: 1.6em; transition: opacity .4s; }
.quip.fade { opacity: 0; }
.hero-cta { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; position: relative; }
.kbd-hint { font-size: .74rem; }
.hero-bust { position: relative; }
.bust-btn { position: relative; width: 92px; height: 104px; padding: 0; border: 0; background: none; cursor: pointer; }
.bust-btn svg { width: 100%; height: 100%; fill: var(--bust); filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .35)); }
.bust-btn::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: -6px; height: 8px; border-radius: 50%; background: radial-gradient(rgba(0, 0, 0, .35), transparent 70%); }
.bust-btn.wobble { animation: bustWobble .6s var(--ease); }
@keyframes bustWobble { 25% { transform: rotate(-6deg); } 55% { transform: rotate(4deg); } 80% { transform: rotate(-2deg); } }
.specs { position: absolute; left: 22%; top: 24%; width: 30%; height: 12%; opacity: 0; transition: opacity .4s; }
.specs::before, .specs::after { content: ""; position: absolute; top: 0; width: 46%; height: 100%; border: 2px solid #3a2a10; border-radius: 50%; }
.specs::before { left: 0; } .specs::after { right: 0; }
.bust-btn.spectacles .specs { opacity: 1; }
.bust-bubble { position: absolute; left: 100%; top: -.4rem; width: max-content; max-width: 240px; margin: 0 0 0 .6rem; padding: .55rem .8rem; background: var(--paper); color: var(--paper-ink); border-radius: 10px; font-size: .8rem; font-style: italic; box-shadow: var(--shadow); z-index: 5; animation: modalIn .3s var(--ease); }
.bust-bubble::before { content: ""; position: absolute; left: -7px; top: 1rem; border: 7px solid transparent; border-left: 0; border-right-color: var(--paper); }
.hero-lamp { position: absolute; right: calc(100% + 1rem); bottom: 0; width: 76px; }
.hero-lamp svg { width: 76px; height: 76px; fill: var(--lamp); filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .4)); position: relative; z-index: 1; }
.lamp-glow { position: absolute; left: -60%; right: -60%; top: 36%; height: 110px; background: radial-gradient(50% 60% at 50% 20%, rgba(255, 214, 140, .45), transparent 70%); pointer-events: none; animation: lampFlicker 7s infinite; transition: opacity .8s; }
@keyframes lampFlicker { 0%, 100% { opacity: .95; } 46% { opacity: .9; } 48% { opacity: .7; } 50% { opacity: .95; } 72% { opacity: .85; } }
html[data-theme="minimal"] .hero-lamp, html[data-theme="minimal"] .case-lamp { display: none; }
@media (max-width: 900px) {
  .hero { grid-template-columns: auto 1fr; }
  .hero-cta { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
  .hero-lamp { display: none; }
}
@media (max-width: 520px) {
  .bust-btn { width: 62px; height: 70px; }
  .bust-bubble { left: 0; top: 100%; margin: .5rem 0 0; max-width: 70vw; }
  .bust-bubble::before { display: none; }
  .kbd-hint { display: none; }
  .hero-cta .btn { width: 100%; }
}

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .7rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.search-field { position: relative; flex: 1 1 260px; display: flex; }
.search-field svg { position: absolute; left: .7rem; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; pointer-events: none; }
.search-field input { width: 100%; padding-left: 2.3rem; }
.toolbar select { flex: 0 1 auto; }
.sort-group { display: inline-flex; gap: .3rem; }
.view-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.view-switch button { border: 0; background: transparent; color: var(--ink-soft); padding: .5rem .75rem; cursor: pointer; font-size: .84rem; min-height: 2.5rem; transition: background .2s, color .2s; }
.view-switch button + button { border-left: 1px solid var(--line); }
.view-switch button[aria-pressed="true"] { background: var(--brass); color: #2a1a06; font-weight: 600; }
html[data-theme="minimal"] .view-switch button[aria-pressed="true"] { color: #fff; }
.result-count { color: var(--muted); font-size: .84rem; font-style: italic; margin: .8rem .2rem 1rem; min-height: 1.2em; }
@media (max-width: 760px) {
  .toolbar select, .sort-group { flex: 1 1 45%; }
  .sort-group select { flex: 1; }
  .view-switch { flex: 1 1 100%; }
  .view-switch button { flex: 1; padding: .5rem .3rem; }
}

/* ---------- Bookcase ---------- */
.shelf-opts { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem 1rem; margin: 0 0 1.6rem; }
.shelf-opts .hint { margin: 0; }
.bookcase { --row: 236px; --k: 1; position: relative; margin: 2.6rem 0 2.6rem; padding: 0 18px; border-radius: 6px 6px 4px 4px;
  background: linear-gradient(90deg, var(--wood-2), var(--wood-1) 2.5%, var(--wood-3) 3.2%, var(--wood-1) 4%, var(--wood-1) 96%, var(--wood-3) 96.8%, var(--wood-1) 97.5%, var(--wood-2));
  box-shadow: 0 24px 40px rgba(0, 0, 0, .35); }
.case-crown { position: relative; display: flex; justify-content: center; align-items: flex-end; height: 58px; margin: 0 -18px; border-radius: 6px 6px 0 0;
  background: linear-gradient(var(--wood-3), var(--wood-1) 40%, var(--wood-2)); border-bottom: 5px solid var(--wood-2); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .12); }
.case-crown::before { content: ""; position: absolute; left: -6px; right: -6px; top: -8px; height: 10px; border-radius: 4px 4px 0 0; background: linear-gradient(var(--wood-3), var(--wood-1)); box-shadow: 0 2px 3px rgba(0, 0, 0, .25); }
.case-plate { margin-bottom: 10px; padding: .3em 1.1em; border-radius: 3px; background: var(--brass); color: #3a2710; font: 600 .8rem/1.2 var(--display); letter-spacing: .14em; text-transform: uppercase; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 2px 3px rgba(0, 0, 0, .45); }
html[data-theme="minimal"] .case-plate { color: #fff; }
.case-plate small { font-family: var(--serif); letter-spacing: .05em; opacity: .7; margin-left: .3em; }
.case-lamp { position: absolute; right: 7%; bottom: calc(100% + 2px); width: 56px; height: 56px; }
.case-lamp svg { width: 100%; height: 100%; fill: var(--lamp); filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .35)); }
.case-lamp::after { content: ""; position: absolute; left: -70%; right: -70%; top: 40%; height: 90px; background: radial-gradient(50% 50% at 50% 30%, rgba(255, 210, 130, .32), transparent 70%); pointer-events: none; }
.case-inner { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 3px; padding: 0 8px; min-height: var(--row);
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, .5), transparent 30px) 0 0 / 100% var(--row) repeat-y,
    linear-gradient(to bottom, transparent calc(var(--row) - 20px), var(--wood-3) calc(var(--row) - 20px), var(--wood-1) calc(var(--row) - 8px), var(--wood-2) var(--row)) 0 0 / 100% var(--row) repeat-y,
    linear-gradient(90deg, rgba(0, 0, 0, .55), transparent 5%, transparent 95%, rgba(0, 0, 0, .55)),
    var(--back);
  margin: 0 -4px; }
html[data-theme="minimal"] .case-inner { background:
    linear-gradient(to bottom, transparent calc(var(--row) - 14px), var(--wood-2) calc(var(--row) - 14px), var(--wood-2) var(--row)) 0 0 / 100% var(--row) repeat-y, var(--back); }
.case-plinth { height: 18px; margin: 0 -18px; border-radius: 0 0 4px 4px; background: linear-gradient(var(--wood-2), var(--wood-1) 40%, var(--wood-2)); }
.slot { height: var(--row); display: flex; align-items: flex-end; padding-bottom: 20px; perspective: 800px; }

.spine, .spine-preview {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: calc(max(30px, var(--w)) * var(--k, 1)); height: calc(var(--h) * var(--k, 1)); padding: 9px 0 7px; border: 0; margin: 0;
  color: #f1dca0; font: inherit; cursor: pointer; border-radius: 3px 3px 2px 2px; transform-origin: 50% 100%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .42) 0, rgba(255, 255, 255, .06) 14%, rgba(255, 255, 255, .16) 28%, rgba(255, 255, 255, 0) 52%, rgba(0, 0, 0, .3) 100%),
    radial-gradient(120% 60% at 30% 10%, rgba(255, 255, 255, .08), transparent 60%),
    var(--c, #6b1e1e);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .3), inset 0 -3px 4px rgba(0, 0, 0, .25), 2px 0 3px rgba(0, 0, 0, .4);
  transition: transform .38s var(--ease), box-shadow .38s var(--ease), filter .3s;
}
.sp-band { flex: none; width: 100%; height: 7px; border-top: 1px solid rgba(232, 200, 120, .85); border-bottom: 1px solid rgba(232, 200, 120, .85); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.band-1 .sp-band { height: 4px; border-width: 2px; }
.band-2 .sp-band { height: 12px; background: repeating-linear-gradient(90deg, transparent 0 3px, rgba(232, 200, 120, .35) 3px 4px); }
.sp-title { flex: 1 1 auto; min-height: 0; writing-mode: vertical-rl; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--display); font-weight: 600; letter-spacing: .05em; line-height: 1;
  font-size: clamp(10px, calc(max(30px, var(--w)) * var(--k, 1) * .36), 15px);
  background: var(--foil); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .65)); padding: 2px 0; }
.sp-author { flex: none; max-height: 54px; writing-mode: vertical-rl; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: rgba(240, 214, 150, .85); }
.sp-label { flex: none; width: calc(100% - 6px); padding: 2px 1px; border-radius: 2px; background: #f7f0dc; color: #1e1a14; font: 700 clamp(6px, calc(max(30px, var(--w)) * .2), 9px)/1.15 var(--type); text-align: center; overflow: hidden; white-space: nowrap; box-shadow: 0 1px 1px rgba(0, 0, 0, .35); }
.sp-ribbon { position: absolute; top: -6px; right: 22%; width: 6px; height: 30px; background: var(--rb, #9b2a2a); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); box-shadow: 0 1px 1px rgba(0, 0, 0, .3); }
.sp-ribbon.st-read { --rb: #4c9a49; } .sp-ribbon.st-reading { --rb: #e0a23c; } .sp-ribbon.st-dnf { --rb: #b5473a; }
.spine.is-lent { filter: saturate(.45) brightness(.72); }
.spine.is-lent::after { content: "OUT"; position: absolute; top: -12px; left: 50%; transform: translateX(-50%) rotate(-4deg); padding: 1px 4px; background: #f7f0dc; color: #9b2a2a; font: 700 8px/1.2 var(--type); letter-spacing: .1em; border-radius: 1px; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.spine:hover, .spine:focus-visible { transform: translateY(-18px) rotate(-1.5deg); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .3), 0 18px 18px -6px rgba(0, 0, 0, .6); z-index: 2; filter: brightness(1.08); }
.spine:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.spine.pulling { animation: pullOut .42s var(--ease) forwards; z-index: 3; }
@keyframes pullOut { 0% { transform: translateY(-18px); } 55% { transform: translateY(-46px) translateZ(80px) rotateX(12deg); } 100% { transform: translateY(-70px) translateZ(160px) rotateX(18deg) scale(1.1); opacity: 0; } }
.spine.arrive, .gcard.arrive .cover, .icard-btn.arrive, .linkish.arrive { animation: arrive 1.6s var(--ease); }
@keyframes arrive { 0% { transform: translateY(-60px) rotate(-8deg); filter: brightness(1.6); } 40% { transform: translateY(4px); } 60% { transform: translateY(-10px); } 100% { transform: none; filter: none; } }
.library-view.animate .spine { animation: spineIn .6s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 16ms); }
@keyframes spineIn { from { opacity: 0; transform: translateX(46px) rotateY(-40deg); } }
html[data-theme="minimal"] .spine, html[data-theme="minimal"] .spine-preview { background: var(--c); box-shadow: inset -2px 0 0 rgba(0, 0, 0, .12), 1px 0 2px rgba(0, 0, 0, .15); }
html[data-theme="minimal"] .sp-title, html[data-theme="minimal"] .gc-title, html[data-theme="minimal"] .tc-title { background: none; color: #fff; -webkit-text-fill-color: #fff; filter: none; }
html[data-theme="minimal"] .sp-band { border-color: rgba(255, 255, 255, .5); background: none; }
html[data-theme="minimal"] .sp-author { color: rgba(255, 255, 255, .8); }
@media (max-width: 600px) { .bookcase { --row: 196px; --k: .8; padding: 0 10px; } .case-crown, .case-plinth { margin: 0 -10px; } .case-lamp { width: 42px; height: 42px; } }
@media (min-width: 2000px) { .bookcase { --row: 290px; --k: 1.25; } }

/* ---------- Covers (generated & real) ---------- */
.cover { position: relative; display: block; aspect-ratio: 2 / 3; border-radius: 3px 8px 8px 3px; overflow: hidden; background: var(--c, #5a3b1c); box-shadow: inset 4px 0 0 rgba(0, 0, 0, .25), 0 8px 18px rgba(0, 0, 0, .35); transition: transform .35s var(--ease), box-shadow .35s; }
.gen-cover { position: absolute; inset: 0; display: flex; padding: 9%; background: linear-gradient(90deg, rgba(0, 0, 0, .35) 0 6%, rgba(255, 255, 255, .08) 7%, transparent 14%), radial-gradient(120% 80% at 30% 15%, rgba(255, 255, 255, .1), transparent 60%), var(--c); }
.gc-frame { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .45em; text-align: center; padding: .5em .4em; border: 1px solid rgba(232, 200, 120, .7); outline: 1px solid rgba(232, 200, 120, .35); outline-offset: 3px; }
.gc-title { font: 600 .95rem/1.15 var(--display); background: var(--foil-h); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .6)); overflow-wrap: anywhere; }
.gc-rule { width: 40%; height: 1px; background: rgba(232, 200, 120, .7); }
.gc-author { font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(240, 214, 150, .9); }
.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .5s; }
.cover-img.loaded { opacity: 1; }
.cover.thumb { width: 46px; border-radius: 2px 4px 4px 2px; box-shadow: 0 3px 6px rgba(0, 0, 0, .3); }
.cover.thumb .gc-author, .cover.thumb .gc-rule { display: none; }
.cover.thumb .gc-frame { padding: 0; border: 0; outline: 0; }
.cover.thumb .gc-title { font-size: .42rem; }
.cover.big { width: min(190px, 70%); margin: 0 auto; }

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.6rem 1.2rem; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 1.2rem .9rem; } }
@media (min-width: 2000px) { .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.library-view.animate .gcell { animation: cardIn .5s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 25ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px); } }
.gcard { position: relative; display: flex; flex-direction: column; gap: .55rem; width: 100%; padding: 0; border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.gcard:hover .cover, .gcard:focus-visible .cover { transform: translateY(-6px) rotate(-1deg); box-shadow: inset 4px 0 0 rgba(0, 0, 0, .25), 0 18px 24px rgba(0, 0, 0, .4); }
.gmeta { display: flex; flex-direction: column; gap: .15rem; }
.gtitle { font-family: var(--display); font-size: .95rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gauthor { font-size: .8rem; color: var(--muted); font-style: italic; }
.grow { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.gcard .badge { position: absolute; top: 10px; left: -6px; box-shadow: 0 2px 4px rgba(0, 0, 0, .35); }
.mini-stamp { position: absolute; top: 34%; right: -4px; transform: rotate(10deg); padding: .1em .45em; border: 2px solid currentColor; border-radius: 3px; background: rgba(247, 240, 220, .92); color: #9b2a2a; font: 700 .66rem/1.2 var(--display); letter-spacing: .14em; text-transform: uppercase; }
.mini-stamp.inline { position: static; display: inline-block; transform: rotate(-4deg); font-size: .58rem; }
.stars { letter-spacing: .05em; font-size: .85rem; white-space: nowrap; }
.stars .on { color: var(--accent); }
.stars .off { color: var(--muted); opacity: .4; }
.badge { display: inline-block; padding: .32em .6em; border-radius: 2px; color: #fff; font: 600 .62rem/1 var(--serif); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.badge.st-read { background: var(--st-read); } .badge.st-reading { background: var(--st-reading); } .badge.st-to-read { background: var(--st-to-read); } .badge.st-dnf { background: var(--st-dnf); }
.dewey-chip { display: inline-block; padding: .1em .45em; border-radius: 3px; background: #f7f0dc; color: #1e1a14; font: 700 .7rem/1.3 var(--type); box-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.pbar { display: block; height: 5px; border-radius: 3px; background: rgba(127, 127, 127, .25); overflow: hidden; }
.pbar > span { display: block; height: 100%; background: var(--brass); border-radius: 3px; transition: width .6s var(--ease); }
.pbar.wide { width: 100%; min-width: 80px; }

/* ---------- List ---------- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.ledger-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ledger-table th { text-align: left; padding: .75rem .7rem; font-family: var(--display); font-weight: 600; letter-spacing: .04em; border-bottom: 3px double var(--line-strong); white-space: nowrap; }
.ledger-table td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ledger-table tbody tr { transition: background .2s; }
.ledger-table tbody tr:hover td { background: rgba(200, 160, 80, .06); }
.th-sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; letter-spacing: inherit; }
.th-sort:hover { color: var(--accent); }
.show-s { display: none; }
@media (max-width: 900px) { .hide-m { display: none; } }
@media (max-width: 640px) { .hide-s { display: none; } .show-s { display: block; } }

/* ---------- Card catalogue ---------- */
.cabinet { max-width: 1020px; margin: 0 auto; padding: 1.1rem; border-radius: 10px; background: linear-gradient(90deg, var(--wood-2), var(--wood-1) 4%, var(--wood-1) 96%, var(--wood-2)); box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 255, 255, .1); }
.cabinet-top { text-align: center; margin: -.2rem 0 1rem; }
.cabinet-top span { display: inline-block; padding: .3em 1.2em; border-radius: 3px; background: var(--brass); color: #3a2710; font: 600 .78rem var(--display); letter-spacing: .18em; text-transform: uppercase; box-shadow: 0 2px 3px rgba(0, 0, 0, .4); }
html[data-theme="minimal"] .cabinet-top span { color: #fff; }
.drawers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; perspective: 900px; }
@media (max-width: 640px) { .drawers { grid-template-columns: repeat(2, 1fr); } }
.drawer { position: relative; padding: 0; border: 0; background: rgba(0, 0, 0, .35); border-radius: 5px; cursor: pointer; transform-style: preserve-3d; }
.drawer:disabled { cursor: not-allowed; opacity: .5; }
.drawer-face { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 14px 10px 10px; border-radius: 4px;
  background: linear-gradient(var(--wood-3), var(--wood-1)); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .14), inset 0 -8px 12px rgba(0, 0, 0, .22), 0 2px 0 var(--wood-2);
  transition: transform .5s var(--ease), box-shadow .5s var(--ease); }
.drawer:not(:disabled):hover .drawer-face { transform: translateZ(10px); }
.drawer.open .drawer-face { transform: translateZ(60px) translateY(10px); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .14), 0 22px 26px rgba(0, 0, 0, .5); }
.drawer.open::after { content: ""; position: absolute; left: 6%; right: 6%; bottom: -14px; height: 18px; background: linear-gradient(var(--wood-2), rgba(0, 0, 0, .6)); border-radius: 0 0 4px 4px; transform-origin: top; animation: drawerSides .5s var(--ease); }
@keyframes drawerSides { from { transform: scaleY(0); } }
.label-holder { padding: 3px; border-radius: 3px; background: var(--brass); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.label-holder span { display: block; padding: .15em .9em; background: #f7f0dc; color: #2a1d10; font: 700 .95rem/1.3 var(--type); border-radius: 1px; }
.drawer-pull { width: 48px; height: 13px; border-radius: 0 0 22px 22px; background: var(--brass); box-shadow: 0 3px 3px rgba(0, 0, 0, .45), inset 0 -2px 0 rgba(0, 0, 0, .2); }
.drawer-count { font-size: .7rem; color: var(--wood-ink); font-style: italic; }
.tray, .tray-empty { max-width: 1020px; margin: 1.6rem auto 0; border-radius: 0 0 10px 10px; }
.tray { position: relative; padding: 18px 18px 26px; background: linear-gradient(var(--wood-2), var(--wood-1)); box-shadow: inset 0 12px 20px rgba(0, 0, 0, .5), var(--shadow); animation: trayOpen .6s var(--ease); transform-origin: top; }
@keyframes trayOpen { from { opacity: 0; transform: perspective(900px) rotateX(-24deg) translateY(-30px); } }
.tray-rod { position: absolute; left: 16px; right: 16px; bottom: 9px; height: 6px; border-radius: 3px; background: var(--brass); box-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.tray-empty { text-align: center; padding: 1.4rem; color: var(--muted); font-style: italic; }
.tray-empty p { margin: .3rem 0; }
.icards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 16px; }
.icard { animation: cardRise .45s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes cardRise { from { opacity: 0; transform: translateY(40px) rotateX(30deg); } }
.icard-btn { position: relative; display: grid; grid-template-columns: 66px 1fr; gap: 0 8px; width: 100%; min-height: 182px; padding: 8px 12px 18px 10px; border: 0; border-radius: 3px; cursor: pointer; text-align: left;
  color: #262019; font: .74rem/22px var(--type);
  background: linear-gradient(transparent 29px, rgba(200, 60, 60, .5) 29px, rgba(200, 60, 60, .5) 30px, transparent 30px), repeating-linear-gradient(transparent 0 21px, rgba(70, 110, 160, .2) 21px 22px) 0 8px, #fbf7ea;
  box-shadow: 0 2px 0 #e9dfc5, 0 4px 0 #dfd3b5, 0 10px 16px rgba(0, 0, 0, .35); transition: transform .3s var(--ease), box-shadow .3s; overflow: hidden; }
.icard-btn:hover, .icard-btn:focus-visible { transform: translateY(-8px) rotate(-.6deg); box-shadow: 0 2px 0 #e9dfc5, 0 4px 0 #dfd3b5, 0 18px 22px rgba(0, 0, 0, .4); }
.ic-call { display: flex; flex-direction: column; font-weight: 700; }
.ic-body > span { display: block; }
.ic-head { font-weight: 700; }
.ic-title { text-indent: 1.4em; }
.ic-line { text-indent: 1.4em; color: #4a4033; }
.ic-hole { position: absolute; bottom: 5px; left: 50%; width: 11px; height: 11px; margin-left: -5px; border-radius: 50%; background: rgba(60, 40, 20, .45); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5); }
.ic-stamp { position: absolute; top: 12px; right: 10px; transform: rotate(9deg); padding: 0 .4em; border: 2px solid #b3261e; color: #b3261e; font: 700 .7rem/1.5 var(--display); letter-spacing: .14em; text-transform: uppercase; border-radius: 3px; opacity: .85; }

/* ---------- Empty states ---------- */
.empty-state { max-width: 560px; margin: 2rem auto; padding: 2rem 1.5rem; text-align: center; background: var(--panel); border: 1px dashed var(--line-strong); border-radius: 14px; }
.empty-state h3 { font-size: 1.5rem; margin: .6rem 0 .4rem; }
.empty-state p { color: var(--ink-soft); margin: 0 0 1rem; }
.empty-art { width: 160px; height: 100px; }
.es-line { stroke: var(--accent); stroke-width: 2; fill: none; }
.es-book { fill: var(--accent-2); opacity: .8; } .es-book.alt { fill: var(--accent); }
.es-dot { fill: var(--muted); animation: dust 3s ease-in-out infinite; }
.es-dot:nth-of-type(2) { animation-delay: .6s; } .es-dot:nth-of-type(3) { animation-delay: 1.2s; }
@keyframes dust { 50% { transform: translateY(-6px); opacity: .3; } }
.es-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; }
.empty-mini { padding: 1rem; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); font-style: italic; text-align: center; }
.empty-mini p { margin: 0; }

/* ---------- The tome (book detail) ---------- */
.modal-tome { width: min(1100px, 97vw); padding: 0; background: none; box-shadow: none; overflow: visible; max-height: none; }
.modal-tome .modal-title { color: #f6ead0; text-align: center; margin: 0 3rem .7rem; font-size: clamp(1.2rem, 2.6vw, 1.8rem); text-shadow: 0 2px 6px rgba(0, 0, 0, .6); }
.modal-tome .modal-x { top: -.3rem; right: 0; background: rgba(0, 0, 0, .4); color: #fff; border-color: rgba(255, 255, 255, .4); }
.tome { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 0; padding: 12px; border-radius: 8px 14px 14px 8px; height: min(720px, calc(100vh - 110px));
  background: linear-gradient(90deg, rgba(0, 0, 0, .3), transparent 6%, transparent 94%, rgba(0, 0, 0, .3)), radial-gradient(120% 80% at 30% 10%, rgba(255, 255, 255, .1), transparent 60%), var(--c);
  box-shadow: 0 34px 70px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .35); perspective: 2400px; }
.tome .page { position: relative; min-height: 0; overflow: auto; padding: 1.3rem 1.4rem; background-color: var(--paper); color: var(--paper-ink); }
.tome-left { border-radius: 4px 0 0 4px; background-image: linear-gradient(to left, rgba(0, 0, 0, .16), transparent 9%), radial-gradient(90% 80% at 0% 100%, rgba(150, 110, 50, .12), transparent 60%); box-shadow: inset 2px 0 0 rgba(0, 0, 0, .05); }
.tome-right { border-radius: 0 4px 4px 0; display: flex; flex-direction: column; overflow: hidden !important; padding: 0 !important; perspective: 1800px;
  background-image: linear-gradient(to right, rgba(0, 0, 0, .18), transparent 9%), radial-gradient(90% 80% at 100% 0%, rgba(255, 255, 255, .5), transparent 60%); }
.tome.opening .page { animation: pagesIn .7s .45s var(--ease) backwards; }
@keyframes pagesIn { from { opacity: 0; } }
.tome-cover { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 8%; border-radius: inherit; pointer-events: none; transform-origin: 0 50%; backface-visibility: hidden;
  background: linear-gradient(90deg, rgba(0, 0, 0, .45) 0 3%, rgba(255, 255, 255, .1) 3.5%, transparent 8%), radial-gradient(120% 80% at 35% 15%, rgba(255, 255, 255, .14), transparent 60%), var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4); }
.tome:not(.opening) .tome-cover { display: none; }
.tome.opening .tome-cover { animation: coverOpen 1.05s .12s cubic-bezier(.55, .05, .3, 1) forwards; }
@keyframes coverOpen { 0% { transform: rotateY(0); } 70% { opacity: 1; } 100% { transform: rotateY(-128deg); opacity: 0; visibility: hidden; } }
.tc-frame { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 2.4rem 2rem; border: 2px solid rgba(232, 200, 120, .75); outline: 1px solid rgba(232, 200, 120, .4); outline-offset: 6px; text-align: center; max-width: 80%; }
.tc-title { font: 600 clamp(1.4rem, 3.5vw, 2.4rem)/1.15 var(--display); background: var(--foil-h); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .6)); }
.tc-author { color: rgba(240, 214, 150, .9); letter-spacing: .2em; text-transform: uppercase; font-size: .8rem; }
.tabs { display: flex; gap: 4px; padding: .9rem 1rem 0 1.6rem; border-bottom: 1px solid rgba(80, 55, 25, .25); flex-wrap: wrap; }
.tabs [role="tab"] { position: relative; border: 1px solid rgba(80, 55, 25, .25); border-bottom: 0; background: rgba(120, 80, 30, .08); color: var(--paper-ink); padding: .45rem .8rem; border-radius: 6px 6px 0 0; cursor: pointer; font-size: .84rem; top: 1px; }
.tabs [role="tab"][aria-selected="true"] { background: var(--paper); font-weight: 600; border-color: rgba(80, 55, 25, .35); }
.tabs [role="tab"][aria-selected="true"]::before { content: ""; position: absolute; left: 10px; top: -1px; width: 8px; height: 14px; background: #9b2a2a; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.tab-panel { flex: 1; overflow: auto; padding: 1.2rem 1.6rem 1.4rem 2rem; }
.tab-panel:focus { outline: none; }
.page-flip { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0; transform-origin: 0 50%; backface-visibility: hidden;
  background: linear-gradient(to right, rgba(0, 0, 0, .12), transparent 12%, transparent 80%, rgba(0, 0, 0, .1)), var(--paper); }
.page-flip.go { animation: pageTurn .62s cubic-bezier(.45, .05, .35, 1); }
@keyframes pageTurn { 0% { opacity: 1; transform: rotateY(0); box-shadow: 0 0 0 rgba(0, 0, 0, 0); } 50% { opacity: 1; box-shadow: -20px 0 40px rgba(0, 0, 0, .3); } 100% { opacity: 0; transform: rotateY(-175deg); } }
.tl-cover { margin-bottom: 1rem; }
.tl-status { display: flex; align-items: center; justify-content: center; gap: .7rem; margin-bottom: .8rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: 0 0 .8rem; font-size: .86rem; }
.facts dt { color: var(--paper-muted); font-style: italic; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0 .8rem; }
.chip { font-size: .74rem; padding: .15em .6em; border-radius: 999px; background: rgba(120, 80, 30, .12); color: var(--paper-ink); }
.tl-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.loan-note { margin: .6rem 0; padding: .7rem .8rem; border: 1px dashed rgba(80, 55, 25, .4); border-radius: 6px; font-size: .84rem; }
.loan-note p { margin: .4rem 0 .5rem; }
.loan-note.overdue { background: rgba(179, 38, 30, .07); }
.blurb { font-size: 1.02rem; line-height: 1.65; margin-top: 0; }
.blurb::first-letter { font-family: var(--display); font-size: 2.6em; float: left; line-height: .9; margin: .05em .08em 0 0; color: #7d2330; }
.subjects { font-size: .84rem; }
.subjects .eyebrow { display: inline; margin-right: .4rem; }
.status-pick { border: 0; padding: 0; margin: 1rem 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.status-pick legend { font-size: .8rem; color: var(--paper-muted); margin-bottom: .4rem; padding: 0; }
.st-btn { border: 1px solid rgba(80, 55, 25, .35); background: rgba(255, 255, 255, .5); color: var(--paper-ink); border-radius: 999px; padding: .4rem .85rem; cursor: pointer; font-size: .84rem; transition: background .2s, color .2s, transform .15s; }
.st-btn:hover { transform: translateY(-1px); }
.st-btn[aria-pressed="true"] { color: #fff; border-color: transparent; }
.st-btn.st-read[aria-pressed="true"] { background: var(--st-read); } .st-btn.st-reading[aria-pressed="true"] { background: var(--st-reading); }
.st-btn.st-to-read[aria-pressed="true"] { background: var(--st-to-read); } .st-btn.st-dnf[aria-pressed="true"] { background: var(--st-dnf); }
.prog-wrap { position: relative; width: 150px; height: 150px; margin: 0 auto 1rem; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(80, 55, 25, .15); stroke-width: 9; }
.ring-fg { fill: none; stroke: #b88c3c; stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .8s var(--ease); }
.ring-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num b { font: 600 1.8rem var(--display); }
.ring-num span { font-size: .76rem; color: var(--paper-muted); }
.inline-num { display: flex; align-items: center; gap: .5rem; }
.inline-num input[type="number"] { width: 6rem; }
.inline-num input[type="range"] { flex: 1; }
.tab-panel .field, .tab-panel .row2 { margin-bottom: .8rem; }
.log-box { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px dashed rgba(80, 55, 25, .35); }
.log-box .field input { width: 8rem; }
.sub-h { font-size: 1.05rem; margin: 0 0 .7rem; }
.quote-list { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .7rem; }
.quote-list li { position: relative; padding: .6rem 2.2rem .6rem .9rem; border-left: 3px solid #b88c3c; background: rgba(255, 255, 255, .4); border-radius: 0 6px 6px 0; }
.quote-list blockquote { margin: 0; font-style: italic; }
.quote-list .x-btn { position: absolute; top: .3rem; right: .3rem; }
.q-meta { font-size: .74rem; color: var(--paper-muted); }
.quote-form { margin-bottom: 1rem; }
.rate { display: flex; gap: .2rem; margin: .2rem 0; }
.rate-star { font-size: 2rem; line-height: 1; background: none; border: 0; padding: .1rem; cursor: pointer; color: rgba(80, 55, 25, .25); transition: transform .15s, color .2s; }
.rate-star.on { color: #c4962f; text-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.rate-star:hover { transform: scale(1.18) rotate(-8deg); }
@media (max-width: 760px) {
  .modal-root { padding: 2vh 2vw; align-items: start; }
  .tome { grid-template-columns: 1fr; height: auto; }
  .tome .page { overflow: visible; }
  .tome-left { border-radius: 4px 4px 0 0; background-image: linear-gradient(to top, rgba(0, 0, 0, .12), transparent 6%); }
  .tome-right { border-radius: 0 0 4px 4px; overflow: hidden; background-image: linear-gradient(to bottom, rgba(0, 0, 0, .14), transparent 6%); }
  .tab-panel { overflow: visible; padding: 1rem 1.1rem 1.2rem; }
  .tabs { padding: .8rem .8rem 0; }
  .tl-cover .cover.big { width: 130px; }
}

/* ---------- Editor ---------- */
.modal-form { width: min(900px, 96vw); }
.lookup { padding: .9rem 1rem; margin-bottom: 1rem; border: 1px dashed rgba(80, 55, 25, .4); border-radius: 8px; background: rgba(255, 255, 255, .35); }
.lk-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .3rem; }
.lk-row input { flex: 1 1 240px; }
.lk-results ul { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: .5rem; max-height: 280px; overflow: auto; }
.lk-item { display: flex; gap: .7rem; align-items: center; width: 100%; padding: .45rem .55rem; border: 1px solid rgba(80, 55, 25, .25); border-radius: 6px; background: rgba(255, 255, 255, .6); color: var(--paper-ink); cursor: pointer; text-align: left; font-size: .84rem; transition: transform .15s, border-color .2s; }
.lk-item:hover, .lk-item:focus-visible { transform: translateY(-2px); border-color: #b88c3c; }
.lk-text { display: flex; flex-direction: column; min-width: 0; }
.lk-text b { font-family: var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lk-text span { color: var(--paper-muted); font-size: .78rem; }
.lk-loading { display: flex; gap: 6px; padding: .6rem 0; }
.lk-loading span { width: 10px; height: 26px; border-radius: 2px; background: #8a5532; animation: lkBounce 1s infinite ease-in-out; }
.lk-loading span:nth-child(2) { animation-delay: .15s; background: #2f4a43; } .lk-loading span:nth-child(3) { animation-delay: .3s; background: #233a5e; }
@keyframes lkBounce { 50% { transform: translateY(-8px); } }
.form-grid { display: grid; grid-template-columns: 110px 1fr; gap: 1.2rem; }
.preview-col { display: flex; flex-direction: column; align-items: center; }
.spine-preview { --w: 46px; --h: 220px; cursor: default; position: sticky; top: 0; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem .9rem; }
.span2 { grid-column: 1 / -1; }
.isbn-state { font-size: .76rem; font-weight: 600; }
.isbn-state.ok { color: #2f6b2d; } .isbn-state.bad { color: #9b2a2a; }
.dewey-hint { justify-content: flex-end; }
.dewey-hint .hint { margin: 0; }
.color-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; }
.color-pick { display: inline-flex; align-items: center; gap: .5rem; font-size: .86rem; }
.form-error { color: #9b2a2a; font-weight: 600; min-height: 1.2em; margin: .8rem 0 0; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .8rem; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .preview-col { display: none; }
  .fields { grid-template-columns: 1fr; }
  .form-actions .btn { flex: 1; }
  .row2 { grid-template-columns: 1fr; }
}
