/* Library engine styles
   Warm, readable defaults — system fonts, neutral palette. */

:root {
  --lib-bg: #faf8f5;
  --lib-surface: #ffffff;
  --lib-text: #1a1a1a;
  --lib-text-muted: #6b7280;
  --lib-accent: #92400e;
  --lib-accent-hover: #78350f;
  --lib-border: #e5e2dd;
  --lib-radius: 6px;
}

.library {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--lib-text);
  background: var(--lib-bg);
  min-height: 100vh;
}

/* ---- Header ---- */

.library-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--lib-border);
}

.library-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
}

/* ---- Empty state ---- */

.library-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--lib-text-muted);
}

.library-empty p {
  margin: 0.5rem 0;
}

.library-empty-hint {
  font-size: 0.875rem;
}

.library-empty code {
  font-size: 0.8125rem;
  background: var(--lib-surface);
  border: 1px solid var(--lib-border);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
}

/* ---- Book grid (index) ---- */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.book-card {
  display: flex;
  flex-direction: column;
  background: var(--lib-surface);
  border: 1px solid var(--lib-border);
  border-radius: var(--lib-radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.book-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.book-card-cover {
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #f0ece6;
}

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

.book-card-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8e0d4, #d4ccc0);
  color: var(--lib-text-muted);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

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

.book-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

.book-card-author {
  font-size: 0.8125rem;
  color: var(--lib-text-muted);
  margin: 0 0 0.125rem;
}

.book-card-date {
  font-size: 0.75rem;
  color: var(--lib-text-muted);
  margin: 0;
}

/* ---- Navigation ---- */

.library-nav {
  margin-bottom: 1.5rem;
}

.library-back-link {
  color: var(--lib-accent);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.library-back-link:hover {
  color: var(--lib-accent-hover);
  text-decoration: underline;
}

/* ---- Book detail (show) ---- */

.book-detail-layout {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
}

.book-detail-cover {
  flex: 0 0 200px;
}

.book-detail-cover img {
  width: 100%;
  border-radius: var(--lib-radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.book-detail-meta {
  flex: 1;
  min-width: 0;
}

.book-detail-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  line-height: 1.25;
}

.book-detail-subtitle {
  font-size: 1rem;
  color: var(--lib-text-muted);
  margin: 0 0 1.25rem;
  font-style: italic;
}

.book-detail-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.375rem 1rem;
  font-size: 0.9375rem;
  margin: 0;
}

.book-detail-fields dt {
  font-weight: 500;
  color: var(--lib-text-muted);
}

.book-detail-fields dd {
  margin: 0;
}

.book-detail-fields code {
  font-size: 0.8125rem;
  background: var(--lib-bg);
  border: 1px solid var(--lib-border);
  padding: 0.0625rem 0.3125rem;
  border-radius: 3px;
}

.book-detail-link {
  margin-top: 1rem;
}

.book-detail-link a {
  color: var(--lib-accent);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.book-detail-link a:hover {
  text-decoration: underline;
}

/* ---- References ---- */

.book-references {
  border-top: 1px solid var(--lib-border);
  padding-top: 1.5rem;
}

.book-references h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.book-references-empty {
  color: var(--lib-text-muted);
  font-size: 0.875rem;
}

.book-reference-group h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  margin: 0.75rem 0 0.375rem;
}

.book-reference-count {
  color: var(--lib-text-muted);
  font-weight: 400;
}

.book-reference-group ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
}

.book-reference-group li {
  margin-bottom: 0.25rem;
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
  .library {
    padding: 1rem;
  }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }

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

  .book-detail-cover {
    flex: none;
    max-width: 180px;
  }
}
