:root {
  --ink: #101322;
  --muted: #667085;
  --line: #e7e8ee;
  --paper: #ffffff;
  --soft: #f7f7fb;
  --purple: #321191;
  --purple-2: #5b22ce;
  --gold: #ffb915;
  --red: #e62117;
  --sidebar: 244px;
  --topbar: 58px;
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button, input { font: inherit; }

.site-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar);
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  overflow-y: auto;
}

.brand-block { margin-bottom: 20px; }

.brand, .mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), #981b15);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  flex: 0 0 auto;
}

.brand small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.category-nav {
  display: grid;
  gap: 6px;
}

.cat-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: #1b1b22;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font-weight: 800;
}

.cat-button:hover { background: #f2f0f8; }

.cat-button.active {
  background: #efeafe;
  color: var(--purple);
}

.cat-count {
  color: #7b748c;
  font-size: 12px;
  font-weight: 800;
}

.main {
  margin-left: var(--sidebar);
  min-height: 100vh;
}

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  padding: 0 14px;
}

.menu-button {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  display: grid;
  place-content: center;
  gap: 5px;
  cursor: pointer;
}

.menu-button span {
  display: block;
  width: 22px;
  height: 2px;
  background: #111;
  border-radius: 999px;
}

.mobile-brand { font-size: 17px; }

.intro {
  padding: 34px clamp(24px, 5vw, 72px) 12px;
  max-width: 1140px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--purple);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .17em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-family: Oswald, Inter, sans-serif;
  font-size: clamp(36px, 5vw, 70px);
  line-height: .98;
  letter-spacing: -.02em;
  text-transform: uppercase;
}

.intro-copy {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.search-panel {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  padding: 14px clamp(24px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
}

.search-box {
  max-width: 760px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #d8d9e2;
  border-radius: 999px;
  background: #fff;
  padding: 0 14px 0 18px;
  box-shadow: 0 12px 32px rgba(16, 19, 34, .06);
}

.search-icon {
  color: #111827;
  font-size: 24px;
  line-height: 1;
  transform: rotate(-20deg);
}

.search-box input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.clear-search {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #f0f0f4;
  color: #555;
  cursor: pointer;
  display: none;
  font-size: 20px;
  line-height: 1;
}

.clear-search.show { display: grid; place-items: center; }

.mobile-categories { display: none; }

.library-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 34px clamp(24px, 5vw, 72px) 8px;
}

.library-heading h2 {
  margin: 0;
  font-family: Oswald, Inter, sans-serif;
  font-size: clamp(31px, 4.2vw, 54px);
  line-height: 1;
  text-transform: uppercase;
}

.book-count {
  margin: 0 0 7px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 28px 22px;
  padding: 22px clamp(24px, 5vw, 72px) 70px;
}

.book-card {
  min-width: 0;
}

.cover-link {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  overflow: hidden;
  background: #f2f2f6;
  border: 1px solid #e2e3eb;
  box-shadow: 0 18px 36px rgba(25, 21, 43, .12);
  transform: translateY(0);
  transition: transform .18s ease, box-shadow .18s ease;
}

.cover-link:hover {
  transform: translateY(-4px);
  box-shadow: 0 26px 48px rgba(25, 21, 43, .18);
}

.cover-link img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #fff;
}

.cover-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 20% 12%, rgba(255,185,21,.8), transparent 25%),
    linear-gradient(145deg, #0b1024 0%, #321191 100%);
  color: #fff;
  text-align: center;
}

.cover-fallback span {
  font-family: Oswald, Inter, sans-serif;
  font-size: 25px;
  line-height: 1.05;
  text-transform: uppercase;
}

.book-meta {
  padding: 10px 2px 0;
}

.book-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
}

.book-category {
  margin: 5px 0 0;
  color: var(--purple);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.listen-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  border: 0;
  border-radius: 999px;
  background: #fff3c4;
  color: #201400;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,185,21,.42);
}

.listen-button:hover,
.listen-button.playing {
  background: var(--gold);
}

.listen-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #111322;
  color: #fff;
  font-size: 9px;
  line-height: 1;
}

.book-audio {
  display: none;
  width: 100%;
  height: 34px;
  margin-top: 9px;
}

.book-audio.show {
  display: block;
}

.empty-state {
  margin: 40px clamp(24px, 5vw, 72px);
  max-width: 520px;
  padding: 38px;
  border-radius: 22px;
  background: var(--soft);
  text-align: center;
}

.empty-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #efeafe;
  color: var(--purple);
  font-size: 34px;
}

.empty-state h2 { margin: 0 0 7px; }
.empty-state p { margin: 0; color: var(--muted); }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0,0,0,.34);
}

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

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-104%);
    transition: transform .2s ease;
    box-shadow: 18px 0 40px rgba(0,0,0,.16);
  }

  .sidebar.open { transform: translateX(0); }

  .main { margin-left: 0; }

  .topbar { display: flex; }

  .intro {
    padding: 18px 16px 4px;
  }

  .eyebrow {
    font-size: 10px;
    margin-bottom: 6px;
  }

  h1 {
    font-size: 34px;
  }

  .intro-copy {
    margin-top: 9px;
    font-size: 14px;
    line-height: 1.42;
  }

  .search-panel {
    top: var(--topbar);
    padding: 10px 12px 11px;
  }

  .search-box {
    max-width: none;
    height: 44px;
  }

  .search-box input {
    font-size: 14px;
  }

  .mobile-categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 2px 1px;
    scrollbar-width: none;
  }

  .mobile-categories::-webkit-scrollbar { display: none; }

  .chip {
    flex: 0 0 auto;
    border: 1px solid #e0dde8;
    border-radius: 999px;
    background: #fff;
    color: #222;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 850;
    cursor: pointer;
  }

  .chip.active {
    border-color: var(--purple);
    background: var(--purple);
    color: #fff;
  }

  .library-heading {
    padding: 19px 16px 4px;
  }

  .library-heading h2 {
    font-size: 31px;
  }

  .book-count {
    font-size: 12px;
  }

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

  .cover-link {
    border-radius: 14px;
  }

  .book-title {
    font-size: 13px;
  }

  .listen-button {
    width: 100%;
    justify-content: center;
    padding: 7px 10px;
    font-size: 11px;
    margin-top: 8px;
  }

  .book-audio {
    height: 32px;
  }
}

@media (max-width: 390px) {
  .book-grid { gap: 17px 11px; padding-inline: 12px; }
  .library-heading { padding-inline: 12px; }
  .intro { padding-inline: 12px; }
}
