:root {
  --ink: #24362f;
  --muted: #718078;
  --cream: #fffaf0;
  --paper: #fffdf8;
  --sage: #dce9d8;
  --sage-deep: #5d806d;
  --coral: #ee8c72;
  --yellow: #f3c869;
  --line: #e7e5da;
  --shadow: 0 20px 50px rgba(58, 76, 67, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: "DM Sans", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; cursor: pointer; }

.sun-glow {
  position: fixed;
  top: -30vw;
  left: -10vw;
  width: 70vw;
  height: 70vw;
  border-radius: 50%;
  background: rgba(246, 213, 133, 0.19);
  filter: blur(40px);
  pointer-events: none;
  z-index: -1;
}

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 132px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.brand {
  display: block;
  width: max-content;
}

.brand img {
  display: block;
  width: 116px;
  height: 116px;
  object-fit: contain;
  border: 3px solid rgba(255, 255, 255, .72);
  border-radius: 25px;
  box-shadow: 0 7px 20px rgba(72, 91, 81, .1);
  transition: transform .2s ease, box-shadow .2s ease;
}

.brand:hover img {
  transform: rotate(-2deg) scale(1.03);
  box-shadow: 0 10px 24px rgba(72, 91, 81, .14);
}

nav {
  padding: 5px;
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, .55);
  border: 1px solid rgba(231, 229, 218, .8);
  border-radius: 99px;
}

.nav-button {
  padding: 9px 18px;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.nav-button.active { color: var(--ink); background: white; box-shadow: 0 3px 10px rgba(58, 76, 67, .08); }

.profile-button {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  text-align: left;
}

.profile-button > span:first-child {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid white;
  box-shadow: 0 3px 12px rgba(58, 76, 67, .14);
  font: 700 13px/1 "Fredoka";
}
.profile-copy strong, .profile-copy small { display: block; }
.profile-copy strong { font-size: 12px; }
.profile-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.hero {
  position: relative;
  min-height: 420px;
  padding: 65px 8%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  overflow: hidden;
  border-radius: 32px;
  background: #dce9d8;
  box-shadow: inset 0 0 0 1px rgba(74, 103, 86, .07);
}

.hero::before, .hero::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  border: 1px solid rgba(93, 128, 109, .19);
  border-radius: 50%;
}
.hero::before { left: -140px; bottom: -150px; }
.hero::after { right: -80px; top: -110px; width: 300px; height: 300px; }

.hero-copy { position: relative; z-index: 2; }
.eyebrow {
  color: var(--sage-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .17em;
  text-transform: uppercase;
}

h1, h2, h3 { margin-top: 0; }
h1 {
  margin-bottom: 17px;
  font: 600 clamp(48px, 6vw, 73px)/.98 "Fredoka", sans-serif;
  letter-spacing: -.045em;
}
h1 em { color: var(--coral); font-style: normal; }
.hero-copy p { max-width: 390px; margin: 0 0 27px; color: #617269; font-size: 15px; line-height: 1.7; }

.primary-button {
  padding: 13px 20px;
  border: 0;
  border-radius: 99px;
  color: white;
  background: var(--ink);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(36, 54, 47, .17);
}
.primary-button span { margin-right: 7px; color: var(--yellow); }

.hero-art { position: relative; height: 100%; min-height: 280px; }
.floating-book {
  position: absolute;
  left: 52%;
  top: 51%;
  width: 280px;
  height: 155px;
  display: flex;
  transform: translate(-50%, -50%) rotate(-4deg);
  filter: drop-shadow(0 20px 18px rgba(75, 100, 85, .18));
  z-index: 2;
}
.book-page {
  position: relative;
  width: 50%;
  padding: 35px 15px;
  color: #9a8769;
  background: #fff9e9;
  border: 3px solid #5f7769;
  font: 600 14px/1.4 "Fredoka";
  text-align: center;
}
.left-page { border-radius: 10px 5px 5px 18px; transform: skewY(6deg); }
.right-page { border-radius: 5px 10px 18px 5px; transform: skewY(-6deg); }
.book-page::after { content: ""; position: absolute; inset: 10px; border: 1px dashed #d5c9a9; border-radius: 5px; }
.book-page span { position: relative; z-index: 1; }

.moon {
  position: absolute;
  left: 9%;
  top: 12%;
  width: 53px;
  height: 53px;
  display: grid;
  place-items: center;
  color: #fff5cd;
  background: var(--yellow);
  border-radius: 50%;
  box-shadow: 0 0 0 10px rgba(243, 200, 105, .13);
}
.cloud { position: absolute; height: 15px; background: rgba(255,255,255,.65); border-radius: 99px; }
.cloud::before, .cloud::after { content: ""; position: absolute; bottom: 0; border-radius: 50%; background: inherit; }
.cloud::before { left: 12px; width: 25px; height: 25px; }
.cloud::after { right: 10px; width: 34px; height: 34px; }
.cloud-one { width: 88px; right: 0; top: 24%; }
.cloud-two { width: 68px; left: 0; bottom: 15%; opacity: .6; }
.sparkle { position: absolute; color: white; font-size: 18px; }
.sparkle-one { right: 10%; top: 10%; }
.sparkle-two { right: 17%; bottom: 12%; font-size: 12px; }
.sparkle-three { left: 18%; bottom: 29%; color: var(--yellow); font-size: 10px; }

.library-section { padding: 70px 0 80px; }
.library-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 24px; }
.library-heading h2 { margin: 7px 0 0; font: 600 31px/1.1 "Fredoka"; letter-spacing: -.03em; }

.search-box {
  width: min(260px, 100%);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  background: rgba(255,255,255,.62);
}
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }

.filter-row { margin-bottom: 34px; display: flex; flex-wrap: wrap; gap: 8px; }
.filter-button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.filter-button.active { border-color: var(--ink); color: white; background: var(--ink); }

.book-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px 22px; }
.book-card { min-width: 0; }
.book-cover-button { width: 100%; padding: 0; border: 0; border-radius: 10px 15px 15px 10px; background: transparent; perspective: 700px; }
.book-cover {
  --cover: #e78c74;
  position: relative;
  aspect-ratio: .76;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px 14px 14px 8px;
  border-left: 8px solid rgba(36, 54, 47, .17);
  color: white;
  background: var(--cover);
  box-shadow: 8px 13px 0 #e6e0d1, 11px 17px 22px rgba(58, 76, 67, .15);
  transition: transform .25s ease, box-shadow .25s ease;
}
.book-cover::before, .book-cover::after {
  content: "";
  position: absolute;
  width: 130px;
  height: 130px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 50%;
}
.book-cover::before { top: -60px; right: -60px; }
.book-cover::after { bottom: -75px; left: -50px; }
.book-cover-button:hover .book-cover { transform: translateY(-7px) rotateY(-4deg); box-shadow: 12px 19px 0 #e6e0d1, 17px 25px 28px rgba(58, 76, 67, .17); }
.cover-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.book-cover.has-cover-image {
  padding: 0;
  background: var(--cover);
}
.book-cover.has-cover-image::before,
.book-cover.has-cover-image::after { display: none; }
.real-book-badge {
  position: absolute;
  z-index: 2;
  left: 10px;
  bottom: 10px;
  padding: 5px 8px;
  border-radius: 99px;
  color: var(--ink);
  background: rgba(255, 250, 240, .9);
  box-shadow: 0 3px 9px rgba(36, 54, 47, .13);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.cover-symbol { position: relative; z-index: 1; margin-bottom: 15px; font-size: 45px; text-shadow: 0 2px 0 rgba(0,0,0,.05); }
.cover-title { position: relative; z-index: 1; max-width: 180px; font: 600 clamp(20px, 2.3vw, 29px)/1.05 "Fredoka"; letter-spacing: -.03em; text-align: center; }
.book-cover small { position: absolute; z-index: 1; bottom: 17px; font-size: 7px; line-height: 1.5; letter-spacing: .12em; text-align: center; text-transform: uppercase; opacity: .75; }

.book-info { min-height: 65px; margin-top: 23px; display: flex; justify-content: space-between; gap: 10px; }
.book-category { color: var(--coral); font-size: 8px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.book-title { margin: 6px 0 0; font: 600 16px/1.2 "Fredoka"; letter-spacing: -.02em; }
.book-pages { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.favorite-button, .favorite-reader-button {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255,255,255,.5);
  font-size: 18px;
}
.favorite-button.is-favorite, .favorite-reader-button.is-favorite { color: var(--coral); background: #fff0ea; border-color: #f2c6b9; }
.read-button { padding: 0; border: 0; color: var(--sage-deep); background: transparent; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.read-button span { margin-left: 4px; transition: margin .2s; }
.read-button:hover span { margin-left: 8px; }

.empty-state { padding: 60px; color: var(--muted); text-align: center; }
.empty-state span { font-size: 40px; color: var(--sage-deep); }
.empty-state h3 { margin: 10px 0 4px; color: var(--ink); font: 600 22px/1 "Fredoka"; }
.empty-state p { font-size: 12px; }

footer {
  padding: 24px max(20px, calc((100% - 1180px)/2));
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  background: #f2eddf;
  font-size: 9px;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.reader-dialog {
  width: min(1180px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  border-radius: 25px;
  color: var(--ink);
  background: #f8f4e9;
  box-shadow: 0 30px 90px rgba(36, 54, 47, .35);
}
.reader-dialog::backdrop { background: rgba(36, 54, 47, .66); backdrop-filter: blur(5px); }
.reader-shell {
  min-height: min(850px, calc(100vh - 24px));
  padding: 18px;
  display: flex;
  flex-direction: column;
}
.reader-shell:fullscreen { padding: 22px; background: #f8f4e9; }
.reader-topbar { padding: 3px 3px 13px; display: grid; grid-template-columns: 80px 1fr 80px; align-items: center; text-align: center; }
.reader-topbar strong, .reader-topbar small { display: block; }
.reader-topbar strong { font: 600 15px/1.2 "Fredoka"; }
.reader-topbar small { margin-top: 2px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.icon-button { width: 35px; height: 35px; border: 1px solid var(--line); border-radius: 50%; background: white; font-size: 21px; }
.reader-actions { display: flex; justify-content: end; gap: 7px; }
.reader-progress-track {
  width: calc(100% - 110px);
  height: 4px;
  margin: 0 auto 13px;
  overflow: hidden;
  border-radius: 99px;
  background: #e4dfd2;
}
.reader-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
  transition: width .25s ease;
}
.illustrated-reader {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 16px;
}
.illustrated-page-wrap {
  position: relative;
  height: min(710px, calc(100vh - 150px));
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px 18px 18px 10px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, .8), transparent 70%),
    #e6e0d2;
  box-shadow: inset 0 0 30px rgba(93, 78, 54, .08), 6px 9px 0 #e8e0d0;
}
.illustrated-page-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 12px 0 18px rgba(58, 45, 27, .07);
}
#illustrated-page {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 8px 18px rgba(58, 45, 27, .18);
  opacity: 1;
  transition: opacity .16s ease, transform .2s ease;
}
#illustrated-page.is-turning { opacity: .5; transform: scale(.985); }
.page-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  box-shadow: 0 5px 13px rgba(36, 54, 47, .1);
  font-size: 29px;
}
.page-button:disabled { opacity: .25; cursor: default; }
.reader-hint { margin: 12px 0 0; color: var(--muted); font-size: 9px; letter-spacing: .06em; text-align: center; text-transform: uppercase; }
.reader-open { overflow: hidden; }

@media (max-width: 860px) {
  .site-header { grid-template-columns: 1fr auto; }
  nav { display: none; }
  .hero { grid-template-columns: 1fr; padding: 50px 9%; }
  .hero-art { position: absolute; inset: 0 0 0 48%; opacity: .33; }
  .hero-copy { max-width: 500px; }
  .book-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .site-header { width: min(100% - 24px, 1180px); min-height: 104px; }
  .brand img { width: 90px; height: 90px; border-radius: 20px; }
  .profile-copy { display: none; }
  main { width: min(100% - 24px, 1180px); }
  .hero { min-height: 420px; padding: 44px 25px; border-radius: 23px; }
  .hero-art { left: 25%; }
  h1 { font-size: 47px; }
  .library-section { padding-top: 52px; }
  .library-heading { align-items: start; flex-direction: column; }
  .search-box { width: 100%; }
  .book-grid { gap: 29px 15px; }
  .book-cover { padding: 16px 12px; border-left-width: 5px; }
  .cover-symbol { font-size: 35px; }
  .cover-title { font-size: 19px; }
  .book-title { font-size: 14px; }
  .reader-dialog { width: 100%; max-height: 100vh; border-radius: 0; }
  .reader-shell { min-height: 100vh; padding: 12px; }
  .reader-topbar { grid-template-columns: 72px 1fr 72px; }
  .reader-topbar strong { max-width: 170px; margin: 0 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reader-actions { gap: 3px; }
  #fullscreen-reader { display: none; }
  .reader-progress-track { width: calc(100% - 25px); }
  .illustrated-reader { position: relative; grid-template-columns: 1fr; }
  .illustrated-page-wrap { height: calc(100vh - 135px); padding: 8px; border-radius: 8px; }
  .page-button { position: absolute; z-index: 3; bottom: 18px; background: rgba(255,255,255,.92); }
  #previous-page { left: 18px; }
  #next-page { right: 18px; }
  .reader-hint { display: none; }
  footer { flex-direction: column; text-align: center; }
}
