:root{
  --bg0:#050505;
  --bg1:#1b0707;
  --ember:#ff5a1f;
  --ink:#1b1b1f;
  --paper:#f3ead5;
  --paper2:#efe1c4;
  --stroke:rgba(0,0,0,.14);
  --shadow:0 26px 80px rgba(0,0,0,.55);
  --ease:cubic-bezier(.2,.9,.2,1);
  --radius:22px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  background:
    radial-gradient(1200px 700px at 20% 0%, rgba(255,90,31,.22), transparent 60%),
    radial-gradient(1200px 900px at 80% 20%, rgba(255,160,31,.12), transparent 65%),
    linear-gradient(135deg, #0a0505, #000);
  color:var(--ink);
  overflow:hidden;
}

#embers{
  position:fixed;
  inset:0;
  z-index:0;
  pointer-events:none;
  opacity:.95;
  filter: blur(.2px);
}

.sidebar{
  position:fixed;
  inset: 18px auto 18px 18px;
  width: 300px;
  z-index:5;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(20,20,20,.82), rgba(8,8,8,.78));
  border: 1px solid rgba(255,90,31,.18);
  box-shadow: 0 22px 60px rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.brand{
  padding: 16px 16px 12px;
  display:flex;
  gap:12px;
  align-items:center;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.brandMark{
  width:46px; height:46px;
  border-radius:16px;
  display:grid; place-items:center;
  background: radial-gradient(circle at 30% 30%, rgba(255,164,97,.35), rgba(255,90,31,.10) 55%, rgba(0,0,0,.25));
  border: 1px solid rgba(255,90,31,.22);
}
.brandLogo{
  width:34px; height:34px;
  object-fit:contain;
  filter: drop-shadow(0 0 10px rgba(255,90,31,.22));
}
.brandEmoji{ font-size:22px; }
.brandTitle{ color:#fff; font-weight:700; letter-spacing:.4px; }
.brandSub{ color: rgba(255,255,255,.70); font-size: 12px; }

.menu{
  padding: 12px;
  overflow:auto;
  scrollbar-width: none;
}
.menu::-webkit-scrollbar{ width:0; height:0; }

.menu a{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 12px 14px;
  margin: 10px 0;
  border-radius: 16px;
  text-decoration:none;
  color: rgba(255,255,255,.82);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid rgba(255,90,31,.12);
  transition: transform .14s var(--ease), border-color .14s var(--ease), background .14s var(--ease);
}
.menu a:hover{
  transform: translateY(-1px);
  border-color: rgba(255,90,31,.28);
  background: linear-gradient(180deg, rgba(255,90,31,.12), rgba(255,255,255,.03));
}
.menu a.active{
  border-color: rgba(255,90,31,.45);
  box-shadow: 0 10px 30px rgba(255,90,31,.10);
}

.sidebarFoot{
  padding: 10px 14px 14px;
  border-top:1px solid rgba(255,255,255,.06);
  color: rgba(255,255,255,.65);
  font-size: 12px;
}
.footHint{ margin-top:6px; }

.stage{
  position:fixed;
  inset:0;
  z-index:2;
  display:grid;
  place-items:center;
  padding-left: 340px;
}

.bookShell{
  position:relative;
  width:min(1180px, calc(100vw - 380px));
  height:min(760px, calc(100vh - 72px));
  display:grid;
  place-items:center;
}

.bookGlow{
  position:absolute;
  inset: 10px 12px 18px;
  border-radius: calc(var(--radius) + 16px);
  background: radial-gradient(circle at 50% 20%, rgba(255,90,31,.11), rgba(0,0,0,.58) 70%);
  filter: blur(18px);
  opacity:.88;
}

.book{
  position:relative;
  width: 100%;
  height: 100%;
  perspective: 2400px;
  z-index:1;
}

.spread{
  width: 100%;
  height: 100%;
  position:relative;
  display:grid;
  grid-template-columns: 1fr 1fr;
  border-radius: var(--radius);
}

.page{
  background:
    radial-gradient(1200px 700px at 0% 0%, rgba(255,255,255,.85), transparent 55%),
    linear-gradient(180deg, var(--paper), var(--paper2));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  height: 100%;
  border-radius: var(--radius);
  padding: 44px 46px;
  overflow:hidden;
  position:relative;
}

.pageLeft{ border-top-right-radius: 12px; border-bottom-right-radius: 12px; }
.pageRight{ border-top-left-radius: 12px; border-bottom-left-radius: 12px; }

.page:before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  background:
    radial-gradient(700px 500px at 100% 50%, rgba(0,0,0,.08), transparent 55%),
    radial-gradient(700px 500px at 0% 50%, rgba(0,0,0,.06), transparent 60%);
  pointer-events:none;
}

.page:after{
  content:"";
  position:absolute;
  top:0; bottom:0;
  width:18px;
  opacity:.22;
  pointer-events:none;
}
.pageLeft:after{ right:0; background: linear-gradient(90deg, transparent, rgba(0,0,0,.22)); }
.pageRight:after{ left:0; background: linear-gradient(90deg, rgba(0,0,0,.18), transparent); }

.pageInner{
  position:relative;
  height:100%;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.h1{
  margin:0;
  font-size: 44px;
  letter-spacing:.6px;
  font-variant: small-caps;
}
.lead{
  margin: -4px 0 6px;
  opacity:.78;
  min-height: 18px;
}
.hr{
  height:1px;
  border:0;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.22), transparent);
  margin: 6px 0 10px;
}

.prose{
  font-size: 18px;
  line-height: 1.65;
  overflow:auto;
  padding-right: 6px;
  scrollbar-width: none;
}
.prose::-webkit-scrollbar{ width:0; height:0; }
.prose h2{
  margin: 18px 0 8px;
  font-size: 22px;
  letter-spacing:.4px;
  font-variant: small-caps;
}
.prose ul{ margin: 10px 0 10px 18px; }
.prose li{ margin: 8px 0; }
.prose p{ margin: 10px 0; }

.badges{
  margin-top:auto;
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  padding-top: 8px;
}
.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(255,255,255,.55);
  font-size: 13px;
}
.badgeDot{
  width:10px; height:10px;
  border-radius:999px;
  background: rgba(255,90,31,.75);
  box-shadow: 0 0 14px rgba(255,90,31,.35);
}

.figure{
  margin: 14px 0;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(255,255,255,.55);
}
.figure img{
  width:100%;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.12);
  cursor: zoom-in;
}
.figure figcaption{
  margin-top: 8px;
  font-size: 14px;
  opacity: .78;
}

/* Flip overlay */
.flipOverlay{
  position:absolute;
  top:0; bottom:0;
  width:50%;
  display:none;
  pointer-events:none;
  transform-style:preserve-3d;
  perspective:2400px;
  z-index:4;
}
.flipOverlay.on{ display:block; }
.flipCard{
  position:absolute;
  inset:0;
  transform-style:preserve-3d;
}
.flipFace{
  position:absolute;
  inset:0;
  border-radius: var(--radius);
  overflow:hidden;
  backface-visibility:hidden;
  border: 1px solid rgba(0,0,0,.12);
  box-shadow: 0 20px 70px rgba(0,0,0,.35);
  background:
    radial-gradient(900px 600px at 0% 50%, rgba(0,0,0,.10), transparent 55%),
    linear-gradient(180deg, var(--paper), var(--paper2));
}
.flipBack{
  transform: rotateY(180deg);
  background:
    radial-gradient(900px 600px at 100% 50%, rgba(0,0,0,.10), transparent 55%),
    linear-gradient(180deg, var(--paper), var(--paper2));
}

/* Lightbox */
.lightbox{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.82);
  display:none;
  align-items:center;
  justify-content:center;
  padding: 20px;
  z-index: 20;
}
.lightbox.on{ display:flex; }
.lightbox img{
  max-width: min(1200px, 92vw);
  max-height: 90vh;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 26px 80px rgba(0,0,0,.55);
  cursor: zoom-out;
}

@media (max-width: 980px){
  .sidebar{ width: 250px; }
  .stage{ padding-left: 290px; }
  .page{ padding: 34px 34px; }
  .h1{ font-size: 36px; }
  .prose{ font-size: 16px; }
}

@media (max-width: 760px){
  body{ overflow:auto; }
  .sidebar{
    position:sticky;
    inset:auto;
    width: 100%;
    border-radius: 0;
  }
  .stage{
    position:relative;
    padding-left:0;
    padding: 14px;
    height: calc(100vh - 260px);
  }
  .bookShell{
    width:100%;
    height: 62vh;
  }
  .spread{ grid-template-columns: 1fr; }
  .pageRight{ display:none; }
  .flipOverlay{ width:100%; left:0 !important; }
}