:root {
  color-scheme: light;
  --bg: #e4e8ee;
  --bg-deep: #d5dbe4;
  --surface: #f6f7fa;
  --ink: #141a24;
  --muted: #5a6578;
  --accent: #152238;
  --accent-soft: #d7deea;
  --brass: #8f7348;
  --brass-soft: #efe6d4;
  --chip-fg: var(--accent);
  --info-fg: var(--accent);
  --have: #0c5c34;
  --have-bg: #d9efe3;
  --missing: #7a4e00;
  --missing-bg: #f7e7c2;
  --border: rgba(21, 34, 56, 0.14);
  --shadow: 0 1px 0 rgba(21, 34, 56, 0.04);
  --radius: 14px;
  --nav-h: 76px;
  --font-ui: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-family: var(--font-ui);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
}

body {
  padding: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255, 255, 255, 0.7), transparent 55%),
    linear-gradient(180deg, #eef1f5 0%, var(--bg) 40%, var(--bg-deep) 100%);
  background-attachment: fixed;
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
}

.app-main {
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px)
    max(16px, env(safe-area-inset-left));
}

.tab-panel[hidden] {
  display: none !important;
}

.view-header {
  position: relative;
  margin-bottom: 16px;
}

.view-header.compact {
  margin-bottom: 12px;
}

.tab-icon {
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  box-shadow: 0 4px 12px rgba(26, 39, 68, 0.18);
}

.brand-mark {
  margin: 0 0 4px;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 700;
}

.view-header h1 {
  margin: 0;
  padding-right: 44px;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 6vw, 2.35rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.15rem;
  padding: 0.4rem 0.35rem calc(0.4rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, #f6f7fa 88%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 40;
}

.bottom-nav[hidden] {
  display: none !important;
}

.bottom-nav button {
  min-height: 54px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  transition: background 160ms ease, color 160ms ease;
}

.bottom-nav .nav-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.bottom-nav .nav-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body[data-tab="home"] .app-main {
  padding: 0;
}

.home-entry {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding:
    max(24px, env(safe-area-inset-top))
    24px
    calc(24px + env(safe-area-inset-bottom));
  background: var(--bg);
  animation: home-in 420ms ease-out both;
}

.home-montage {
  /* 3×2 book grid is roughly square; keep under half the screen */
  height: min(50vh, 50dvh);
  width: min(50vh, 50dvh, 90vw);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  overflow: hidden;
  background: #1a2744;
  box-shadow: 0 10px 24px rgba(26, 39, 68, 0.2);
}

.home-montage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #1a2744;
}

.home-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  text-align: center;
}

.home-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.home-enter {
  min-width: 10rem;
  min-height: 52px;
  padding: 0.85rem 2rem;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 10px 24px rgba(21, 34, 56, 0.28);
}

.home-enter:active {
  transform: scale(0.98);
}

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

@media (prefers-reduced-motion: reduce) {
  .home-entry,
  .tab-panel.is-on,
  .status-banner,
  .back-to-top {
    animation: none;
  }
}

.bottom-nav button.is-on {
  background: var(--accent);
  color: #fff;
}

.check-card,
.books-toolbar,
.more-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, white);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.check-matches {
  margin-top: 4px;
  padding-bottom: 8px;
}

.check-match-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.check-match-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brass);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  padding: 12px 14px;
  cursor: pointer;
  display: grid;
  gap: 3px;
  transition: transform 120ms ease, background 120ms ease;
}

.check-match-item:active {
  transform: scale(0.99);
  background: var(--brass-soft);
}

.check-match-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
}

.check-match-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.check-match-why {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brass);
}

.more-stack {
  display: grid;
  gap: 14px;
}

.more-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--accent);
}

.more-link {
  display: block;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.file-button {
  display: block;
  text-align: center;
  cursor: pointer;
}

.add-form {
  padding-bottom: 8px;
}

.sticky-actions {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  background: var(--bg);
  padding-top: 8px;
}

.app {
  max-width: 720px;
  margin: 0 auto;
}

.header {
  margin-bottom: 12px;
}

.kicker {
  margin: 0 0 2px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.header h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4.5vw, 1.9rem);
  line-height: 1.15;
  color: var(--accent);
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.search-panel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

body[data-page="browse"] .search-panel.books-filters,
body[data-page="books"] .search-panel.books-filters {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 20;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.adding {
  overflow: hidden;
  padding: 0;
}

body.adding .app {
  max-width: none;
}

body.adding .header,
body.adding #search-panel,
body.adding #results,
body.adding .footer {
  display: none !important;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.header-actions .btn.compact,
.header-actions .nav-button {
  width: auto;
  min-width: 4.5rem;
}

.more-menu {
  margin-top: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  display: grid;
  gap: 4px;
}

.more-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.more-menu-item:hover,
.more-menu-item:focus-visible {
  background: var(--accent-soft);
}

.isbn-inline {
  margin-top: 10px;
}

.isbn-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.add-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.add-sheet.hidden {
  display: none !important;
}

.add-sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 4px 4px 12px;
  border-bottom: 1px solid var(--border);
}

.add-sheet-bar h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--accent);
}

.add-sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 4px 20px;
}

.add-sheet-body .form-field + .form-field {
  margin-top: 12px;
}

.add-sheet-actions {
  flex-shrink: 0;
  display: grid;
  gap: 8px;
  padding: 12px 4px 4px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.status-link-button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.offline-status {
  margin: 8px 0 0;
  font-size: 0.85rem;
}

.offline-status.ready {
  color: var(--have);
}

.offline-status.pending {
  color: var(--missing);
}

#boot-hint.hidden {
  display: none;
}

.search-label,
.filter-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.search-input,
.section-filter,
.series-filter,
.text-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.search-input {
  font-size: 1rem;
}

.search-input:focus,
.section-filter:focus,
.series-filter:focus,
.text-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.title-input {
  resize: vertical;
  min-height: 84px;
  line-height: 1.4;
}

.icon-button {
  min-width: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}

.filter-row {
  margin-top: 12px;
}

.filter-row:first-child {
  margin-top: 0;
}

.filter-row + .search-label {
  margin-top: 12px;
}

.filter-row.hidden {
  display: none;
}

.page-nav {
  margin-bottom: 16px;
}

.page-nav-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 10px;
}

.nav-button {
  width: 100%;
  margin-top: 10px;
  cursor: pointer;
  font: inherit;
}

.backup-mac-button {
  background: var(--have);
  color: #fff;
  border-color: transparent;
  justify-content: center;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.nav-link.primary-link {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.entry-form {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-field + .form-field {
  margin-top: 14px;
}

.form-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.btn.secondary {
  background: var(--surface);
  color: var(--accent);
}

.scan-panel {
  margin-bottom: 18px;
}

.home-actions {
  margin: 0 0 18px;
}

.go-to-books-button {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.drill-down-row {
  margin-top: 12px;
}

.drill-down-row.hidden {
  display: none;
}

.drill-down-options {
  margin-top: 8px;
}

.isbn-check-panel {
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.scan-divider {
  margin: 18px 0 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.scan-reader {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #000;
  min-height: 280px;
  position: relative;
}

.scan-reader.hidden {
  display: none;
}

.scan-video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  min-height: 280px;
  background: #000;
}

.scan-hint {
  text-align: center;
}

.scan-hint.hidden {
  display: none;
}

#reader video {
  width: 100% !important;
  height: auto !important;
  display: block !important;
  object-fit: cover;
  min-height: 280px;
}

#reader img {
  display: none !important;
}

#reader > div {
  width: 100% !important;
}

.scan-result {
  display: grid;
  gap: 12px;
}

.scan-result.hidden {
  display: none;
}

.scan-result-banner {
  margin: 0;
}

.scan-lookup {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.scan-match-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
}

.status-banner {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  line-height: 1.35;
  animation: banner-in 220ms ease-out both;
}

.status-banner.hidden {
  display: none;
}

.status-banner.have {
  background: var(--have);
  color: #fff;
}

.status-banner.missing {
  background: var(--missing);
  color: #fff;
}

.status-banner.info {
  background: var(--accent-soft);
  color: var(--info-fg);
}

@keyframes banner-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.status-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.recent-searches,
.series-shortcuts {
  margin-top: 12px;
}

.recent-searches.hidden {
  display: none;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.chip-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.chip-button:hover,
.chip-button:focus-visible {
  border-color: var(--brass);
  background: var(--brass-soft);
}

.chip-button.is-on,
.filter-chip.is-on {
  background: var(--brass);
  color: #fff;
  border-color: transparent;
}

.series-number-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem;
  gap: 10px;
  align-items: end;
}

.series-number-field .filter-label {
  margin-bottom: 4px;
}

.series-number-field-narrow .text-input {
  text-align: center;
}

.filter-block .filter-label {
  margin-bottom: 2px;
}

.filter-block .chip-row {
  margin-top: 4px;
}

#clear-filters {
  margin-top: 4px;
  width: auto;
  min-width: 8rem;
}

.back-to-top {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 45;
  min-width: 3.4rem;
  min-height: 3.4rem;
  padding: 0.55rem 0.8rem;
  border: 0;
  border-radius: 999px;
  background: var(--brass);
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 8px 24px rgba(143, 115, 72, 0.35);
  animation: banner-in 180ms ease-out both;
}

.back-to-top[hidden] {
  display: none !important;
}

body[data-tab="home"] .back-to-top {
  display: none !important;
}

.backup-nudge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.backup-nudge-action,
.backup-nudge-dismiss {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.backup-nudge-action {
  background: var(--have);
  color: #fff;
}

.backup-nudge-dismiss {
  background: transparent;
  color: inherit;
  text-decoration: underline;
}

.book-card-focused {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.results {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.results-summary {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  padding: 28px 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}

.book-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 120ms ease;
}

.book-card:active {
  transform: scale(0.995);
}

.book-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.book-card-header strong {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.12rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--accent);
}

.book-card-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  margin-top: 1px;
}

.book-edit,
.book-delete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.book-edit {
  width: auto;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.book-edit:active {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

.book-delete {
  font-size: 1.25rem;
}

.book-delete:active {
  background: #fff5f5;
  color: #9b2c2c;
  border-color: #e8b4b4;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.book-category-row {
  margin-top: 12px;
}

.book-category-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}

.category-toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.category-toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.category-toggle-summary {
  font-size: 0.9rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-toggle-icon {
  color: var(--muted);
  font-size: 0.8rem;
}

.category-panel {
  padding: 0 14px 14px;
}

.category-panel.hidden {
  display: none;
}

.category-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.btn.compact {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.92rem;
}

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

.book-category-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.category-checkboxes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.category-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.92rem;
}

.category-checkbox input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.field-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.filter-category-panel {
  margin-top: 10px;
}

.filter-category-panel .category-actions {
  margin-top: 12px;
}

.filter-category-panel > .btn.compact {
  margin-top: 8px;
}

.filter-category-toggle {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--chip-fg);
  font-size: 0.82rem;
  font-weight: 600;
}

.section-chip {
  background: color-mix(in srgb, var(--have) 18%, var(--surface));
  color: var(--have);
}

.series-chip {
  background: var(--accent);
  color: #f4efe6;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.category-chip {
  background: var(--brass-soft);
  color: var(--brass);
}

.footer {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.footer-link {
  color: var(--accent);
  font-weight: 600;
}

.backup-panel {
  display: grid;
  gap: 14px;
}

.backup-status p {
  margin: 0 0 8px;
  line-height: 1.5;
}

/* Sticky filters while browsing books — removed: covered the book list on phones */

.books-toolbar {
  padding: 10px 12px;
}

.books-search-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.books-search-bar .search-input {
  padding: 12px 14px;
  font-size: 1rem;
}

.books-search-bar #toggle-filters {
  width: auto;
  min-width: 5.5rem;
  margin: 0;
  white-space: nowrap;
}

.books-search-bar #toggle-filters.has-filters,
.books-search-bar #toggle-filters.is-open {
  background: var(--brass);
  color: #fff;
  border-color: transparent;
}

.active-filters-summary {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.books-filter-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.books-filter-panel[hidden] {
  display: none !important;
}

.books-filter-panel .filter-block {
  margin-bottom: 10px;
}

.books-filter-panel .chip-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.books-filter-panel .chip-button {
  flex: 0 0 auto;
  padding: 7px 10px;
  font-size: 0.82rem;
}

body[data-tab="books"] .view-header.compact {
  margin-bottom: 8px;
}

body[data-tab="books"] .view-header h1 {
  font-size: clamp(1.45rem, 5vw, 1.85rem);
}

body[data-tab="books"] .results {
  margin-top: 10px;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
