:root {
  color-scheme: light;
  --ink: #ffffff;
  --muted: #d6d1d3;
  --paper: #fafafa;
  --surface: #ffffff;
  --panel: #201f1f;
  --field: #343434;
  --field-strong: #171316;
  --line: #503d45;
  --primary: #911943;
  --primary-hover: #bc1d55;
  --focus: #395b6a;
  --accent: #db4e61;
  --shadow: 0 24px 55px rgba(2, 2, 1, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(250, 250, 250, 0.18), rgba(250, 250, 250, 0.18)),
    url("../img/logo-background.jpg") center / cover fixed,
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 0;
  padding: clamp(20px, 4vw, 48px);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 28px);
}

.brand-logo {
  width: clamp(74px, 9vw, 110px);
  height: auto;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 3.85rem);
  line-height: 1;
  letter-spacing: 0;
  font-weight: 700;
}

.library-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-field,
.search-field span {
  display: grid;
  gap: 6px;
}

.search-field span {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--field);
  color: var(--ink);
  padding: 0 16px;
  outline: none;
}

input:focus,
select:focus {
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(57, 91, 106, 0.45);
}

#book-search {
  width: min(330px, 72vw);
}

.bookshelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: clamp(18px, 3vw, 34px);
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 56px;
  padding: clamp(18px, 3vw, 30px);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.book-card {
  display: grid;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.cover-frame {
  position: relative;
  aspect-ratio: 0.695;
  border-radius: 16px;
  background: var(--field);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: translateY(0);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.cover-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.17), transparent 12%, transparent 88%, rgba(255, 255, 255, 0.2));
  pointer-events: none;
}

.book-card:hover .cover-frame,
.book-card:focus-visible .cover-frame {
  transform: translateY(-5px);
  box-shadow: 0 28px 60px rgba(2, 2, 1, 0.38);
}

.book-card:focus-visible {
  outline: 3px solid rgba(219, 78, 97, 0.65);
  outline-offset: 8px;
  border-radius: 16px;
}

.pdf-cover,
.cover-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pdf-cover {
  background: #ffffff;
}

.cover-fallback[hidden],
.pdf-cover[hidden],
.cover-loading[hidden] {
  display: none;
}

.cover-loading {
  position: absolute;
  inset: auto 14px 14px;
  border-radius: 999px;
  background: rgba(32, 31, 31, 0.82);
  color: #ffffff;
  padding: 8px 10px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
}

.book-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 700;
}

.book-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.category-pill {
  justify-self: start;
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
}

.empty-state {
  margin: 36px auto;
  max-width: 620px;
  border-radius: 24px;
  padding: 32px 20px;
  background: var(--panel);
  color: var(--ink);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 760px) {
  .site-header {
    display: grid;
    align-items: start;
  }

  .library-actions {
    justify-content: stretch;
  }

  .search-field,
  #book-search,
  #category-filter {
    width: 100%;
  }

  .bookshelf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 14px;
  }
}

@media (max-width: 430px) {
  .bookshelf {
    grid-template-columns: minmax(0, 1fr);
  }
}
