:root {
  --paper: #f2f5f0;
  --surface: #fbfcfa;
  --surface-strong: #ffffff;
  --ink: #17211d;
  --ink-soft: #40504a;
  --muted: #64736d;
  --line: rgba(23, 58, 46, 0.16);
  --line-strong: rgba(23, 58, 46, 0.32);
  --forest: #173a2e;
  --forest-light: #285744;
  --brick: #b43a27;
  --brick-dark: #842719;
  --success: #28633f;
  --info: #255f82;
  --danger: #9b2d20;
  --font-display: "Literata", Georgia, serif;
  --font-body: "Libre Franklin", "Segoe UI", sans-serif;
  --shell: 76rem;
  --radius: 6px;
  --page-pad: clamp(1rem, 4vw, 3rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 31px,
    rgba(23, 58, 46, 0.035) 32px
  );
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
}

body[data-page] {
  color-scheme: dark;
  --paper: #101913;
  --surface: #19251e;
  --surface-strong: #202d24;
  --ink: #f0e6d2;
  --ink-soft: #d4cbb9;
  --muted: #b5b3a0;
  --line: rgba(208, 180, 126, 0.18);
  --line-strong: rgba(208, 180, 126, 0.35);
  --forest: #c3d4bb;
  --brick: #8d3945;
  --brick-dark: #9b3d4a;
  --danger: #ed9a9b;
  background-image: repeating-linear-gradient(90deg, transparent 0 110px, rgba(0, 0, 0, 0.1) 111px 113px);
}

body[data-page] .page-shell {
  background: transparent;
}

body[data-page] .topbar {
  min-height: 0;
  padding-block: 2rem;
  background: #14261c;
}

body[data-page] .brand-block h1 {
  max-width: none;
  font-size: 2.5rem;
}

body[data-page] .page-nav {
  margin-bottom: 1.25rem;
  background: #18221b;
}

body[data-page="catalog"] .stats-strip {
  margin-bottom: 2rem;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
}

body[data-page="catalog"] .stat-block {
  padding-block: 1rem;
}

body[data-page] .catalog-panel {
  padding: 0;
}

@media (max-width: 30rem) {
  body[data-page="catalog"] .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-page="catalog"] .stat-wide {
    grid-column: auto;
  }

  body[data-page="catalog"] .stat-block:nth-child(even) {
    border-left: 1px solid var(--line);
  }
}

body[data-page] .filter-tabs button:hover,
body[data-page] .filter-tabs button[aria-pressed="true"] {
  color: var(--ink);
  background: #31533e;
}

body[data-page] .book-detail-rating,
body[data-page] .book-rating {
  color: #e7cc9d;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  letter-spacing: 0;
}

:focus-visible {
  outline: 3px solid var(--brick);
  outline-offset: 3px;
}

.page-shell {
  width: 100%;
  max-width: var(--shell);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 var(--page-pad) 5rem;
  background: rgba(242, 245, 240, 0.9);
}

.topbar {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  min-height: 17rem;
  margin: 0 calc(-1 * var(--page-pad));
  padding: 3rem var(--page-pad) 2.5rem;
  overflow: hidden;
  color: #f5f7f3;
  background: var(--forest);
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 7px;
  background: var(--brick);
}

.compact-topbar {
  min-height: 13rem;
}

.brand-block {
  position: relative;
  z-index: 1;
}

.collection-label {
  display: block;
  margin-bottom: 0.75rem;
  color: #bbcdc5;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-block h1 {
  max-width: 16ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: 3.25rem;
  font-weight: 650;
  line-height: 1.08;
  letter-spacing: 0;
  text-wrap: balance;
}

.brand-block p {
  max-width: 52ch;
  margin: 1rem 0 0;
  color: #d5e0db;
  font-size: 1rem;
}

.home-link {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(245, 247, 243, 0.55);
  border-radius: var(--radius);
  color: #f5f7f3;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
}

.home-link:hover {
  border-color: #f5f7f3;
  background: rgba(255, 255, 255, 0.1);
}

.page-nav {
  display: flex;
  align-items: center;
  min-height: 58px;
  margin: 0 calc(-1 * var(--page-pad)) 2.5rem;
  padding: 0 var(--page-pad);
  overflow-x: auto;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-strong);
}

.nav-link {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0 1.15rem;
  border-bottom: 3px solid transparent;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
}

.nav-link:first-child {
  padding-left: 0;
}

.nav-link:hover {
  color: var(--forest);
}

.nav-link.is-active {
  border-bottom-color: var(--brick);
  color: var(--forest);
}

.status-banner,
.inline-status {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line-strong);
  border-left-width: 5px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink-soft);
}

.status-banner {
  margin-bottom: 1.5rem;
}

.inline-status {
  margin-top: 1.25rem;
}

.status-info {
  border-left-color: var(--info);
  color: #b9d8ed;
  background: #192d37;
}

.status-success {
  border-left-color: var(--success);
  color: #b6dbc0;
  background: #1b3024;
}

.status-error {
  border-left-color: var(--danger);
  color: #f0b5b5;
  background: #382126;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(8rem, 0.7fr)) minmax(15rem, 1.9fr);
  margin-bottom: 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-strong);
}

.stat-block {
  min-width: 0;
  padding: 1.35rem;
  border-left: 1px solid var(--line);
}

.stat-block:first-child {
  border-left: 0;
}

.stat-label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  color: var(--forest);
  font-family: var(--font-display);
  font-size: 2.1rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.stat-title {
  font-size: 1.35rem;
}

.catalog-panel,
.ranking-layout,
.editor-panel,
.records-panel,
.auth-panel {
  border-radius: var(--radius);
  background: var(--surface);
}

.catalog-panel {
  padding: 0;
  background: transparent;
}

.catalog-toolbar,
.section-heading,
.ranking-heading,
.signed-in-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
}

h2 {
  margin: 0;
  color: var(--forest);
  font-family: var(--font-display);
  font-size: 1.65rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.catalog-toolbar {
  flex-wrap: wrap;
}

.catalog-toolbar > div {
  margin-right: auto;
}

.sort-field {
  width: 11rem;
  max-width: 100%;
}

.catalog-toolbar p,
.section-heading p,
.ranking-heading p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.search-field {
  width: min(100%, 21rem);
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface-strong);
  font-size: 1rem;
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brick);
  box-shadow: 0 0 0 3px rgba(180, 58, 39, 0.14);
}

button {
  min-height: 44px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--brick);
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--brick);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 100ms ease;
}

button:hover {
  border-color: var(--brick-dark);
  background: var(--brick-dark);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button-secondary {
  border-color: var(--line-strong);
  color: var(--forest);
  background: transparent;
}

.button-secondary:hover {
  border-color: var(--forest);
  color: var(--ink);
  background: #31533e;
}

.button-danger {
  border-color: transparent;
  color: var(--danger);
  background: transparent;
}

.button-danger:hover {
  border-color: #9b3d4a;
  color: #ffffff;
  background: #9b3d4a;
}

.filter-tabs {
  display: inline-flex;
  max-width: 100%;
  margin: 1.5rem 0 1.75rem;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.filter-tabs button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0.5rem 0.95rem;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: 0.86rem;
}

.filter-tabs button:first-child {
  border-left: 0;
}

.filter-tabs button:hover {
  color: var(--forest);
  background: #e7ede9;
}

.filter-tabs button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--forest);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  gap: 1.5rem;
}

.bookshelves {
  display: grid;
  gap: 2rem;
}

.book-shelf {
  min-width: 0;
}

.shelf-books {
  display: grid;
  grid-template-columns: repeat(var(--shelf-capacity), minmax(0, 1fr));
  padding-inline: 0.75rem;
  background: linear-gradient(to bottom, #211812, #35271c);
  border-inline: 1px solid #392619;
  box-shadow: inset 0 8px 14px -8px #100c09;
}

.spine-slot {
  display: flex;
  align-items: end;
  justify-content: center;
  height: 274px;
}

.book-spine {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 70px;
  height: var(--spine-height);
  padding: 12px 6px 9px;
  border: 1px solid rgba(221, 190, 132, 0.3);
  border-radius: 3px 5px 3px 2px;
  color: #fff9e9;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.25), transparent 12%, rgba(255, 255, 255, 0.09) 20%, transparent 32%, rgba(0, 0, 0, 0.15)), var(--spine-color);
  box-shadow: 3px 1px 3px rgba(23, 33, 29, 0.2), inset 0 6px 0 rgba(255, 249, 233, 0.12), inset 0 -6px 0 rgba(255, 249, 233, 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.book-spine:hover,
.book-spine:focus-visible {
  z-index: 1;
  border-color: #c5aa72;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.1) 25%, transparent), var(--spine-color);
  transform: translateY(-7px);
  box-shadow: 4px 8px 9px rgba(23, 33, 29, 0.22);
}

.spine-text {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-height: 0;
  width: 100%;
  padding-block: 5px;
  border-block: 1px solid rgba(255, 249, 233, 0.35);
}

.spine-title,
.spine-author {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 100%;
  overflow-wrap: anywhere;
  text-align: left;
}

.spine-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: var(--spine-font);
  font-weight: 500;
  line-height: 1.15;
}

.spine-author {
  flex: 0 0 11px;
  max-width: 11px;
  font-size: 0.57rem;
  line-height: 1.1;
  font-weight: 400;
}

.spine-rating {
  margin-top: 7px;
  font-size: 0.63rem;
  line-height: 1;
}

.shelf-base {
  display: grid;
  grid-template-columns: repeat(var(--shelf-capacity), minmax(0, 1fr));
  align-items: start;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid #805b3b;
  border-bottom: 3px solid #21160f;
  background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(196, 151, 95, 0.08) 5px 6px), #47301f;
  color: #f2dfb6;
}

.shelf-base h3 {
  min-width: 0;
  margin: 0;
  padding-inline: 0.35rem;
  border-left: 1px solid rgba(242, 223, 182, 0.25);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shelf-base h3:first-child {
  border-left: 0;
}

.shelf-base h3:hover,
.shelf-base h3:focus-visible {
  white-space: normal;
  overflow-wrap: anywhere;
}

.book-dialog {
  width: min(48rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 1.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}

.book-dialog::backdrop {
  background: rgba(14, 25, 20, 0.65);
}

.book-dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.book-dialog-header h2 {
  font-size: 1.5rem;
  overflow-wrap: anywhere;
}

.book-dialog-close {
  flex: 0 0 44px;
  padding: 0;
  font-size: 1.5rem;
}

.book-detail-overview {
  display: grid;
  grid-template-columns: minmax(0, 12rem) minmax(0, 1fr);
  align-items: start;
  gap: 1.5rem;
}

.book-detail-cover {
  width: 100%;
  height: auto;
  max-height: 20rem;
  object-fit: contain;
}

.book-detail-cover.cover-fallback {
  height: 17rem;
}

.book-detail-copy {
  min-width: 0;
}

.book-detail-copy > p {
  margin: 0 0 0.75rem;
}

.book-detail-subtitle {
  color: var(--muted);
}

.book-detail-copy .book-detail-rating {
  color: var(--brick-dark);
  font-family: var(--font-display);
  font-size: 1.65rem;
}

.book-detail-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.4rem 1rem;
  font-size: 0.85rem;
}

.book-detail-facts dt {
  color: var(--muted);
}

.book-detail-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.book-detail-section {
  margin-top: 1.5rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.book-detail-section h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.book-detail-section p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.book-card-content > button {
  margin-top: 1rem;
}

@media (max-width: 40rem) {
  .book-dialog {
    padding: 1rem;
  }

  .book-detail-overview {
    grid-template-columns: 1fr;
  }

  .book-detail-cover {
    width: min(100%, 10rem);
    justify-self: center;
    max-height: 15rem;
  }
}

.book-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.book-cover {
  display: block;
  width: 100%;
  height: 17rem;
  padding: 0.75rem;
  object-fit: contain;
  background: #26342b;
}

.cover-fallback {
  display: grid;
  place-items: center;
  height: 17rem;
  padding: 0.5rem;
  color: #dce7e1;
  background: var(--forest-light);
  font-family: var(--font-display);
  font-size: 2rem;
}

.book-card-content {
  min-width: 0;
  padding: 1rem;
}

.book-card h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.08rem;
  line-height: 1.25;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.book-rating {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--brick-dark);
  font-size: 0.88rem;
  font-weight: 700;
}

.book-authors,
.book-meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.book-meta {
  color: var(--ink-soft);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.tag,
.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
}

.tag {
  color: var(--ink-soft);
  background: #2a3b30;
}

.status-tag {
  color: #ffffff;
  background: var(--forest-light);
}

.status-tag.wanted {
  background: var(--brick);
}

.loading-block,
.empty-state {
  grid-column: 1 / -1;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.ranking-layout {
  max-width: 58rem;
  margin: 0 auto;
  padding: 1.75rem;
  border: 1px solid var(--line);
}

.ranking-heading {
  align-items: start;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--forest);
}

.admin-context {
  flex: 0 0 auto;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-soft) !important;
  background: var(--surface-strong);
  font-size: 0.78rem !important;
  font-weight: 700;
}

.admin-context.is-admin {
  border-color: var(--success);
  color: #174c2d !important;
  background: #edf7f0;
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ranking-row {
  display: grid;
  grid-template-columns: 3rem 3.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  min-height: 6.25rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.ranking-row:last-child {
  border-bottom: 0;
}

.ranking-row:first-child {
  background: linear-gradient(90deg, rgba(180, 58, 39, 0.08), transparent 72%);
}

.ranking-row.is-drag-chosen {
  background: #f5eee4;
}

.ranking-row.is-dragging {
  opacity: 0.35;
}

.rank-position {
  display: grid;
  justify-items: center;
  gap: 0.3rem;
}

.rank-number {
  color: var(--forest);
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.rank-drag-handle {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: var(--line-strong);
  color: var(--forest);
  background: var(--surface-strong);
  font-size: 1.15rem;
  line-height: 1;
  cursor: grab;
  touch-action: none;
}

.rank-drag-handle:hover {
  border-color: var(--forest);
  color: #ffffff;
  background: var(--forest);
}

.rank-drag-handle:active {
  cursor: grabbing;
}

.rank-cover,
.rank-cover-fallback {
  width: 3.5rem;
  aspect-ratio: 2 / 3;
  border-radius: 3px;
}

.rank-cover {
  object-fit: cover;
  background: #dce5df;
}

.rank-cover-fallback {
  display: grid;
  place-items: center;
  color: #dce7e1;
  background: var(--forest-light);
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.rank-book h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.rank-book p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.favorite-label {
  display: inline-block;
  margin-top: 0.4rem;
  color: var(--brick);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.rank-controls {
  display: flex;
  align-items: end;
  justify-content: end;
  gap: 0.5rem;
}

.rank-step-controls {
  display: grid;
  grid-template-columns: repeat(2, 42px);
  gap: 0.35rem;
}

.rank-button,
.rank-jump-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-color: var(--line-strong);
  color: var(--forest);
  background: var(--surface-strong);
  font-size: 1.05rem;
}

.rank-button:hover,
.rank-jump-button:hover {
  border-color: var(--forest);
  color: #ffffff;
  background: var(--forest);
}

.rank-jump-form {
  display: grid;
  grid-template-columns: 3.6rem 42px;
  align-items: end;
  gap: 0.35rem;
}

.rank-jump-label {
  display: grid;
  gap: 0.15rem;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}

.rank-jump-input {
  width: 3.6rem;
  min-height: 42px;
  padding: 0.35rem;
  text-align: center;
}

.auth-panel,
.editor-panel,
.records-panel {
  padding: 1.5rem;
  border: 1px solid var(--line);
}

.auth-panel,
.editor-panel {
  margin-bottom: 1.5rem;
}

.auth-panel h2 {
  font-size: 1.35rem;
}

.inline-auth-form {
  display: grid;
  grid-template-columns: minmax(14rem, 24rem) auto;
  align-items: end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.signed-in-row {
  align-items: center;
}

.signed-in-row p {
  margin: 0;
  overflow-wrap: anywhere;
}

.section-heading {
  align-items: start;
  margin-bottom: 1.5rem;
}

#bookForm {
  display: grid;
  gap: 1.5rem;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

legend {
  padding: 0 0.4rem;
  color: var(--forest);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 650;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lookup-row {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) auto;
  align-items: end;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.title-lookup-row {
  margin-top: 1rem;
}

.title-lookup-row p {
  align-self: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.record-list {
  border-top: 2px solid var(--forest);
}

.record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.record-row:last-child {
  border-bottom: 0;
}

.record-main {
  min-width: 0;
}

.record-main h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0;
}

.record-main p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.record-actions {
  display: flex;
  gap: 0.35rem;
}

.record-actions button {
  min-height: 40px;
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
}

@media (max-width: 58rem) {
  .stats-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat-wide {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .three-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 45rem) {
  .topbar {
    align-items: start;
    flex-direction: column-reverse;
    justify-content: end;
    min-height: 15rem;
    padding-top: 1.5rem;
  }

  .brand-block h1 {
    font-size: 2.35rem;
  }

  .catalog-toolbar,
  .section-heading,
  .ranking-heading,
  .signed-in-row {
    align-items: stretch;
    flex-direction: column;
    gap: 1rem;
  }

  .search-field {
    width: 100%;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-block:nth-child(3) {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .stat-wide {
    grid-column: auto;
    border-left: 1px solid var(--line);
  }

  .two-up,
  .three-up,
  .lookup-row,
  .inline-auth-form {
    grid-template-columns: 1fr;
  }

  .lookup-row button,
  .inline-auth-form button {
    justify-self: stretch;
  }

  .ranking-row {
    grid-template-columns: 2.5rem 3rem minmax(0, 1fr);
  }

  .rank-controls {
    grid-column: 2 / 4;
    justify-self: start;
  }

  .rank-cover,
  .rank-cover-fallback {
    width: 3rem;
  }

  .record-row {
    grid-template-columns: 1fr;
  }

  .record-actions {
    justify-content: start;
  }
}

@media (max-width: 30rem) {
  .page-shell {
    padding-inline: 0.85rem;
  }

  .topbar,
  .page-nav {
    margin-inline: -0.85rem;
    padding-inline: 0.85rem;
  }

  .stats-strip {
    grid-template-columns: 1fr;
  }

  .stat-block,
  .stat-block:nth-child(3),
  .stat-wide {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .stat-block:first-child {
    border-top: 0;
  }

  .catalog-panel,
  .ranking-layout,
  .auth-panel,
  .editor-panel,
  .records-panel {
    padding: 1rem;
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .book-cover,
  .cover-fallback {
    height: 12rem;
  }

  .book-card-content {
    padding: 0.75rem;
  }

  .book-card h3 {
    font-size: 0.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}