.books-index .page-heading { align-items: stretch; flex-direction: column; }
.catalog-controls { display: grid; width: 100%; gap: 0.9rem; }
.search-form { display: flex; min-width: 0; width: 100%; gap: 0.5rem; }
.search-form input { min-width: 0; }
.search-form input[type="search"] { flex: 1; width: auto; }
.search-form input[type="submit"] { width: auto; }
.search-form button { width: auto; }
.search-form button[aria-expanded="true"] { border-color: var(--brand-gold); background: #fffdf9; }
.catalog-filter-toggle { flex: 0 0 42px; width: 42px !important; padding: 0; }
.catalog-filter-toggle svg { width: 18px; height: 18px; }
.catalog-active-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.catalog-active-filters[hidden] { display: none; }
.catalog-active-filter { display: inline-flex; padding: 0.3rem 0.6rem; border: 1px solid rgba(198, 156, 108, 0.65); border-radius: 99px; background: #fffdf9; color: var(--brand-blue); font-size: 0.75rem; font-weight: 700; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2rem 1.4rem; }
.book-grid--compact { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.book-card { display: block; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: 0 8px 24px rgba(4, 14, 133, 0.06); color: inherit; text-decoration: none; transition: transform 180ms ease, box-shadow 180ms ease; }
.book-card[href]:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.book-card[href]:focus-visible { outline: 3px solid var(--brand-gold); outline-offset: 3px; }
.book-cover { position: relative; display: block; aspect-ratio: 9 / 13; overflow: hidden; background: var(--surface); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card__body { padding: 1rem; }
.access-badge { display: inline-block; margin-bottom: 0.65rem; padding: 0.22rem 0.55rem; border-radius: 99px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; }
.access-badge--free { background: #f5eadf; color: #745029; }
.access-badge--available { background: #e8e9ff; color: var(--brand-blue); }
.access-badge--locked { background: #ececf0; color: #5d5f6b; }
.book-cover > .book-access-prompt { position: absolute; right: 0.75rem; bottom: 0.75rem; left: 0.75rem; margin: 0; padding: 0.45rem 0.7rem; background: rgba(4, 14, 133, 0.92); box-shadow: 0 4px 14px rgba(4, 14, 133, 0.24); color: white; text-align: center; }
.access-expiration { margin: 0.35rem 0 0.8rem; color: var(--muted); font-size: 0.78rem; }
.book-card h3 a { color: var(--ink); text-decoration: none; }
.book-author { margin: 0.2rem 0 0.8rem; color: var(--muted); }
.book-classifications { display: grid; gap: 0.45rem; margin: 0.65rem 0 0.9rem; }
.book-classifications__group { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.book-tag { display: inline-flex; padding: 0.2rem 0.5rem; border-radius: 99px; font-size: 0.68rem; font-weight: 700; line-height: 1.25; }
.book-tag--language { border: 1px solid rgba(198, 156, 108, 0.65); background: #fffdf9; color: #745029; }
.book-tag--category { background: #eef0ff; color: var(--brand-blue); }
.catalog-filters { display: grid; min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 0.9rem; padding: 0.9rem; border: 1px solid var(--border); border-radius: var(--radius); background: white; }
.catalog-filters[hidden] { display: none; }
.catalog-filters fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.catalog-filters legend { margin-bottom: 0.45rem; color: var(--brand-blue); font-size: 0.78rem; font-weight: 700; }
.catalog-filter-options { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.catalog-filter-options label { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.55rem; border: 1px solid var(--border); border-radius: 99px; cursor: pointer; font-size: 0.75rem; }
.catalog-filter-options label:has(input:checked) { border-color: var(--brand-gold); background: #fffdf9; color: var(--brand-blue); }
.catalog-filter-options input { width: auto; margin: 0; }
.catalog-filter-actions { display: flex; align-items: center; align-self: end; gap: 0.65rem; }
.book-card--horizontal { display: grid; grid-template-columns: 100px 1fr; }
.book-card--horizontal > img { width: 100%; height: 100%; object-fit: cover; }
.progress-track { overflow: hidden; height: 4px; margin: 0.8rem 0; border-radius: 99px; background: var(--border); }
.progress-track span { display: block; height: 100%; background: var(--brand-gold); }
.empty-state { padding: 3rem; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; }
.book-detail { display: grid; grid-template-columns: minmax(220px, 360px) 1fr; gap: clamp(2rem, 6vw, 6rem); margin-top: 2rem; }
.book-detail__cover { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); }
.book-description { max-width: 700px; white-space: pre-line; }
.book-reading-action { margin-top: 2.5rem; }
.book-reading-action > form { display: inline-block; margin: 0; }
.book-access-notice { max-width: 680px; padding: 1.25rem; border: 1px solid var(--border); border-left: 4px solid var(--brand-gold); border-radius: 10px; background: var(--surface); }
.book-access-notice h2 { font-size: clamp(1.45rem, 2.2vw, 1.9rem); }
.book-access-notice p { margin-bottom: 0; color: var(--muted); }
.edition-update-notice { max-width: 680px; margin-top: 2rem; padding: 1.25rem; border: 1px solid rgba(198, 156, 108, 0.55); border-left: 4px solid var(--brand-gold); border-radius: 10px; background: #fffdf9; }
.edition-update-notice h2 { font-size: clamp(1.55rem, 2.4vw, 2.1rem); }
.edition-update-link { display: inline-block; margin-top: 0.7rem; color: var(--brand-blue); font-size: 0.78rem; font-weight: 700; text-decoration: none; }
.edition-update-link::before { color: var(--brand-gold); content: "●"; margin-right: 0.35rem; }
.reading-migration__heading { margin-top: 2rem; }
.migration-form { display: grid; gap: 1rem; }
.migration-summary { padding: 1rem 1.2rem; border-left: 4px solid var(--brand-gold); background: #fffdf9; }
.migration-summary p { margin-bottom: 0; color: var(--muted); }
.migration-form > h2 { margin-top: 1.5rem; }
.migration-item { padding: 1.1rem; border: 1px solid var(--border); border-radius: 10px; background: white; }
.migration-item h3 { margin-bottom: 0.8rem; }
.migration-item fieldset { display: grid; gap: 0.55rem; margin: 0; padding: 0; border: 0; }
.migration-item legend { margin-bottom: 0.55rem; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.migration-choice { display: flex; align-items: start; gap: 0.75rem; padding: 0.8rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.migration-choice:has(input:checked) { border-color: var(--brand-gold); background: #fffdf9; }
.migration-choice input { margin-top: 0.25rem; }
.migration-choice span { display: grid; gap: 0.2rem; }
.migration-choice small, .migration-item__missing { color: var(--muted); }
.migration-choice--skip, .migration-choice--approximate { border-style: dashed; }
.migration-actions { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding: 1rem; border-top: 1px solid var(--border); background: rgba(255, 255, 255, 0.96); box-shadow: 0 -8px 24px rgba(4, 14, 133, 0.06); }
.migration-actions p { margin: 0; color: var(--muted); font-size: 0.82rem; }
.migration-actions > div { display: flex; gap: 0.6rem; }
.search-message { padding: 1rem; border-left: 3px solid var(--brand-gold); background: white; color: var(--muted); }
.catalog-result-list { display: grid; gap: 1rem; }
.catalog-result { display: grid; grid-template-columns: 110px 1fr; gap: 1.25rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: 0 8px 24px rgba(4, 14, 133, 0.05); }
.catalog-result__cover { align-self: start; overflow: hidden; border-radius: 8px; }
.catalog-result__cover img { display: block; width: 100%; aspect-ratio: 9 / 13; object-fit: cover; }
.catalog-result__body h3 { margin-bottom: 0; }
.catalog-result__body h3 a { color: var(--ink); text-decoration: none; }
.catalog-result__matches { display: grid; gap: 0.6rem; margin-top: 1rem; }
.catalog-result__matches form { margin: 0; }
.catalog-match { display: grid; width: 100%; gap: 0.25rem; padding: 0.8rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; text-decoration: none; }
.catalog-match:hover, .catalog-match:focus-visible { border-color: var(--brand-gold); background: white; }
.catalog-match--locked { cursor: default; }
.catalog-match--locked:hover { border-color: var(--border); background: var(--surface); }
.catalog-match strong { color: var(--brand-blue); font-size: 0.78rem; }
.catalog-match span { line-height: 1.45; }
.catalog-match small { color: var(--brand-blue); font-weight: 700; }
.catalog-result__description { max-width: 760px; color: var(--muted); }
.search-highlight { padding: 0.03em 0.12em; border-radius: 0.18em; background: rgba(198, 156, 108, 0.35); color: inherit; }
.offline-library .page-heading { align-items: start; flex-direction: column; margin-bottom: 2rem; }
.offline-library .page-heading p:last-child { max-width: 680px; margin: 0; color: var(--muted); }
.offline-library__status { color: var(--muted); }
.offline-library__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.offline-library-card { padding: 1.25rem; border: 1px solid var(--border); border-left: 4px solid var(--brand-gold); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.offline-library-card h2 { font-size: 1.8rem; }
.offline-library-card p { color: var(--muted); }

@media (max-width: 720px) {
  .search-form { flex-wrap: wrap; }
  .search-form input[type="search"] { flex-basis: 100%; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 0.75rem; }
  .book-grid--compact { grid-template-columns: 1fr; }
  .book-card__body { padding: 0.75rem; }
  .book-detail { grid-template-columns: 1fr; }
  .book-detail__cover { width: min(78%, 340px); margin: auto; }
  .catalog-result { grid-template-columns: 74px 1fr; gap: 0.8rem; padding: 0.75rem; }
  .catalog-filters { grid-template-columns: 1fr; }
  .catalog-filter-actions { justify-content: space-between; }
  .migration-actions { align-items: stretch; flex-direction: column; }
  .migration-actions > div { display: grid; }
}
