.shelf-showcase { min-width: 0; width: 100%; margin: 0; position: relative; }
.shelf-showcase[hidden], .shelf-editor [hidden] { display: none; }
.shelf-showcase .shelf-preview { display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: hidden; color: #43382e; }
.profile-showcase .shelf-edit { position: absolute; inset: auto 12px 4px auto; padding: 6px 8px; border: 1px solid #bca98d; border-radius: 5px; background: #fff9ed; font-size: 11px; box-shadow: none; transform: scale(calc(1 / var(--showcase-scale, 1))); transform-origin: bottom right; white-space: nowrap; }
.is-arranging .shelf-edit { visibility: hidden; }
.shelf-stage { position: relative; display: block; height: 180px; padding: 0 14px; margin-bottom: 74px; box-sizing: border-box; }
.shelf-spines { position: relative; display: block; height: 180px; transform-origin: top left; }
.shelf-stage::after { content: ''; position: absolute; top: 100%; left: -2.5%; right: -2.5%; height: 74px; background: url('/static/images/shelf.png') center -94px / 100% 240px no-repeat; pointer-events: none; }
.shelf-preview .shelf-stage { overflow: clip visible; }
.shelf-showcase .shelf-book, .shelf-editor .shelf-book, .shelf-magnifier .shelf-book { position: absolute; display: block; padding: 0; margin: 0; border: 0; background: transparent; border-radius: 0; color: inherit; box-shadow: none; line-height: 0; pointer-events: none; }
.shelf-book img { display: block; height: 100%; width: 100%; max-width: none; pointer-events: none; user-select: none; }
.shelf-book > .object-finishes { -webkit-mask: var(--spine-mask) center / 100% 100% no-repeat; mask: var(--spine-mask) center / 100% 100% no-repeat; }
.shelf-book:focus-visible { outline: 3px solid #8853c9; outline-offset: 2px; }
.shelf-missing { display: flex; writing-mode: vertical-rl; justify-content: center; gap: 10px; height: 180px; width: 100%; padding: 6px; box-sizing: border-box; background: #544367; color: white; border: 2px solid #30223b; font-size: 12px; line-height: 1.4; }
.shelf-missing small { font-size: 9px; opacity: .75; }
.shelf-editor { --shelf-ink: #302832; --shelf-paper: #fcf8f1; --shelf-field: white; --shelf-line: #c5b5a4; --shelf-kicker: #8b735d; --shelf-hint: #807164; --shelf-link: #7441ad; --shelf-focus: #8853c9; }
/* By night the editor's paper and ink name the theme's tokens (docs/design-system.md, Themes); the shelf it edits keeps its wood. */
html[data-theme="dark"] .shelf-editor { --shelf-ink: var(--text-dark); --shelf-paper: var(--white); --shelf-field: var(--bg-subtle); --shelf-line: var(--ink-border); --shelf-kicker: var(--text-muted); --shelf-hint: var(--text-muted); --shelf-link: var(--accent-purple); --shelf-focus: var(--accent-purple); }
.shelf-editor { box-sizing: border-box; margin: auto; width: min(850px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 24px; overflow-y: auto; border: 2px solid var(--shelf-ink); border-radius: 16px; background: var(--shelf-paper); color: var(--shelf-ink); }
.shelf-editor::backdrop { background: #20182799; backdrop-filter: blur(5px); }
.shelf-editor header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.shelf-editor header small { font-size: 9px; letter-spacing: .13em; color: var(--shelf-kicker); }
.shelf-editor h3 { font-size: 28px; margin: 6px 0 0; }
.shelf-scroll { overflow-x: auto; padding: 6px 0 16px; }
.shelf-scroll .shelf-stage { width: max-content; min-width: 100%; touch-action: pan-y; }
/* In the editor the plank stops at the shelf's edges, so it scrolls only when the books do not fit; its bar is the felt's quiet one. */
.shelf-scroll .shelf-stage::after { left: 0; right: 0; }
.shelf-editor.is-felt .shelf-scroll { scrollbar-color: #ffffff40 transparent; }
.shelf-editor .shelf-book { cursor: grab; touch-action: none; }
.shelf-book[aria-pressed="true"] { z-index: 1; outline: 3px solid var(--shelf-focus, #8853c9); outline-offset: 2px; }
.shelf-editor button:not(.shelf-book), .shelf-editor select { min-height: 40px; padding: 8px 12px; border: 1px solid var(--shelf-line); border-radius: 7px; background: var(--shelf-field); color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.shelf-editor button:disabled { opacity: .4; cursor: default; }
.shelf-editor button:focus-visible, .shelf-preview:focus-visible { outline: 3px solid var(--shelf-focus, #8853c9); outline-offset: 3px; }
.shelf-selection { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 12px; font-size: 14px; }
.shelf-selection a { color: var(--shelf-link, #7441ad); font-size: 12px; }
.shelf-hint { font-size: 12px; line-height: 1.6; color: var(--shelf-hint, #807164); }
.shelf-arrange { display: flex; gap: 6px; }
.shelf-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 22px; }
.shelf-add label { grid-column: 1 / -1; font-size: 12px; font-weight: 700; }
.shelf-add select { min-width: 0; }
.shelf-editor footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
/* The felt fills the window, but the shelf keeps the width its plank is drawn for: the editor is a column in its middle. */
dialog.shelf-editor.is-felt > :not(.showcase-object-editor-header, footer) { box-sizing: border-box; width: min(100%, 860px); margin-inline: auto; }
/* On the felt the window may be shorter than the editor: Cancel and Save stay at its foot while the rest scrolls. */
.shelf-editor.is-felt footer { position: sticky; bottom: -28px; z-index: 2; margin: 24px -14px 0; padding: 14px max(14px, calc((100% - 860px) / 2 + 14px)); border-top: 1px solid var(--felt-line); background: #1a1424e6; backdrop-filter: blur(6px); }
.shelf-editor [data-save] { background: #ead8ff !important; border-color: #a07cbd !important; font-weight: 750 !important; }
.shelf-editor [data-status] { font-size: 12px; color: #8d3a31; }
.shelf-editor [data-status]:empty { display: none; }
.shelf-magnifier { --magnifier-background: #fcf8f1; }
@media (max-width: 600px) { .shelf-editor { padding: 16px; } }
