/*
 *= require_tree .
 *= require_self
 */

/*
 * Responsive breakpoints (standardized across the app — reuse these two
 * values in every subsequent responsive task rather than inventing new ones):
 *   Mid-size:  max-width: 960px
 *   Phone:     max-width: 640px
 */

:root {
  --accent-primary: #6E8854;
  --accent-secondary: #3E4D30;
  --surface-primary: #F2F0E8;
  --surface-secondary: #E5E2D8;
  --foreground-primary: #2D3129;
  --foreground-secondary: #575C50;
  --foreground-muted: #888D82;
  --border-subtle: #D4D7CD;
  --white: #FFFFFF;
  --shadow-color: rgba(0, 0, 0, 0.07);
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;

  /* Responsive foundation */
  --page-gutter: 48px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --bottom-nav-height: 64px;
}

@media (max-width: 960px) {
  :root {
    --page-gutter: 24px;
  }
}

@media (max-width: 640px) {
  :root {
    --page-gutter: 16px;
  }
}

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

html {
  overflow-x: clip;
}

body {
  font-family: var(--font-body);
  color: var(--foreground-primary);
  background-color: var(--surface-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

/* Global responsive image guard — covers are explicitly sized via
   max-width/max-height percentages on their own classes, which win on
   specificity, so this default is safe. */
img {
  max-width: 100%;
  height: auto;
}

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

a:hover {
  color: var(--accent-secondary);
}

/* Navbar */
.navbar {
  background: var(--surface-primary);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 20px var(--page-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-logo .logo-link {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--accent-secondary);
}

.navbar-logo .logo-link:hover {
  color: var(--accent-secondary);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground-secondary);
  display: inline-flex;
  align-items: center;
}

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

.nav-link-active {
  color: var(--accent-primary);
}

.avatar-circle {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background: var(--accent-primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

/* Profile Dropdown */
.profile-dropdown {
  position: relative;
}

.profile-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: var(--white);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 100;
  flex-direction: column;
}

.profile-dropdown.open .profile-dropdown-menu {
  display: flex;
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground-primary);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
}

.profile-dropdown-item svg {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.profile-dropdown-item:hover {
  background: var(--surface-secondary);
}

.profile-dropdown-item--danger {
  color: #D94444;
}

.profile-dropdown-item--danger svg {
  color: #D94444;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--accent-primary);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--accent-secondary);
  color: var(--white);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  background: var(--surface-secondary);
  color: var(--foreground-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: var(--border-subtle);
}

/* Flash messages */
.flash {
  max-width: 600px;
  margin: 16px auto;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
}

.flash-notice {
  background: #e8f0e0;
  color: var(--accent-secondary);
  border: 1px solid var(--accent-primary);
}

.flash-alert {
  background: #f0e0e0;
  color: #6b2c2c;
  border: 1px solid #c47070;
}

/* Auth pages */
.auth-container {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border-radius: 12px;
  padding: 48px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-header h1 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--foreground-primary);
  margin-bottom: 8px;
}

.auth-header p {
  font-size: 15px;
  color: var(--foreground-secondary);
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground-secondary);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--foreground-primary);
  background: var(--surface-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.field input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(110, 136, 84, 0.15);
}

.field input::placeholder {
  color: var(--foreground-muted);
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
}

.field-checkbox label {
  font-size: 14px;
  color: var(--foreground-secondary);
}

.auth-submit {
  width: 100%;
  padding: 14px;
  background: var(--accent-primary);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

.auth-submit:hover {
  background: var(--accent-secondary);
}

.auth-links {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-links a {
  font-size: 13px;
  color: var(--foreground-muted);
}

.auth-links a:hover {
  color: var(--accent-primary);
}

.auth-disclaimer {
  margin-top: 16px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--foreground-muted);
  text-align: center;
}

.auth-disclaimer a {
  color: var(--foreground-muted);
  text-decoration: underline;
}

.auth-disclaimer a:hover {
  color: var(--accent-primary);
}

.auth-errors {
  background: #f0e0e0;
  border: 1px solid #c47070;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
}

.auth-errors h3 {
  font-size: 14px;
  font-weight: 600;
  color: #6b2c2c;
  margin-bottom: 4px;
}

.auth-errors ul {
  list-style: none;
  font-size: 13px;
  color: #6b2c2c;
}

.auth-notice {
  background: #f6ecd9;
  border: 1px solid #d6ad60;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #6b5326;
  line-height: 1.5;
}

.auth-inviter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 12px;
}

.auth-inviter-row .avatar-circle {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.auth-inviter-row span {
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground-secondary);
}

/* Minimum password hint */
.field-hint {
  font-size: 12px;
  color: var(--foreground-muted);
}

/* Settings divider */
.settings-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 4px 0;
}

/* Network level selector */
.network-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.network-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.network-option input[type="radio"] {
  display: none;
}

.radio-indicator {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  border: 2px solid var(--border-subtle);
  transition: border-color 0.2s;
  position: relative;
}

.network-option--selected .radio-indicator {
  border-color: var(--accent-primary);
}

.radio-indicator::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-primary);
  transition: transform 0.15s ease;
}

.network-option--selected .radio-indicator::after {
  transform: translate(-50%, -50%) scale(1);
}

.network-option--selected {
  border: 2px solid var(--accent-primary);
  background: var(--surface-primary);
}

.network-option-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.network-option-text strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground-primary);
}

.network-option-text span {
  font-size: 12px;
  color: var(--foreground-secondary);
  line-height: 1.5;
}

/* Network level warning */
.network-warning {
  background: #FEF3E2;
  border: 1px solid #E8A840;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

.network-warning[hidden] {
  display: none;
}

.network-warning-header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #C27812;
}

.network-warning-header span {
  font-size: 13px;
  font-weight: 700;
  color: #8B5A0E;
}

.network-warning-list {
  margin: 0;
  padding-left: 30px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.network-warning-list li {
  font-size: 12px;
  color: #7A510D;
  line-height: 1.5;
}

.network-warning-list li::marker {
  font-weight: 600;
  color: #8B5A0E;
}

.network-warning-confirm {
  padding-top: 4px;
  transition: background 0.3s;
  border-radius: 4px;
}

.network-warning-confirm label {
  font-size: 12px !important;
  font-weight: 500 !important;
  color: #8B5A0E !important;
  line-height: 1.5;
}

.network-warning-confirm input[type="checkbox"] {
  accent-color: #C27812;
}

.network-warning-confirm-highlight {
  background: rgba(194, 120, 18, 0.12);
  padding: 6px;
}

.network-warning-shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-4px);
  }

  40% {
    transform: translateX(4px);
  }

  60% {
    transform: translateX(-3px);
  }

  80% {
    transform: translateX(3px);
  }
}

/* Network info note */
.network-info-note {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-secondary);
  border-radius: 8px;
  margin-top: 6px;
}

.network-info-note svg {
  flex-shrink: 0;
  color: var(--foreground-muted);
  margin-top: 1px;
}

.network-info-note span {
  font-size: 12px;
  color: var(--foreground-secondary);
  line-height: 1.5;
}

/* Account settings page (mobile-first: stacked "one card" below 900px,
   two-column card grid at 900px+). See docs/projects/desktop-account-settings-layout. */
.settings-container {
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

/* Mobile: header visually merges into the same white card as the grid below it
   (flush, no gap) to recreate the pre-restructure single-card look, since header
   and form are sibling elements with no shared wrapper. Reset to a plain block
   above the grid at the 900px+ desktop breakpoint. */
.settings-header {
  width: 100%;
  max-width: 440px;
  text-align: center;
  margin-bottom: 0;
  background: var(--white);
  border-radius: 12px 12px 0 0;
  padding: 48px 48px 0;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
}

.settings-header h1 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--foreground-primary);
  margin-bottom: 8px;
}

.settings-header p {
  font-size: 15px;
  color: var(--foreground-secondary);
  line-height: 1.5;
}

.settings-form {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Mobile: the grid IS the visual "card" — one shared white surface with
   dividers between sections, matching today's single-card design. */
.settings-grid {
  display: flex;
  flex-direction: column;
  background: var(--white);
  /* Flat top corners: sits flush against .settings-header above it. */
  border-radius: 0 0 12px 12px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 32px 48px;
}

.settings-grid > .settings-card:first-child {
  padding-top: 48px;
}

.settings-card + .settings-card,
.settings-card + .settings-actions {
  border-top: 1px solid var(--border-subtle);
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 32px 48px 48px;
}

@media (min-width: 900px) {
  .settings-container {
    display: block;
    min-height: 0;
    max-width: 1000px;
    margin: 0 auto;
    padding: 56px 24px;
  }

  .settings-header {
    max-width: 640px;
    margin: 0 auto 40px;
    background: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }

  .settings-form {
    max-width: none;
    width: 100%;
  }

  .settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
    background: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }

  .settings-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow:
      0 2px 4px rgba(0, 0, 0, 0.03),
      0 12px 32px rgba(0, 0, 0, 0.06);
    padding: 40px 48px;
  }

  .settings-grid > .settings-card:first-child {
    padding-top: 40px;
  }

  .settings-card + .settings-card,
  .settings-card + .settings-actions {
    border-top: none;
  }

  .settings-card--email,
  .settings-actions {
    grid-column: 1 / -1;
  }

  .settings-actions {
    align-items: center;
    text-align: center;
    padding: 8px 0 0;
    gap: 16px;
  }

  .settings-actions .auth-submit {
    max-width: 320px;
  }
}

/* Mirrors the .auth-card mid-size tightening (~line 4690: max-width: 960px)
   but capped to 899px so it never bleeds into the min-width: 900px grid above. */
@media (max-width: 899px) {
  .settings-container {
    padding: 40px var(--page-gutter);
  }

  .settings-header {
    padding-left: 32px;
    padding-right: 32px;
  }

  .settings-card,
  .settings-actions {
    padding-left: 32px;
    padding-right: 32px;
  }

  /* Matches the old .auth-header margin-bottom: 32px gap between the header
     text and the first field, now that the header is flush against the card. */
  .settings-grid > .settings-card:first-child {
    padding-top: 32px;
  }

  .settings-actions {
    padding-bottom: 40px;
  }
}

/* Page layout */
.page-header {
  padding: 40px var(--page-gutter) 0 var(--page-gutter);
  max-width: 1300px;
  margin: 0 auto;
}

.page-header h1 {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 700;
  color: var(--foreground-primary);
}

.page-header p {
  font-size: 16px;
  color: var(--foreground-secondary);
  margin-top: 4px;
}

/* Page header row (side-by-side title + action) */
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.page-header-left {
  flex: 1;
}

.page-header-right {
  flex-shrink: 0;
  padding-top: 4px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Filter bar (legacy — used by connections page) */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--page-gutter);
  max-width: 1300px;
  margin: 0 auto;
}

.filter-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.filter-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 1;
}

/* Filter bar (new) */
.filter-bar-wrapper {
  padding: 16px var(--page-gutter);
  max-width: 1300px;
  margin: 0 auto;
}

.filter-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.filter-dropdowns {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-dropdown {
  position: relative;
}

.filter-select {
  appearance: none;
  padding: 7px 34px 7px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground-secondary);
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23888D82' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  white-space: nowrap;
}

.filter-select:hover {
  border-color: var(--accent-primary);
  color: var(--foreground-primary);
}

.filter-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(110, 136, 84, 0.12);
}

/* Multiselect dropdown */
.filter-multiselect {
  position: relative;
}

.filter-multiselect .filter-select {
  width: auto;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.filter-multiselect .filter-select.has-selection {
  color: var(--foreground-primary);
  border-color: var(--accent-primary);
}

.filter-multiselect-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 200px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 4px 16px var(--shadow-color);
  padding: 6px 0;
}

.filter-multiselect-menu.open {
  display: block;
}

.filter-multiselect-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--foreground-secondary);
  cursor: pointer;
  transition: background 0.15s;
}

.filter-multiselect-option:hover {
  background: var(--surface-secondary);
}

.filter-multiselect-option input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.filter-clear {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground-muted);
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-clear:hover {
  color: var(--foreground-primary);
  background: var(--surface-secondary);
  border-color: var(--border-subtle);
}

.filter-bar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.filter-count {
  font-size: 13px;
  color: var(--foreground-muted);
  white-space: nowrap;
}

/* Books grid: columns are at least 280px and stretch to share the full
   container width, so partial rows (e.g. 2 books) still span the page and
   the column count steps up as the viewport widens. */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: start;
  gap: 28px;
  padding: 0 var(--page-gutter) 48px var(--page-gutter);
  max-width: 1300px;
  margin: 0 auto;
}

/* Let cards fill their grid track; the fixed 280px width below still
   applies in flex contexts (.profile-books-grid). */
.books-grid .book-card {
  width: auto;
}

/* Book card (matches Pencil Component/MyBookCard: 300px wide) */
.book-card {
  width: 280px;
  background: var(--white);
  border-radius: 12px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
}

.book-card-cover {
  width: 100%;
  height: 320px;
  background-color: var(--surface-secondary);
  border-radius: 12px 12px 0 0;
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.book-card-cover-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.25));
}

.book-card-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-card-cover-placeholder span {
  font-family: var(--font-heading);
  font-size: 48px;
  font-weight: 700;
  color: var(--foreground-muted);
  opacity: 0.3;
}

.book-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.book-card-title-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.book-card-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--foreground-primary);
  line-height: 1.3;
}

.book-card-author {
  font-size: 13px;
  color: var(--foreground-muted);
}

.book-card-cover-wrap {
  position: relative;
}

.book-card-attribution-avatar {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.book-card-attribution-avatar .avatar-circle {
  width: 32px;
  height: 32px;
  font-size: 13px;
  border: 2px solid var(--white);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Status badge: opposite corner from the attribution avatar so they never collide */
.book-card-status-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  background: var(--white);
  color: var(--foreground-secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Read-status check reflects the rating: filled green circle when liked,
   filled red circle when disliked (mirrors the #8b3a3a danger red used in
   the card menu). Unrated stays the default white circle / gray check. */
.book-card-status-badge-read-like {
  background: #3a8b44;
  color: var(--white);
}

.book-card-status-badge-read-dislike {
  background: #8b3a3a;
  color: var(--white);
}

.book-card-review {
  font-size: 13px;
  color: var(--foreground-secondary);
  line-height: 1.5;
}

.book-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.book-card-footer-end {
  justify-content: flex-end;
}

.book-card-genre {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--foreground-muted);
  background: var(--surface-secondary);
  padding: 3px 10px;
  border-radius: 9999px;
}

.book-card-shelf-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.book-card-shelf-badge {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-secondary);
  background: var(--surface-secondary);
  padding: 3px 10px;
  border-radius: 9999px;
  white-space: nowrap;
}

.book-card-shelf-empty {
  font-size: 12px;
  color: var(--foreground-muted);
}

.book-card-add-btn {
  padding: 6px 14px;
  font-size: 13px;
  white-space: nowrap;
}

.book-card-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  border: none;
  background: var(--surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--foreground-muted);
  transition: background 0.2s;
}

.book-card-action-btn:hover {
  background: var(--border-subtle);
}

/* Discover card extras */
.book-card-match {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-primary);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-stack {
  display: inline-flex;
  align-items: center;
  flex: 1;
}

.avatar-stack-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
  border: 2px solid var(--white);
  box-sizing: border-box;
}

.avatar-stack>.avatar-link {
  display: inline-flex;
}

.avatar-stack>*+* {
  margin-left: -8px;
}

.avatar-stack-more {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: var(--surface-secondary);
  color: var(--foreground-secondary);
  font-weight: 700;
  font-size: 10px;
}

.book-card-added-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: var(--surface-secondary);
  color: var(--foreground-muted);
  flex-shrink: 0;
}

.book-card-frame {
  display: contents;
}

/* Book card popup menu (matches Pencil FAB Menu: W2lI8) */
.book-card-menu-wrap {
  position: relative;
  margin-left: auto;
}

.book-card-menu {
  display: none;
  position: absolute;
  bottom: 40px;
  right: 0;
  width: 200px;
  max-height: min(420px, calc(100vh - 96px));
  overflow-y: auto;
  background: var(--white);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 10;
  flex-direction: column;
}

.book-card-menu-wrap.open .book-card-menu {
  display: flex;
}

.book-card-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground-primary);
  cursor: pointer;
  transition: background 0.15s;
  /* button_to items are real <button> elements, whose UA default
     text-align: center is invisible on single-line labels but visibly
     centers a wrapped two-line label like "Currently Reading". */
  text-align: left;
}

.book-card-menu-item:hover {
  background: var(--surface-secondary);
}

.book-card-menu-item svg {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.book-card-menu-item-danger {
  color: #8b3a3a;
}

.book-card-menu-item-danger svg {
  color: #8b3a3a;
}

.book-card-menu-item-danger:hover {
  background: #f5e8e8;
}

/* Selected-state styling for the rating rows in the card menu — reuses the
   detail-page segmented toggle's colors (var(--accent-primary) for Liked,
   var(--foreground-secondary) for Disliked) so the two surfaces read as one system. */
.book-card-menu-item.is-selected {
  background: var(--surface-secondary);
  font-weight: 600;
}

.book-card-menu-item-like.is-selected svg:first-child {
  color: var(--accent-primary);
}

.book-card-menu-item-dislike.is-selected svg:first-child {
  color: var(--foreground-secondary);
}

.book-card-menu-check {
  margin-left: auto;
  flex-shrink: 0;
}

.book-card-menu-item-like.is-selected .book-card-menu-check {
  color: var(--accent-primary);
}

.book-card-menu-item-dislike.is-selected .book-card-menu-check {
  color: var(--foreground-secondary);
}

/* Visually separates the status section from Edit/Like/Dislike above and
   Add to list…/Remove below in the owner card menu. */
.book-card-menu-divider {
  height: 1px;
  margin: 6px 8px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

/* Status section of the owner card menu: a single row of icon-only buttons
   (Want to Read / Currently Reading / Read / DNF) instead of four stacked
   text rows. Selected status gets a filled accent circle, matching the
   active-filter-pill treatment used elsewhere. */
.book-card-menu-status-row {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  padding: 4px 8px;
}

.book-card-menu-status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--foreground-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.book-card-menu-status-icon:hover {
  background: var(--surface-secondary);
}

.book-card-menu-status-icon.is-selected {
  background: var(--accent-primary);
  color: var(--white);
}

/* "Add to list…" submenu — nested dropdown (book-card menu and book detail
   page) that expands in place to show the owner's lists. list-picker-detail-
   wrap sits inline in the detail page's action row rather than inside a
   popup menu, but shares the same open/closed toggling. */
.list-picker-submenu-wrap {
  position: relative;
  width: 100%;
}

.list-picker-detail-wrap {
  display: flex;
  width: auto;
}

.list-picker-submenu-panel {
  display: none;
}

.list-picker-submenu-wrap.open .list-picker-submenu-panel {
  display: block;
}

.list-picker-detail-wrap .list-picker-submenu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  min-width: 240px;
  background: var(--white);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 20;
}

.list-picker-submenu-content {
  padding-top: 4px;
}

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

.list-picker-submenu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground-primary);
  cursor: pointer;
  text-align: left;
}

.list-picker-submenu-item-add:hover {
  background: var(--surface-secondary);
}

.list-picker-submenu-item.is-added,
.list-picker-submenu-item.is-full {
  color: var(--foreground-secondary);
  cursor: default;
}

.list-picker-submenu-item.is-added {
  color: var(--accent-primary);
}

.list-picker-submenu-item-count {
  font-size: 12px;
  color: var(--foreground-secondary);
  flex-shrink: 0;
}

.list-picker-submenu-loading,
.list-picker-submenu-empty {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--foreground-secondary);
}

.list-picker-submenu-flash {
  padding: 6px 12px;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #8b3a3a;
}

.list-picker-submenu-new {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-primary);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 80px var(--page-gutter);
  text-align: center;
}

.empty-state-icon {
  color: var(--border-subtle);
}

.empty-state h2 {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--foreground-primary);
}

.empty-state p {
  font-size: 15px;
  color: var(--foreground-secondary);
  line-height: 1.6;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 var(--page-gutter) 48px var(--page-gutter);
}

.pagination-info {
  font-size: 14px;
  color: var(--foreground-muted);
}

/* Book detail page (matches Pencil DnBF6) */
.book-detail-hero {
  display: flex;
  gap: 48px;
  padding: 48px 56px;
  max-width: 1300px;
  margin: 0 auto;
}

.book-detail-cover {
  width: 340px;
  height: 500px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-secondary);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.15),
    inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.book-detail-cover-img {
  max-width: 87%;
  max-height: 87%;
  object-fit: contain;
  border-radius: 4px;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.3));
}

.book-detail-info {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.book-detail-title {
  font-family: var(--font-heading);
  font-size: 42px;
  font-weight: 700;
  color: var(--foreground-primary);
  line-height: 1.15;
}

.book-detail-author {
  font-size: 18px;
  color: var(--foreground-secondary);
}

.book-detail-ratio {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ratio-icon {
  color: var(--accent-primary);
}

.ratio-pct {
  font-family: var(--font-body);
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-primary);
}

.ratio-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
}

.ratio-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ratio-text {
  font-size: 13px;
  color: var(--foreground-secondary);
}

.ratio-bar {
  width: 140px;
  height: 5px;
  background: var(--surface-secondary);
  border-radius: 3px;
}

.ratio-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 3px;
}

.book-detail-tags {
  display: flex;
  gap: 10px;
}

.book-detail-tag {
  padding: 6px 14px;
  background: var(--surface-secondary);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground-secondary);
}

.book-detail-desc {
  font-size: 15px;
  color: var(--foreground-secondary);
  line-height: 1.6;
}

.book-detail-meta {
  font-size: 14px;
  color: var(--foreground-muted);
}

.book-detail-actions {
  display: flex;
  gap: 14px;
  align-items: stretch;
}

.book-detail-actions form {
  display: flex;
}

.btn-detail {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-detail-primary {
  background: var(--accent-primary);
  color: var(--white);
  border: 1.5px solid var(--accent-primary);
}

.btn-detail-primary:hover {
  background: var(--accent-secondary);
}

.btn-detail-secondary {
  background: none;
  color: var(--foreground-muted);
  border: 1.5px solid var(--foreground-muted);
}

.btn-detail-secondary:hover {
  background: var(--surface-secondary);
}

/* Segmented Like/Dislike rating toggle (book detail page) */
.rating-toggle-frame {
  display: contents;
}

.rating-toggle {
  display: flex;
  border: 1.5px solid var(--foreground-muted);
  border-radius: 8px;
  overflow: hidden;
}

.rating-toggle-form {
  display: flex;
  margin: 0;
}

.rating-toggle-form+.rating-toggle-form {
  border-left: 1.5px solid var(--foreground-muted);
}

.rating-toggle-segment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--foreground-muted);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.rating-toggle-segment:hover {
  background: var(--surface-secondary);
}

.rating-toggle-segment.is-selected {
  color: var(--white);
}

.rating-toggle-like.is-selected {
  background: var(--accent-primary);
}

.rating-toggle-like.is-selected:hover {
  background: var(--accent-secondary);
}

.rating-toggle-dislike.is-selected {
  background: var(--foreground-secondary);
}

.rating-toggle-dislike.is-selected:hover {
  background: var(--foreground-primary);
}

/* Book detail body (reviews) */
.book-detail-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  padding: 48px 120px;
  max-width: 1300px;
  margin: 0 auto;
}

.book-detail-section {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.book-detail-section-header h2 {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--foreground-primary);
}

.section-subtitle {
  font-size: 13px;
  color: var(--foreground-muted);
  margin-top: 4px;
  display: block;
}

/* Review cards */
.review-card {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 8px 24px rgba(0, 0, 0, 0.05);
}

.review-card-reviewer {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-small {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.avatar-tiny {
  width: 32px;
  height: 32px;
  font-size: 11px;
}

.reviewer-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.reviewer-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground-primary);
}

.reviewer-date {
  font-size: 12px;
  color: var(--foreground-muted);
}

.reviewer-rating {
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 9999px;
}

.reviewer-rating-like {
  color: var(--accent-primary);
  background: rgba(110, 136, 84, 0.1);
}

.reviewer-rating-dislike {
  color: var(--foreground-muted);
  background: var(--surface-secondary);
}

.review-card-body {
  font-size: 16px;
  color: var(--foreground-secondary);
  line-height: 1.6;
}

.review-card-body+.review-card-body {
  margin-top: 1em;
}

.review-card-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.review-action {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--foreground-muted);
  cursor: pointer;
}

.review-action:hover {
  color: var(--foreground-secondary);
}

.review-action-button {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.review-action-liked {
  color: var(--foreground-primary);
}

/* Review comments thread */
.review-comments-thread {
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.review-comment {
  display: flex;
  gap: 10px;
  padding: 12px 0;
}

.review-comment+.review-comment {
  border-top: 1px solid var(--border-subtle);
}

.review-comment-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.review-comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.review-comment-text {
  font-size: 15px;
  color: var(--foreground-secondary);
  line-height: 1.5;
}

.review-comment-text+.review-comment-text {
  margin-top: 0.75em;
}

/* Comment input */
.review-comment-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.review-comment-form {
  flex: 1;
}

.review-comment-field {
  width: 100%;
  height: 36px;
  border: none;
  outline: none;
  background: var(--surface-primary);
  border-radius: 9999px;
  padding: 0 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--foreground-primary);
}

.review-comment-field::placeholder {
  color: var(--foreground-muted);
}

/* Review form (new review) */
.review-form {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 8px 24px rgba(0, 0, 0, 0.05);
}

.review-form-input-wrap {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
}

.review-form-textarea {
  flex: 1;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--foreground-primary);
  background: var(--surface-primary);
  resize: vertical;
  outline: none;
}

.review-form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(110, 136, 84, 0.15);
}

.review-form-textarea::placeholder {
  color: var(--foreground-muted);
}

.review-form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.review-form-actions .btn-primary,
.review-form-actions .btn-secondary {
  min-width: 140px;
}

.book-card-cover-link {
  text-decoration: none;
  display: block;
}

/* Connections / My Circle */

/* Invite Link card */
.invite-link-section {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 var(--page-gutter);
}

.invite-link-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 14px 0;
  background: var(--white);
  border-radius: 12px;
  padding: 22px 32px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
}

.invite-link-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.invite-link-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.invite-link-icon-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  background: var(--surface-secondary);
  color: var(--accent-primary);
}

.invite-link-text-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.invite-link-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground-primary);
  margin: 0;
}

.invite-link-subtitle {
  font-size: 13px;
  color: var(--foreground-secondary);
  margin: 0;
}

.invite-link-slots-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 9999px;
  background: var(--surface-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--foreground-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.invite-link-slots-badge svg {
  color: var(--foreground-muted);
  flex-shrink: 0;
}

.invite-link-slots-badge--full {
  background: var(--surface-primary);
}

.invite-link-bottom-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.invite-link-bottom-row form {
  display: inline-flex;
  flex-shrink: 0;
}

.invite-link-box {
  flex: 1;
  min-width: 220px;
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--surface-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--foreground-secondary);
  font-family: var(--font-body);
  font-size: 13px;
}

.invite-link-box--input {
  cursor: text;
}

.invite-link-box--disabled {
  background: var(--surface-primary);
  color: var(--foreground-muted);
}

.invite-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent-primary);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.invite-link-btn--copy:hover {
  background: var(--accent-secondary);
}

.invite-link-btn--copied {
  background: var(--accent-secondary);
}

.invite-link-btn--outline {
  background: var(--white);
  color: var(--foreground-secondary);
  border: 1px solid var(--border-subtle);
}

.invite-link-btn--outline:hover {
  background: var(--surface-secondary);
}

.invite-link-btn--disabled {
  background: var(--surface-secondary);
  color: var(--foreground-muted);
  cursor: not-allowed;
  pointer-events: none;
}

.invite-link-btn--disabled.invite-link-btn--outline {
  background: var(--surface-primary);
  color: var(--foreground-muted);
}

.invite-link-full-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--surface-secondary);
  color: var(--foreground-secondary);
  font-size: 13px;
}

.invite-link-full-notice svg {
  color: var(--foreground-muted);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .invite-link-card {
    padding: 18px 20px;
  }

  .invite-link-top-row {
    align-items: flex-start;
  }

  .invite-link-bottom-row {
    flex-direction: column;
    align-items: stretch;
  }

  .invite-link-bottom-row form,
  .invite-link-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Circle filter pills */
.circle-filter-bar {
  display: flex;
  gap: 8px;
  padding: 16px var(--page-gutter);
  max-width: 1300px;
  margin: 0 auto;
}

.circle-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--foreground-primary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.circle-filter-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.circle-filter-btn--active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--white);
}

.circle-filter-btn--active:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--white);
}

.circle-filter-btn-count {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.6;
}

.circle-filter-btn--active .circle-filter-btn-count {
  opacity: 0.85;
}

/* Circle content area */
.circle-content {
  padding: 24px var(--page-gutter) 40px var(--page-gutter);
  max-width: 1300px;
  margin: 0 auto;
}

/* Connections grid */
.connections-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* Connection card — horizontal layout */
.connection-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--white);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
}

.connection-card[data-pending] {
  opacity: 0.7;
}

/* Inactive first-degree connection: muted "aged paper" parchment treatment.
   Binary signal only — no icon, no tooltip, no exact dates. */
.connection-card--inactive {
  background:
    radial-gradient(circle at 12% 15%, rgba(122, 98, 56, 0.18), transparent 60%),
    radial-gradient(circle at 88% 85%, rgba(85, 96, 58, 0.14), transparent 55%),
    radial-gradient(circle at 50% 50%, transparent 55%, rgba(42, 36, 24, 0.1) 100%),
    #F1ECD9;
  background-blend-mode: multiply, multiply, multiply, normal;
  border: 1px solid rgba(181, 169, 140, 0.25);
  border-radius: 12px 13px 11px 12px;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.082),
    0 2px 6px rgba(0, 0, 0, 0.047);
}

.connection-card--inactive .avatar-circle {
  filter: saturate(0.4) sepia(0.12) brightness(0.96);
  opacity: 0.95;
}

.connection-card--inactive .connection-card-name {
  color: rgba(60, 56, 48, 0.92);
}

.connection-card--inactive .connection-card-meta {
  color: #6E6754;
}

.connection-card-avatar {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.connection-card-avatar .avatar-circle {
  width: 48px;
  height: 48px;
  font-size: 18px;
}

.avatar-degree-badge {
  position: absolute;
  bottom: 7px;
  right: 7px;
  width: 20px;
  height: 20px;
  border-radius: 9999px;
  background: var(--white);
  border: 2px solid var(--foreground-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--foreground-primary);
}

.avatar-pending {
  background: var(--surface-secondary) !important;
  color: var(--foreground-muted);
}

.connection-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.connection-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-card-name:hover {
  color: var(--accent-primary);
}

.connection-card-meta-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.connection-card-meta {
  font-size: 13px;
  color: var(--foreground-muted);
}

.connection-card-meta-row form {
  display: inline;
}

.connection-card-separator {
  font-size: 13px;
  color: var(--foreground-muted);
  padding: 0 4px;
}

.connection-card-disconnect {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: #C0392B;
  cursor: pointer;
  transition: opacity 0.15s;
}

.connection-card-disconnect:hover {
  opacity: 0.7;
}

/* Circle footer */
.circle-footer {
  margin-top: 24px;
}

.circle-separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 16px 0;
}

.circle-info {
  display: block;
  font-size: 13px;
  color: var(--foreground-muted);
  margin-bottom: 12px;
}

/* Pagination */
.circle-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding-top: 8px;
}

.pagination-btn {
  height: 36px;
  min-width: 36px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--surface-secondary);
}

.pagination-btn--active {
  background: var(--accent-primary);
  color: var(--white);
  font-weight: 600;
}

.pagination-btn--active:hover {
  background: var(--accent-primary);
  color: var(--white);
}

.pagination-btn--disabled {
  color: var(--foreground-muted);
  cursor: default;
  opacity: 0.5;
}

/* Slot dots */
.slot-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.slot-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border-subtle);
}

.slot-dot-filled {
  background: var(--accent-primary);
}

/* Edit book page */
.edit-book-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px var(--page-gutter) 48px var(--page-gutter);
}

.edit-book-form {
  margin-top: 24px;
}

.edit-book-columns {
  display: flex;
  gap: 48px;
}

.edit-book-cover-col {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.edit-book-cover-preview {
  width: 240px;
  height: 320px;
  background: var(--surface-secondary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.edit-book-cover-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

.edit-book-fields-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.edit-book-section h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--foreground-primary);
  margin-bottom: 16px;
}

.edit-book-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.edit-book-section .field {
  gap: 6px;
}

.edit-book-status-row {
  display: flex;
  gap: 16px;
}

.edit-book-status-row .field {
  flex: 1;
}

.edit-book-row {
  display: flex;
  gap: 16px;
}

.edit-book-row .field {
  flex: 1;
}

.edit-book-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--foreground-primary);
  background: var(--surface-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(110, 136, 84, 0.15);
}

.field-textarea {
  resize: vertical;
  line-height: 1.5;
}

.field-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23888D82' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* Search page */
.search-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Search results */
.search-result-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  background: var(--white);
  border-radius: 12px;
  margin-bottom: 12px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
}

.search-result-cover {
  width: 56px;
  height: 84px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-result-cover-text {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--foreground-muted);
  opacity: 0.3;
}

.search-result-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground-primary);
}

.search-result-author {
  font-size: 13px;
  color: var(--foreground-muted);
}

.search-result-genre {
  font-size: 12px;
  color: var(--foreground-muted);
}

.search-result-meta {
  font-size: 12px;
  color: var(--foreground-muted);
}

.search-result-meta-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.search-result-meta-sep {
  color: var(--foreground-muted);
}

.search-result-actions {
  flex-shrink: 0;
}

.search-result-form {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
}

.search-result-checks {
  display: flex;
  gap: 16px;
}

.search-result-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--foreground-secondary);
  cursor: pointer;
  user-select: none;
}

.search-result-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--foreground-muted);
  border-radius: 5px;
  background: var(--background-primary, #fff);
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
  margin: 0;
  flex-shrink: 0;
}

.search-result-check input[type="checkbox"]:hover {
  border-color: var(--accent-primary);
}

.search-result-check input[type="checkbox"]:checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.search-result-check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.search-result-form.is-loading {
  pointer-events: none;
}

.search-result-save-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.search-result-form.is-loading .search-result-save-label {
  display: none;
}

.search-result-form.is-loading .search-result-save-spinner {
  display: inline-block;
}

.search-result-form.is-loading .search-result-save {
  opacity: 0.85;
}

.search-result-added {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-primary);
}

.btn-small {
  padding: 8px 20px;
  font-size: 13px;
}

/* Manual add form */
.manual-add-section {
  max-width: 800px;
  margin: 32px auto 56px;
}

.manual-add-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  padding: 12px 24px;
  background: none;
  border: 2px solid var(--border-subtle);
  border-radius: 9999px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground-secondary);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.manual-add-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.manual-add-toggle svg {
  flex-shrink: 0;
}

.manual-add-content {
  display: none;
  margin-top: 20px;
}

.manual-add-section.open .manual-add-content {
  display: block;
}

.manual-add-section.open .manual-add-toggle {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.manual-add-form {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
}

.manual-add-row {
  display: flex;
  gap: 16px;
}

.manual-add-row .field {
  flex: 1;
}

/* Unified search page: In BooksCubed / From other sources sections */
.search-sections {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--page-gutter);
}

.search-section {
  margin-top: 32px;
}

.search-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.search-section-header h2 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--foreground-primary);
}

.search-section-sub {
  font-size: 13px;
  color: var(--foreground-muted);
  margin-top: 2px;
}

.search-section-count {
  font-size: 13px;
  color: var(--foreground-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.search-provider-pill {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-secondary);
  background: var(--surface-secondary);
  padding: 4px 12px;
  border-radius: 9999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.search-result-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-internal-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  text-align: center;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}

.search-internal-empty-icon {
  color: var(--foreground-muted);
}

.search-internal-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground-secondary);
}

.search-internal-empty-hint {
  font-size: 13px;
  color: var(--foreground-muted);
  max-width: 420px;
}

.search-external-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 24px;
  border: 1px dashed var(--border-subtle);
  border-radius: 12px;
  text-align: center;
  color: var(--foreground-muted);
  font-size: 14px;
}

.search-external-loading-hint {
  font-size: 12px;
  color: var(--foreground-muted);
}

.search-external-failure {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  background: var(--surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  font-size: 13px;
  color: var(--foreground-secondary);
}

.search-external-failure-left {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--foreground-muted);
}

.search-external-failure-left p {
  color: var(--foreground-secondary);
}

.search-external-empty {
  font-size: 14px;
  color: var(--foreground-secondary);
  padding: 4px 0 8px;
}

/* Load more (per-section pagination) */
.load-more-row {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.load-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--white);
  color: var(--foreground-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}

.load-more-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.load-more-btn.is-loading {
  pointer-events: none;
  opacity: 0.65;
}

.load-more-icon {
  flex-shrink: 0;
}

.load-more-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.load-more-btn.is-loading .load-more-icon {
  display: none;
}

.load-more-btn.is-loading .load-more-spinner {
  display: block;
}

.load-more-row-failed {
  flex-direction: column;
  gap: 10px;
}

.load-more-note {
  font-size: 13px;
  color: var(--foreground-muted);
}

/* Profile Page */
.profile-header {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 48px var(--page-gutter) 0 var(--page-gutter);
  max-width: 1300px;
  margin: 0 auto;
}

.profile-avatar-large {
  width: 96px;
  height: 96px;
  min-width: 96px;
  border-radius: 9999px;
  background: var(--accent-primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 40px;
  font-weight: 700;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.profile-name {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--foreground-primary);
  margin: 0;
}

.profile-stats {
  display: flex;
  gap: 24px;
}

.profile-stat {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground-muted);
}

.profile-connect-btn {
  border-radius: 9999px;
  padding: 12px 28px;
  white-space: nowrap;
}

.profile-shelf {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px var(--page-gutter);
  max-width: 1300px;
  margin: 0 auto;
}

.profile-shelf .filter-bar-wrapper {
  padding: 0;
  max-width: none;
  margin: 0;
}

.profile-shelf-title {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--foreground-primary);
  margin: 0;
}

.profile-books-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 28px;
}

/* Clickable avatar links */
a.avatar-link {
  text-decoration: none;
}

a.avatar-link .avatar-circle:hover {
  opacity: 0.85;
}

/* =========================================================================
   Landing page (home#index)
   ========================================================================= */

.landing-hero {
  background: var(--surface-primary);
  padding: 80px 48px;
}

.landing-hero-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 60px;
}

.landing-hero-copy {
  flex: 1 1 520px;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.landing-hero-copy h1 {
  font-family: var(--font-heading);
  font-size: 48px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--foreground-primary);
}

.landing-hero-copy p {
  font-size: 17px;
  line-height: 1.6;
  color: var(--foreground-secondary);
  max-width: 520px;
}

.landing-hero-cta {
  align-self: flex-start;
  padding: 16px 36px;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

.landing-book-grid {
  /*
   * Sizing knobs. One loop = 3 covers + 3 gaps (each column renders
   * its slice twice), so --landing-loop must equal 3*(cover-h + v-gap).
   */
  --landing-cover-w: 128px;
  --landing-cover-h: 176px;
  --landing-col-gap: 14px;
  --landing-row-gap: 14px;
  --landing-loop: 570px;
  /* 3 * (176 + 14) */

  position: relative;
  flex: 0 0 auto;
  width: calc(var(--landing-cover-w) * 4 + var(--landing-col-gap) * 3);
  height: 400px;
  border-radius: 12px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
}

.landing-book-col {
  position: absolute;
  top: 0;
  width: var(--landing-cover-w);
  display: flex;
  flex-direction: column;
  gap: var(--landing-row-gap);
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.landing-book-col:nth-child(1) {
  left: 0;
}

.landing-book-col:nth-child(2) {
  left: calc((var(--landing-cover-w) + var(--landing-col-gap)) * 1);
}

.landing-book-col:nth-child(3) {
  left: calc((var(--landing-cover-w) + var(--landing-col-gap)) * 2);
}

.landing-book-col:nth-child(4) {
  left: calc((var(--landing-cover-w) + var(--landing-col-gap)) * 3);
}

.landing-book-cover {
  width: var(--landing-cover-w);
  height: var(--landing-cover-h);
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: var(--surface-secondary);
  transform: translateZ(0);
}

@keyframes landing-scroll-down {
  from {
    transform: translate3d(0, calc(-1 * var(--landing-loop)), 0);
  }

  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes landing-scroll-up {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(0, calc(-1 * var(--landing-loop)), 0);
  }
}

.landing-book-col--down {
  animation: landing-scroll-down 40s linear infinite;
}

.landing-book-col--up {
  animation: landing-scroll-up 40s linear infinite;
}

.landing-book-col--delayed {
  animation-delay: -14s;
}

@media (prefers-reduced-motion: reduce) {
  .landing-book-col {
    animation: none !important;
    transform: translate3d(0, calc(-0.5 * var(--landing-loop)), 0);
  }
}

/* Features */

.landing-features {
  background: var(--surface-secondary);
  padding: 96px 48px;
}

.landing-features-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.landing-features h2 {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 700;
  color: var(--foreground-primary);
  text-align: center;
}

.landing-features-sub {
  font-size: 16px;
  line-height: 1.6;
  color: var(--foreground-secondary);
  max-width: 620px;
  text-align: center;
  margin-bottom: 28px;
}

.landing-feature-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 28px;
  width: 100%;
}

.landing-feature-card {
  flex: 0 1 380px;
  background: var(--white);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
}

.landing-feature-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--surface-secondary);
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-feature-card h3 {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--foreground-primary);
}

.landing-feature-card p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--foreground-secondary);
}

/* Feature shelf */

.landing-shelf {
  background: var(--white);
  padding: 96px 48px;
}

.landing-shelf-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 80px;
}

.landing-shelf-copy {
  flex: 0 1 440px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.landing-shelf-eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-primary);
}

.landing-shelf-copy h2 {
  font-family: var(--font-heading);
  font-size: 38px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--foreground-primary);
}

.landing-shelf-desc {
  font-size: 16px;
  line-height: 1.6;
  color: var(--foreground-secondary);
}

.landing-shelf-screenshot {
  flex: 0 1 auto;
  width: 600px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
}

/* CTA section */

.landing-cta-section {
  background: var(--surface-primary);
  padding: 96px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.landing-cta-section h2 {
  font-family: var(--font-heading);
  font-size: 40px;
  font-weight: 700;
  color: var(--foreground-primary);
  max-width: 640px;
  line-height: 1.2;
}

.landing-cta-section p {
  font-size: 17px;
  color: var(--foreground-secondary);
  line-height: 1.6;
}

.landing-cta-btn {
  margin-top: 8px;
  padding: 16px 40px;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

/* Footer */

.landing-footer {
  background: var(--surface-primary);
  padding: 40px 48px;
  border-top: 1px solid var(--border-subtle);
}

.landing-footer-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.landing-footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.landing-footer-logo {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-secondary);
}

.landing-footer-links {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.landing-footer-links a {
  font-size: 13px;
  color: var(--foreground-muted);
}

.landing-footer-links a:hover {
  color: var(--accent-primary);
}

.landing-footer-divider {
  height: 1px;
  background: var(--border-subtle);
}

.landing-footer-copy {
  font-size: 12px;
  color: var(--foreground-muted);
}

/* Global responsive touch targets (baseline only — screen-specific targets
   are handled in their own tasks) */
@media (max-width: 640px) {
  .nav-link {
    padding: 12px 8px;
    min-height: 44px;
  }

  .avatar-circle::after {
    content: "";
    position: absolute;
    inset: -6px;
  }

  .btn-primary,
  .btn-secondary,
  .filter-select,
  .filter-clear,
  .circle-filter-btn,
  .profile-connect-btn {
    min-height: 44px;
  }

  /* Discover/My Books now live in the bottom tab bar on phones — the top
     nav keeps only the logo and avatar/profile dropdown. */
  .nav-links-authenticated {
    display: none;
  }

}

/* Pull-to-refresh indicator (installed PWA only — driven by
   pull_to_refresh_controller.js, which sets transform/opacity inline
   while dragging). Rests hidden above the viewport. */
.ptr-indicator {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  box-shadow: 0 2px 10px var(--shadow-color);
  color: var(--accent-primary);
  transform: translate(-50%, -56px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  pointer-events: none;
}

.ptr-indicator svg {
  display: block;
}

.ptr-indicator--loading svg {
  animation: ptr-spin 0.8s linear infinite;
}

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

/* Bottom tab bar (phones only) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--bottom-nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface-primary);
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -2px 8px var(--shadow-color);
}

.bottom-nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  color: var(--foreground-secondary);
  font-size: 11px;
  font-weight: 500;
}

.bottom-nav-tab:hover {
  color: var(--accent-primary);
}

.bottom-nav-tab-active {
  color: var(--accent-primary);
}

@media (max-width: 640px) {
  .bottom-nav {
    display: flex;
  }

  /* Compensate for the fixed bottom bar so page content (and the iOS home
     indicator safe area) is never obscured. Lives on body — the scroll
     container — not a nested element. Only signed-in pages render the bar,
     so this is scoped to the body class the layout adds for them. */
  body.has-bottom-nav {
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  }
}

/* Landing responsive */

@media (max-width: 960px) {
  .landing-hero-inner {
    flex-direction: column;
    gap: 48px;
  }

  .landing-hero-copy {
    /* The desktop 520px flex-basis becomes a *height* once the hero stacks
       vertically, opening a big gap under the CTA — size to content instead. */
    flex: 0 0 auto;
    max-width: 100%;
  }

  .landing-hero-copy h1 {
    font-size: 38px;
  }

  .landing-book-grid {
    flex: 0 0 auto;
  }

  .landing-shelf-inner {
    flex-direction: column;
    gap: 48px;
  }

  .landing-shelf-copy {
    flex: 0 0 auto;
    max-width: 520px;
  }
}

@media (max-width: 640px) {

  .landing-hero,
  .landing-features,
  .landing-shelf,
  .landing-cta-section {
    padding-left: 24px;
    padding-right: 24px;
  }

  .landing-hero {
    padding-top: 56px;
    padding-bottom: 56px;
  }

  .landing-features,
  .landing-shelf,
  .landing-cta-section {
    padding-top: 72px;
    padding-bottom: 72px;
  }

  .landing-shelf-copy h2 {
    font-size: 30px;
  }

  .landing-hero-copy h1 {
    font-size: 32px;
  }

  .landing-book-grid {
    --landing-cover-w: 88px;
    --landing-cover-h: 120px;
    --landing-col-gap: 10px;
    --landing-row-gap: 10px;
    --landing-loop: 390px;
    /* 3 * (120 + 10) */
    height: 360px;
  }

  .landing-cta-section h2 {
    font-size: 30px;
  }
}

/* Internal Dashboard */
.dashboard {
  max-width: 1300px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.dashboard-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-subtle);
}

.dashboard-header-text h1 {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 600;
  color: var(--foreground-primary);
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.dashboard-header-text p {
  color: var(--foreground-muted);
  font-size: 15px;
}

.dashboard-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--foreground-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dashboard-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(110, 136, 84, 0.2);
}

.dashboard-section-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--foreground-muted);
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 24px 24px 22px;
  box-shadow: 0 1px 2px var(--shadow-color);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent-primary);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--shadow-color);
  border-color: var(--accent-primary);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.dashboard-back-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--foreground-secondary);
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.dashboard-back-link:hover {
  border-color: var(--accent-primary);
  color: var(--foreground-primary);
}

.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--foreground-muted);
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-secondary);
  color: var(--accent-secondary);
  font-size: 16px;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 40px;
  font-weight: 600;
  color: var(--foreground-primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-meta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--foreground-secondary);
}

.dashboard-section-title+.dashboard-table-wrap {
  margin-top: 0;
}

.dashboard .dashboard-section-title:not(:first-of-type) {
  margin-top: 8px;
}

.dashboard-panel {
  padding: 20px 20px 16px;
  margin-bottom: 40px;
  overflow: visible;
}

.dashboard-test-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-test-form .field {
  flex: 1 1 280px;
  gap: 6px;
}

.dashboard-test-form .btn-primary {
  flex: 0 0 auto;
}

.dashboard-panel .field-hint {
  margin-top: 10px;
}

.dashboard-table-wrap {
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 1px 2px var(--shadow-color);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.dashboard-table thead th {
  text-align: left;
  padding: 14px 20px;
  background: var(--surface-secondary);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--foreground-muted);
}

.dashboard-table tbody td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--foreground-primary);
}

.dashboard-table tbody tr:last-child td {
  border-bottom: 0;
}

.dashboard-table tbody tr {
  transition: background-color 0.15s ease;
}

.dashboard-table tbody tr:hover {
  background: var(--surface-secondary);
}

.dashboard-table tbody td:first-child {
  font-weight: 500;
}

.dashboard-table tbody td:nth-child(2) {
  color: var(--foreground-secondary);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 13px;
}

.dashboard-table tbody td:last-child {
  color: var(--foreground-muted);
  font-size: 13px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .dashboard {
    padding: 32px 16px 48px;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-header-text h1 {
    font-size: 28px;
  }

  .stat-value {
    font-size: 32px;
  }

  .dashboard-table thead th,
  .dashboard-table tbody td {
    padding: 12px 14px;
  }
}

/* Suspected-duplicates admin queue */
.duplicate-queue {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.duplicate-card {
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 20px 24px 24px;
  box-shadow: 0 1px 2px var(--shadow-color);
}

.duplicate-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.duplicate-card-meta {
  font-size: 12px;
  color: var(--foreground-muted);
}

.duplicate-reason-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.duplicate-reason-badge--confirmed {
  background: #e8f0e0;
  color: var(--accent-secondary);
  border: 1px solid var(--accent-primary);
}

.duplicate-reason-badge--fuzzy {
  background: #f5efdb;
  color: #8a6d1f;
  border: 1px solid #d9c17a;
}

.duplicate-reason-similarity {
  font-weight: 500;
  opacity: 0.85;
}

.duplicate-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 20px;
}

.duplicate-pair-divider {
  align-self: center;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--foreground-muted);
}

.duplicate-side {
  display: flex;
  gap: 14px;
  min-width: 0;
}

.duplicate-side-cover {
  flex-shrink: 0;
  width: 64px;
  height: 96px;
  border-radius: 6px;
  background: var(--surface-secondary);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.duplicate-side-cover-text {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  color: var(--foreground-muted);
  text-transform: uppercase;
}

.duplicate-side-info {
  min-width: 0;
}

.duplicate-side-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.duplicate-side-title a {
  color: var(--foreground-primary);
  text-decoration: none;
}

.duplicate-side-title a:hover {
  color: var(--accent-primary);
}

.duplicate-side-author {
  font-size: 13px;
  color: var(--foreground-secondary);
  margin-bottom: 10px;
}

.duplicate-side-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.duplicate-side-meta-row {
  display: flex;
  gap: 8px;
  font-size: 12px;
}

.duplicate-side-meta-row dt {
  flex: 0 0 72px;
  color: var(--foreground-muted);
  font-weight: 500;
}

.duplicate-side-meta-row dd {
  color: var(--foreground-primary);
  word-break: break-word;
}

.duplicate-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.duplicate-card-stale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--foreground-muted);
  font-size: 14px;
  font-style: italic;
}

@media (max-width: 720px) {
  .duplicate-pair {
    grid-template-columns: 1fr;
  }

  .duplicate-pair-divider {
    justify-self: center;
  }
}

/* Navbar search pill */
.navbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  width: 320px;
  padding: 0 14px;
  border-radius: 9999px;
  background: var(--surface-secondary);
  transition: background 120ms ease, box-shadow 120ms ease;
}

.navbar-search:focus-within {
  background: var(--white);
  box-shadow: 0 0 0 2px var(--accent-primary);
}

.navbar-search-icon {
  color: var(--foreground-muted);
  flex-shrink: 0;
}

.navbar-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--foreground-primary);
  outline: none;
  min-width: 0;
}

.navbar-search-input::placeholder {
  color: var(--foreground-muted);
}

/* Single-reviewer attribution used on search cards */
.book-card-attribution {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 0;
}

.book-card-attribution .avatar-circle {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.book-card-attribution-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.book-card-attribution-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card-attribution-meta {
  font-size: 12px;
  color: var(--foreground-muted);
}

/* Search page header */
.search-header-sub {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
  font-size: 16px;
  color: var(--foreground-secondary);
}

.search-query-text {
  font-weight: 600;
  color: var(--foreground-primary);
}

.search-query-count {
  font-size: 14px;
  color: var(--foreground-muted);
}

/* Search empty state */
.search-empty-state {
  padding: 64px 48px;
}

.search-empty-tips {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 520px;
  font-size: 14px;
  color: var(--foreground-secondary);
  text-align: left;
  line-height: 1.7;
}

.search-empty-tips li {
  padding-left: 20px;
  position: relative;
}

.search-empty-tips li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--accent-primary);
}

/* On-page search input for the /search page — visible at every width. It's
   the unified page's primary search bar; "Add Book" lands here queryless. */
.search-page-form {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  width: 100%;
  margin-top: 16px;
  padding: 0 8px 0 20px;
  border-radius: 12px;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  transition: box-shadow 120ms ease;
}

.search-page-form:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary);
}

.search-page-form-icon {
  color: var(--foreground-muted);
  flex-shrink: 0;
}

.search-page-form-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  /* 16px keeps iOS Safari from zooming in on focus. */
  font-size: 16px;
  color: var(--foreground-primary);
  outline: none;
}

.search-page-form-input::placeholder {
  color: var(--foreground-muted);
}

.search-page-form-submit {
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: var(--accent-primary);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 26px;
  cursor: pointer;
  transition: background 0.2s;
}

.search-page-form-submit:hover {
  background: var(--accent-secondary);
}

@media (max-width: 900px) {
  .navbar-search {
    width: 220px;
  }
}

@media (max-width: 640px) {
  .navbar-search {
    display: none;
  }
}

/* Responsive: book screens (discover, my books, book detail, reviews) */

@media (max-width: 960px) {
  .book-detail-hero {
    gap: 32px;
    padding: 32px var(--page-gutter);
  }

  .book-detail-body {
    padding: 32px var(--page-gutter);
    gap: 32px;
  }
}

@media (max-width: 640px) {

  /* Book cards go fluid: full-width single column instead of the fixed
     280px card. This also keeps the popup menu (200px, right-aligned)
     well clear of the viewport edge, so no separate clip-proofing is
     needed here (unlike the dropdowns near a grid edge on other pages). */
  .books-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .book-card {
    width: 100%;
  }

  .book-card-cover {
    height: 260px;
    padding: 24px;
  }

  /* Book detail hero: stack cover above info; the cover scales fluidly
     while keeping its aspect ratio (desktop is a fixed 340x500 slot). */
  .book-detail-hero {
    flex-direction: column;
    gap: 20px;
    padding: 24px var(--page-gutter);
  }

  .book-detail-cover {
    width: min(60vw, 260px);
    height: auto;
    aspect-ratio: 340 / 500;
    align-self: center;
  }

  .book-detail-info {
    gap: 16px;
  }

  .book-detail-title {
    font-size: 28px;
  }

  .book-detail-author {
    font-size: 16px;
  }

  .book-detail-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .book-detail-actions form {
    width: 100%;
  }

  .btn-detail {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .rating-toggle {
    width: 100%;
  }

  .rating-toggle-form {
    width: auto;
    flex: 1;
  }

  .rating-toggle-segment {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .book-detail-body {
    padding: 24px var(--page-gutter);
    gap: 32px;
  }

  .review-card,
  .review-form,
  .manual-add-form {
    padding: 16px;
  }

  /* Filter bar: on desktop the form and the sort control are two separate
     flex containers, which on phones stacks into four ragged left-hung rows.
     Flatten both containers (display: contents keeps the <form> element and
     its Stimulus targets intact) so every control lays out on one wrapping
     grid: status pills on their own scrollable row, then dropdowns paired
     at half width, with sort + clear-filters closing the group. */
  .filter-bar-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .filter-dropdowns,
  .filter-bar-meta {
    display: contents;
  }

  .filter-pills {
    order: -1;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 4px 6px;
    margin: 0 -4px;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 20px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 20px), transparent 100%);
  }

  .filter-pills::-webkit-scrollbar {
    display: none;
  }

  .filter-pills .circle-filter-btn {
    flex-shrink: 0;
  }

  .filter-multiselect,
  .filter-dropdown {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
  }

  .filter-dropdown .filter-select,
  .filter-multiselect .filter-select {
    width: 100%;
  }

  .filter-multiselect .filter-select span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .filter-clear {
    order: 5;
  }

  /* Edit book: stack cover column above the fields, cover preview fluid. */
  .edit-book-columns {
    flex-direction: column;
    gap: 24px;
  }

  .edit-book-cover-col {
    width: 100%;
  }

  .edit-book-cover-preview {
    width: min(60vw, 240px);
    height: auto;
    aspect-ratio: 240 / 320;
    align-self: center;
    margin: 0 auto;
  }

  .edit-book-status-row,
  .edit-book-row {
    flex-direction: column;
    gap: 16px;
  }

  .edit-book-actions {
    flex-direction: column-reverse;
  }

  .edit-book-actions .btn-primary,
  .edit-book-actions .btn-secondary {
    width: 100%;
  }

  /* Prevent iOS Safari's zoom-on-focus, which triggers on any text input
     under 16px. */
  .field-input,
  .field-select,
  .field-textarea,
  .search-input,
  .review-form-textarea,
  .review-comment-field {
    font-size: 16px;
  }

  /* Search results: let cover+title wrap onto their own row above the
     actions row instead of squeezing everything into one line. */
  .search-result-card {
    flex-wrap: wrap;
  }

  .search-external-failure {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-result-info {
    min-width: 0;
    flex: 1 1 160px;
  }

  .search-result-actions {
    flex: 1 1 100%;
  }

  .search-result-form {
    flex-wrap: wrap;
    width: 100%;
    justify-content: space-between;
  }

  .search-result-checks {
    flex-wrap: wrap;
  }

  .manual-add-row {
    flex-direction: column;
    gap: 16px;
  }

  /* Review edit actions (reviews/edit.html.erb): the desktop min-width
     140px on Cancel/Update overflows narrow phones — stack full-width. */
  .review-form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .review-form-actions .btn-primary,
  .review-form-actions .btn-secondary {
    min-width: 0;
    width: 100%;
  }
}

/* Responsive: social, auth, and secondary screens (connections, profiles,
   invitations, devise, shared dropdown/filter menus, internal dashboard) */

@media (max-width: 960px) {

  /* Connections grid: 4 columns is too tight once the mid breakpoint hits. */
  .connections-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .auth-container {
    padding: 40px var(--page-gutter);
  }

  .auth-card {
    padding: 40px 32px;
  }
}

@media (max-width: 640px) {

  /* Connections grid: single column; cards already flex horizontally so
     they stay comfortably tappable at full width. */
  .connections-grid {
    grid-template-columns: 1fr;
  }

  .connection-card {
    padding: 14px 16px;
  }

  /* Expand the tap target for the small text-style Disconnect/Resend/Cancel
     actions without changing their visual size (padding + equal negative
     margin keeps layout identical, just grows the hit area). */
  .connection-card-disconnect {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 12px 8px;
    margin: -12px -8px;
  }

  /* Page header row (title + action button): side-by-side space-between
     squeezes the heading into a narrow column, causing an awkward
     mid-word wrap at 36px. Stack instead, tightened for the small screen,
     with the count/action row spanning the full width (count left,
     button right) instead of floating mid-page. */
  .page-header {
    padding-top: 28px;
  }

  .page-header h1 {
    font-size: 30px;
  }

  .page-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .page-header-right {
    padding-top: 0;
  }

  .page-header-actions {
    justify-content: space-between;
  }

  /* Degree filter pills ("All" / "1st Degree" / ...) and page-number
     pagination can exceed 4 fixed-width items across a phone width —
     wrap instead of clipping items off-screen. */
  .circle-filter-bar {
    flex-wrap: wrap;
  }

  .circle-pagination {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  /* Profile header: avatar on the left with name + stats in a column
     beside it; the action button/badge wraps to its own full-width row. */
  .profile-header {
    flex-wrap: wrap;
    gap: 20px 16px;
    padding: 32px var(--page-gutter) 0 var(--page-gutter);
  }

  .profile-avatar-large {
    width: 64px;
    height: 64px;
    min-width: 64px;
    font-size: 26px;
  }

  .profile-info {
    min-width: 0;
    gap: 4px;
  }

  .profile-name {
    font-size: 22px;
  }

  .profile-stats {
    flex-wrap: wrap;
    gap: 4px 14px;
  }

  .profile-header .profile-connect-btn {
    flex: 1 1 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Auth pages (devise + invitations): fluid card, gutter-based padding
     instead of the fixed 48px that eats over a third of a 375px screen. */
  .auth-container {
    padding: 24px var(--page-gutter);
    min-height: calc(100vh - 64px);
  }

  .auth-card {
    max-width: none;
    padding: 28px 20px;
    border-radius: 12px;
  }

  .auth-header h1 {
    font-size: 24px;
  }

  .settings-container {
    padding: 24px var(--page-gutter);
    min-height: calc(100vh - 64px);
  }

  .settings-header,
  .settings-form {
    max-width: none;
  }

  .settings-header h1 {
    font-size: 24px;
  }

  .settings-card,
  .settings-actions {
    padding-left: 20px;
    padding-right: 20px;
  }

  .settings-grid > .settings-card:first-child {
    padding-top: 28px;
  }

  .settings-actions {
    padding-bottom: 28px;
  }

  /* Prevent iOS Safari's zoom-on-focus on the plain devise/profile-edit
     inputs (the shared .field-input/.field-select/.field-textarea classes
     used elsewhere already get this treatment). */
  .field input[type="text"],
  .field input[type="email"],
  .field input[type="password"] {
    font-size: 16px;
  }

  /* Shared dropdown/overlay menus: keep them within the viewport instead
     of overflowing past the edge near narrow gutters. */
  .profile-dropdown-menu,
  .book-card-menu,
  .filter-multiselect-menu {
    max-width: calc(100vw - 2 * var(--page-gutter));
  }
}

/* Books / Lists tab switcher (My Books page) */
.library-tabs {
  display: flex;
  gap: 4px;
  width: calc(100% - 2 * var(--page-gutter));
  max-width: calc(1300px - 2 * var(--page-gutter));
  margin: 24px auto 24px auto;
  border-bottom: 1px solid var(--border-subtle);
}

.library-tab {
  padding: 10px 18px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.library-tab:hover {
  color: var(--foreground-primary);
}

.library-tab-active,
.library-tab-active:hover {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* Lists grid + card */
.lists-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 28px;
  padding: 0 var(--page-gutter) 48px var(--page-gutter);
  max-width: 1300px;
  width: fit-content;
  margin: 0 auto;
}

.list-card {
  width: 280px;
  background: var(--white);
  border-radius: 12px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
}

.list-card-cover-link {
  display: block;
}

.list-card-cover {
  width: 100%;
  height: 200px;
  background-color: var(--surface-secondary);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-card-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-card-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--foreground-muted);
  opacity: 0.4;
}

/* Live CSS collage of the list's first few book covers — no image
   generation, just overlapping <img> tags laid out per book count. */
.list-card-collage {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 2px;
  padding: 2px;
}

.list-card-collage-img {
  width: 100%;
  height: 100%;
  /* Grid fr tracks can't shrink below their content's minimum size, and an
     img's minimum is its intrinsic size — without these the rows blow out
     past the 200px cover and overflow:hidden leaves only the first cover
     visible. */
  min-width: 0;
  min-height: 0;
  object-fit: cover;
  background: var(--surface-primary);
}

.list-card-collage-1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.list-card-collage-2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

.list-card-collage-3,
.list-card-collage-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.list-card-collage-3 .list-card-collage-img:first-child {
  grid-column: 1 / 3;
}

.list-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-card-title-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-card-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.list-card-title-link {
  color: var(--foreground-primary);
}

.list-card-title-link:hover {
  color: var(--accent-primary);
}

.list-card-description {
  font-size: 13px;
  color: var(--foreground-secondary);
  line-height: 1.5;
}

.list-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.list-card-count {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--foreground-muted);
  background: var(--surface-secondary);
  padding: 3px 10px;
  border-radius: 9999px;
}

@media (max-width: 640px) {
  .lists-grid {
    width: 100%;
    gap: 20px;
  }

  .list-card {
    width: 100%;
  }
}

/* List new/edit form (mirrors .edit-book-* layout) */
.list-form {
  margin-top: 24px;
}

.list-form-columns {
  display: flex;
  gap: 48px;
}

.list-form-cover-col {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.list-form-cover-preview {
  width: 240px;
  height: 240px;
  background: var(--surface-secondary);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-form-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-form-fields-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.list-form-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

@media (max-width: 640px) {
  .list-form-columns {
    flex-direction: column;
  }

  .list-form-cover-col {
    width: 100%;
  }

  .list-form-cover-preview {
    width: 100%;
  }
}

/* List show page — page-local flash slot used by list_items turbo-stream
   responses (the global layout flash only shows up after a full visit). */
.list-flash {
  margin: 0 0 20px 0;
  max-width: none;
}

/* List show page — ordered, numbered book rows with owner move/remove
   controls. Ranked lists ("Top 10 Books") read top-to-bottom, so this is a
   vertical list rather than the grid used on My Books / Lists index. */
.list-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 48px;
}

.list-item-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--white);
  border-radius: 12px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 12px 32px rgba(0, 0, 0, 0.06);
  padding: 12px 16px;
}

.list-item-position {
  width: 24px;
  flex-shrink: 0;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground-muted);
}

.list-item-cover-link {
  flex-shrink: 0;
}

.list-item-cover {
  width: 48px;
  height: 68px;
  background-color: var(--surface-secondary);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-item-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-item-cover-placeholder span {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground-muted);
  opacity: 0.4;
}

.list-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-item-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-title:hover {
  color: var(--accent-primary);
}

.list-item-author {
  font-size: 13px;
  color: var(--foreground-muted);
}

.list-item-controls {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.list-item-move-btn,
.list-item-remove-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--foreground-muted);
  cursor: pointer;
}

.list-item-move-btn:hover:not(:disabled) {
  background: var(--surface-secondary);
  color: var(--foreground-primary);
}

.list-item-move-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.list-item-remove-btn:hover {
  background: #f0e0e0;
  color: #6b2c2c;
}

/* List show page */
.list-show-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 40px var(--page-gutter) 48px var(--page-gutter);
}

/* .books-grid and .empty-state already carry their own --page-gutter
   horizontal padding (matching my_books/discover, which render them with
   no wrapping container). Zero it out here so it isn't applied twice on
   top of .list-show-container's own gutter padding. */
.list-show-container .books-grid,
.list-show-container .empty-state {
  padding-left: 0;
  padding-right: 0;
}

/* Picker and book list sit side-by-side on wide viewports, stack on narrow
   ones. Spacing between them is entirely the flex gap, not the children's
   own margins, so it's consistent in both layouts. */
.list-columns {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.list-columns-picker {
  flex: 0 0 340px;
}

.list-columns-items {
  flex: 1;
  min-width: 0;
}

@media (max-width: 900px) {
  .list-columns {
    flex-direction: column;
    align-items: stretch;
  }

  .list-columns-picker {
    flex: 1;
  }
}

/* List edit page — book-management section (picker + items), below the
   metadata form. */
.list-edit-management {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border-subtle);
}

.list-edit-management-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.list-edit-management-header h2 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--foreground-primary);
}

/* List show page — owner-only "Add books" picker */
.list-picker {
  background: var(--surface-secondary);
  border-radius: 12px;
  padding: 20px;
}

.list-picker-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground-primary);
  margin: 0 0 12px 0;
}

.list-picker-full-message {
  font-size: 14px;
  color: var(--foreground-muted);
}

.list-picker-search {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.list-picker-search-input {
  flex: 1;
}

.list-picker-empty {
  font-size: 14px;
  color: var(--foreground-muted);
}

.list-picker-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.list-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: 8px;
  padding: 8px 12px;
}

.list-picker-row-cover {
  width: 36px;
  height: 52px;
  flex-shrink: 0;
  background-color: var(--surface-secondary);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-picker-row-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-picker-row-cover-text {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--foreground-muted);
  opacity: 0.4;
}

.list-picker-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-picker-row-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-picker-row-author {
  font-size: 12px;
  color: var(--foreground-muted);
}

.list-picker-row-added {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--foreground-muted);
  background: var(--surface-secondary);
  padding: 5px 12px;
  border-radius: 9999px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .list-item-row {
    flex-wrap: wrap;
  }

  .list-picker-search {
    flex-direction: column;
  }
}

/* Reviews tab (My Books / profile) — book on the left, review text + date
   on the right. Modeled on .list-item-row but not numbered/ranked. */
.review-rows {
  display: flex;
  flex-direction: column;
  margin-bottom: 48px;
}

/* On /reviews the list is the outermost element; on profiles it sits inside
   .profile-shelf, which already provides the max-width + gutters. */
.review-rows-standalone {
  max-width: 1300px;
  margin: 0 auto 48px auto;
  padding: 0 var(--page-gutter);
}

.review-row {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  padding: 28px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.review-row:first-child {
  padding-top: 12px;
}

.review-row-book {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex: 0 0 300px;
  min-width: 0;
}

.review-row-cover-link {
  flex-shrink: 0;
}

.review-row-cover {
  width: 76px;
  height: 110px;
  flex-shrink: 0;
  background-color: var(--surface-secondary);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.review-row-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.review-row-cover-placeholder span {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--foreground-muted);
  opacity: 0.4;
}

.review-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
}

.review-row-title {
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--foreground-primary);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.review-row-title:hover {
  color: var(--accent-primary);
}

.review-row-author {
  font-size: 14px;
  color: var(--foreground-muted);
}

.review-row-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

.review-row-body {
  font-size: 16px;
  color: var(--foreground-secondary);
  line-height: 1.65;
  overflow-wrap: break-word;
  white-space: pre-line;
  max-width: 70ch;
}

.review-row-date {
  font-size: 13px;
  color: var(--foreground-muted);
}

@media (max-width: 640px) {
  .review-row {
    flex-wrap: wrap;
    gap: 16px;
  }

  .review-row-book {
    flex: 1 1 100%;
  }

  .review-row-content {
    flex: 1 1 100%;
    padding-top: 0;
  }
}