/* ASCENTIUM Library - catalogue, copies, import/export and labels.
   Builds on theme.css (tokens, cards, tables). Printing the label sheets is the last section. */

/* ---- covers: a real picture, or a typographic cover drawn from the title ---- */
.lib-cover { display: block; width: 56px; aspect-ratio: 2 / 3; flex: none; border-radius: 3px 6px 6px 3px; background: var(--lib-surface-2);
  box-shadow: inset 3px 0 0 rgba(255,255,255,.18), inset -2px 0 0 rgba(0,0,0,.1), 0 8px 14px -8px var(--lib-shadow); }
.lib-cover--sm { width: 42px; border-radius: 2px 4px 4px 2px; box-shadow: inset 2px 0 0 rgba(255,255,255,.18), 0 5px 9px -6px var(--lib-shadow); }
.lib-cover--lg { width: min(210px, 62vw); border-radius: 4px 9px 9px 4px; box-shadow: inset 4px 0 0 rgba(255,255,255,.2), inset -3px 0 0 rgba(0,0,0,.1), 0 22px 30px -18px var(--lib-shadow); }
.lib-cover--img { object-fit: cover; }
.lib-cover--gen { position: relative; overflow: hidden; background-color: var(--sp, var(--lib-primary)); color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  container-type: inline-size; }   /* (padding in % would be measured against the parent, so the text uses margins in % instead) */
.lib-cover--gen::before { content: ""; position: absolute; inset: 0; pointer-events: none; }
.lib-cover--gen.pat-0::before { background: linear-gradient(to bottom, rgba(255,255,255,.14) 0 20%, transparent 20%); }
.lib-cover--gen.pat-1::before { background: repeating-linear-gradient(135deg, rgba(255,255,255,.09) 0 5px, transparent 5px 11px); }
.lib-cover--gen.pat-2::before { background: radial-gradient(circle at 82% 88%, rgba(255,255,255,.18) 0 30%, transparent 31%); }
.lib-cover--gen.pat-3::before { background: linear-gradient(to top, rgba(0,0,0,.2) 0 24%, transparent 24%); }
.lib-cover__t, .lib-cover__a { position: relative; display: block; }
.lib-cover__t { margin: 12% 9% 0 16%; } .lib-cover__a { margin: 0 9% 10% 16%; }
.lib-cover__t { font-family: var(--lib-serif); font-weight: 700; line-height: 1.08; font-size: .7rem; font-size: 12.5cqw; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; text-wrap: balance; }
.lib-cover__a { font-size: .5rem; font-size: 7.5cqw; text-transform: uppercase; letter-spacing: .08em; opacity: .9; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lib-cover--sm .lib-cover__a { display: none; }
.lib-cover--sm .lib-cover__t { font-size: 5px; font-size: 14cqw; -webkit-line-clamp: 5; }

/* ---- finder: search, filters, view switch ---- */
.lib-finder { margin-bottom: .6rem; }
.lib-finder__main { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.lib-finder__box { position: relative; flex: 1 1 260px; min-width: 0; display: flex; align-items: center; }
.lib-finder__box > .ic { position: absolute; left: .95rem; color: var(--lib-muted); pointer-events: none; }
.lib-finder__box .form-control { padding-left: 2.8rem; min-height: 50px; border-radius: 14px; font-size: 1.02rem; }
.lib-finder__more { margin-top: .5rem; }
.lib-finder__more > summary { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; list-style: none; padding: .4rem .7rem; margin-left: -.7rem; border-radius: 10px; color: var(--lib-ink-2); font-weight: 650; font-size: .9rem; }
.lib-finder__more > summary::-webkit-details-marker { display: none; }
.lib-finder__more > summary:hover { background: rgba(var(--lib-primary-rgb), .08); color: var(--lib-primary-ink); }
.lib-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--lib-surface-2); border: 1px solid var(--lib-line); border-radius: 14px; }
.lib-seg a { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .85rem; border-radius: 11px; color: var(--lib-ink-2); text-decoration: none; font-weight: 650; font-size: .88rem; }
.lib-seg a:hover { background: rgba(var(--lib-primary-rgb), .08); }
.lib-seg a.is-on { background: var(--lib-surface); color: var(--lib-primary-ink); box-shadow: 0 1px 0 var(--lib-line), 0 6px 12px -8px var(--lib-shadow); }

/* ---- list: table view ---- */
.lib-bookcell { display: flex; align-items: center; gap: .85rem; min-width: 200px; }
.lib-bookcell > span { min-width: 0; line-height: 1.3; }
.lib-bookcell strong { font-weight: 650; }
.lib-books td { padding-top: .65rem; padding-bottom: .65rem; }
.lib-books .form-check-input { margin: 0; cursor: pointer; }

/* ---- list: shelf view (spines standing on boards) ---- */
.lib-wall { --row-h: 262px; --board-h: 16px; --board: color-mix(in srgb, #7a5330 52%, var(--lib-surface)); --board-d: color-mix(in srgb, var(--board) 62%, #000);
  display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: 5px; padding: 0 clamp(.7rem, 2vw, 1.4rem); border: 1px solid var(--lib-line); border-radius: var(--lib-radius);
  background-color: color-mix(in srgb, var(--lib-ink) 5%, var(--lib-surface-2));
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--row-h) - var(--board-h)), var(--board) calc(var(--row-h) - var(--board-h)), var(--board) calc(var(--row-h) - var(--board-h) + 5px),
    var(--board-d) calc(var(--row-h) - var(--board-h) + 5px), var(--board-d) var(--row-h));
  box-shadow: inset 0 14px 26px -18px var(--lib-shadow); overflow-x: clip; }
.lib-slot { height: var(--row-h); padding-bottom: var(--board-h); display: flex; align-items: flex-end; position: relative; }
.lib-spine { position: relative; display: flex; justify-content: center; gap: 3px; width: var(--w); height: var(--h); padding: 22px 3px 9px; background: var(--sp); color: #fff; text-decoration: none; overflow: visible;
  border-radius: 4px 4px 2px 2px; box-shadow: inset -6px 0 0 rgba(0,0,0,.15), inset 3px 0 0 rgba(255,255,255,.15); container-type: inline-size; transition: transform .28s var(--lib-ease), filter .2s; }
.lib-spine::before, .lib-spine::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; background: rgba(255,255,255,.38); pointer-events: none; }
.lib-spine::before { top: 12%; } .lib-spine::after { bottom: 9%; }
.lib-spine:hover, .lib-spine:focus-visible { transform: translateY(-9px); z-index: 5; filter: brightness(1.06); }
.lib-spine.is-pulled { transform: translateY(-26px) rotate(-3deg); transition-duration: .16s; }
.lib-spine__t, .lib-spine__a { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 0; max-height: 100%; }
.lib-spine__t { font-family: var(--lib-serif); font-weight: 650; font-size: .86rem; line-height: 1.12; }
.lib-spine__a { font-size: .66rem; opacity: .82; font-weight: 600; letter-spacing: .03em; }
@container (max-width: 41px) { .lib-spine__a { display: none; } }
.lib-spine__dot { position: absolute; top: 6px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); box-sizing: border-box; }
.lib-spine__dot.is-in { background: #8be8b0; border-color: #fff; } .lib-spine__dot.is-out { background: #ffb85c; border-color: #fff; } .lib-spine__dot.is-none { background: transparent; }
.lib-spine__card { position: absolute; bottom: calc(100% + 12px); left: 50%; z-index: 30; width: 250px; display: flex; gap: .75rem; align-items: center; padding: .7rem .8rem; transform: translate(-50%, 8px);
  background: var(--lib-surface); color: var(--lib-ink); border: 1px solid var(--lib-line); border-radius: 14px; box-shadow: 0 26px 40px -18px var(--lib-shadow);
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .16s, transform .2s var(--lib-ease), visibility .16s; writing-mode: horizontal-tb; white-space: normal; text-align: left; transform-origin: bottom center; }
.lib-spine:hover .lib-spine__card, .lib-spine:focus-visible .lib-spine__card { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.lib-spine__card.is-left { left: 0; transform: translate(0, 8px); } .lib-spine:hover .lib-spine__card.is-left, .lib-spine:focus-visible .lib-spine__card.is-left { transform: none; }
.lib-spine__card.is-right { left: auto; right: 0; transform: translate(0, 8px); } .lib-spine:hover .lib-spine__card.is-right, .lib-spine:focus-visible .lib-spine__card.is-right { transform: none; }
.lib-spine__card > span { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.lib-spine__card strong { font-family: var(--lib-serif); font-size: 1rem; }
.lib-spine__card small { color: var(--lib-muted); }
.lib-spine__card em { font-style: normal; font-weight: 700; font-size: .82rem; margin-top: .2rem; }
.lib-spine__card em.is-in { color: var(--lib-ok); } .lib-spine__card em.is-out { color: var(--lib-warn); } .lib-spine__card em.is-none { color: var(--lib-muted); }
@media (max-width: 575.98px) { .lib-wall { --row-h: 236px; } .lib-spine__card { display: none; } }

/* ---- bulk bar ---- */
.lib-bulkbar { position: sticky; bottom: 1rem; z-index: 25; display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin-top: 1rem; padding: .7rem .9rem; border-radius: 16px;
  background: var(--lib-ink); color: var(--lib-bg); box-shadow: 0 26px 44px -18px rgba(0,0,0,.6); animation: lib-pop .2s var(--lib-ease); }
.lib-bulkbar > strong { margin-right: auto; }
.lib-bulkbar .form-control, .lib-bulkbar .form-select { background-color: var(--lib-surface); color: var(--lib-ink); }
@media (max-width: 991.98px) { .lib-bulkbar { bottom: 78px; } .sticky-save { bottom: 70px; } }

/* ---- add / edit a book ---- */
.lib-quick { display: flex; gap: 1rem; align-items: flex-start; background: linear-gradient(135deg, var(--lib-primary-soft), var(--lib-surface) 70%); border-color: var(--lib-primary-line); }
.lib-quick__icon { width: 52px; height: 52px; border-radius: 16px; background: var(--lib-primary); color: var(--lib-on-primary); display: inline-grid; place-items: center; flex: none; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), 0 10px 18px -10px rgba(var(--lib-primary-rgb), .9); }
.lib-quick__msg { margin-top: .6rem; padding: .5rem .8rem; border-radius: 12px; font-size: .92rem; background: var(--lib-surface); border: 1px solid var(--lib-line); }
.lib-quick__msg.is-ok { background: var(--lib-ok-soft); color: var(--lib-ok); border-color: transparent; }
.lib-quick__msg.is-warn { background: var(--lib-warn-soft); color: var(--lib-warn); border-color: transparent; }
.lib-quick__msg.is-busy::before { content: ""; display: inline-block; width: .9em; height: .9em; margin-right: .5rem; vertical-align: -.1em; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: lib-spin .8s linear infinite; }
@media (max-width: 575.98px) { .lib-quick__icon { display: none; } }
.is-filled { animation: lib-filled 1.6s var(--lib-ease); border-color: var(--lib-primary-line) !important; }
@keyframes lib-filled { from { background-color: var(--lib-primary-soft); box-shadow: 0 0 0 4px rgba(var(--lib-primary-rgb), .18); } }
.lib-dups__list { list-style: none; margin: 0 0 .8rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.lib-dups__list li { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; padding: .55rem .65rem; background: var(--lib-surface); color: var(--lib-ink); border: 1px solid var(--lib-line); border-radius: 12px; }
.lib-dups__list li > .flex-grow-1 small { color: var(--lib-muted); font-weight: 500; }
.min-w-0 { min-width: 0; }
.lib-more > summary { display: flex; align-items: center; gap: 1rem; cursor: pointer; list-style: none; font-weight: 650; min-height: 44px; }
a.lib-chip { display: inline-flex; align-items: center; min-height: 32px; }
@media (pointer: coarse) { .btn-sm { min-height: 38px; } a.lib-chip { min-height: 38px; } .lib-finder__more > summary { min-height: 44px; } }
.lib-more > summary::-webkit-details-marker { display: none; }
.lib-more > summary > span { display: inline-flex; align-items: center; gap: .5rem; }
.lib-more > summary > small { margin-left: auto; font-weight: 500; }
.lib-more > summary::after { content: ""; flex: none; margin-left: .5rem; width: .5rem; height: .5rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: .55; transition: transform .2s var(--lib-ease); }
.lib-more:not(:has(> summary > small)) > summary::after { margin-left: auto; }
.lib-more[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.lib-more--inner { padding: .7rem .9rem; border: 1px solid var(--lib-line-2); border-radius: 12px; background: var(--lib-surface-2); }
@media (max-width: 575.98px) { .lib-more > summary > small { display: none; } }
.lib-coverbox { display: flex; gap: 1rem; align-items: flex-start; }
.lib-coverbox #cover-preview .lib-cover { width: 108px; }
.lib-coverbox__tools { display: flex; flex-direction: column; gap: .6rem; min-width: 0; align-items: flex-start; }

/* ---- a book's page ---- */
.lib-bookhead { display: flex; flex-direction: column; align-items: center; gap: 1rem; text-align: center; }
.lib-bookhead__facts { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.lib-booksub { font-family: var(--lib-serif); font-style: italic; font-size: 1.2rem; color: var(--lib-muted); margin: 0 0 .3rem; }
.lib-bookby { margin: 0; font-size: 1.2rem; color: var(--lib-ink); font-weight: 600; }
.lib-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem 1.5rem; margin: 1.2rem 0 0; padding-top: 1.1rem; border-top: 1px solid var(--lib-line-2); }
.lib-bookby + .lib-facts, .lib-booksub + .lib-facts { margin-top: 1rem; }
@media (max-width: 575.98px) {
  .lib-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; }
  .lib-facts__wide { grid-column: 1 / -1; }
}
.lib-facts dt { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--lib-muted); }
.lib-facts dd { margin: .1rem 0 0; font-weight: 600; overflow-wrap: anywhere; }
.lib-bookdesc { margin: 1.2rem 0 0; max-width: 70ch; color: var(--lib-ink-2); line-height: 1.7; }
.lib-danger-zone { box-shadow: none; background: transparent; border-color: color-mix(in srgb, var(--lib-danger) 28%, var(--lib-line)); }
.lib-copies td { padding-top: .7rem; padding-bottom: .7rem; }
@media (max-width: 575.98px) {   /* on a phone the list must fit without sideways scrolling */
  .lib-copies th, .lib-copies td, .lib-books th, .lib-books td { padding-left: .45rem; padding-right: .45rem; }
  .lib-copies th:first-child, .lib-copies td:first-child, .lib-books th:first-child, .lib-books td:first-child { padding-left: .8rem; }
  .lib-copies th:last-child, .lib-copies td:last-child { padding-left: .2rem; padding-right: .35rem; }
}
.lib-copyno { display: inline-grid; place-items: center; padding: .5rem .9rem; border-radius: 12px; background: var(--lib-primary-soft); color: var(--lib-primary-ink); border: 1px solid var(--lib-primary-line); font-weight: 800; letter-spacing: .03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lib-barcode-preview { max-width: 100%; height: 56px; width: 100%; border-radius: 8px; border: 1px solid var(--lib-line); background: #fff; }
.lib-empty--flat { padding: 1.4rem 1rem; }
@media (min-width: 992px) { .lib-bookhead { position: sticky; top: 84px; } }
/* where the cover card runs the full width, the cover sits beside its chips instead of filling a whole screen */
@media (max-width: 991.98px) {
  .lib-bookhead { flex-direction: row; align-items: center; text-align: left; gap: 1.2rem; }
  .lib-bookhead .lib-cover--lg { width: clamp(84px, 24vw, 130px); }
  .lib-bookhead__facts { flex-direction: column; align-items: flex-start; justify-content: flex-start; }
}

/* ---- tables you edit in place (types, places): on a phone every row becomes a small card ---- */
@media (max-width: 575.98px) {
  .lib-rowtable thead { display: none; }
  .lib-rowtable, .lib-rowtable tbody { display: block; }
  .lib-rowtable tr { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .9rem; padding: .85rem .9rem; border-bottom: 1px solid var(--lib-line-2); }
  .lib-rowtable tr:last-child { border-bottom: 0; }
  .lib-rowtable td { display: block; padding: 0; border: 0; min-width: 0; text-align: left !important; }
  .lib-rowtable td:empty { display: none; }
  .lib-rowtable td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--lib-muted); margin-bottom: .25rem; }
  .lib-rowtable .lib-rowtable__wide { grid-column: 1 / -1; }
  .lib-rowtable .lib-rowtable__act { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
  .lib-rowtable .form-control, .lib-rowtable .form-select { width: 100% !important; }
  .lib-rowtable .lib-addrow { background: var(--lib-surface-2); }
}

/* ---- import and export ---- */
.lib-drop { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .45rem; padding: 2.4rem 1rem; border: 2px dashed var(--lib-primary-line); border-radius: 18px; background: var(--lib-primary-soft); color: var(--lib-primary-ink); cursor: pointer; transition: transform .2s var(--lib-ease), border-color .2s, background .2s; }
.lib-drop:hover, .lib-drop.is-over { border-style: solid; border-color: var(--lib-primary); transform: translateY(-2px); }
.lib-drop:focus-within { outline: 3px solid rgba(var(--lib-primary-rgb), .55); outline-offset: 2px; }
.lib-drop__name { font-weight: 800; color: var(--lib-ink); overflow-wrap: anywhere; }
.lib-steps { counter-reset: st; list-style: none; padding: 0; margin: 0 0 1.1rem; display: flex; flex-direction: column; gap: .95rem; }
.lib-steps li { counter-increment: st; display: grid; grid-template-columns: 2rem 1fr; gap: 0 .8rem; align-items: start; }
.lib-steps li::before { content: counter(st); grid-row: span 2; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--lib-primary); color: var(--lib-on-primary); font-weight: 800; font-size: .9rem; }
.lib-steps strong { line-height: 1.8rem; } .lib-steps span { color: var(--lib-muted); font-size: .9rem; }
.lib-map td { vertical-align: middle; }
.lib-map tr.is-mapped .lib-chip { background: var(--lib-primary-soft); border-color: var(--lib-primary-line); color: var(--lib-primary-ink); }
/* on a phone the three columns would scroll sideways and hide the choice, so each row becomes a small card */
@media (max-width: 575.98px) {
  .lib-map, .lib-map tbody { display: block; }
  .lib-map thead { display: none; }
  .lib-map tr { display: grid; grid-template-columns: auto 1fr; column-gap: .75rem; row-gap: .55rem; align-items: start; padding: .8rem .9rem; border-bottom: 1px solid var(--lib-line); }
  .lib-map tr:last-child { border-bottom: 0; }
  .lib-map td { display: block; padding: 0 !important; border: 0 !important; width: auto !important; min-width: 0 !important; background: transparent !important; }
  .lib-map td:last-child { grid-column: 1 / -1; }
  .lib-map td.text-end { text-align: left !important; }
}
.lib-choices { display: grid; gap: .5rem; }
.lib-choice { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem .95rem; border: 1.5px solid var(--lib-line); border-radius: 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.lib-choice:hover { border-color: var(--lib-primary-line); }
.lib-choice:has(input:checked) { border-color: var(--lib-primary); background: var(--lib-primary-soft); }
.lib-choice .form-check-input { margin-top: .25rem; flex: none; }
.lib-choice small { display: block; color: var(--lib-muted); }
.lib-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.lib-stats--wide { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); text-align: left; }
.lib-stats .lib-stat { padding: .8rem .9rem; border-radius: 14px; background: var(--lib-surface-2); border: 1px solid var(--lib-line-2); }
.lib-stat strong { font-family: var(--lib-serif); font-size: 2rem; line-height: 1; font-weight: 650; font-variant-numeric: tabular-nums; }
.lib-stat span { color: var(--lib-muted); font-size: .82rem; line-height: 1.25; }
.lib-stat.is-bad strong { color: var(--lib-danger); }
.lib-problems { list-style: none; margin: 0; padding: .6rem 0 0; display: flex; flex-direction: column; gap: .45rem; font-size: .88rem; max-height: 280px; overflow: auto; }
.lib-sticky { position: sticky; top: 84px; }
.lib-importbox .lib-bar, .lib-bar { height: 12px; border-radius: 99px; background: var(--lib-surface-2); border: 1px solid var(--lib-line); overflow: hidden; }
.lib-bar > i { display: block; height: 100%; background: var(--lib-primary); border-radius: 99px; transition: width .4s var(--lib-ease); }
.lib-result__icon { width: 68px; height: 68px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--lib-ok-soft); color: var(--lib-ok); }
.lib-result__icon.is-warn { background: var(--lib-warn-soft); color: var(--lib-warn); }
.lib-addrow td { background: var(--lib-surface-2); }

/* ---- setup: built-in class list ---- */
.lib-dewey { columns: 2 300px; column-gap: 2rem; }
.lib-dewey__group { break-inside: avoid; margin-bottom: 1.1rem; }
.lib-dewey__group h3 { font-size: 1rem; font-family: var(--lib-font); font-weight: 700; margin: 0 0 .35rem; display: flex; gap: .5rem; align-items: center; }
.lib-dewey ul { list-style: none; margin: 0; padding: 0; font-size: .88rem; color: var(--lib-ink-2); }
.lib-dewey li { display: flex; gap: .6rem; padding: .12rem 0; }
.lib-dewey li > span { flex: none; width: 2.6rem; font-variant-numeric: tabular-nums; color: var(--lib-muted); font-weight: 650; }

/* ---- welcome (empty catalogue) ---- */
.lib-welcome { padding: clamp(1.6rem, 5vw, 3.2rem) 1rem; overflow: hidden; }
.lib-welcome .lib-shelf { --shelf-h: 130px; max-width: 520px; margin: 0 auto; padding: 0 1rem; justify-content: center; }

/* ---- labels: pickers ---- */
.lib-kindpick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.lib-kind { display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; padding: .9rem; border: 2px solid var(--lib-line); border-radius: 16px; cursor: pointer; background: var(--lib-surface); transition: border-color .15s, background .15s, transform .15s var(--lib-ease); }
.lib-kind:hover { border-color: var(--lib-primary-line); transform: translateY(-2px); }
.lib-kind:has(input:checked) { border-color: var(--lib-primary); background: var(--lib-primary-soft); box-shadow: 0 0 0 4px rgba(var(--lib-primary-rgb), .14); color: var(--lib-primary-ink); }
.lib-kind:has(input:focus-visible) { outline: 3px solid rgba(var(--lib-primary-rgb), .55); outline-offset: 2px; }
.lib-kind small { color: var(--lib-muted); line-height: 1.3; }
.lib-printbar { position: sticky; top: 64px; z-index: 12; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .75rem 1rem; margin-bottom: .8rem; background: var(--lib-surface); border: 1px solid var(--lib-line); border-radius: 14px; box-shadow: 0 14px 24px -20px var(--lib-shadow); }

/* ---- labels: the sheets (millimetres, so what you see is what the printer makes) ---- */
.lib-sheets { display: flex; flex-direction: column; gap: 1.6rem; align-items: flex-start; }
.lib-sheetframe { zoom: var(--z, 1); max-width: none; }
.lib-sheetno { font-size: .8rem; font-weight: 700; color: var(--lib-muted); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .08em; }
.lib-sheet { box-sizing: border-box; position: relative; width: var(--pw); height: var(--ph); padding: var(--top) 0 0 var(--left); overflow: hidden; background: #fff; color: #000;
  display: grid; grid-template-columns: repeat(var(--cols), var(--lw)); grid-auto-rows: var(--lh); gap: var(--gy) var(--gx); align-content: start; justify-content: start;
  box-shadow: 0 0 0 1px var(--lib-line), 0 26px 40px -24px var(--lib-shadow); break-after: page; page-break-after: always; }
.lib-sheetframe:last-child .lib-sheet { break-after: auto; page-break-after: auto; }
.lib-cell { box-sizing: border-box; width: var(--lw); height: var(--lh); overflow: hidden; }
.has-outline .lib-cell { outline: .2mm dashed #888; outline-offset: -.1mm; }
.lib-label { box-sizing: border-box; width: 100%; height: 100%; padding: 1.6mm 2mm; display: flex; flex-direction: column; gap: .5mm; overflow: hidden; background: #fff; color: #000;
  font-family: Arial, Helvetica, sans-serif; line-height: 1.12; }
.lib-label svg { display: block; }
.lib-label--barcode .lib-label__top { display: flex; justify-content: space-between; gap: 2mm; font-size: 6pt; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; }
.lib-label--barcode .lib-label__top span:last-child { flex: none; }
.lib-label--barcode .lib-label__top span:first-child { overflow: hidden; text-overflow: ellipsis; }
.lib-label__code { flex: 1 1 auto; min-height: 0; display: flex; }
.lib-label__code svg { width: 100%; height: 100%; }
.lib-label__num { font-size: 8pt; font-weight: 800; letter-spacing: .06em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-label--barcode .lib-label__title { font-size: 6.5pt; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-label--barcode.is-compact { padding: 1.2mm 1.6mm; gap: .3mm; }
.lib-label--barcode.is-compact .lib-label__top { display: none; }
.lib-label--barcode.is-compact .lib-label__num { font-size: 7pt; }
.lib-label--barcode.is-compact .lib-label__title { font-size: 5.5pt; }
.lib-label--qr { flex-direction: row; align-items: center; gap: 2.2mm; }
.lib-label--qr .lib-label__qr { flex: none; height: 100%; aspect-ratio: 1; }
.lib-label--qr .lib-label__qr svg { width: 100%; height: 100%; }
.lib-label--qr .lib-label__txt { min-width: 0; display: flex; flex-direction: column; gap: .5mm; }
.lib-label--qr .lib-label__num { text-align: left; font-size: 9pt; }
.lib-label--qr .lib-label__title { font-size: 7pt; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lib-label__call-line { font-size: 7pt; font-weight: 700; }
.lib-label__lib { font-size: 5.5pt; text-transform: uppercase; letter-spacing: .06em; color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-label--qr.is-compact { padding: 1.2mm 1.6mm; gap: 1.6mm; }
.lib-label--qr.is-compact .lib-label__num { font-size: 7.5pt; } .lib-label--qr.is-compact .lib-label__title { font-size: 6pt; -webkit-line-clamp: 2; } .lib-label--qr.is-compact .lib-label__lib { display: none; }
.lib-label--spine { align-items: center; justify-content: center; text-align: center; gap: 0; }
.lib-label__call { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: .4mm; font-size: 12pt; font-weight: 800; letter-spacing: .02em; width: 100%; }
.lib-label__call.is-long { font-size: 9.5pt; }
.lib-label__call span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-label--spine .lib-label__acc { font-size: 5pt; color: #444; letter-spacing: .05em; }
.lib-label--shelf { flex-direction: row; align-items: center; gap: 4mm; padding: 4mm; }
.lib-label--shelf .lib-label__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1.5mm; }
.lib-label__room { font-size: 22pt; font-weight: 800; line-height: 1.05; overflow-wrap: anywhere; }
.lib-label__shelf { font-size: 14pt; font-weight: 700; color: #333; }
.lib-label--shelf .lib-label__qr { flex: none; height: 100%; aspect-ratio: 1; max-height: 100%; }
.lib-label--shelf .lib-label__qr svg { width: 100%; height: 100%; }
.lib-label--shelf.is-compact { padding: 2mm; gap: 2mm; } .lib-label--shelf.is-compact .lib-label__room { font-size: 14pt; } .lib-label--shelf.is-compact .lib-label__shelf { font-size: 10pt; }
.lib-label--bad { align-items: center; justify-content: center; text-align: center; color: #a00; font-size: 7pt; }

/* ---- printing: only the sheets, exactly at paper size ---- */
@media print {
  html, body { background: #fff !important; }
  body { background-image: none !important; }
  .lib-content:has(.lib-sheets) { padding: 0 !important; max-width: none; }
  .lib-content:has(.lib-sheets) .lib-pagehead, .lib-labels-ui, .lib-sheetno, .lib-banner { display: none !important; }
  .lib-sheets { display: block; }
  .lib-sheetframe { zoom: 1 !important; }
  .lib-sheet { box-shadow: none; }
  .lib-label, .lib-cover--gen, .lib-label svg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
