/* BookList - Global Styles */

/* ==================== */
/* Design Tokens        */
/* ==================== */

:root {
  /* Ground */
  --paper: #f5f3ef;
  --surface: #ffffff;
  --surface-tint: #faf9f6;
  --line: #e4ddd1;
  --line-light: #ede9e2;
  /* Ink — every pair checked ≥ 4.5:1 on --paper and --surface (tests/contrast_test.ts) */
  --ink: #1e1c18;
  --ink-2: #5a524a;
  --ink-3: #6e665c;
  /* Accent — abyss (design-system scale #1b1b2d / #24243a / #2c2c47; mid and light derived) */
  --abyss: #24243a;
  --abyss-deep: #1b1b2d;
  --abyss-mid: #4b4b78;
  --abyss-light: #e7e7f0;
  --focus: rgba(75, 75, 120, 0.35);
  /* Semantic */
  --oxblood: #a83232;
  --oxblood-deep: #8a2626;
  --oxblood-light: #fdf2f2;
  --oxblood-line: #e5c4c4;
  --brass: #b08d3c;
  --brass-ink: #6b4f12;
  --brass-light: #fbf4e3;
  --brass-line: #e6d3a1;
  /* Type */
  --serif: "Lora", Georgia, serif;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  /* Legacy aliases used by the book-detail rules */
  --bd-bg: var(--paper);
  --bd-surface: var(--surface);
  --bd-surface-tint: var(--surface-tint);
  --bd-border: var(--line);
  --bd-border-light: var(--line-light);
  --bd-text: var(--ink);
  --bd-text-2: var(--ink-2);
  --bd-text-3: var(--ink-3);
  --bd-accent: var(--abyss);
  --bd-accent-light: var(--abyss-light);
  --bd-accent-mid: var(--abyss-mid);
  --bd-serif: var(--serif);
  --bd-sans: var(--sans);
}

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base */
html {
  font-family: var(--sans);
  font-size: 100%;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
}

a {
  color: var(--abyss);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip navigation link for keyboard users */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--abyss);
  color: var(--surface);
  padding: 0.75rem 1.5rem;
  z-index: 1000;
  font-weight: 600;
  border-radius: 0 0 8px 0;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--surface);
  outline-offset: -2px;
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--abyss);
  outline-offset: 2px;
}

/* Ensure all interactive elements have visible focus rings */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--abyss);
  outline-offset: 2px;
}

/* Enhanced focus for buttons where blue outline on blue bg is invisible */
.btn-primary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(75, 75, 120, 0.3);
}

/* ==================== */
/* Auth Pages           */
/* ==================== */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  padding: 2rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  font-size: 1rem;
  color: var(--ink-3);
}

/* ==================== */
/* Forms                */
/* ==================== */

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-2);
}

.form-group--full {
  grid-column: 1 / -1;
}

.required-mark {
  color: var(--oxblood);
  margin-left: 2px;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 44px;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-input::placeholder {
  color: var(--ink-3);
}

.form-input:focus {
  outline: none;
  border-color: var(--abyss);
  box-shadow: 0 0 0 3px rgba(75, 75, 120, 0.15);
}

.form-input[aria-invalid="true"] {
  border-color: var(--oxblood);
}

.form-input[aria-invalid="true"]:focus {
  border-color: var(--oxblood);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.form-hint {
  font-size: 0.875rem;
  color: var(--ink-3);
}

.form-error {
  padding: 0.75rem 1rem;
  background: var(--oxblood-light);
  border: 1px solid var(--oxblood-line);
  border-radius: 8px;
  color: var(--oxblood);
  font-size: 0.875rem;
  font-weight: 500;
}

.field-error {
  font-size: 0.875rem;
  color: var(--oxblood);
  font-weight: 500;
}

.form-input-error {
  border-color: var(--oxblood);
}

.form-input-error:focus {
  border-color: var(--oxblood);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.form-footer {
  text-align: center;
  font-size: 0.875rem;
  color: var(--ink-3);
  margin-top: 0.5rem;
}

/* ==================== */
/* Buttons              */
/* ==================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  min-height: 44px;
}

.btn:hover {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--abyss);
  color: var(--surface);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--abyss-deep);
}

.btn-secondary {
  background-color: var(--line);
  color: var(--ink-2);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--line);
  text-decoration: none;
}

.btn-full {
  width: 100%;
}

.btn-landing {
  min-width: 160px;
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
}

/* ==================== */
/* Navigation           */
/* ==================== */

.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.navbar-brand:hover {
  text-decoration: none;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.navbar-nav-link {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  color: var(--ink-3);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.navbar-nav-link:hover {
  background-color: var(--surface-tint);
  color: var(--ink);
  text-decoration: none;
}

.navbar-nav-link--active {
  background-color: var(--abyss-light);
  color: var(--abyss);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--ink-3);
}

.navbar-email {
  font-weight: 500;
  color: var(--ink-2);
}

.navbar-link {
  color: var(--abyss);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 0.875rem;
  text-decoration: none;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.navbar-link:hover {
  text-decoration: underline;
}

/* Signed-in user menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.navbar-email {
  cursor: default;
  user-select: text;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clerk-user-button {
  display: flex;
  align-items: center;
  min-width: 32px;
  min-height: 32px;
}

.navbar-logout {
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  min-height: 36px;
}

.user-menu--mobile {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.navbar-mobile-logout {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--oxblood-deep);
}

.navbar-mobile-logout:hover {
  background-color: var(--oxblood-light);
}

/* Mobile hamburger menu */
.navbar-mobile-toggle {
  display: none;
  position: relative;
}

.navbar-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0.5rem;
  cursor: pointer;
  list-style: none;
  border-radius: 6px;
}

.navbar-hamburger:hover {
  background-color: var(--surface-tint);
}

.navbar-hamburger::-webkit-details-marker {
  display: none;
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink-2);
  border-radius: 1px;
}

.navbar-mobile-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  min-width: 200px;
  margin-top: 0.25rem;
  z-index: 200;
}

.navbar-mobile-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  min-height: 44px;
}

.navbar-mobile-link:hover {
  background-color: var(--surface-tint);
  text-decoration: none;
}

.navbar-mobile-link--active {
  background-color: var(--abyss-light);
  color: var(--abyss);
}

.navbar-mobile-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.25rem 0;
}

.navbar-mobile-email {
  display: block;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==================== */
/* App Layout           */
/* ==================== */

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==================== */
/* Landing Page         */
/* ==================== */

.landing-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.landing-container {
  text-align: center;
  max-width: 500px;
  width: 100%;
  padding: 2rem;
}

.landing-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.landing-tagline {
  font-size: 1.25rem;
  color: var(--ink-2);
  margin-bottom: 0.75rem;
}

.landing-description {
  font-size: 1rem;
  color: var(--ink-3);
  margin-bottom: 2rem;
}

.landing-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ==================== */
/* Page Layout          */
/* ==================== */

.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
  flex: 1;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1rem;
}

/* ==================== */
/* Book List             */
/* ==================== */

.booklist-container {
  margin-top: 0.5rem;
}

.booklist-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.export-dropdown {
  display: flex;
  gap: 0.5rem;
}

.export-button {
  font-size: 1rem;
  padding: 0.5rem 1rem;
}

.search-group {
  flex: 1;
  max-width: 400px;
}

.search-input {
  width: 100%;
}

.filter-group {
  flex-shrink: 0;
}

.collection-filter {
  min-width: 180px;
  cursor: pointer;
}

/* Bulk Actions */
.bulk-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--surface-tint);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.bulk-selection-info {
  font-size: 1rem;
  color: var(--ink-2);
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Result-set bar — the count of what the search/filter matched, plus the
   select-all control that feeds the bulk actions above. */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.results-bar__count {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-2);
}

.results-bar__selected {
  margin-left: 0.5rem;
  color: var(--ink-2);
}

.results-bar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.results-bar__select-all[aria-pressed="true"] {
  border-color: var(--brass);
}

@media (max-width: 768px) {
  .results-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .results-bar__actions {
    width: 100%;
  }

  .results-bar__actions .btn {
    flex: 1;
  }
}

.results-bar__hint {
  margin-left: 0.5rem;
  color: var(--ink-3);
}

.bulk-collection-select {
  min-width: 180px;
}

.checkbox-column {
  width: 40px;
  text-align: center;
}

.checkbox-column input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.btn-small {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  background: var(--surface-tint);
  color: var(--ink-2);
  border-radius: 6px;
}

.btn-small:hover {
  background: var(--line);
  text-decoration: none;
}

.btn-add-book {
  white-space: nowrap;
  text-decoration: none;
}

.btn-add-book:hover {
  text-decoration: none;
}

.booklist-table-wrapper {
  overflow-x: auto;
}

.booklist-table {
  width: 100%;
  border-collapse: collapse;
}

.booklist-table th,
.booklist-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.booklist-table th {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.sortable-header {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.sortable-header:hover {
  background-color: var(--surface-tint);
}

.booklist-row {
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.booklist-row:nth-child(even) {
  background-color: var(--surface-tint);
}

.booklist-row:hover {
  background-color: var(--line);
}

.book-title-link {
  font-weight: 500;
  color: var(--ink);
}

.book-title-link:hover {
  color: var(--abyss);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--surface);
  border-radius: 12px;
  border: 2px dashed var(--line);
}

.empty-state-text {
  color: var(--ink-3);
  margin-bottom: 1rem;
}

.loading-state {
  text-align: center;
  padding: 2rem;
  color: var(--ink-3);
}

/* ==================== */
/* Form Grid & Actions  */
/* ==================== */

.book-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.form-actions-left {
  display: flex;
  gap: 0.75rem;
}

.form-actions-right {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
}

/* ==================== */
/* Scanner              */
/* ==================== */

.scanner-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--surface);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.scanner-manual-link {
  font-size: 0.875rem;
  color: var(--ink-3);
}

.book-preview {
  background: var(--surface);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.book-preview-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1rem;
}

.duplicate-warning {
  padding: 0.75rem 1rem;
  background: var(--brass-light);
  border: 1px solid var(--brass-line);
  border-radius: 8px;
  color: var(--brass-ink);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.book-preview-cover {
  max-width: 150px;
  height: auto;
  border-radius: 4px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.book-preview-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  margin-bottom: 1.5rem;
}

.book-preview-details dt {
  font-weight: 600;
  color: var(--ink-2);
}

.book-preview-details dd {
  color: var(--ink-2);
}

/* Loading indicator */
.loading-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--abyss-light);
  border: 1px solid var(--abyss-light);
  border-radius: 8px;
  color: var(--abyss);
  font-weight: 500;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--abyss-light);
  border-top-color: var(--abyss);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Book source badge */
.book-source-badge {
  font-size: 0.875rem;
  color: var(--ink-3);
  margin-bottom: 1rem;
  padding: 0.375rem 0.75rem;
  background: var(--surface-tint);
  border-radius: 6px;
  display: inline-block;
}

.book-source-badge strong {
  color: var(--abyss);
}

/* Book preview layout */
.book-preview-layout {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.book-preview-cover-container {
  flex-shrink: 0;
}

.book-preview-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.book-preview-hint {
  font-size: 0.875rem;
  color: var(--ink-3);
  font-style: italic;
  margin-bottom: 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .book-preview-layout {
    flex-direction: column;
    align-items: center;
  }

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

.scanner-container {
  max-width: 700px;
}

.scanner-success {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--abyss-light);
  border-radius: 12px;
  border: 1px solid var(--abyss-light);
}

.scanner-success h2 {
  color: var(--abyss);
  margin-bottom: 0.5rem;
}

.scanner-success p {
  color: var(--ink-2);
  margin-bottom: 1.5rem;
}

/* Camera Viewfinder */
.scanner-viewfinder {
  margin-bottom: 1.5rem;
}

.scanner-video {
  width: 100%;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--line);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--ink);
}

.scanner-status {
  font-size: 0.875rem;
  color: var(--ink-3);
  text-align: center;
  margin-top: 0.5rem;
}

/* ==================== */
/* Collection Form      */
/* ==================== */

.collection-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 500px;
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 1.5rem;
}

/* Collections Container */
.collections-container {
  margin-top: 0.5rem;
}

.collections-toolbar {
  margin-bottom: 1rem;
}

/* Collections List */
.collections-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.collection-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  gap: 0.5rem;
}

.collection-card--clickable {
  cursor: pointer;
}

.collection-card--clickable:hover {
  border-color: var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.collection-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.collection-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.collection-name:hover {
  color: var(--abyss);
}

.collection-count {
  font-size: 0.875rem;
  color: var(--ink-3);
}

.collection-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Collection Edit Form (inline) */
.collection-edit-form {
  width: 100%;
}

.collection-edit-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.collection-edit-input-group .form-input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  font-size: 1rem;
}

.collection-edit-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-danger {
  background-color: var(--oxblood-light);
  color: var(--oxblood);
  border: 1px solid var(--oxblood-line);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--oxblood-light);
  text-decoration: none;
}

.btn-share-active {
  background-color: var(--abyss-light);
  color: var(--abyss);
  border: 1px solid var(--abyss-light);
}

.btn-share-active:hover:not(:disabled) {
  background-color: var(--abyss-light);
  text-decoration: none;
}

.btn-link-danger {
  background: none;
  border: none;
  color: var(--oxblood);
  font-size: 0.875rem;
  padding: 0.25rem 0;
  cursor: pointer;
  min-height: auto;
  text-decoration: underline;
}

.btn-link-danger:hover:not(:disabled) {
  color: var(--oxblood-deep);
}

/* ==================== */
/* Responsive           */
/* ==================== */

@media (max-width: 768px) {
  .navbar-links,
  .navbar-user {
    display: none;
  }

  .navbar-mobile-toggle {
    display: block;
  }

  .hide-mobile {
    display: none;
  }

  .booklist-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .auth-container {
    padding: 1.5rem;
    box-shadow: none;
    background: transparent;
  }

  .navbar-inner {
    padding: 0.5rem 1rem;
  }

  .page-container {
    padding: 1rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .landing-title {
    font-size: 2rem;
  }

  .landing-actions {
    flex-direction: column;
    align-items: center;
  }

  .btn-landing {
    width: 100%;
    max-width: 280px;
  }
}

/* Ensure minimum 44px touch targets on touch devices */
@media (pointer: coarse) {
  .btn,
  .navbar-nav-link,
  .navbar-mobile-link,
  .navbar-link,
  .navbar-hamburger,
  .form-input,
  select,
  textarea {
    min-height: 44px;
  }

  .booklist-table td {
    padding: 0.875rem 0.75rem;
  }

  .btn-small {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
  }
}

/* Book Collections Selector */
.book-collections-container {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--ink);
}

.collections-selector {
  margin-top: 1rem;
}

.collection-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.collection-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.collection-checkbox-label:hover {
  background-color: var(--surface-tint);
}

.collection-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.collection-checkbox-text {
  font-size: 1rem;
  color: var(--ink);
}

.current-collections {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.collection-tags-label {
  font-size: 1rem;
  color: var(--ink-3);
  margin-bottom: 0.5rem;
}

.collection-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.collection-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background-color: var(--abyss);
  color: var(--surface);
  border-radius: 16px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Collection tags in book list rows */
.book-row-collections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.collection-tag-small {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background-color: var(--abyss-light);
  color: var(--abyss);
  border: 1px solid var(--abyss);
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Book Cover Display */
.book-cover-display {
  margin-bottom: 1.5rem;
  text-align: center;
}

.book-cover-image {
  max-width: 200px;
  max-height: 300px;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Book Metadata */
.book-metadata {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background-color: var(--paper);
  border-radius: 8px;
  border: 1px solid var(--surface-tint);
}

.book-date-added {
  margin: 0;
  font-size: 1rem;
  color: var(--ink-2);
}

.book-date-added strong {
  color: var(--ink);
  margin-right: 0.5rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease-out;
  border-left: 4px solid;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.toast-icon {
  font-size: 1.25rem;
  font-weight: bold;
  line-height: 1;
}

.toast-message {
  font-size: 1rem;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--ink-3);
  cursor: pointer;
  padding: 0.25rem;
  margin-left: 1rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toast-close:hover {
  opacity: 1;
}

.toast-success {
  border-left-color: var(--abyss-mid);
}

.toast-success .toast-icon {
  color: var(--abyss-mid);
}

.toast-error {
  border-left-color: var(--oxblood);
}

.toast-error .toast-icon {
  color: var(--oxblood);
}

.toast-info {
  border-left-color: var(--abyss-mid);
}

.toast-info .toast-icon {
  color: var(--abyss-mid);
}

.toast-closing {
  animation: slideOut 0.3s ease-out forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .toast-container {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* Error Page */
.error-page {
  text-align: center;
  padding: 3rem 1.5rem;
  max-width: 600px;
  margin: 0 auto;
}

.error-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1rem;
}

.error-message {
  font-size: 1.125rem;
  color: var(--oxblood);
  margin-bottom: 1rem;
  font-weight: 500;
}

.error-help {
  font-size: 1rem;
  color: var(--ink-2);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.error-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* ===== CollectionPicker Component ===== */
.collection-picker {
  position: relative;
}

.collection-picker-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: text;
}

.collection-picker-inner:focus-within {
  border-color: var(--abyss);
  outline: 2px solid rgba(75, 75, 120, 0.2);
}

.collection-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  background-color: var(--abyss-light);
  color: var(--abyss);
  border: 1px solid var(--abyss);
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.collection-chip-remove {
  background: none;
  border: none;
  color: var(--abyss);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
}

.collection-chip-remove:hover {
  color: var(--oxblood);
}

.collection-picker-input {
  flex: 1;
  min-width: 120px;
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  padding: 0.1rem 0;
}

.collection-picker-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  max-height: 220px;
  overflow-y: auto;
}

.collection-picker-option {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 1rem;
}

.collection-picker-option:hover {
  background-color: var(--abyss-light);
}

.collection-picker-option--create {
  font-style: italic;
  color: var(--abyss);
  border-bottom: 1px solid var(--abyss-light);
}

.collection-picker-option--create:hover {
  background-color: var(--abyss-light);
}
/* ===== End CollectionPicker Component ===== */

/* Bulk action bar collection picker and feedback */
.bulk-collection-picker-wrapper {
  min-width: 200px;
  flex: 1;
  max-width: 340px;
}

.bulk-action-feedback {
  width: 100%;
  margin-top: 0.5rem;
}

.bulk-action-success {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--abyss-light);
  color: var(--abyss);
  border: 1px solid var(--abyss-mid);
  border-radius: 4px;
  font-size: 1rem;
}

/* ==================== */
/* Collection Sharing   */
/* ==================== */

.collection-share-section {
  width: 100%;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.collection-share-url-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.collection-share-url-input {
  flex: 1;
  font-size: 0.875rem;
  padding: 0.4rem 0.6rem;
  min-height: 36px;
  color: var(--ink-3);
  background: var(--surface-tint);
}

/* ========================= */
/* Public Collection Page    */
/* ========================= */

.public-collection-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.public-collection-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 1.5rem;
}

.public-collection-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.public-collection-brand:hover {
  text-decoration: none;
  color: var(--abyss);
}

.public-collection-main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.public-collection-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.public-collection-count {
  font-size: 1rem;
  color: var(--ink-3);
  margin-bottom: 1.5rem;
}

.public-books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.public-book-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  gap: 0.875rem;
  transition: box-shadow 0.15s ease;
}

.public-book-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.public-book-cover {
  width: 60px;
  height: 88px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.public-book-cover-placeholder {
  width: 60px;
  height: 88px;
  background: var(--surface-tint);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.public-book-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.public-book-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.public-book-author {
  font-size: 0.875rem;
  color: var(--ink-2);
}

.public-book-meta {
  font-size: 0.875rem;
  color: var(--ink-3);
}

.public-book-genre {
  display: inline-block;
  font-size: 0.875rem;
  background: var(--abyss-light);
  color: var(--abyss);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  margin-top: 0.25rem;
  width: fit-content;
}

.public-book-subtitle {
  font-size: 0.875rem;
  font-style: italic;
  color: var(--ink-3);
  line-height: 1.35;
}

.public-book-description {
  margin-top: 0.35rem;
  font-size: 0.875rem;
}

.public-book-description .expandable-text {
  font-size: 0.875rem;
  color: var(--ink-3);
  line-height: 1.5;
}

.public-book-description .expandable-text-toggle {
  font-size: 0.875rem;
}

.public-book-page-meta {
  font-size: 0.875rem;
  color: var(--ink-3);
  margin: 0;
}

.public-book-page-meta-sep {
  color: var(--line);
}

.public-collection-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.875rem;
  color: var(--ink-3);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* ==================== */
/* ExpandableText       */
/* ==================== */

.expandable-text {
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0;
  white-space: pre-line;
}

.expandable-text--clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

.expandable-text-container {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.expandable-text-toggle {
  background: none;
  border: none;
  color: var(--abyss);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-align: left;
  min-height: auto;
  width: fit-content;
}

.expandable-text-toggle:hover {
  text-decoration: underline;
}

/* ==================== */
/* Book Detail View     */
/* ==================== */

.book-detail-view {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.book-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.book-detail-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.book-detail-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.book-detail-field--full {
  grid-column: 1 / -1;
}

.book-detail-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.book-detail-value {
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.5;
}

@media (max-width: 640px) {
  .book-detail-fields {
    grid-template-columns: 1fr;
  }
}

/* ============================================= */
/* Book Detail — Redesigned Layout               */
/* ============================================= */

.bd-page {
  max-width: 660px;
  margin: 0 auto;
}

.bd-back-link {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bd-text-3);
  text-decoration: none;
  margin-bottom: 1rem;
  letter-spacing: 0.01em;
  transition: color 0.15s;
}

.bd-back-link:hover {
  color: var(--bd-text-2);
  text-decoration: none;
}

/* ── Public book detail: the outbound reference and its description ── */

/* We send people to Wikipedia's Special:BookSources rather than to a shop, so
   the reader picks the library or seller — we never do. */
.bd-section--find {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}

.bd-find-note {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--bd-text-3);
  max-width: 46ch;
}

.bd-find-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--abyss);
  text-decoration: none;
  white-space: nowrap;
}

.bd-find-link:hover {
  text-decoration: underline;
}

.bd-public-desc {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--bd-text-2);
  white-space: pre-wrap;
}

/* ── Public viewer actions: add to library, and the invitation for everyone else ── */

.bd-section--add {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.pv-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

/* Holds the space while we ask the server who is looking, so the section does
   not jump once the answer lands. */
.pv-action--placeholder {
  min-height: 44px;
}

/* The picker needs room for its dropdown, and a width that is not the whole page. */
.pv-picker {
  width: 100%;
  max-width: 24rem;
}

.pv-picker .form-label {
  display: block;
  margin-bottom: 0.3rem;
}

.pv-note,
.pv-invite,
.pv-added {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--bd-text-3);
  max-width: 46ch;
}

.pv-added {
  color: var(--bd-text-2);
  font-weight: 500;
}

.pv-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.875rem;
  margin: 1.75rem 0 0;
  padding: 1rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.pv-banner__text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 54ch;
}

@media (max-width: 768px) {
  .pv-banner {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ── Collections bar ── */

.bd-collections-bar {
  background: var(--bd-surface);
  border: 1px solid var(--bd-border);
  border-radius: 12px;
  padding: 0.875rem 1.125rem;
  margin-bottom: 0.875rem;
}

.bd-collections-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.bd-collections-label {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--bd-text-3);
}

.bd-collections-save {
  margin-left: auto;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bd-accent);
  background: var(--bd-accent-light);
  border: none;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s;
  min-height: auto;
}

.bd-collections-save:hover:not(:disabled) {
  filter: brightness(0.94);
}

.bd-collections-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── View mode card ── */

.bd-view {
  background: var(--bd-surface);
  border: 1px solid var(--bd-border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 0.875rem;
}

.bd-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.375rem;
  padding: 1.625rem 1.625rem 1.375rem;
  align-items: start;
}

.bd-hero--no-cover {
  grid-template-columns: 1fr;
}

.bd-cover {
  width: 88px;
  height: auto;
  border-radius: 5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.20), 0 1px 5px rgba(0, 0, 0, 0.10);
  display: block;
  object-fit: cover;
}

.bd-hero-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.bd-title {
  font-family: var(--bd-serif);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--bd-text);
  line-height: 1.25;
  margin: 0 0 0.25rem;
}

.bd-subtitle {
  font-family: var(--bd-serif);
  font-size: 1rem;
  font-style: italic;
  color: var(--bd-text-2);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.bd-author {
  font-size: 1rem;
  font-weight: 500;
  color: var(--bd-text-2);
  margin: 0 0 0.875rem;
}

.bd-hero-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.bd-date-added {
  font-size: 0.875rem;
  color: var(--bd-text-3);
  letter-spacing: 0.01em;
}

.bd-edit-btn {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bd-text-2);
  background: var(--bd-surface-tint);
  border: 1px solid var(--bd-border);
  border-radius: 7px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  min-height: auto;
  margin-left: auto;
}

.bd-edit-btn:hover {
  border-color: var(--bd-text-3);
  background: var(--bd-surface);
  color: var(--bd-text);
}

/* Section */

.bd-section {
  border-top: 1px solid var(--bd-border-light);
  padding: 1.125rem 1.625rem;
}

.bd-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--bd-text-3);
  margin: 0 0 0.625rem;
}

.bd-section--notes {
  background: var(--bd-surface-tint);
}

.bd-section--notes .bd-section-title {
  color: var(--bd-accent);
}

/* Genre chips */

.bd-genre-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.bd-genre-chip {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bd-accent);
  background: var(--bd-accent-light);
  padding: 0.175rem 0.6rem;
  border-radius: 99px;
}

.bd-genre-chip--clickable {
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.bd-genre-chip--clickable:hover:not(:disabled) {
  background: color-mix(in srgb, var(--bd-accent-light) 80%, var(--bd-accent) 20%);
}

.bd-genre-chip--clickable:active:not(:disabled) {
  background: color-mix(in srgb, var(--bd-accent-light) 65%, var(--bd-accent) 35%);
}

.bd-genre-chip--pending,
.bd-genre-chip--clickable:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Collapsible detail groups */

.bd-details {
  border-top: 1px solid var(--bd-border-light);
}

.bd-details summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.8rem 1.625rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--bd-text-3);
  transition: color 0.15s;
}

.bd-details summary::-webkit-details-marker {
  display: none;
}

.bd-details summary::before {
  content: "›";
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
  color: var(--bd-text-3);
  transition: transform 0.2s;
  display: inline-block;
  width: 0.7rem;
}

.bd-details[open] summary::before {
  transform: rotate(90deg);
}

.bd-details summary:hover {
  color: var(--bd-text-2);
}

.bd-details-body {
  padding: 0.125rem 1.625rem 1.25rem;
}

.bd-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem 1.75rem;
}

.bd-field {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.bd-field--full {
  grid-column: 1 / -1;
}

.bd-field-label {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bd-text-3);
}

.bd-field-value {
  font-size: 1rem;
  color: var(--bd-text-2);
  line-height: 1.45;
}

.bd-field-value--mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.875rem;
  color: var(--bd-text-3);
}

/* ── Edit form card ── */

.bd-form {
  background: var(--bd-surface);
  border: 1px solid var(--bd-border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 0.875rem;
}

.bd-form-section {
  padding: 1.25rem 1.625rem;
  border-bottom: 1px solid var(--bd-border-light);
}

.bd-form-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--bd-text-3);
  margin: 0 0 0.875rem;
}

.bd-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.bd-full {
  grid-column: 1 / -1;
}

/* Collapsible technical section inside the form */

.bd-form-technical {
  border-bottom: 1px solid var(--bd-border-light);
}

.bd-form-technical summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.8rem 1.625rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--bd-text-3);
  transition: color 0.15s;
}

.bd-form-technical summary::-webkit-details-marker {
  display: none;
}

.bd-form-technical summary::before {
  content: "›";
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
  color: var(--bd-text-3);
  transition: transform 0.2s;
  display: inline-block;
  width: 0.7rem;
}

.bd-form-technical[open] summary::before {
  transform: rotate(90deg);
}

.bd-form-technical-body {
  padding: 0.25rem 1.625rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.bd-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.625rem;
  background: var(--bd-surface-tint);
  flex-wrap: wrap;
}

.bd-form-actions-right {
  display: flex;
  gap: 0.625rem;
  margin-left: auto;
}

/* Inputs inherit calm palette inside bd-form */

.bd-form .form-input,
.bd-loan-section .form-input {
  border-color: var(--bd-border);
  background: var(--bd-surface);
  color: var(--bd-text);
  font-family: var(--bd-sans);
}

.bd-form .form-input:focus,
.bd-loan-section .form-input:focus {
  border-color: var(--bd-accent-mid);
  box-shadow: 0 0 0 3px rgba(75, 75, 120, 0.13);
}

.bd-form .form-label {
  color: var(--bd-text-2);
  font-size: 0.875rem;
}

/* ── Shared bd button styles ── */

.bd-btn-primary {
  background: var(--bd-accent);
  color: var(--surface);
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--bd-sans);
  transition: filter 0.15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.bd-btn-primary:hover:not(:disabled) {
  filter: brightness(1.12);
  text-decoration: none;
}

.bd-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.bd-btn-ghost {
  background: transparent;
  color: var(--bd-text-2);
  border: 1px solid var(--bd-border);
  font-weight: 500;
  padding: 0.625rem 1.125rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--bd-sans);
  transition: background 0.15s, border-color 0.15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.bd-btn-ghost:hover:not(:disabled) {
  background: var(--bd-surface-tint);
  border-color: var(--bd-text-3);
  text-decoration: none;
}

.bd-btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bd-btn-danger {
  background: transparent;
  color: var(--oxblood);
  border: 1px solid var(--oxblood-line);
  font-weight: 500;
  padding: 0.625rem 1.125rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--bd-sans);
  transition: background 0.15s, border-color 0.15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.bd-btn-danger:hover:not(:disabled) {
  background: var(--oxblood-light);
  border-color: var(--oxblood);
}

.bd-btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Loan status card ── */

.bd-loan-container {
  background: var(--bd-surface);
  border: 1px solid var(--bd-border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 0.875rem;
}

.bd-loan-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--brass-light);
  border-bottom: 1px solid var(--brass-line);
}

.bd-loan-banner-text {
  font-size: 0.875rem;
  color: var(--brass-ink);
}

.bd-loan-banner-date {
  font-weight: 400;
  margin-left: 0.5rem;
  color: var(--brass-ink);
  font-size: 0.875rem;
}

.bd-loan-section {
  padding: 1.125rem 1.625rem;
}

.bd-loan-header {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--bd-text-3);
  margin: 0 0 0.75rem;
}

.bd-loan-form {
  display: flex;
  gap: 0.625rem;
  align-items: flex-end;
}

.bd-loan-form .form-group {
  flex: 1;
  margin: 0;
}

.bd-loan-return-btn {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--brass-ink);
  background: var(--brass-light);
  border: 1px solid var(--brass-line);
  padding: 0.375rem 0.875rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  min-height: auto;
}

.bd-loan-return-btn:hover:not(:disabled) {
  background: var(--brass-line);
}

/* ── Responsive ── */

@media (max-width: 640px) {
  .bd-hero {
    gap: 1rem;
    padding: 1.25rem;
  }

  .bd-cover {
    width: 70px;
  }

  .bd-title {
    font-size: 1.2rem;
  }

  .bd-section,
  .bd-details summary,
  .bd-details-body,
  .bd-form-section,
  .bd-form-technical summary,
  .bd-form-technical-body,
  .bd-form-actions,
  .bd-loan-section {
    padding-left: 1.125rem;
    padding-right: 1.125rem;
  }

  .bd-field-grid,
  .bd-form-grid,
  .bd-form-technical-body {
    grid-template-columns: 1fr;
  }

  .bd-full {
    grid-column: 1;
  }

  .bd-form-actions-right {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ============================================= */
/* Audit 2026-09 — type, focus, list, covers     */
/* Spec: docs/specs/15-spec-mobile-browse-a11y   */
/* ============================================= */

/* Type: eyebrow labels sit at 13px with tracking; everything else ≥ 14px */
.booklist-table th,
.bd-section-title,
.bd-collections-label,
.bd-field-label,
.bd-form-section-title,
.bd-loan-header,
.bd-details summary,
.bd-form-technical summary,
.row-drawer__label {
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
}

.booklist-table td {
  font-size: 1rem;
  vertical-align: top;
}

h1, h2, h3 {
  text-wrap: balance;
}

.page-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.75rem;
}

/* Focus: one ring everywhere */
:focus-visible {
  outline: 2px solid var(--abyss-mid);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus);
}

.btn-primary:focus-visible {
  outline-color: var(--ink);
}

/* ---- View toggle (List | Covers) ---- */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 2px;
  flex-shrink: 0;
}

.view-toggle__btn {
  border: none;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-weight: 500;
  padding: 0 0.875rem;
  min-height: 40px;
  border-radius: 6px;
  cursor: pointer;
}

.view-toggle__btn[aria-pressed="true"] {
  background: var(--abyss);
  color: var(--surface);
}

/* ---- Export menu ---- */
.export-menu {
  position: relative;
}

.export-menu > summary {
  list-style: none;
  cursor: pointer;
}

.export-menu > summary::-webkit-details-marker {
  display: none;
}

.export-menu__list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 50;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  padding: 0.375rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(30, 28, 24, 0.12);
}

.export-menu__item {
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  color: var(--ink);
  padding: 0.625rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  min-height: 44px;
}

.export-menu__item:hover {
  background: var(--surface-tint);
}

/* ---- List rows ---- */
.booklist-row {
  background: var(--surface);
}

.booklist-row:nth-child(4n+3) {
  background: var(--surface-tint);
}

.booklist-row--open {
  background: var(--abyss-light) !important;
}

.row-main {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.row-cover-thumb {
  width: 40px;
  height: 60px;
  flex: 0 0 40px;
  aspect-ratio: auto;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(30, 28, 24, 0.25);
}

.row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.book-title-link {
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}

.row-author-inline {
  display: none;
  color: var(--ink-3);
  font-size: 0.9375rem;
}

.row-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.row-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin: -0.5rem -0.5rem -0.5rem 0;
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.row-toggle:hover {
  background: var(--surface-tint);
  color: var(--ink);
}

.row-toggle svg {
  transition: transform 0.2s ease;
}

.row-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.sort-btn {
  all: unset;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 44px;
  padding: 0 0.25rem;
  border-radius: 6px;
}

.sort-btn:focus-visible {
  outline: 2px solid var(--abyss-mid);
  outline-offset: 2px;
}

/* Tags and loan */
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.6rem;
  border-radius: 99px;
  background: var(--abyss-light);
  color: var(--abyss);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  max-width: 12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-chip--more {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-3);
}

.loan-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.6rem;
  border-radius: 99px;
  background: var(--brass-light);
  border: 1px solid var(--brass-line);
  color: var(--brass-ink);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.loan-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brass-ink);
}

/* Drawer */
.booklist-drawer-row td {
  padding: 0 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.row-drawer {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 1rem 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-tint);
}

.row-drawer__cover {
  width: 88px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(30, 28, 24, 0.22);
}

.row-drawer__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.row-drawer__label {
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink-3);
}

.row-drawer__author {
  font-size: 1rem;
  color: var(--ink-2);
  margin: 0;
}

.row-drawer__meta {
  font-size: 0.875rem;
  color: var(--ink-3);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.row-drawer__desc {
  margin: 0;
  color: var(--ink-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-drawer__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

/* Cover placeholder — hue from the title */
.cover-ph {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0.75rem;
  aspect-ratio: 2 / 3;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(160deg, hsl(var(--ph-h) 28% 88%) 0%, hsl(var(--ph-h) 22% 72%) 100%);
  color: hsl(var(--ph-h) 30% 20%);
  box-shadow: inset 0 0 0 1px rgba(30, 28, 24, 0.08);
  overflow: hidden;
}

.cover-ph__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-ph__author {
  font-size: 0.75rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-cover-thumb.cover-ph {
  padding: 0.25rem;
  justify-content: center;
}

/* At thumbnail size the placeholder is a tinted spine: no legible text */
.row-cover-thumb.cover-ph .cover-ph__title,
.row-cover-thumb.cover-ph .cover-ph__author,
.collection-covers .cover-ph .cover-ph__title,
.collection-covers .cover-ph .cover-ph__author {
  display: none;
}

/* ---- Cover grid + flip ---- */
.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  align-items: start;
}

/* A flipped card takes two columns so the detail face has room to breathe */
.cover-grid__item--flipped {
  grid-column: span 2;
}

.cover-card {
  perspective: 1200px;
  position: relative;
}

.cover-card__inner {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.cover-card[data-flipped="true"] .cover-card__inner {
  transform: rotateY(180deg);
}

.cover-card__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 6px;
  overflow: hidden;
}

/* backface-visibility hides the turned-away face but does not stop it catching
   taps: the front face covers the whole card, so it was intercepting clicks
   meant for links on the detail face. Only the face you can see is live. */
.cover-card__face--back {
  pointer-events: none;
}

.cover-card[data-flipped="true"] .cover-card__face--front {
  pointer-events: none;
}

.cover-card[data-flipped="true"] .cover-card__face--back {
  pointer-events: auto;
}

.cover-card__face--front {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: var(--surface-tint);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(30, 28, 24, 0.22), 0 1px 3px rgba(30, 28, 24, 0.12);
  text-align: left;
}

.cover-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-card__face--front .cover-ph {
  height: 100%;
  border-radius: 0;
}

.cover-card__face--back {
  transform: rotateY(180deg);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 6px 18px rgba(30, 28, 24, 0.22);
}

.cover-card__face--back .row-pills {
  flex-shrink: 0;
}

.cover-card__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.25;
  margin: 0;
  color: var(--ink);
}

/* The title carries the heading's own colour; it reads as a title, and only
   underlines on hover to show it is a link. */
.cover-card__title-link {
  color: inherit;
  text-decoration: none;
}

.cover-card__title-link:hover,
.cover-card__title-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cover-card__author {
  font-size: 0.875rem;
  color: var(--ink-2);
  margin: 0;
}

.cover-card__meta {
  font-size: 0.875rem;
  color: var(--ink-3);
  margin: 0;
}

.cover-card__desc {
  font-size: 0.9375rem;
  color: var(--ink-2);
  line-height: 1.5;
  margin: 0;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
}

.cover-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
}

.cover-card__open {
  min-height: 44px;
  text-decoration: none;
}

.cover-card__close {
  border: none;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  min-height: 44px;
  padding: 0 0.25rem;
}

.cover-card__loan {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
}

.cover-card__badge-count {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  background: rgba(30, 28, 24, 0.75);
  color: var(--surface);
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
}

/* Selection check badge. Lives inside the front face, so it turns away with the
   card instead of floating over the detail text. */
.cover-card__check {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: rgba(30, 28, 24, 0.45);
  color: var(--surface);
  font-size: 0.95rem;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(30, 28, 24, 0.35);
}

.cover-card[data-selected="true"] .cover-card__check {
  background: var(--abyss);
  border-color: var(--surface);
}

/* A selected tile reads as selected from across the grid, not just at the badge. */
.cover-card[data-selected="true"] .cover-card__face--front {
  outline: 3px solid var(--abyss);
  outline-offset: -3px;
}

.cover-card__footer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cover-card__select-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  min-height: 44px;
  padding: 0 0.7rem;
}

.cover-card__select-btn[aria-pressed="true"] {
  border-color: var(--abyss);
  background: var(--abyss);
  color: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
  .cover-card__inner {
    transition: none;
    transform: none !important;
  }

  .cover-card__face--back {
    transform: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
  }

  .cover-card[data-flipped="true"] .cover-card__face--back {
    opacity: 1;
    pointer-events: auto;
  }

  .row-toggle svg {
    transition: none;
  }
}

/* Phones: covers stack full width, one per row; a flipped card keeps its single column */
@media (max-width: 480px) {
  .cover-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .cover-grid__item--flipped {
    grid-column: auto;
  }

  .cover-card__face--back {
    padding: 1.25rem;
    gap: 0.6rem;
  }

  .cover-card__title {
    font-size: 1.375rem;
  }

  .cover-card__author,
  .cover-card__meta {
    font-size: 1rem;
  }

  .cover-card__desc {
    -webkit-line-clamp: 14;
    font-size: 1rem;
  }

  .cover-card__loan {
    top: 0.75rem;
    left: 0.75rem;
  }

  .cover-card__badge-count {
    right: 0.75rem;
    bottom: 0.75rem;
    font-size: 0.875rem;
  }
}

/* Full-width placeholders can carry a real title */
@media (max-width: 480px) {
  .cover-grid .cover-ph {
    padding: 1.25rem;
  }

  .cover-grid .cover-ph__title {
    font-size: 1.5rem;
    -webkit-line-clamp: 5;
  }

  .cover-grid .cover-ph__author {
    font-size: 1rem;
  }
}

/* Public collection page uses the same grid; give it the page's own rhythm */
.public-covers {
  margin-top: 0.5rem;
}

.public-collection-title {
  font-family: var(--serif);
  font-weight: 600;
}

.public-collection-brand {
  font-family: var(--serif);
  color: var(--abyss);
}

/* ---- Collection cards: cover stack ---- */
.collection-covers {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.collection-covers img,
.collection-covers .cover-ph {
  width: 30px;
  height: 45px;
  aspect-ratio: auto;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(30, 28, 24, 0.25);
  padding: 0;
}

.collection-card .collection-info {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.collection-name {
  font-family: var(--serif);
  font-size: 1.125rem;
}

/* ---- Responsive overlap fixes (#92) ---- */
@media (max-width: 768px) {
  .row-author-inline {
    display: block;
  }
}

@media (max-width: 640px) {
  .booklist-toolbar {
    gap: 0.75rem;
  }

  .toolbar-left {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .toolbar-right {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .collection-filter {
    min-width: 0;
    width: 100%;
  }

  .toolbar-right .btn-add-book {
    flex: 1 1 100%;
  }

  .export-menu__list {
    left: 0;
    right: auto;
  }

  .bulk-action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .bulk-actions {
    flex-wrap: wrap;
  }

  .bulk-actions .btn {
    flex: 1 1 45%;
  }

  .bulk-collection-picker-wrapper {
    max-width: none;
    flex-basis: 100%;
    min-width: 0;
  }

  .booklist-table th,
  .booklist-table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .row-drawer {
    grid-template-columns: 72px 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .row-drawer__cover {
    width: 72px;
  }

  .bd-loan-form {
    flex-direction: column;
    align-items: stretch;
  }

  .bd-loan-form .bd-btn-ghost {
    width: 100%;
    justify-content: center;
  }

  .bd-loan-banner {
    flex-wrap: wrap;
  }

  .bd-loan-return-btn {
    width: 100%;
    text-align: center;
    min-height: 44px;
  }

  .collection-card {
    flex-direction: column;
    align-items: stretch;
  }

  .collection-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .collection-share-url-row {
    flex-wrap: wrap;
  }

  .navbar-email {
    max-width: 10rem;
  }
}

/* ============================================= */
/* Palette: abyss + brass (#95)                  */
/* ============================================= */

/* Primary actions: navy with a lit top edge — stately, a touch of gilt */
.btn-primary,
.bd-btn-primary,
.view-toggle__btn[aria-pressed="true"] {
  background: linear-gradient(
    180deg,
    var(--abyss-mid) 0%,
    var(--abyss) 55%,
    var(--abyss-deep) 100%
  );
  color: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(27, 27, 45, 0.25);
}

.btn-primary:hover:not(:disabled),
.bd-btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--abyss) 0%, var(--abyss-deep) 100%);
  filter: none;
}

/* Page titles carry a brass hairline with a small ornament */
.page-title {
  position: relative;
  padding-bottom: 0.625rem;
  margin-bottom: 1.25rem;
}

.page-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 4.5rem;
  height: 2px;
  background: linear-gradient(90deg, var(--brass) 0%, var(--brass) 70%, transparent 100%);
}

/* Brand mark in navy with a brass dot */
.navbar-brand {
  font-family: var(--serif);
  color: var(--abyss);
}

.navbar-brand::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brass);
  margin-left: 0.15rem;
  align-self: flex-end;
  margin-bottom: 0.35rem;
}

/* The flipped cover carries a gilt edge */
.cover-card[data-flipped="true"] .cover-card__face--back {
  border: 1px solid var(--brass-line);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--brass), 0 10px 24px rgba(27, 27, 45, 0.22);
}

/* Open row drawer gets the same edge in quieter form */
.booklist-row--open {
  background: var(--abyss-light) !important;
  box-shadow: inset 3px 0 0 var(--brass);
}

/* Loan pill in brass */
.loan-pill::before {
  background: var(--brass);
}

/* Navy title links, brass on hover */
.book-title-link:hover,
.collection-name:hover {
  color: var(--abyss);
  text-decoration: underline;
  text-decoration-color: var(--brass);
  text-underline-offset: 3px;
}

.cover-card__open {
  color: var(--abyss);
}

/* ---- Book page: tap the cover to see it full screen (#102) ---- */
.bd-cover-btn {
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  border-radius: 5px;
  display: block;
  line-height: 0;
}

.bd-cover-btn:focus-visible {
  outline: 2px solid var(--abyss-mid);
  outline-offset: 3px;
}

.cover-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(27, 27, 45, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  cursor: zoom-out;
  animation: lightbox-in 0.15s ease-out;
}

.cover-lightbox__img {
  /* Fill the width; cap by height so a 2:3 cover never overflows the viewport */
  width: 100%;
  max-width: calc((100vh - 7rem) * 0.6667);
  max-width: calc((100dvh - 7rem) * 0.6667);
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--brass-line), 0 24px 60px rgba(0, 0, 0, 0.55);
}

.cover-lightbox__close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  right: 0.75rem;
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.cover-lightbox__close:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.cover-lightbox__hint {
  margin: 1rem 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
}

@keyframes lightbox-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cover-lightbox {
    animation: none;
  }
}
