﻿#libraryPage {
  max-width: 1320px;
  padding-top: var(--space-4);
  padding-bottom: var(--space-8);
}

#libraryPage .library-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

#libraryPage .library-heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#libraryPage .library-eyebrow {
  color: var(--text-muted);
  font-size: var(--t-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#libraryPage .page-title {
  font-family: var(--font-serif);
  font-size: clamp(3rem, 5vw, 4.6rem);
  color: var(--text-strong);
  letter-spacing: 0;
  line-height: 0.95;
}

#libraryPage .page-subtitle {
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

#libraryPage .library-filters {
  margin-bottom: var(--space-6);
  padding: var(--space-2);
  background: rgba(255,255,255,0.62);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
}

#libraryPage .library-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: var(--space-3);
  align-items: end;
  margin: var(--space-4) 0 var(--space-5);
}

#libraryPage .library-search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--surface-3);
}

#libraryPage .library-search-icon {
  color: var(--text-dim);
  flex-shrink: 0;
}

#libraryPage .library-search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
}

#libraryPage .library-search-input::placeholder {
  color: var(--text-dim);
}

#libraryPage .library-search-clear {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--text-dim);
}

#libraryPage .library-sort-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 210px;
}

#libraryPage .library-sort-label {
  font-size: var(--text-xs);
  color: var(--text-dim);
  font-weight: var(--weight-medium);
}

#libraryPage .library-sort-select {
  min-height: 48px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--text-primary);
  font: inherit;
}

#libraryPage .library-filters .chip {
  min-height: 38px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
}

#libraryPage .library-filters .chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

#libraryPage .library-filters .chip.active span {
  background: var(--gold-18);
  color: var(--gold);
}

#libraryPage .books-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-6);
  align-items: stretch;
}

#libraryPage .book-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

#libraryPage .book-card:hover {
  background: var(--bg-elevated);
  border-color: var(--gold-18);
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}

#libraryPage .book-card > .book-cover {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  border-radius: 18px;
  box-shadow: var(--shadow-cover);
}

#libraryPage .book-card-info {
  gap: var(--space-2);
  min-height: 0;
}

#libraryPage .book-card-title {
  color: var(--text-strong);
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  line-height: var(--leading-snug);
}

#libraryPage .book-card-author {
  color: var(--text-body);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#libraryPage .book-card-meta {
  gap: var(--space-2);
  margin-top: 2px;
}

#libraryPage .book-card-meta .star-rating {
  margin-left: 0;
}

#libraryPage .badge {
  min-height: 24px;
}

#libraryPage .reading-progress {
  margin-top: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

#libraryPage .progress-label {
  gap: var(--space-2);
}

#libraryPage .progress-text {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#libraryPage .progress-pct {
  flex-shrink: 0;
  color: var(--gold);
}

#libraryPage .book-card-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-1);
  padding-top: 6px;
  border-top: 1px solid var(--border-divider);
}

#libraryPage .book-card-actions-primary,
#libraryPage .book-card-actions-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

#libraryPage .book-card-actions-primary {
  flex-wrap: wrap;
}

#libraryPage .book-card-actions-secondary {
  flex-wrap: nowrap;
}

#libraryPage .book-card-actions .btn:not(.btn-icon) {
  flex: 1 1 0;
  min-width: 0;
  padding-left: 10px;
  padding-right: 10px;
  white-space: nowrap;
}

#libraryPage .book-card--finished .book-card-actions {
  margin-top: var(--space-1);
}

#libraryPage .book-card--finished .book-card-complete {
  margin-top: var(--space-1);
  padding: 2px var(--space-2);
}

#libraryPage .book-card--finished .book-card-meta {
  min-height: 40px;
}

#libraryPage .book-card-actions .btn-icon {
  flex: 0 0 36px;
  width: 36px;
  min-width: 36px;
  max-width: 36px;
}

#libraryPage .book-card-actions .btn-ghost.btn-icon {
  background: var(--gold-04);
  border-color: var(--gold-08);
  color: var(--text-body);
}

#libraryPage .book-card-actions .btn-ghost.btn-icon:hover,
#libraryPage .book-card-actions .btn-ghost.btn-icon:focus-visible {
  background: var(--gold-12);
  border-color: var(--gold-18);
  color: var(--text-strong);
}

#libraryPage .book-card-actions .ph-fill.ph-heart {
  color: var(--gold) !important;
  opacity: 1;
}

#libraryPage .empty-state {
  min-height: 360px;
  padding: var(--space-12) var(--space-6);
  background: linear-gradient(180deg, var(--gold-04), rgba(255,255,255,0.01));
}

#libraryPage .empty-state-icon {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--surface-3);
  border: 1px solid var(--gold-12);
  color: var(--gold);
  font-size: 1.65rem;
}

#libraryPage .empty-state-title {
  font-family: var(--font-serif);
  color: var(--text-strong);
  font-size: var(--t-card);
}

#libraryPage .book-card > .book-cover {
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border-subtle);
}

#libraryPage .book-cover-placeholder {
  padding: var(--space-3);
  background:
    radial-gradient(circle at top, rgba(67, 56, 202, 0.1), transparent 44%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(248, 250, 252, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--text-secondary);
}

#libraryPage .book-cover-placeholder .cover-title {
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

#libraryPage .book-cover-placeholder i {
  color: #4338ca;
  opacity: 0.5;
}

html[data-theme="dark"] #libraryPage {
  color: #e2e8f0;
}

html[data-theme="dark"] #libraryPage .page-title,
html[data-theme="dark"] #libraryPage .book-card-title,
html[data-theme="dark"] #libraryPage .empty-state-title {
  color: #f8fafc;
}

html[data-theme="dark"] #libraryPage .page-subtitle,
html[data-theme="dark"] #libraryPage .library-sort-label,
html[data-theme="dark"] #libraryPage .library-search-icon,
html[data-theme="dark"] #libraryPage .library-search-input::placeholder,
html[data-theme="dark"] #libraryPage .library-search-clear,
html[data-theme="dark"] #libraryPage .book-card-author,
html[data-theme="dark"] #libraryPage .progress-text,
html[data-theme="dark"] #libraryPage .empty-state-body {
  color: #94a3b8;
}

html[data-theme="dark"] #libraryPage .library-filters,
html[data-theme="dark"] #libraryPage .library-search-wrap,
html[data-theme="dark"] #libraryPage .library-sort-select,
html[data-theme="dark"] #libraryPage .book-card,
html[data-theme="dark"] #libraryPage .empty-state {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(148, 163, 184, 0.14);
  box-shadow: 0 20px 50px rgba(2, 6, 23, 0.28);
}

html[data-theme="dark"] #libraryPage .library-filters .chip {
  background: rgba(15, 23, 42, 0.82);
  border-color: rgba(148, 163, 184, 0.16);
}

html[data-theme="dark"] #libraryPage .library-filters .chip span {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
}

html[data-theme="dark"] #libraryPage .library-filters .chip.active span {
  background: rgba(67, 56, 202, 0.18);
  color: #c7d2fe;
}

html[data-theme="dark"] #libraryPage .book-card-actions .btn-ghost.btn-icon {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
}

html[data-theme="dark"] #libraryPage .book-card-actions .btn-ghost.btn-icon:hover,
html[data-theme="dark"] #libraryPage .book-card-actions .btn-ghost.btn-icon:focus-visible {
  background: rgba(67, 56, 202, 0.16);
  border-color: rgba(67, 56, 202, 0.3);
}

html[data-theme="dark"] #libraryPage .reading-progress {
  background: rgba(15, 23, 42, 0.76);
  border-color: rgba(148, 163, 184, 0.16);
}

html[data-theme="dark"] #libraryPage .progress-bar {
  background: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] #libraryPage .progress-fill {
  background: linear-gradient(90deg, #5b63f6, #4338ca);
  box-shadow: none;
}

html[data-theme="dark"] #libraryPage .empty-state-icon {
  background: rgba(67, 56, 202, 0.12);
  border-color: rgba(67, 56, 202, 0.18);
  color: #c7d2fe;
}

html[data-theme="dark"] #libraryPage .book-card:hover,
html[data-theme="dark"] #libraryPage .book-card:focus-within {
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(99, 102, 241, 0.28);
}

html[data-theme="dark"] #libraryPage .book-card-actions {
  border-top-color: rgba(148, 163, 184, 0.14);
}

html[data-theme="dark"] #libraryPage .book-cover-placeholder {
  background:
    radial-gradient(circle at top, rgba(99, 102, 241, 0.16), transparent 44%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.94));
  border-color: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

html[data-theme="dark"] #libraryPage .book-cover-placeholder .cover-title {
  color: #cbd5e1;
}

html[data-theme="dark"] #libraryPage .book-cover-placeholder i {
  color: #c7d2fe;
  opacity: 0.7;
}

html[data-theme="dark"] .btn-primary {
  background: linear-gradient(180deg, #5b63f6, #4338ca);
  color: #f8fafc;
  box-shadow: 0 10px 24px rgba(67, 56, 202, 0.24);
}

html[data-theme="dark"] .btn-primary:hover,
html[data-theme="dark"] .btn-primary:focus-visible {
  filter: none;
  background: linear-gradient(180deg, #6b72ff, #4f46e5);
  box-shadow: 0 12px 30px rgba(67, 56, 202, 0.28);
}

html[data-theme="dark"] .btn-secondary {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}

html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-secondary:focus-visible {
  background: rgba(30, 41, 59, 0.96);
  border-color: rgba(99, 102, 241, 0.34);
  color: #f8fafc;
}

html[data-theme="dark"] .btn-ghost {
  color: #cbd5e1;
}

html[data-theme="dark"] .btn-ghost:hover,
html[data-theme="dark"] .btn-ghost:focus-visible {
  background: rgba(148, 163, 184, 0.08);
  color: #f8fafc;
}

html[data-theme="dark"] .btn:disabled,
html[data-theme="dark"] .btn[aria-disabled="true"] {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  opacity: 0.78;
  box-shadow: none;
}

html[data-theme="dark"] #statusPage {
  color: #e2e8f0;
}

html[data-theme="dark"] #statusPage .page-title,
html[data-theme="dark"] #statusPage .book-card-title,
html[data-theme="dark"] #statusPage .empty-state-title {
  color: #f8fafc;
}

html[data-theme="dark"] #statusPage .page-subtitle,
html[data-theme="dark"] #statusPage .library-eyebrow,
html[data-theme="dark"] #statusPage .book-card-author,
html[data-theme="dark"] #statusPage .empty-state-body,
html[data-theme="dark"] #statusPage .progress-text {
  color: #94a3b8;
}

html[data-theme="dark"] #statusPage .book-card,
html[data-theme="dark"] #statusPage .empty-state {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(148, 163, 184, 0.14);
  box-shadow: 0 20px 50px rgba(2, 6, 23, 0.28);
}

html[data-theme="dark"] #statusPage .book-card:hover,
html[data-theme="dark"] #statusPage .book-card:focus-within {
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(99, 102, 241, 0.28);
}

html[data-theme="dark"] #statusPage .book-card-actions {
  border-top-color: rgba(148, 163, 184, 0.14);
}

html[data-theme="dark"] #statusPage .book-card-actions .btn-ghost.btn-icon {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
}

html[data-theme="dark"] #statusPage .book-card-actions .btn-ghost.btn-icon:hover,
html[data-theme="dark"] #statusPage .book-card-actions .btn-ghost.btn-icon:focus-visible {
  background: rgba(67, 56, 202, 0.16);
  border-color: rgba(67, 56, 202, 0.3);
}

html[data-theme="dark"] #statusPage .book-card-actions .btn:not(.btn-icon) {
  box-shadow: none;
}

html[data-theme="dark"] #statusPage .book-card-actions .btn-secondary {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}

html[data-theme="dark"] #statusPage .book-card-actions .btn-secondary:hover,
html[data-theme="dark"] #statusPage .book-card-actions .btn-secondary:focus-visible {
  background: rgba(30, 41, 59, 0.96);
  border-color: rgba(99, 102, 241, 0.34);
  color: #f8fafc;
}

html[data-theme="dark"] #statusPage .book-card > .book-cover {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.94));
  border-color: rgba(148, 163, 184, 0.16);
}

html[data-theme="dark"] #statusPage .empty-state-icon {
  background: rgba(67, 56, 202, 0.12);
  border-color: rgba(67, 56, 202, 0.18);
  color: #c7d2fe;
}

@media (max-width: 820px) {
  #statusPage .status-header {
    align-items: flex-start;
    flex-direction: column;
  }

  #statusPage .books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }

  #statusPage .book-card {
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

  #statusPage .book-card-actions {
    margin-top: auto;
  }

  #statusPage .book-card-actions .btn:not(.btn-icon) {
    flex: 1 0 100%;
    min-width: 100%;
  }

  #statusPage .book-card-actions .btn-icon {
    flex-basis: 44px;
    width: 44px;
    min-width: 44px;
  }
}

@media (max-width: 430px) {
  #statusPage .books-grid {
    grid-template-columns: 1fr;
  }

  #statusPage .book-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: var(--space-4);
  }

  #statusPage .book-card > .book-cover {
    width: 96px;
    height: 144px;
  }

  #statusPage .book-card-actions {
    grid-column: 1 / -1;
  }

  #statusPage .book-card-actions-primary,
  #statusPage .book-card-actions-secondary {
    min-height: 0;
  }
}

@media (min-width: 1280px) {
  #libraryPage .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }
}

@media (max-width: 768px) {
  #libraryPage .library-tools {
    grid-template-columns: 1fr;
  }

  #libraryPage .library-sort-wrap {
    min-width: 0;
  }
}

@media (max-width: 820px) {
  #libraryPage .library-header {
    align-items: flex-start;
    flex-direction: column;
  }

  #libraryPage .library-header .btn {
    width: 100%;
  }

  #libraryPage .books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }

  #libraryPage .book-card {
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

  #libraryPage .book-card-actions .btn:not(.btn-icon) {
    flex: 1 0 100%;
    min-width: 100%;
  }

  #libraryPage .book-card-actions .btn-icon {
    flex-basis: 44px;
    width: 44px;
    min-width: 44px;
  }
}

@media (max-width: 430px) {
  #libraryPage {
    overflow-x: clip;
  }

  #libraryPage .library-header {
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }

  #libraryPage .library-heading {
    gap: var(--space-1);
  }

  #libraryPage .page-title {
    font-size: clamp(2rem, 9vw, 2.6rem);
    line-height: 0.96;
  }

  #libraryPage .page-subtitle {
    letter-spacing: 0.14em;
  }

  #libraryPage .library-tools {
    gap: var(--space-2);
    margin: var(--space-3) 0 var(--space-4);
  }

  #libraryPage .library-search-wrap,
  #libraryPage .library-sort-select {
    min-height: 44px;
  }

  #libraryPage .library-search-wrap {
    padding: 0 var(--space-3);
  }

  #libraryPage .library-sort-label {
    font-size: 0.65rem;
    letter-spacing: 0.1em;
  }

  #libraryPage .library-sort-select {
    padding: 0 var(--space-3);
  }

  #libraryPage .library-filters {
    display: flex;
    gap: 6px;
    padding: var(--space-2);
    margin-bottom: var(--space-4);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #libraryPage .library-filters::-webkit-scrollbar {
    display: none;
  }

  #libraryPage .library-filters .chip {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 var(--space-3);
    white-space: nowrap;
  }

  #libraryPage .library-filters .chip span {
    min-width: 20px;
    height: 20px;
    padding: 0 7px;
  }

  #libraryPage .books-grid {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  #libraryPage .book-card {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: var(--space-2);
    padding: 10px;
    border-radius: 18px;
  }

  #libraryPage .book-card > .book-cover {
    width: 84px;
    height: 126px;
    border-radius: 14px;
  }

  #libraryPage .book-card-title {
    font-size: 0.95rem;
    line-height: 1.2;
  }

  #libraryPage .book-card-author {
    font-size: var(--text-xs);
  }

  #libraryPage .book-card-meta {
    gap: 4px;
    margin-top: 0;
  }

  #libraryPage .badge {
    min-height: 20px;
  }

  #libraryPage .badge-metadata-missing-description {
    display: none;
  }

  #libraryPage .reading-progress {
    padding: 8px 10px;
    margin-top: 4px;
  }

  #libraryPage .book-card-actions {
    grid-column: 1 / -1;
    gap: 4px;
    padding-top: 8px;
  }

  #libraryPage .book-card-actions-primary,
  #libraryPage .book-card-actions-secondary {
    gap: 4px;
  }

  #libraryPage .book-card-actions .btn:not(.btn-icon) {
    min-height: 34px;
    padding: 0 var(--space-3);
    font-size: var(--text-xs);
  }

  #libraryPage .book-card-actions .btn-icon {
    flex-basis: 36px;
    width: 36px;
    min-width: 36px;
  }

  #libraryPage .empty-state {
    padding: var(--space-5);
    border-radius: 18px;
  }

  #libraryPage .empty-state-title {
    font-size: var(--text-lg);
  }
}

@media (max-width: 390px) {
  #libraryPage .page-title {
    font-size: clamp(1.8rem, 8.5vw, 2.25rem);
  }

  #libraryPage .book-card {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: var(--space-3);
  }

  #libraryPage .book-card > .book-cover {
    width: 76px;
    height: 114px;
  }

  #libraryPage .book-card-actions .btn:not(.btn-icon) {
    min-height: 32px;
  }
}

@media (max-width: 360px) {
  #libraryPage .library-search-wrap,
  #libraryPage .library-sort-select {
    min-height: 42px;
  }

  #libraryPage .book-card {
    grid-template-columns: 72px minmax(0, 1fr);
    padding: 9px;
  }

  #libraryPage .book-card > .book-cover {
    width: 72px;
    height: 108px;
  }

  #libraryPage .book-card-actions .btn-icon {
    flex-basis: 34px;
    width: 34px;
    min-width: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #libraryPage .book-card,
  #libraryPage .book-card > .book-cover {
    transition-duration: 0.01ms !important;
  }
}
