:root {
  --ink: #181817;
  --muted: #6e6b63;
  --paper: #f5f1e8;
  --card: #fffdf7;
  --line: #d8d2c6;
  --accent: #ff5b2d;
  --yellow: #ffd938;
  --sidebar: 112px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Cascadia Mono", "Segoe UI Mono", "SFMono-Regular", Consolas, "Liberation Mono", "Courier New", monospace;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--line);
  background: #fffaf0;
}
.brand {
  width: 100%;
  height: 96px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
}
.brand img { width: 44px; height: 44px; object-fit: contain; }
.side-nav { width: 100%; padding: 22px 12px; display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-size: .69rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.nav-item svg {
  width: 31px; height: 31px;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.nav-item.active, .nav-item:hover { color: var(--accent); background: #ffebe2; }
.sidebar-bottom { width: 100%; margin-top: auto; padding: 12px; border-top: 1px solid var(--line); }

.library { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 96px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 clamp(24px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 241, 232, .96);
  backdrop-filter: blur(12px);
}
.search {
  width: min(620px, 70%);
  height: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 15px;
  border: 1.5px solid var(--ink);
  background: #fffaf0;
  box-shadow: 3px 3px 0 rgba(24,24,23,.14);
}
.search svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; }
.search input::placeholder { color: #777267; }
.search kbd { padding: 2px 7px; border: 1px solid #c9c1b2; border-radius: 4px; color: #7c766a; background: #fff; }
.library-mark { margin-left: auto; font-size: .82rem; font-weight: 700; }
.library-mark span { display: inline-grid; place-items: center; min-width: 32px; height: 32px; margin-right: 6px; border-radius: 50%; background: var(--ink); color: #fff; }
.mobile-menu { display: none; }

.library-content { width: 100%; padding: 48px clamp(24px, 4vw, 64px) 80px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { max-width: none; margin: 0; font-size: clamp(1.75rem, 3vw, 3.15rem); line-height: 1; letter-spacing: -.045em; white-space: nowrap; }
.result-count { margin: 0; color: var(--muted); font-size: .85rem; }
.category-chips { display: flex; gap: 9px; margin: 34px 0 52px; overflow-x: auto; padding-bottom: 4px; }
.chip {
  flex: 0 0 auto;
  padding: 11px 19px;
  border: 1px solid var(--ink);
  background: transparent;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
}
.chip.active, .chip:hover { background: var(--accent); color: white; }
.section-title { margin-bottom: 23px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.section-title h2 { margin: 0; font-size: 1.5rem; letter-spacing: -.03em; }
.book-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 44px 30px; }
.book-card { min-width: 0; outline: none; }
.book-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.cover-button {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5.25;
  display: block;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ink);
  background: #e5dfd2;
  cursor: pointer;
  box-shadow: 5px 5px 0 #cec7ba;
}
.cover-button img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .25s ease; }
.quick-view {
  position: absolute; inset: auto 10px 10px;
  padding: 9px 10px;
  color: #fff; background: var(--ink);
  font-size: .72rem; font-weight: 700;
  opacity: 0; transform: translateY(5px); transition: .2s ease;
}
.cover-button:hover img { transform: scale(1.025); }
.cover-button:hover .quick-view { opacity: 1; transform: none; }
.book-card-copy { padding-top: 16px; }
.book-topic { margin: 0 0 7px; color: var(--accent); font-size: .69rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.book-card h3 { margin: 0; font-size: 1rem; line-height: 1.25; }
.book-summary {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  min-height: 38px; margin: 9px 0 11px; overflow: hidden;
  color: var(--muted); font-size: .79rem; line-height: 1.45;
}
.text-button { padding: 0; border: 0; color: var(--ink); background: transparent; font-size: .76rem; font-weight: 800; cursor: pointer; }
.text-button span { color: var(--accent); }
.empty-state { padding: 72px 20px; border: 1px dashed var(--line); text-align: center; }
.empty-state h2 { margin: 0; }
.empty-state p { color: var(--muted); }
.empty-state button { padding: 10px 16px; border: 0; color: white; background: var(--ink); cursor: pointer; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(24,24,23,.68); backdrop-filter: blur(3px); cursor: default; }
.modal-panel {
  position: relative;
  width: min(560px, 100%);
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--ink);
  background: var(--card);
  box-shadow: -18px 0 50px rgba(0,0,0,.22);
  animation: dockIn .28s ease-out;
}
@keyframes dockIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.modal-close { position: absolute; top: 16px; right: 16px; z-index: 2; width: 38px; height: 38px; border: 1px solid var(--ink); border-radius: 50%; background: var(--card); font-size: 1.7rem; line-height: 1; cursor: pointer; }
.modal-cover-wrap { display: grid; place-items: center; min-height: 330px; padding: 45px; background: var(--yellow); border-bottom: 1px solid var(--ink); }
.modal-cover-wrap img { width: auto; max-width: 210px; max-height: 260px; object-fit: cover; border: 1px solid var(--ink); box-shadow: 8px 8px 0 rgba(24,24,23,.22); }
.modal-copy { padding: 45px 48px 60px; }
.modal-copy h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 3.4rem); line-height: 1; letter-spacing: -.05em; }
.modal-description { color: var(--muted); line-height: 1.65; }
.book-facts { margin: 28px 0; border-top: 1px solid var(--line); }
.book-facts div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .82rem; }
.book-facts dt { color: var(--muted); }
.book-facts dd { margin: 0; font-weight: 700; }
.download-button { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 14px 17px; border: 0; color: #fff; background: var(--accent); font-size: .84rem; font-weight: 800; text-align: left; cursor: pointer; }
.download-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; }
.download-gate { margin-top: 18px; padding: 22px; border: 1px solid var(--ink); background: #fffaf0; }
.download-gate[hidden] { display: none; }
.gate-heading h3 { margin: 0; font-size: 1.15rem; }
.gate-heading > p:last-child { margin: 7px 0 18px; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.download-gate label { display: block; margin-bottom: 6px; font-size: .76rem; font-weight: 800; }
.download-gate input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--ink); background: white; outline: none; }
.download-gate input:focus { box-shadow: 0 0 0 2px var(--yellow); }
.submit-download, .skip-download { width: 100%; min-height: 43px; margin-top: 10px; border: 1px solid var(--ink); font-size: .78rem; font-weight: 800; cursor: pointer; }
.submit-download { color: white; background: var(--ink); }
.skip-download { background: transparent; }
.submit-download:disabled { opacity: .6; cursor: wait; }
body.modal-open { overflow: hidden; }

@media (max-width: 1500px) {
  .book-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  :root { --sidebar: 88px; }
  h1 { white-space: normal; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .sidebar { width: min(280px, 82vw); transform: translateX(-100%); transition: transform .22s ease; box-shadow: 12px 0 30px rgba(0,0,0,.15); }
  .sidebar.open { transform: none; }
  .library { margin-left: 0; }
  .topbar { height: 76px; padding: 0 16px; gap: 12px; }
  .mobile-menu { width: 42px; height: 42px; display: grid; align-content: center; gap: 5px; padding: 9px; border: 1px solid var(--ink); background: #fffaf0; }
  .mobile-menu span { display: block; height: 2px; background: var(--ink); }
  .search { width: auto; flex: 1; height: 45px; }
  .search kbd, .library-mark { display: none; }
  .library-content { padding: 34px 18px 60px; }
  .page-heading { align-items: start; }
  .result-count { padding-top: 6px; white-space: nowrap; }
  .category-chips { margin: 28px 0 40px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 34px 15px; }
  .book-summary { display: none; }
  .modal-panel { width: min(500px, 100%); }
  .modal-cover-wrap { min-height: 280px; padding: 36px 60px; }
  .modal-cover-wrap img { max-height: 220px; width: auto; }
  .modal-copy { padding: 38px 26px 50px; }
}
@media (max-width: 390px) {
  .book-grid { grid-template-columns: 1fr; }
  .cover-button { aspect-ratio: 4 / 4.8; }
}


.side-app-icon {
    width: 28px;
}

.nav-item img {
    filter: grayscale(1);
}
.nav-item.active img {
    filter: none;
}
.nav-item:hover img {
    filter: none;
}

