:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --text: #17202f;
  --muted: #687382;
  --brand: #11235e;
  --brand-strong: #140e6e;
  --jishu:rgb(28, 156, 168);
  --accent: #ca8a04;
  --line: #ddd3c2;
  --header-bg: #14213d;
  --header-text: #f8fafc;
  --header-muted: #d7dfef;
  --footer-bg: #0f2f2f;
  --footer-text: #f7fbf7;
  --footer-muted: #bdd7d0;
  --footer-line: rgba(255, 255, 255, 0.16);
  --reader: #fbfaf7;
  --shadow: 0 20px 48px rgba(23, 32, 47, 0.13);
}

body.dark {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1b2027;
  --surface-strong: #232a33;
  --text: #f5f7fb;
  --muted: #bbc5d3;
  --brand: #45c1ad;
  --brand-strong: #e278a6;
  --accent: #f4bd4f;
  --line: #343d49;
  --header-bg: #0b1720;
  --header-text: #f4f8fb;
  --header-muted: #a9bed0;
  --footer-bg: #26113b;
  --footer-text: #fff9ff;
  --footer-muted: #d8c5e9;
  --footer-line: rgba(255, 255, 255, 0.16);
  --reader: #0f1216;
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
        font-family: "TeX Gyre Adventor", sans-serif;
}
.hero-copy h1,
.section-heading h2,


.footer-contact h2 {
    font-family: "Cormorant Garamond", serif;
}
button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 14px clamp(18px, 5vw, 72px);
  border-bottom: 1px solid color-mix(in srgb, var(--header-text) 18%, transparent);
  background: color-mix(in srgb, var(--header-bg) 94%, transparent);
  color: var(--header-text);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
}

.brand,
.main-nav a,
.secondary-button {
  color: inherit;
  text-decoration: none;
}

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

.brand-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 22px;
  color: var(--header-muted);
  font-weight: 800;
}

.main-nav a:hover {
  color: #ffffff;
}

.icon-button,
.theme-button,
.primary-button,
.secondary-button,
.book-card button {
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.icon-button {
  width: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.theme-button {
  border: 1px solid color-mix(in srgb, var(--header-text) 30%, transparent);
  background: rgba(255, 255, 255, 0.1);
  color: var(--header-text);
  padding: 0 16px;
}

.primary-button,
.book-card button {
  border: 0;
  background: var(--brand);
  color: #ffffff;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--brand);
  padding: 0 16px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 520px);
  gap: clamp(24px, 5vw, 68px);
  align-items: end;
  padding: clamp(44px, 8vw, 104px) clamp(18px, 5vw, 72px) clamp(24px, 5vw, 58px);
}

.hero-copy h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.6rem, 6.5vw, 5.6rem);
  line-height: 0.97;
}

.hero-copy p:last-child {
  max-width: 650px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.75;
}

.eyebrow {
  margin: 0 0 11px;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.featured-book {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 20px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.featured-book img {
  width: 100%;
  aspect-ratio: 7 / 10;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.featured-book h2,
.featured-book p {
  margin: 0 0 8px;
}

.featured-book p:not(.eyebrow) {
  color: var(--muted);
}

.featured-book .primary-button {
  margin-top: 10px;
}

.featured-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.featured-actions .primary-button,
.featured-actions .secondary-button {
  margin-top: 0;
}

.control-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(190px, 270px);
  gap: 16px;
  margin: 0 clamp(18px, 5vw, 72px);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 128px;
  padding: 12px;
  resize: vertical;
}

.library-section,
.saved-section {
  padding: 72px clamp(18px, 5vw, 72px);
}

.section-heading {
  max-width: 720px;
  margin-bottom: 24px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.book-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.book-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.book-actions button {
  height: 44px;
}

.book-card .save-card-button,
.book-card .cover-card-button {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--brand);
}

.book-card .save-card-button.saved,
.secondary-button.saved {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  color: var(--brand);
}

.book-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

.book-card img {
  width: 100%;
  aspect-ratio: 7 / 10;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.book-card h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
  line-height: 1.25;
}

.book-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.book-tag {
  display: inline-flex;
  width: fit-content;
  margin-top: 10px;
  padding: 6px 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
}

.saved-list {
  display: grid;
  gap: 12px;
}

.reader-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  padding: 22px;
  background: rgba(17, 24, 39, 0.62);
}

.reader-overlay[hidden] {
  display: none;
}

.reader-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.reader-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.reader-header h2 {
  margin: 0;
}

.modal-reader-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-reader-actions a {
  color: var(--brand);
  font-weight: 900;
  text-decoration: none;
}

#pdfReader {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #ffffff;
}

.saved-item,
.empty-state {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.saved-item {
  display: grid;
  grid-template-columns: 64px 1fr auto auto;
  gap: 14px;
  align-items: center;
}

.saved-item img {
  width: 64px;
  aspect-ratio: 7 / 10;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface-strong);
}

.saved-item h3,
.saved-item p,
.empty-state {
  margin: 0;
}

.saved-item p,
.empty-state {
  color: var(--muted);
}

.saved-item button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--brand);
  cursor: pointer;
  font-weight: 900;
}

.saved-item .remove-saved {
  color: #9e3b36;
}

.site-footer {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(280px, 1.2fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: start;
  padding: 44px clamp(18px, 5vw, 72px);
  border-top: 1px solid var(--footer-line);
  background: var(--footer-bg);
  color: var(--footer-text);
}

.site-footer .brand {
  width: fit-content;
}

.footer-brand p,
.footer-contact p {
  max-width: 560px;
  margin: 14px 0 0;
  color: var(--footer-muted);
  line-height: 1.7;
}

.footer-contact {
  justify-self: end;
  max-width: 620px;
}

.footer-contact .eyebrow {
  color: var(--accent);
}

.footer-contact h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.05;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.footer-button,
.footer-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 900;
  text-decoration: none;
}

.footer-button {
  border: 1px solid #f8fafc;
  background: #f8fafc;
  color: var(--footer-bg);
  padding: 0 18px;
}

.footer-link {
  border: 1px solid var(--footer-line);
  color: var(--footer-text);
  padding: 0 16px;
}

.back-to-top {
  position: fixed;
  right: clamp(16px, 4vw, 32px);
  bottom: clamp(16px, 4vw, 32px);
  z-index: 35;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid color-mix(in srgb, var(--header-text) 24%, transparent);
  border-radius: 999px;
  background: var(--header-bg);
  color: var(--header-text);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.28);
  cursor: pointer;
  font-size: 1.45rem;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--jishu);
}

@media (max-width: 980px) {
  .app-header {
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-footer {
    grid-template-columns: 1fr;
  }

  .footer-contact {
    justify-self: stretch;
  }
}

@media (max-width: 620px) {
  .hero-copy h1 {
    font-size: 2.55rem;
  }

  .featured-book,
  .control-bar,
  .book-grid,
  .book-actions,
  .saved-item {
    grid-template-columns: 1fr;
  }

  .contact-actions {
    display: grid;
  }

  .featured-book img {
    max-width: 210px;
  }

  .reader-overlay {
    padding: 0;
  }

  .reader-panel {
    border-radius: 0;
  }

  .reader-header {
    flex-direction: column;
  }
}
