:root {
  --ink: #1e2723;
  --muted: #67736c;
  --paper: #fff8e5;
  --vellum: #fffdf4;
  --gold: #d9a441;
  --sun: #ffe6a0;
  --rose: #c75068;
  --teal: #178d8f;
  --green: #6fa75c;
  --blue: #2e75a7;
  --line: rgba(89, 66, 26, .18);
  --shadow: rgba(72, 54, 22, .14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.7;
  background:
    linear-gradient(180deg, rgba(255, 251, 238, .98), rgba(241, 255, 247, .9)),
    repeating-linear-gradient(90deg, rgba(217, 164, 65, .07) 0 1px, transparent 1px 28px);
}

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

button {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 244, .9);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 34px rgba(92, 70, 32, .08);
}

.brand,
.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 950;
}

.manuscript-mark {
  width: 42px;
  height: 30px;
  border-radius: 16px 16px 5px 5px;
  background:
    linear-gradient(90deg, transparent 45%, rgba(255,255,255,.8) 45% 55%, transparent 55%),
    linear-gradient(135deg, var(--rose), var(--gold) 52%, var(--teal));
  box-shadow: 0 0 20px rgba(217, 164, 65, .56), inset 0 -9px 16px rgba(0,0,0,.14);
}

.nav a,
.reader-tools button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(117, 87, 34, .24);
  border-radius: 8px;
  background: rgba(255,255,255,.68);
  font-weight: 850;
}

.nav a::before,
.reader-tools button::before {
  content: "";
  width: 17px;
  height: 12px;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(90deg, var(--rose), var(--gold));
  box-shadow: 0 0 10px rgba(217, 164, 65, .55);
}

.hero {
  position: relative;
  min-height: 80vh;
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(320px, 1.08fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  padding: clamp(36px, 6vw, 86px) clamp(16px, 5vw, 74px);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(100deg, rgba(255, 252, 244, .96) 0 42%, rgba(255, 252, 244, .46)),
    url("assets/bookslab.jpg") center / cover;
  opacity: .5;
}

.kicker {
  margin: 0 0 8px;
  color: #7a5419;
  font-weight: 950;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 790px;
  margin-bottom: 18px;
  font-size: clamp(42px, 6.7vw, 88px);
  line-height: 1.04;
  font-weight: 950;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(27px, 3.8vw, 46px);
  line-height: 1.16;
}

.hero-text p:not(.kicker) {
  max-width: 720px;
  color: #39453f;
  font-size: clamp(18px, 2vw, 23px);
}

.scriptorium {
  position: relative;
  min-height: 510px;
  perspective: 1200px;
}

.window {
  position: absolute;
  inset: 30px 0 0;
  border: 2px solid rgba(122, 84, 25, .3);
  border-bottom-width: 8px;
  border-radius: 50% 50% 8px 8px / 34% 34% 8px 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .58), rgba(255, 246, 222, .9)),
    repeating-linear-gradient(90deg, rgba(199, 80, 104, .14) 0 18px, rgba(23, 141, 143, .12) 18px 36px, rgba(217, 164, 65, .16) 36px 54px);
  transform: rotateY(-8deg) rotateX(3deg);
  box-shadow: inset 0 0 38px rgba(255, 230, 160, .36), 0 40px 90px rgba(74, 56, 24, .2);
}

.scroll {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 230px;
  height: 118px;
  padding: 14px;
  border: 1px solid rgba(117, 87, 34, .24);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(217,164,65,.2), transparent 16% 84%, rgba(217,164,65,.2)),
    linear-gradient(180deg, #fff9df, #fff1c6);
  color: #80591d;
  font-size: 29px;
  font-weight: 950;
  box-shadow: 0 24px 48px rgba(74, 56, 24, .16), inset 0 -10px 20px rgba(154, 104, 22, .1);
}

.scroll-one {
  top: 184px;
  right: 9%;
  transform: rotateZ(-9deg) rotateX(12deg);
}

.scroll-two {
  bottom: 68px;
  left: 9%;
  transform: rotateZ(8deg) rotateX(12deg);
}

.lamp-key {
  position: absolute;
  right: 42%;
  top: 276px;
  width: 220px;
  height: 74px;
  transform: rotateZ(14deg) rotateX(58deg);
  filter: drop-shadow(0 18px 22px rgba(69, 49, 14, .24));
}

.lamp-key::before {
  content: "";
  position: absolute;
  top: 23px;
  right: 64px;
  width: 130px;
  height: 22px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff3ae, var(--gold), #936315);
  box-shadow: 0 0 26px rgba(255, 230, 160, .84), inset 0 -8px 12px rgba(100, 64, 12, .28);
}

.lamp-key::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 78px;
  height: 62px;
  border: 14px solid var(--gold);
  border-left-color: #946416;
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(255, 230, 160, .8);
}

.section-title,
.paths,
.reader-layout,
.reorg {
  max-width: 1360px;
  margin: 0 auto;
}

.paths,
.reader-layout,
.reorg {
  padding: clamp(34px, 6vw, 78px) clamp(16px, 4vw, 44px);
}

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

.path-card,
.toc-card,
.manuscript-page,
.shelf-card,
.reorg-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 24px 56px var(--shadow);
}

.path-card {
  min-height: 220px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 17px;
  cursor: pointer;
  text-align: right;
  transition: transform .18s ease, box-shadow .18s ease;
}

.path-card:hover,
.path-card.active {
  transform: translateY(-4px);
  box-shadow: 0 30px 62px rgba(72, 54, 22, .18), 0 0 22px rgba(217, 164, 65, .2);
}

.path-icon,
.book-icon,
.reader-badge {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: white;
  text-align: center;
  font-weight: 950;
  text-shadow: 0 2px 12px rgba(0,0,0,.28);
  box-shadow: inset 0 -13px 24px rgba(0,0,0,.16), 0 0 22px rgba(255, 230, 160, .36);
}

.path-icon {
  width: 70px;
  height: 70px;
  font-size: 24px;
}

.shape-round { border-radius: 50%; }
.shape-gate { border-radius: 50% 50% 8px 8px / 36% 36% 8px 8px; }
.shape-diamond { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.shape-scroll { border-radius: 18px 8px 18px 8px; }
.tone-rose { background: linear-gradient(135deg, var(--rose), var(--gold)); }
.tone-teal { background: linear-gradient(135deg, var(--teal), var(--blue)); }
.tone-green { background: linear-gradient(135deg, var(--green), var(--gold)); }
.tone-multi { background: conic-gradient(from 30deg, var(--rose), var(--gold), var(--teal), var(--blue), var(--rose)); }
.shape-hex { clip-path: polygon(50% 0, 92% 23%, 92% 77%, 50% 100%, 8% 77%, 8% 23%); }
.shape-oct { clip-path: polygon(20% 0, 80% 0, 100% 24%, 100% 76%, 80% 100%, 20% 100%, 0 76%, 0 24%); }
.shape-dome { clip-path: polygon(50% 0, 88% 18%, 100% 58%, 74% 100%, 26% 100%, 0 58%, 12% 18%); }
.shape-star { clip-path: polygon(50% 0, 62% 30%, 95% 35%, 70% 56%, 78% 91%, 50% 72%, 22% 91%, 30% 56%, 5% 35%, 38% 30%); }
.tone-1 { background: linear-gradient(135deg, #bd3152, #f0b84d); }
.tone-2 { background: linear-gradient(135deg, #178d8f, #2e75a7); }
.tone-3 { background: linear-gradient(135deg, #7656a6, #f07b79); }
.tone-4 { background: linear-gradient(135deg, #6fa75c, #f0b84d); }
.tone-5 { background: conic-gradient(from 20deg, #bd3152, #f0b84d, #178d8f, #2e75a7, #bd3152); }
.tone-6 { background: linear-gradient(135deg, #2e75a7, #79d7cf); }

.path-card h3 {
  margin: 0;
  font-size: 21px;
}

.path-card p,
.path-card small {
  color: var(--muted);
  font-weight: 750;
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(220px, 290px);
  gap: 18px;
  align-items: start;
}

.toc-card,
.shelf-card {
  position: sticky;
  top: 82px;
  padding: 17px;
}

.toc-items,
.book-shelf {
  display: grid;
  gap: 9px;
}

.toc-items button,
.shelf-book {
  border: 1px solid rgba(89, 66, 26, .14);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
  text-align: right;
  cursor: pointer;
}

.toc-items button {
  position: relative;
  min-height: 48px;
  padding: 8px 40px 8px 10px;
  color: #34413a;
  font-weight: 850;
}

.toc-items button::before {
  content: "";
  position: absolute;
  top: 15px;
  right: 11px;
  width: 22px;
  height: 12px;
  border-radius: 8px 8px 2px 2px;
  background: currentColor;
  color: var(--gold);
  box-shadow: 0 0 10px rgba(217, 164, 65, .55);
}

.toc-items button.active {
  background: #fff1c9;
  color: #865b19;
}

.manuscript-page {
  min-width: 0;
  padding: clamp(18px, 4vw, 34px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .76), rgba(255, 247, 226, .72)),
    repeating-linear-gradient(0deg, rgba(128, 89, 29, .05) 0 1px, transparent 1px 34px);
}

.reader-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: #80591d;
  font-weight: 950;
}

.progress-track {
  height: 10px;
  margin: 8px 0 22px;
  border-radius: 999px;
  background: rgba(128, 89, 29, .12);
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rose), var(--gold), var(--teal));
  box-shadow: 0 0 16px rgba(217, 164, 65, .45);
  transition: width .25s ease;
}

.reader-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.reader-badge {
  flex: 0 0 auto;
  width: 92px;
  height: 92px;
  font-size: 22px;
}

.reader-head p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 750;
}

.reader-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.reader-content {
  max-width: 770px;
  margin: 0 auto;
  font-size: var(--reader-size, 18px);
  color: #2e3933;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.reader-actions a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff4bd, var(--gold));
  color: #4d3713;
  font-weight: 900;
}

.reader-actions span {
  color: var(--muted);
  font-weight: 800;
}

.content-frame {
  width: 100%;
  min-height: 78vh;
  border: 1px solid rgba(89, 66, 26, .16);
  border-radius: 8px;
  background: white;
}

.reader-content section {
  scroll-margin-top: 96px;
  padding: 13px 0;
}

.reader-content h3 {
  color: #5c4218;
  font-size: 1.55em;
}

.reader-content .note {
  margin: 18px 0;
  padding: 14px 16px;
  border-right: 4px solid var(--gold);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  color: #654716;
  font-weight: 850;
}

.shelf-book {
  min-height: 78px;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px;
}

.shelf-book.active {
  background: #fff1c9;
}

.book-icon {
  width: 54px;
  height: 54px;
  font-size: 15px;
}

.shelf-book b,
.shelf-book small {
  display: block;
}

.shelf-book small {
  color: var(--muted);
  font-weight: 750;
}

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

.reorg-grid > div {
  min-height: 158px;
  padding: 16px;
}

.reorg-grid b {
  display: block;
  margin-bottom: 8px;
  color: #7a5419;
  font-size: 19px;
}

.reorg-grid span {
  color: #435047;
}

.footer {
  padding: 26px clamp(16px, 4vw, 56px);
  border-top: 1px solid var(--line);
  background: rgba(255, 252, 244, .9);
  color: #435047;
  text-align: center;
  font-weight: 850;
}

@media (max-width: 1120px) {
  .hero,
  .reader-layout {
    grid-template-columns: 1fr;
  }

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

  .toc-card,
  .shelf-card {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar,
  .reader-meta,
  .reader-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .path-grid,
  .reorg-grid {
    grid-template-columns: 1fr;
  }

  .scriptorium {
    min-height: 360px;
  }

  .scroll {
    width: 170px;
    height: 92px;
    font-size: 22px;
  }
}
