:root {
  color-scheme: light;
  --paper: #fff;
  --ink: #151515;
  --muted: #565656;
  --line: #dedede;
  --panel: #f5f5f5;
  --bar-height: 4.125rem;
  --record-width: 76rem;
  --page-gutter: clamp(1rem, 3vw, 2rem);
  font-family: system-ui, sans-serif;
}

:root.dark-theme {
  color-scheme: dark;
  --paper: #111;
  --ink: #f5f5f5;
  --muted: #bcbcbc;
  --line: #414141;
  --panel: #202020;
}

html, body { overflow-x: clip; }
body { min-width: 0; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.editorial-header {
  position: sticky;
  top: 0;
  z-index: 8;
  background: #080808;
  color: #fff;
}

.editorial-bar {
  max-width: var(--record-width);
  min-height: var(--bar-height);
  margin: auto;
  padding: .65rem var(--page-gutter);
  display: flex;
  align-items: center;
  gap: clamp(.55rem, 3vw, 2rem);
}

.editorial-brand, .editorial-section {
  font-size: clamp(.94rem, 3vw, 1.55rem);
  font-weight: 300;
  letter-spacing: .1em;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
}

.editorial-brand span { color: #ef3434; }
.editorial-section { color: #bcbcbc; }
.editorial-section:hover { color: #fff; }

.editorial-theme, .editorial-bar .sidebar-toggle {
  min-height: 44px;
  padding: .4rem .65rem;
  border: 1px solid #707070;
  border-radius: .45rem;
  background: transparent;
  color: inherit;
  font-size: .875rem;
  cursor: pointer;
}

.editorial-theme { margin-left: auto; white-space: nowrap; }

.library-layout {
  max-width: var(--record-width);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
  min-height: calc(100dvh - var(--bar-height));
  grid-template-columns: minmax(0, 12rem) minmax(0, 1fr);
  background: var(--paper);
}

.library-sidebar {
  top: var(--bar-height);
  height: calc(100dvh - var(--bar-height));
  padding: 2.5rem 1rem 1.5rem 0;
  border-right: 0;
  background: var(--paper);
}

.collection-links { max-height: none; overflow: visible; }
.sidebar-search label, .nav-label, .filter-control { font-size: .875rem; color: var(--muted); }
.search-input-wrap input { padding-left: .65rem; height: 44px; font-size: .875rem; }
.collection-link { font-size: .875rem; color: var(--muted); }
.collection-count { font-size: .75rem; color: inherit; }

.library-main { background: var(--paper); }
.library-main > main { padding: clamp(2rem, 5vw, 4rem) 0 3rem clamp(1rem, 3vw, 2.5rem); }
.library-footer { margin: 0 0 0 clamp(1rem, 3vw, 2.5rem); }
.library-footer, .library-footer a { color: var(--muted); font-size: .8rem; }

.catalog-heading h1, .detail-copy h1 {
  font-family: inherit;
  font-weight: 750;
  letter-spacing: -.055em;
  line-height: 1.05;
}

.catalog-heading h1 { font-size: clamp(2.5rem, 6vw, 4.75rem); }
.result-count, .filter-reset, .filter-panel summary, .filter-control select { font-size: .875rem; color: var(--muted); }
.filter-reset:hover, .filter-panel summary::before { color: var(--ink); }
.filter-panel summary { width: fit-content; padding-block: .35rem; letter-spacing: 0; text-transform: none; }
.filter-control select { min-height: 44px; background: var(--paper); border-color: var(--line); }
.filter-controls { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }

.book-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); gap: 2rem 1rem; }
.book-cover {
  aspect-ratio: auto 148 / 210;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.book-cover, .book-card:hover .book-cover, .book-link:focus-visible .book-cover,
html.dark-theme .book-cover { box-shadow: none; }
.book-card:hover .book-cover, .book-link:focus-visible .book-cover { transform: none; }
.book-link:hover .book-title { text-decoration: underline; }
.book-title { font-family: inherit; font-size: .95rem; line-height: 1.3; font-weight: 600; }
.book-collection, .book-author, .eyebrow, .byline, .breadcrumbs { color: var(--muted); font-size: .8rem; }
.book-collection, .book-author { white-space: normal; }
.empty-state { color: var(--muted); font-size: 1rem; }

.breadcrumbs a { color: var(--ink); text-decoration: underline; text-underline-offset: .2em; }
.detail-top { grid-template-columns: minmax(9rem, 15rem) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3rem); }
.detail-cover { border-radius: 0; box-shadow: none; }
.detail-copy h1 { font-size: clamp(2rem, 4.2vw, 3.65rem); overflow-wrap: anywhere; }
.byline { font-size: 1rem; margin-bottom: .85rem; }
.description-section h2, .purchase-section h2, .tag-section h2 { color: var(--muted); font-size: .875rem; letter-spacing: .06em; }
.book-description { max-width: 65ch; color: var(--ink); font-size: 1.125rem; line-height: 1.65; }
.favorite-button-large, .external-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .45rem;
  font-size: .875rem;
}
.favorite-button-large:hover, .favorite-button-large.is-favorite, .external-links a:hover {
  background: var(--ink);
  color: var(--paper);
}
.tag-list li { font-size: .875rem; color: var(--muted); background: var(--panel); }
.book-neighbours { display: flex; flex-wrap: wrap; }
.neighbour { flex: 1 1 14rem; }
.neighbour:hover { text-decoration: underline; }
.neighbour, html.dark-theme .neighbour { border-color: var(--line); }

@media (max-width: 820px) {
  .library-layout { display: block; }
  .library-main > main { padding-left: 0; }
  .library-footer { margin-inline: 0; }
  .library-sidebar {
    visibility: hidden;
    width: min(18rem, 90vw);
    left: 0;
    transform: translateX(-100%);
    transition: transform .2s ease, visibility .2s;
    padding: 1rem;
    z-index: 7;
  }
  .library-sidebar.is-open { visibility: visible; transform: translateX(0); }
  .sidebar-close {
    display: block;
    align-self: flex-end;
    margin-bottom: 1rem;
    min-height: 44px;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: .45rem;
    padding: .4rem .65rem;
    cursor: pointer;
  }
}

@media (max-width: 540px) {
  .detail-cover-wrap { max-width: 13rem; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editorial-bar { gap: .55rem; padding-inline: .75rem; }
  .editorial-theme, .editorial-bar .sidebar-toggle { padding-inline: .35rem; font-size: .75rem; }
}

@media (max-width: 390px) {
  :root { --bar-height: 7rem; }
  .editorial-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: .75rem;
  }
  .editorial-section, .editorial-theme { justify-self: end; }
  .editorial-bar .sidebar-toggle { justify-self: start; }
}
