/* Personal library, annotations and import controls use the reader theme. */
.shelf-view-tabs { display: flex; align-items: center; gap: 8px; width: fit-content; margin-top: 24px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.shelf-view-tabs button { min-height: 44px; padding: 10px 22px; border: 0; border-radius: 10px; background: transparent; color: var(--text-soft); font: 600 var(--text-sm)/1.65 var(--font-ui); cursor: pointer; }
.shelf-view-tabs button[aria-selected="true"] { background: var(--shelf-accent); color: var(--shelf-on-accent); }
.shelf-view-tabs button:focus-visible { outline: 2px solid var(--shelf-accent); outline-offset: 3px; }
.shelf-source-status, .shelf-sync-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 12px 16px; margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text-soft); font: 400 var(--text-xs)/1.8 var(--font-ui); }
.shelf-source-status > span, .shelf-sync-notice > span { flex: 1 1 240px; min-width: 0; }
.shelf-source-status .btn-secondary { min-height: 44px; }
.shelf-sync-notice .btn-link { min-height: 44px; margin: 0; }
.shelf-pagination { display: flex; justify-content: center; margin-top: 20px; }
.shelf-pagination:has([hidden]) { display: none; }
.shelf-pagination button { min-height: 44px; }
.shelf-recommendation { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.shelf-section-title { margin-bottom: 14px; font: 600 var(--text-xl)/1.5 var(--font-serif); }
.shelf-book-position { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 1.7em; color: var(--text-muted); font: 400 var(--text-2xs)/1.7 var(--font-ui); }
.shelf-book-progress { display: block; height: 3px; width: min(100%, 220px); margin-top: 8px; overflow: hidden; border-radius: 2px; background: var(--line-strong); }
.shelf-book-progress > span { display: block; height: 100%; background: var(--shelf-accent); }
.shelf-card-feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 14px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 14px 14px; color: var(--text-soft); background: var(--surface); font: 400 var(--text-2xs)/1.8 var(--font-ui); overflow-wrap: anywhere; }
.shelf-card-feedback span { flex: 1 1 180px; min-width: 0; }
.shelf-card-feedback .btn-link { min-height: 44px; margin: 0; }
.ebook-shelf-item:has(.shelf-card-feedback) > .shelf-card { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.shelf-card[aria-busy="true"] .shelf-card-action::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 7px; border: 1.5px solid var(--line-strong); border-top-color: currentColor; border-radius: 50%; animation: shelf-loading .9s linear infinite; }
@keyframes shelf-loading { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .shelf-card[aria-busy="true"] .shelf-card-action::before { animation: none; } }
.shelf-actions .shelf-update-check { margin-bottom: 0; }
.shelf-shell { --shelf-accent: #3f5d4b; --shelf-accent-rgb: 63, 93, 75; --shelf-on-accent: #fffdf7; }
body[data-theme="dark"] .shelf-shell { --shelf-accent: #abc6ad; --shelf-accent-rgb: 171, 198, 173; --shelf-on-accent: #15251b; }
.shelf-shell { padding-top: 12px; }
.shelf-shell > .eyebrow { font-size: 10px; letter-spacing: 0.14em; }
.shelf-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 10px; }
.shelf-heading .shelf-title { margin-top: 0; font-size: clamp(2.1rem, 4vw, 3.2rem); }
.shelf-heading .shelf-actions { margin-top: 0; gap: 10px; flex-wrap: nowrap; }
.shelf-heading :is(.btn-primary, .btn-secondary) { min-height: 46px; padding: 12px 20px; font-size: var(--text-sm); white-space: nowrap; }
.shelf-intro { margin-top: 10px; font-size: var(--text-base); }
.shelf-offline-status { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 0; color: var(--text-soft); font: 400 var(--text-xs)/1.65 var(--font-ui); }
.shelf-offline-status::before { content: ""; flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--shelf-accent); }
.shelf-device-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; }
#shelf-on-device { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 9px 13px; border: 1px solid var(--line-strong); border-radius: 12px; background: transparent; color: var(--text-soft); font: 500 var(--text-xs)/1.5 var(--font-ui); cursor: pointer; }
#shelf-on-device[aria-pressed="true"] { color: var(--shelf-accent); background: rgba(var(--shelf-accent-rgb), .09); border-color: rgba(var(--shelf-accent-rgb), .3); }
#shelf-on-device:focus-visible { outline: 2px solid var(--shelf-accent); outline-offset: 3px; }
#shelf-on-device-count, .shelf-device-hint { color: var(--text-muted); font: 400 var(--text-2xs)/1.6 var(--font-ui); }
.shelf-device-badge { color: var(--shelf-accent); font: 500 var(--text-2xs)/1.6 var(--font-ui); }
.shelf-device-badge { display: block; min-height: 1.6em; }
.shelf-device-badge[data-state="remote"] { display: none; }
.shelf-device-badge[data-state="partial"] { color: var(--text-soft); }
.shelf-shell .ebook-storage-note { margin-top: 8px; font-size: var(--text-2xs); }
.shelf-more { position: relative; flex: 0 0 auto; }
.shelf-more summary { display: grid; place-items: center; width: 46px; height: 46px; list-style: none; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--text); cursor: pointer; }
.shelf-more summary::-webkit-details-marker { display: none; }
.shelf-more[open] summary, .shelf-more summary:hover { background: var(--surface-2); }
.shelf-more summary:focus-visible, .shelf-menu-action:focus-visible, .shelf-resume-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.shelf-more-menu { position: absolute; z-index: var(--z-dropdown); right: 0; top: calc(100% + 10px); width: min(255px, calc(100vw - 40px)); padding: 6px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--raised); box-shadow: var(--shadow-pop); }
.shelf-menu-action { display: block; width: 100%; min-height: 46px; padding: 11px 14px; border: 0; border-radius: 9px; color: var(--text); background: transparent; font: var(--text-sm)/1.5 var(--font-ui); text-align: left; cursor: pointer; }
.shelf-menu-action:hover { background: var(--surface-2); }
.shelf-menu-action:disabled { opacity: 0.5; cursor: wait; }
.shelf-resume { margin-top: 26px; }
.shelf-reading-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.shelf-remove-reading { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--text-muted); font: 22px/1 var(--font-ui); cursor: pointer; }
.shelf-remove-reading:hover { color: var(--text); background: var(--surface-2); }
.shelf-remove-reading:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.shelf-resume-entry { position: relative; min-width: 0; }
.shelf-resume-entry .shelf-resume-card { width: 100%; height: 100%; padding-right: 52px; }
.shelf-resume-entry .shelf-remove-reading { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-color: transparent; }
.shelf-feature-layout { display: grid; gap: 18px; }
.shelf-feature-layout.has-discovery { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.shelf-feature { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 32px; min-width: 0; padding: 24px 30px; border: 1px solid rgba(var(--shelf-accent-rgb), 0.2); border-radius: 22px; background: linear-gradient(115deg, rgba(var(--shelf-accent-rgb), 0.09), transparent 85%), var(--surface); }
.shelf-feature-copy { flex: 1; min-width: 0; }
.shelf-feature.is-welcome { display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: 16px; }
.shelf-feature.is-welcome .shelf-feature-art { grid-column: 2; grid-row: 1 / span 2; }
.shelf-feature.is-welcome .shelf-feature-actions { grid-column: 1; margin-top: 0; }
.shelf-feature-kicker { display: flex; align-items: center; gap: 7px; color: var(--shelf-accent); font: 600 var(--text-xs)/1.5 var(--font-ui); letter-spacing: 0.04em; }
.shelf-reading-dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: currentColor; }
.shelf-feature h2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 10px; font: 600 clamp(1.5rem, 2.5vw, 2rem)/1.25 var(--font-serif); text-wrap: balance; }
.shelf-feature-author { margin-top: 8px; color: var(--text-muted); font-size: var(--text-xs); }
.shelf-feature-reason, .shelf-feature-place { margin-top: 14px; font-size: var(--text-xs); line-height: 1.7; color: var(--text-soft); }
.shelf-feature-place { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shelf-feature-description { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; max-width: 560px; margin-top: 10px; color: var(--text-soft); font-size: var(--text-sm); line-height: 1.8; }
.shelf-feature-art { flex: 0 0 auto; width: 140px; padding: 0; border: 0; background: transparent; cursor: pointer; transform: rotate(4deg); transition: transform 0.2s var(--steps-3); }
@media (hover: hover) { .shelf-feature-art:hover { transform: rotate(0); } }
.shelf-feature-cover { display: block; width: 100%; height: auto; aspect-ratio: 5 / 7; object-fit: cover; border-radius: 3px 8px 8px 3px; box-shadow: var(--shadow-book); }
.shelf-cover-fallback { display: grid; place-items: center; padding: 14px; background: var(--surface-2); color: var(--text); font: 600 var(--text-md)/1.5 var(--font-serif); overflow-wrap: anywhere; }
.shelf-feature-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.shelf-suggest-button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 44px; padding: 10px 16px; border: 1px solid rgba(var(--shelf-accent-rgb), 0.35); border-radius: 10px; background: transparent; color: var(--shelf-accent); font: 500 var(--text-sm)/1.5 var(--font-ui); cursor: pointer; transition: background-color 0.2s var(--steps-3), border-color 0.2s var(--steps-3); }
.shelf-suggest-button:hover { background: rgba(var(--shelf-accent-rgb), 0.08); border-color: var(--shelf-accent); }
.shelf-feature-button { display: inline-flex; align-items: center; justify-content: center; gap: 24px; min-height: 44px; padding: 11px 20px; border: 1px solid transparent; border-radius: 999px; background: var(--shelf-accent); color: var(--shelf-on-accent); font: 600 var(--text-sm)/1.5 var(--font-ui); cursor: pointer; }
@media (hover: hover) { .shelf-feature-button:hover { box-shadow: 0 0 0 3px rgba(var(--shelf-accent-rgb), 0.14); } }
.shelf-feature-progress { display: grid; gap: 6px; max-width: 340px; margin: 14px 0 18px; }
.shelf-feature-progress > span:last-child { color: var(--text-muted); font-size: var(--text-2xs); font-variant-numeric: tabular-nums; }
.shelf-shell .shelf-resume-meter > span { background: var(--shelf-accent); }
.shelf-feature.is-discovery { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 26px; gap: 20px; background: var(--surface); }
.shelf-feature.is-discovery h2 { font-size: var(--text-xl); }
.shelf-feature.is-discovery .shelf-feature-art { grid-column: 2; grid-row: 1 / span 2; width: 82px; transform: rotate(-4deg); }
.shelf-discovery-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 44px; border: 0; background: transparent; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.shelf-discovery-title > span { color: var(--shelf-accent); font-family: var(--font-ui); }
.shelf-feature.is-discovery .shelf-change-pick { grid-column: 1; }
.shelf-change-pick { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--shelf-accent); background: transparent; font: 24px/1 var(--font-ui); cursor: pointer; }
.shelf-change-pick:hover { background: rgba(var(--shelf-accent-rgb), 0.08); }
.shelf-other-reading { margin-top: 18px; }
.shelf-other-reading > p { margin-bottom: 10px; font-size: var(--text-xs); color: var(--text-muted); }
.shelf-shortcuts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-block: 22px; margin-top: 4px; border-bottom: 1px solid var(--line-strong); }
.shelf-shortcuts button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 10px 14px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text-soft); font: 500 var(--text-xs)/1.5 var(--font-ui); white-space: nowrap; cursor: pointer; }
.shelf-shortcuts button:hover { background: var(--surface); }
.shelf-shortcuts button[aria-pressed="true"] { color: var(--shelf-accent); background: rgba(var(--shelf-accent-rgb), 0.09); border-color: rgba(var(--shelf-accent-rgb), 0.18); }
.shelf-shortcut-count { color: var(--text-muted); font-size: var(--text-2xs); font-variant-numeric: tabular-nums; }
.shelf-library-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-top: 30px; }
.shelf-library-heading h2 { font: 600 var(--text-2xl)/1.3 var(--font-serif); letter-spacing: -0.02em; }
#shelf-result-count { flex: 0 0 auto; color: var(--text-muted); font-size: var(--text-xs); }
.shelf-shell :is(.shelf-feature button, .shelf-shortcuts button):focus-visible { outline: 2px solid var(--shelf-accent); outline-offset: 4px; }
.shelf-shell .shelf-discovery-title:focus-visible { outline-offset: -2px; }
.shelf-shell .filter-btn.is-active { color: var(--shelf-accent); }
.shelf-shell .shelf-density button[aria-pressed="true"] { background: var(--shelf-accent); color: var(--shelf-on-accent); }
.shelf-shell #shelf-search:focus-visible { outline: 2px solid var(--shelf-accent); outline-offset: 2px; }
.shelf-resume-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.shelf-resume-title { font: 600 var(--text-xl)/1.3 var(--font-serif); letter-spacing: -0.01em; }
.shelf-resume-count { color: var(--text-muted); font-size: var(--text-xs); }
/* Books in progress scroll sideways; the row snaps to whole cards. */
.shelf-resume-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(300px, 360px); gap: 14px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 2px 2px 6px; margin: -2px -2px 0; }
.shelf-resume-row::-webkit-scrollbar { display: none; }
.shelf-resume-row.is-single { grid-auto-columns: minmax(0, 520px); }
.shelf-resume-card { display: flex; align-items: center; gap: 16px; width: 100%; min-width: 0; padding: 14px 18px 14px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); text-align: left; font-family: var(--font-ui); cursor: pointer; scroll-snap-align: start; transition: background-color 0.2s var(--steps-3), border-color 0.2s var(--steps-3); }
.shelf-resume-card:hover { background: var(--surface-2); border-color: rgba(var(--ink-rgb), 0.3); }
.shelf-resume-cover { flex: 0 0 auto; width: 52px; height: 74px; object-fit: cover; border-radius: 5px; background: var(--surface-2); box-shadow: var(--shadow-sm); }
.shelf-resume-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 10px; flex: 1; min-width: 0; }
.shelf-resume-copy strong { grid-column: 1 / -1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-family: var(--font-serif); font-size: var(--text-lg); font-weight: 600; line-height: 1.3; }
.shelf-resume-chapter { grid-column: 1 / -1; overflow: hidden; color: var(--text-muted); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.shelf-resume-meter { display: block; height: 4px; margin-top: 4px; border-radius: 999px; background: var(--line-strong); overflow: hidden; }
.shelf-resume-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--ink); }
.shelf-resume-share { margin-top: 4px; color: var(--text-muted); font-size: var(--text-2xs); font-variant-numeric: tabular-nums; }
.shelf-section-tabs { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 20px; width: 100%; max-width: 100%; }
.shelf-section-tabs .toolbar-group { display: inline-flex; flex-wrap: wrap; flex: 0 0 auto; gap: 4px; max-width: 100%; border-radius: 20px; padding: 4px; }
.shelf-primary-tabs .filter-btn,
.shelf-sub-tabs .filter-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: 0 1 auto; }
.shelf-primary-tabs .filter-btn { min-height: 38px; padding: 0 18px; font-size: var(--text-base); }
.shelf-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 19px; padding: 0 7px; border-radius: 999px;
  background: rgba(var(--ink-rgb), 0.08); color: var(--text-muted);
  font-size: var(--text-2xs); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1;
}
.shelf-badge:empty { display: none; }
.filter-btn.is-active .shelf-badge { background: rgba(var(--ink-rgb), 0.15); color: var(--text); }
.shelf-subtabs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-left: 4px; width: 100%; max-width: 100%; }
.shelf-subtabs-label {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--text-muted); font-size: var(--text-2xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap;
}
.shelf-subtabs-label::before { content: ""; width: 8px; height: 8px; margin: 0 2px 4px 0; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; border-bottom-left-radius: 3px; opacity: 0.7; }
.shelf-sub-tabs .filter-btn { min-height: 34px; padding: 0 14px; font-size: var(--text-sm); }
.shelf-filters { display: grid; grid-template-columns: minmax(200px, 1.4fr) minmax(0, 2fr); align-items: end; gap: 14px; margin-top: 16px; }
.shelf-search-row { display: flex; gap: 8px; min-width: 0; }
.shelf-search-row input { flex: 1; }
.shelf-advanced-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.shelf-advanced-filters:has(> label[hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.shelf-advanced-filters label { display: grid; gap: 6px; min-width: 0; color: var(--text-muted); font-size: var(--text-2xs); }
#shelf-filter-toggle { display: none; flex: 0 0 auto; align-items: center; gap: 6px; min-height: 46px; padding: 10px 12px; font-size: var(--text-xs); white-space: nowrap; }
#shelf-filter-toggle.has-active-filters { background: var(--surface-2); border-color: var(--ink); }
.shelf-filters input, .shelf-filters select, #ebook-txt-tools select {
  width: 100%; min-width: 0; min-height: 46px; padding: 11px 12px; border: 1px solid var(--line-strong);
  border-radius: 10px; background: var(--surface); color: var(--text); font: var(--text-sm)/1.5 var(--font-ui);
}
/* The browser's own clear button is blue; draw it in the theme's ink. */
#shelf-search::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; cursor: pointer; background: var(--text-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
}
#shelf-search::-webkit-search-cancel-button:hover { background: var(--text); }
.shelf-shell .shelf-grid { margin-top: 22px; row-gap: 32px; }
/* List / cover-grid switch beside the search box. */
.shelf-density { display: inline-flex; flex: 0 0 auto; gap: 2px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.shelf-density button { display: grid; place-items: center; width: 38px; min-height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--text-muted); cursor: pointer; }
.shelf-density button:hover { color: var(--text); }
.shelf-density button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.shelf-density button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* Cover grid: many books per row, title and author only. */
.shelf-grid.is-covers { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 28px 20px; }
.shelf-grid.is-covers > .ebook-shelf-item > .shelf-card { flex-direction: column; gap: 12px; min-height: 0; padding: 0; border: 0; background: transparent; }
@media (hover: hover) { .shelf-grid.is-covers > .ebook-shelf-item > .shelf-card:hover .shelf-cover { box-shadow: var(--shadow-book-hover); } }
.shelf-grid.is-covers .shelf-cover { width: 100%; flex: none; }
.shelf-grid.is-covers .ebook-shelf-item > .shelf-card .shelf-copy { padding-right: 0; }
.shelf-grid.is-covers .shelf-card-title, .shelf-grid.is-covers .shelf-card-title.is-long { font-size: var(--text-md); -webkit-line-clamp: 2; line-height: 1.3; }
.shelf-grid.is-covers .shelf-card-author { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-grid.is-covers :is(.shelf-card-meta, .shelf-card-description, .shelf-card-action, .shelf-book-tags) { display: none; }
.shelf-grid.is-covers .chapter-update-badge { margin-top: 6px; font-size: var(--text-2xs); }
.shelf-grid.is-covers .shelf-card-more { top: 6px; right: 6px; }
.shelf-grid.is-covers .shelf-card-more summary { background: rgba(0, 0, 0, 0.45); color: #fff; backdrop-filter: blur(6px); }
.shelf-grid.is-covers .shelf-card-more[open] summary, .shelf-grid.is-covers .shelf-card-more summary:hover { background: rgba(0, 0, 0, 0.65); color: #fff; }
/* With a mouse, a cover's menu button appears on hover or keyboard focus only. */
@media (hover: hover) {
  .shelf-grid.is-covers .shelf-card-more:not([open]) summary { opacity: 0; transition: opacity 0.15s; }
  .shelf-grid.is-covers .ebook-shelf-item:is(:hover, :focus-within) .shelf-card-more summary { opacity: 1; }
}
/* Placeholder cards while the catalogue loads. */
.shelf-skeleton { display: flex; gap: 24px; min-height: 292px; padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.shelf-skeleton-cover { flex: 0 0 165px; aspect-ratio: 5 / 7; border-radius: 4px 7px 7px 4px; }
.shelf-skeleton-lines { display: grid; align-content: start; gap: 12px; flex: 1; }
.shelf-skeleton-lines > span { height: 12px; border-radius: 6px; }
.shelf-skeleton-lines > span:first-child { width: 75%; height: 26px; }
.shelf-skeleton-lines > span:nth-child(2) { width: 40%; }
.shelf-skeleton-lines > span:nth-child(3) { width: 90%; margin-top: 12px; }
.shelf-skeleton-lines > span:nth-child(4) { width: 70%; }
:is(.shelf-skeleton-cover, .shelf-skeleton-lines > span) { background: linear-gradient(90deg, var(--surface-2) 30%, rgba(var(--ink-rgb), 0.04) 50%, var(--surface-2) 70%) 0 0 / 300% 100%; animation: shelfShimmer 1.4s linear infinite; }
@keyframes shelfShimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
body.is-shelf-boot #loading-screen { display: none; }
body.is-shelf-boot #view-shelf { animation: none; }
/* The favourite / manage buttons sit in a footer drawn inside the card, so
   they read as part of the book above them rather than the next one. */
.ebook-shelf-item { position: relative; display: flex; flex-direction: column; min-width: 0; }
.ebook-shelf-item:has(.shelf-card-more[open]) { z-index: var(--z-raised); }
.ebook-shelf-item > .shelf-card { flex: 1; }
.ebook-shelf-item > .shelf-card .shelf-copy { padding-right: 30px; }
/* Each book's actions sit behind one quiet button in the card's corner. */
.shelf-card-more { position: absolute; top: 14px; right: 14px; }
.shelf-card-more summary { display: grid; place-items: center; width: 36px; height: 36px; list-style: none; border: 1px solid transparent; border-radius: 50%; color: var(--text-muted); cursor: pointer; transition: background-color 0.2s var(--steps-3), color 0.2s var(--steps-3); }
.shelf-card-more summary::-webkit-details-marker { display: none; }
.shelf-card-more summary:hover, .shelf-card-more[open] summary { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.shelf-card-more summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.shelf-card-more .shelf-more-menu { top: calc(100% + 6px); width: min(240px, calc(100vw - 40px)); }
.shelf-menu-action { display: flex; align-items: center; gap: 10px; }
.shelf-menu-action svg { flex: 0 0 auto; color: var(--text-muted); }
.shelf-menu-action[aria-pressed="true"] svg { color: var(--text); }
.shelf-menu-action.is-danger, .shelf-menu-action.is-danger svg { color: rgb(var(--ui-danger-rgb)); }
.shelf-favorite-badge { display: inline-flex; vertical-align: -0.1em; margin-right: 0.3em; color: var(--text); }
.shelf-favorite-badge svg { width: 0.8em; height: 0.8em; }
.shelf-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 56px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); text-align: center; }
.shelf-empty-title { font: 600 var(--text-xl)/1.3 var(--font-serif); }
.shelf-empty .tools-empty { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }
.shelf-book-tags { display: block; margin-top: 12px; color: var(--text-muted); font-size: var(--text-xs); overflow-wrap: anywhere; }
.book-edit-cover { display: block; max-width: 130px; max-height: 180px; object-fit: contain; margin-bottom: 20px; }
.tools-panel label.library-check { flex-direction: row; align-items: center; }
.library-check input { width: auto; }
.tools-panel input[type="range"] { padding: 0; accent-color: var(--ink); }
.tools-panel output { color: var(--text-muted); font-weight: 400; }
.saved-annotations { margin-top: 24px; }
#library-tools-panel > .tools-actions + label { margin-top: 20px; }
.annotation-quote, .saved-annotations blockquote { white-space: pre-wrap; margin: 12px 0 20px; padding-left: 15px; border-left: 3px solid var(--line-strong); font: var(--text-md)/1.9 var(--font-serif); }
.saved-annotations .tool-card p { overflow-wrap: anywhere; }
#library-dialog .tools-feedback, #workbench-library-slot .tools-feedback { flex-shrink: 0; margin-bottom: 18px; }
.backup-file-label { margin-top: 24px; }
#backup-status { margin-top: 16px; font-size: var(--text-base); line-height: 1.8; }
.ebook-drop { display: grid; justify-items: center; gap: 4px; margin-bottom: 14px; padding: 26px 22px; text-align: center; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); color: var(--text-soft); cursor: pointer; font-size: var(--text-sm); line-height: 1.6; transition: background-color 0.15s, border-color 0.15s; }
.ebook-drop svg { margin-bottom: 6px; color: var(--text-muted); }
.ebook-drop strong { color: var(--text); font-size: var(--text-base); font-weight: 600; }
.ebook-drop span { color: var(--text-muted); }
.ebook-drop:hover { border-color: rgba(var(--ink-rgb), 0.4); background: rgba(var(--ink-rgb), 0.03); }
.ebook-drop.is-dragging, .ebook-drop:focus-visible { background: var(--surface-2); outline: 2px solid var(--ink); }
.ebook-queue { max-height: 220px; overflow: auto; }
.ebook-queue:not(:empty) { margin-top: 18px; }
.ebook-queue-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: var(--text-xs); line-height: 1.7; }
.ebook-queue-row > span { overflow-wrap: anywhere; }
.ebook-queue-row > span:nth-child(2) { grid-column: 1; color: var(--text-muted); }
.ebook-queue-row button { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
#ebook-txt-tools { margin-top: 16px; }
#ebook-txt-tools label { display: block; margin: 14px 0 8px; }
.ebook-txt-preview { max-height: 230px; overflow: auto; padding: 15px; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 10px; background: var(--bg); margin-top: 14px; font: var(--text-sm)/1.8 var(--font-ui); }
#ebook-txt-tools .btn-secondary { font-size: var(--text-xs); padding: 10px 14px; }
#ebook-txt-paragraph { margin-top: 12px; }
.reader-content { padding-inline: var(--reading-margin, 48px); }
.reader-content p { margin-bottom: var(--reading-gap, 0.85em); }
.reader-content mark[data-reader-mark] { color: inherit; cursor: pointer; padding: 0; border-bottom: 1px dotted currentColor; }
.reader-content mark[data-color="yellow"] { background: rgba(235, 184, 50, 0.3); }
.reader-content mark[data-color="mint"] { background: rgba(69, 167, 130, 0.28); }
.reader-content mark[data-color="pink"] { background: rgba(214, 109, 154, 0.3); }
.ebook-text { white-space: pre-line; }
.reader-content .ebook-list { list-style: disc outside; margin: 0 0 var(--reading-gap, 0.85em) 1.7em; padding: 0; }
.reader-content ol.ebook-list { list-style-type: decimal; }
.reader-content .ebook-list p { text-indent: 0; }
.reader-content .ebook-list .ebook-list { margin-bottom: 0; }
.ebook-noteref { padding: 0 2px; border: 0; border-bottom: 1px dotted currentColor; background: transparent; color: inherit; font: inherit; vertical-align: baseline; cursor: pointer; }
.footnote-text { white-space: pre-wrap; font: 16px/1.9 var(--font-serif); }
.ebook-toc { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.ebook-toc button { text-align: left; padding-block: 8px; border-bottom: 1px solid var(--line); font-size: var(--text-base); line-height: 1.7; }
@media (max-width: 900px) {
  .shelf-feature-layout.has-discovery { grid-template-columns: minmax(0, 1fr); }
  .shelf-feature.is-discovery { grid-template-columns: minmax(0, 1fr) auto auto; padding: 20px 26px; }
  .shelf-feature.is-discovery .shelf-feature-art { grid-row: 1; width: 64px; }
  .shelf-feature.is-discovery .shelf-feature-author { display: none; }
  .shelf-feature.is-discovery .shelf-change-pick { grid-column: 3; grid-row: 1; }
  .shelf-filters { grid-template-columns: minmax(0, 1fr); }
  .shelf-section-tabs .toolbar-group { display: inline-flex; flex-wrap: wrap; flex: 0 0 auto; }
  .shelf-section-tabs .toolbar-group .filter-btn { flex: 0 1 auto; }
}
@media (max-width: 640px) {
  .shelf-feature { padding: 22px 20px; gap: 18px; border-radius: 18px; }
  .shelf-feature h2 { font-size: 1.4rem; }
  .shelf-feature-art { width: 88px; }
  .shelf-feature-kicker { font-size: var(--text-2xs); letter-spacing: 0; }
  .shelf-feature-author { margin-top: 6px; }
  .shelf-feature-reason, .shelf-feature-place { margin-top: 10px; }
  .shelf-feature-description { display: none; }
  .shelf-feature-actions { flex-wrap: wrap; gap: 6px; margin-top: 14px; }
  .shelf-feature.is-welcome .shelf-feature-art { grid-row: 1; }
  .shelf-feature.is-welcome .shelf-feature-actions { grid-column: 1 / -1; margin-top: 0; }
  .shelf-feature-button { gap: 12px; padding-inline: 14px; font-size: var(--text-xs); }
  .shelf-feature.is-discovery { padding: 14px 18px; gap: 14px; }
  .shelf-feature.is-discovery h2 { font-size: var(--text-lg); }
  .shelf-feature.is-discovery .shelf-feature-art { width: 48px; }
  .shelf-feature.is-discovery .shelf-feature-reason { margin-top: 6px; }
  .shelf-feature-progress { margin: 10px 0 14px; }
  .shelf-shortcuts { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding-block: 16px; gap: 4px; }
  .shelf-shortcuts::-webkit-scrollbar { display: none; }
  .shelf-shortcuts button { flex: 0 0 auto; padding: 9px 11px; gap: 7px; }
  .shelf-library-heading { margin-top: 22px; }
  .shelf-library-heading h2 { font-size: var(--text-xl); }
  #shelf-result-count { font-size: var(--text-2xs); }
  .shelf-shell .shelf-grid { row-gap: 12px; }
  .shelf-grid:not(.is-covers) .shelf-card { min-height: 170px; padding: 16px; gap: 16px; }
  .shelf-grid:not(.is-covers) .shelf-cover { width: 82px; flex-basis: 82px; }
  .shelf-grid:not(.is-covers) .shelf-card-title { font-size: var(--text-lg); -webkit-line-clamp: 2; text-wrap: initial; }
  .shelf-grid:not(.is-covers) .shelf-card-author, .shelf-grid:not(.is-covers) .shelf-card-meta { margin-top: 5px; font-size: var(--text-2xs); }
  .shelf-grid:not(.is-covers) .shelf-card-description { -webkit-line-clamp: 1; margin-top: 8px; font-size: var(--text-xs); }
  .shelf-grid:not(.is-covers) .shelf-card-action { padding-top: 10px; font-size: var(--text-2xs); color: var(--shelf-accent); }
  .shelf-shell { padding-top: 8px; }
  .shelf-shell > .eyebrow, .shelf-intro { display: none; }
  .shelf-heading { gap: 12px; margin-top: 0; }
  .shelf-heading .shelf-title { font-size: 1.7rem; white-space: nowrap; }
  .shelf-heading :is(.btn-primary, .btn-secondary) { min-height: 44px; padding: 10px 13px; font-size: var(--text-xs); }
  .shelf-heading .shelf-actions { gap: 8px; }
  .shelf-more summary { width: 44px; height: 44px; }
  /* The import dialog repeats the format and size limits. */
  .shelf-shell .ebook-storage-note { display: none; }
  .shelf-filters { margin-top: 16px; gap: 12px; }
  .shelf-filters input, .shelf-filters select { font-size: 16px; }
  #shelf-filter-toggle { display: flex; }
  .shelf-advanced-filters { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .shelf-advanced-filters.is-expanded { display: grid; }
  .shelf-advanced-filters:not(:has(> label[hidden])) label:last-child { grid-column: 1 / -1; }
  .shelf-resume { margin-top: 16px; }
  .shelf-section-tabs { width: 100%; }
  /* One row per tab group that scrolls sideways, instead of wrapping a lone
     tab onto a second line. */
  .shelf-section-tabs .shelf-primary-tabs,
  .shelf-section-tabs .shelf-sub-tabs { position: relative; display: flex; flex-wrap: nowrap; width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; border-radius: 999px; padding: 4px; gap: 4px; }
  .shelf-section-tabs .shelf-primary-tabs::-webkit-scrollbar,
  .shelf-section-tabs .shelf-sub-tabs::-webkit-scrollbar { display: none; }
  .shelf-section-tabs .has-more-end { -webkit-mask-image: linear-gradient(90deg, #000 78%, transparent); mask-image: linear-gradient(90deg, #000 78%, transparent); }
  .shelf-section-tabs .has-more-start { -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%); mask-image: linear-gradient(90deg, transparent, #000 22%); }
  .shelf-section-tabs .has-more-start.has-more-end { -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); }
  .shelf-section-tabs .shelf-primary-tabs .filter-btn,
  .shelf-section-tabs .shelf-sub-tabs .filter-btn { flex: 0 0 auto; justify-content: center; min-height: 40px; padding: 6px 14px; gap: 6px; font-size: var(--text-sm); white-space: nowrap; }
  .shelf-section-tabs .shelf-badge { min-width: 20px; height: 18px; padding: 0 6px; font-size: var(--text-2xs); flex-shrink: 0; }
  .shelf-subtabs-row { width: 100%; padding-left: 0; }
  .shelf-subtabs-label { display: none; }
  .shelf-resume-row { grid-auto-columns: 84%; gap: 10px; }
  .shelf-resume-row.is-single { grid-auto-columns: 100%; }
  .shelf-resume-card { gap: 12px; padding: 12px; border-radius: 14px; }
  .shelf-resume-copy strong { font-size: var(--text-md); }
  .shelf-resume-cover { width: 44px; height: 62px; }
  .shelf-card-more { top: 8px; right: 8px; }
  .shelf-grid.is-covers { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 12px; }
  .shelf-grid.is-covers .shelf-card-title, .shelf-grid.is-covers .shelf-card-title.is-long { font-size: var(--text-sm); }
  .shelf-grid.is-covers .shelf-card-author { font-size: var(--text-2xs); }
  .shelf-grid.is-covers .shelf-card-more { top: 4px; right: 4px; }
  .shelf-skeleton { gap: 16px; min-height: 210px; padding: 16px; border-radius: 16px; }
  .shelf-skeleton-cover { flex-basis: 100px; }
  .shelf-shell .shelf-grid { margin-top: 18px; }
  .ebook-dialog { padding: 22px 18px; }
  .reader-content { padding-inline: min(var(--reading-margin, 24px), 7vw); }
}
@media (max-width: 360px) {
  .shelf-heading { flex-wrap: wrap; gap: 10px; }
  .shelf-heading .shelf-title { font-size: 1.5rem; }
  .shelf-heading :is(.btn-primary, .btn-secondary) { padding-inline: 12px; }
}

/* The shelf leads with one reading card; secondary content stays quieter. */
#shelf-resume .shelf-feature { padding: 20px 24px; gap: 24px; }
#shelf-resume .shelf-feature-art { width: 104px; }
#shelf-resume .shelf-feature h2 { font-size: clamp(1.3rem, 2.2vw, 1.8rem); line-height: 1.45; }
#shelf-resume .shelf-feature-author { display: none; }
#shelf-resume .shelf-feature-place { margin-top: 6px; }
#shelf-resume .shelf-feature-progress { margin: 10px 0 12px; gap: 4px; }
#shelf-resume .shelf-other-reading { margin-top: 12px; }
#shelf-resume .shelf-other-reading > p { margin-bottom: 6px; }
#shelf-resume .shelf-resume-row { grid-auto-columns: minmax(220px, 280px); gap: 8px; }
#shelf-resume .shelf-resume-card { min-height: 72px; padding: 10px 44px 10px 14px; gap: 0; }
#shelf-resume .shelf-resume-cover, #shelf-resume .shelf-resume-card .shelf-resume-meter, #shelf-resume .shelf-resume-share { display: none; }
#shelf-resume .shelf-resume-copy strong { font: 600 var(--text-xs)/1.65 var(--font-ui); }
.shelf-grid .shelf-copy { gap: 6px; }
.shelf-grid .shelf-card-author, .shelf-grid .shelf-card-meta, .shelf-grid:not(.is-covers) .shelf-card-description { margin-top: 0; }
.shelf-grid .shelf-card-title { line-height: 1.45; }
.shelf-grid:not(.is-covers) .shelf-card-action { margin-top: auto; padding-top: 8px; }
.shelf-grid.is-covers .shelf-book-position { font-size: var(--text-2xs); }
.shelf-grid.is-covers .shelf-device-badge { font-size: var(--text-2xs); overflow-wrap: anywhere; }
.shelf-grid.is-covers .shelf-book-progress { margin-top: 2px; }
.shelf-shortcuts { padding-block: 12px; }
.shelf-library-heading { margin-top: 20px; }
@media (max-width: 600px) {
  .shelf-view-tabs { margin-top: 18px; width: 100%; }
  .shelf-view-tabs button { flex: 1; padding-inline: 12px; }
  #shelf-resume { margin-top: 16px; }
  #shelf-resume .shelf-feature { padding: 16px; gap: 16px; }
  #shelf-resume .shelf-feature-art { width: 76px; }
  #shelf-resume .shelf-feature h2 { font-size: 1.2rem; line-height: 1.5; margin-top: 6px; }
  #shelf-resume .shelf-feature-kicker { font-size: var(--text-2xs); }
  #shelf-resume .shelf-feature-place { font-size: var(--text-2xs); }
  #shelf-resume .shelf-feature-button { min-height: 44px; padding: 9px 16px; }
  #shelf-resume .shelf-feature-progress { margin-block: 8px; }
  .shelf-view-tabs + .shelf-offline-status { margin-top: 12px; }
  .shelf-recommendation .shelf-feature h2 { line-height: 1.5; }
  .shelf-shortcuts { padding-block: 10px; }
  .shelf-library-heading { margin-top: 16px; }
}
