
.brand-short {
  display: none;
}
:root {
  --mat-bg: #3a5f4a;
  --mat-accent: #568368;
  --mat-line: rgba(86, 131, 104, 0.45);
  --paper-cream: #fcf9f2;
  --paper-cream-dark: #f2ebe0;
  --paper-edge: #e6dfd1;
  --text-main: #2b251f;
  --text-muted: #6e6459;
  --book-width: 440px;
  --book-height: 600px;
  --book-scale: 1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--mat-bg);
  color: #fff;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

/* CUTTING MAT SURFACE (Hallee.me Authentic Aesthetic) */
.cutting-mat {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: var(--mat-bg);
  background-image: 
    linear-gradient(to right, var(--mat-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--mat-line) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
  background-position: center center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

/* Studio Mat Alignment Marks */
.mat-border {
  position: absolute;
  inset: 18px;
  border: 1px solid var(--mat-accent);
  pointer-events: none;
  opacity: 0.6;
}

.mat-crosshair {
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
}
.mat-crosshair::before, .mat-crosshair::after {
  content: '';
  position: absolute;
  background: var(--mat-accent);
}
.mat-crosshair::before { top: 8px; left: 0; right: 0; height: 2px; }
.mat-crosshair::after  { left: 8px; top: 0; bottom: 0; width: 2px; }

.cross-tl { top: 10px; left: 10px; }
.cross-tr { top: 10px; right: 10px; }
.cross-bl { bottom: 10px; left: 10px; }
.cross-br { bottom: 10px; right: 10px; }

/* HEADER / APP BAR */
.app-header {
  position: relative;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.15);
  color: #cdecd5;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.brand-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #f7fff7;
}

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

/* FROSTED GLASS BUTTONS (Hallee.me Signature Pill Style) */
.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 
    inset 0 0.5px 0 rgba(255, 255, 255, 0.2),
    inset 0 -0.5px 0 rgba(255, 255, 255, 0.1),
    0 2px 5px rgba(0, 0, 0, 0.15);
}

.glass-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.35),
    0 4px 10px rgba(0, 0, 0, 0.2);
}

.glass-btn:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.08);
}

.glass-btn.active {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.glass-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

/* BOOKSHELF / DESK SHELF STAGE */
.shelf-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2500px;
  transform-style: preserve-3d;
  overflow: hidden;
  padding-bottom: 70px;
}

/* CLOSED BOOKS RACK (On the cutting mat) */
.books-rack {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  transform-style: preserve-3d;
  z-index: 30;
  margin: auto;
  pointer-events: auto !important;
}

.books-rack.hidden-rack {
  display: none !important;
  pointer-events: none !important;
}

/* BOOK CARD ON DESK */
.shelf-book-card {
  width: 210px;
  height: 290px;
  border-radius: 6px 14px 14px 6px;
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
  z-index: 35;
  pointer-events: auto !important;
  box-shadow: 
    0 10px 24px -4px rgba(0, 0, 0, 0.45),
    0 3px 8px rgba(0, 0, 0, 0.3),
    4px 0 0 -1px #fff,
    7px 0 0 -1px #d6cec0,
    10px 0 0 -1px #ede7db;
}

.shelf-book-card:hover {
  transform: translateY(-22px) rotateY(-8deg) scale(1.06) !important;
  z-index: 60 !important;
  box-shadow: 
    0 28px 50px -8px rgba(0, 0, 0, 0.6),
    0 8px 18px rgba(0, 0, 0, 0.4),
    5px 0 0 -1px #fff,
    9px 0 0 -1px #d6cec0,
    13px 0 0 -1px #ede7db;
}

.shelf-book-cover {
  width: 100%;
  height: 100%;
  border-radius: 6px 14px 14px 6px;
  object-fit: cover;
  display: block;
}

.shelf-book-spine {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 16px;
  background: linear-gradient(to right, rgba(0,0,0,0.4), transparent 40%, rgba(255,255,255,0.15) 80%, rgba(0,0,0,0.25) 100%);
  border-radius: 6px 0 0 6px;
  pointer-events: none;
}

.shelf-book-badge {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  text-align: left;
}

.shelf-book-badge h4 {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shelf-book-badge p {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.65);
}

/* 3D BOOK MAIN STAGE (Hallee 3D Open Book) */
.book-3d-scene {
  position: absolute;
  transform: scale(var(--book-scale));
  transform-origin: center center;
  display: none !important;
  align-items: center;
  justify-content: center;
  pointer-events: none !important;
  opacity: 0;
  z-index: 50;
  transition: opacity 0.3s ease;
  touch-action: none !important;
}

.book-3d-scene.active {
  display: flex !important;
  pointer-events: auto !important;
  opacity: 1;
}

/* THE 3D BOOK APPARATUS */
.book-3d {
  position: relative;
  width: calc(var(--book-width) * 2);
  height: var(--book-height);
  transform-style: preserve-3d;
  perspective: 2500px;
  transform-origin: center center;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  touch-action: none !important;
}

/* Under-Book Desk Shadow */
.book-desk-shadow {
  position: absolute;
  top: 15px;
  left: 10px;
  width: calc(var(--book-width) * 2 - 20px);
  height: var(--book-height);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.45);
  filter: blur(28px);
  transform: translateZ(-60px);
  pointer-events: none;
}

@media (max-width: 768px), (max-height: 550px) {
  .book-desk-shadow {
    filter: blur(16px);
    transform: translateZ(-60px);
  }
}

/* STATIC BASE PAGES (Left & Right under the leaves) */
.book-base-left, .book-base-right {
  position: absolute;
  top: 0;
  width: var(--book-width);
  height: var(--book-height);
  background-color: var(--paper-cream);
  background-image: radial-gradient(#ece4d4 0.75px, transparent 0.75px);
  background-size: 16px 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateZ(-2px);
  pointer-events: none;
}

.book-base-left {
  left: 0;
  border-radius: 16px 4px 4px 16px;
  box-shadow: 
    -2px 0 0 var(--paper-edge),
    -4px 2px 0 var(--paper-edge),
    -6px 4px 0 #ded6c8,
    -8px 6px 0 #d4ccbe,
    -10px 8px 20px rgba(0, 0, 0, 0.25);
  border-left: 2px solid rgba(0, 0, 0, 0.08);
}

.book-base-right {
  left: var(--book-width);
  border-radius: 4px 16px 16px 4px;
  box-shadow: 
    2px 0 0 var(--paper-edge),
    4px 2px 0 var(--paper-edge),
    6px 4px 0 #ded6c8,
    8px 6px 0 #d4ccbe,
    10px 8px 20px rgba(0, 0, 0, 0.25);
  border-right: 2px solid rgba(0, 0, 0, 0.08);
}

/* ACTION BUTTONS AT END OF BOOK */
.btn-flip-to-cover,
.btn-read-again {
  position: relative !important;
  z-index: 100 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  border-radius: 999px !important;
  padding: 11px 22px !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease !important;
}

.btn-flip-to-cover:hover,
.btn-read-again:hover {
  transform: scale(1.03) !important;
}

.btn-flip-to-cover:active,
.btn-read-again:active {
  transform: scale(0.97) !important;
}

.btn-flip-to-cover *,
.btn-read-again * {
  pointer-events: none !important;
}

.book-base-left .btn-flip-to-cover,
.book-base-left .btn-read-again,
.book-base-right .btn-flip-to-cover,
.book-base-right .btn-read-again {
  pointer-events: auto !important;
}

/* CENTER SPINE VALLEY / GUTTER SHADOW */
.spine-gutter {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--book-width) - 28px);
  width: 56px;
  background: 
    linear-gradient(to right, 
      transparent 0%, 
      rgba(0, 0, 0, 0.08) 35%, 
      rgba(0, 0, 0, 0.3) 49%, 
      rgba(0, 0, 0, 0.45) 50%, 
      rgba(0, 0, 0, 0.3) 51%, 
      rgba(0, 0, 0, 0.08) 65%, 
      transparent 100%);
  pointer-events: none;
  z-index: 120;
}

.spine-stitch {
  position: absolute;
  top: 15px;
  bottom: 15px;
  left: calc(var(--book-width) - 0.5px);
  width: 1px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.35) 0px,
    rgba(255, 255, 255, 0.35) 4px,
    transparent 4px,
    transparent 12px
  );
  z-index: 121;
  pointer-events: none;
}

/* 3D TURNING LEAF (Hallee.me Page Sheet Architecture) */
.page-leaf {
  position: absolute;
  top: 0;
  left: var(--book-width);
  width: var(--book-width);
  height: var(--book-height);
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: auto;
  cursor: pointer;
  will-change: transform, z-index;
  transition: transform 0.65s cubic-bezier(0.47, 0, 0.27, 1);
  contain: layout style;
}

/* Left & Right Faces of the Sheet */
.page-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: var(--paper-cream);
  color: var(--text-main);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* FRONT FACE (visible before turn - sits on right) */
.page-face.page-front {
  border-radius: 4px 16px 16px 4px;
  transform: rotateY(0deg) translateZ(0.5px);
  background: linear-gradient(to right, rgba(0, 0, 0, 0.06) 0%, transparent 12%), var(--paper-cream);
  box-shadow: inset -2px 0 6px rgba(0, 0, 0, 0.04);
}

/* BACK FACE (visible after turn - sits on left) */
.page-face.page-back {
  border-radius: 16px 4px 4px 16px;
  transform: rotateY(180deg) translateZ(0.5px);
  background: linear-gradient(to left, rgba(0, 0, 0, 0.06) 0%, transparent 12%), var(--paper-cream);
  box-shadow: inset 2px 0 6px rgba(0, 0, 0, 0.04);
}

/* DYNAMIC SHADE OVERLAY DURING TURN */
.page-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.page-front .page-shade {
  background: linear-gradient(to right, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.08) 50%, transparent 100%);
}

.page-back .page-shade {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.08) 50%, transparent 100%);
}

/* COVER LEAF (Special Hardcover Styling) */
.cover-leaf .page-front {
  background: #1e1e1e;
  border-radius: 6px 18px 18px 6px;
  box-shadow: 
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    2px 0 6px rgba(0, 0, 0, 0.35);
}

.cover-leaf .page-back {
  background: #23201d;
  border-radius: 18px 6px 6px 18px;
  color: #fff;
  border-right: 3px solid #141311;
}

.cover-image-full {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
}

/* Inside Cover Graphic/Bookplate */
.inside-cover-content {
  padding: 40px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  margin: 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.inside-cover-content h2 {
  font-size: 22px;
  font-family: 'Playfair Display', Georgia, serif;
  letter-spacing: -0.01em;
  color: #f7e6c4;
}

.inside-cover-content p {
  font-size: 13px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.75);
}

.inside-cover-bookplate {
  margin-top: auto;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d1ba95;
}

/* STORY PAGE CONTENT (ILLUSTRATION & TEXT LAYOUTS) */
.page-content-wrapper {
  padding: 28px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.page-header-small {
  position: absolute;
  top: 16px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.page-front .page-header-small { right: 24px; }
.page-back .page-header-small { left: 24px; }

.page-number-footer {
  position: absolute;
  bottom: 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.page-front .page-number-footer { right: 24px; }
.page-back .page-number-footer { left: 24px; }

/* Image layout on page */
.page-illustration-card {
  width: 100%;
  height: 100%;
  max-height: 480px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-illustration-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
}

/* Typography on page */
.story-text-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.story-heading {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  color: #1f1b16;
}

.story-sound-effect {
  display: inline-block;
  font-size: 20px;
  font-weight: 800;
  font-family: 'Fredoka', 'DM Sans', sans-serif;
  color: #c94a29;
  letter-spacing: 0.04em;
  transform: rotate(-2deg);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.08);
}

.story-paragraph {
  font-size: 14.5px;
  line-height: 1.65;
  color: #383129;
}

/* JUMBO GREETING PILLS & VERSES */
.jumbo-greeting-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #ffebe9;
  border-radius: 999px;
  border: 1px solid #ffb8b2;
  margin: 6px 0;
  width: fit-content;
}
.jumbo-greet-word {
  font-weight: 700;
  font-size: 15.5px;
  color: #c93628;
}
.jumbo-greet-pronun {
  font-size: 12px;
  color: #88443e;
  font-style: italic;
}
.jumbo-verse {
  margin: 4px 0;
}

/* BOTTOM FLOATING CONTROL DOCK (Hallee.me Style) */
.dock-container {
  position: fixed;
  bottom: 24px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 200;
}

.dock-bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(18, 26, 21, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 
    0 16px 36px rgba(0, 0, 0, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.dock-counter {
  font-size: 13px;
  font-weight: 600;
  color: #e5f6e8;
  padding: 0 12px;
  letter-spacing: 0.02em;
  min-width: 120px;
  text-align: center;
}

/* MODAL / TABLE OF CONTENTS DRAWER */
.toc-popover {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  width: 380px;
  max-height: 440px;
  border-radius: 18px;
  background: rgba(22, 33, 27, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 300;
}

.toc-popover.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toc-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.toc-list {
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.toc-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateX(4px);
}

.toc-item.active {
  background: rgba(86, 131, 104, 0.4);
  color: #79f59f;
  font-weight: 600;
}

/* HELPER POPUP TOAST (Hallee Paper Toast) */
.paper-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px) rotate(0deg);
  z-index: 999;
  background: #fbf5e7;
  color: #2b251f;
  padding: 14px 24px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 
    0 12px 28px rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.15);
  border: 1px solid #d4cbb8;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.paper-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0) rotate(-1.5deg);
}

/* MOBILE & RESPONSIVE SCALING */
@media (max-width: 950px) {
  .shelf-book-card {
    width: 160px;
    height: 220px;
  }
}

@media (max-width: 680px) {
  /* Header adjustments for small screens */
  .app-header {
    height: 50px !important;
    padding: 0 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 6px !important;
  }
  .brand {
    flex-shrink: 0 !important;
  }
  .brand-long {
    display: none !important;
  }
  .brand-short {
    display: inline-block !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em !important;
  }
  .brand-title {
    white-space: nowrap !important;
    display: inline-block !important;
  }
  .header-controls {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 1 !important;
  }
  .book-selector {
    max-width: 135px !important;
    padding: 4px 6px !important;
    font-size: 11px !important;
  }
  .sound-toggle-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }
  .sound-label {
    display: none !important;
  }

  /* 2x2 Symmetrical Centered Grid for Bookshelf with Clear Cross Section */
  .books-rack {
    position: relative !important;
    left: auto !important;
    transform: none !important;
    display: grid !important;
    grid-template-columns: repeat(2, 138px) !important;
    justify-content: center !important;
    column-gap: 28px !important;
    row-gap: 44px !important;
    padding: 16px 8px !important;
    width: auto !important;
    margin: auto !important;
    perspective: 800px;
  }
  .shelf-book-card {
    width: 138px !important;
    height: 192px !important;
    margin: 0 !important;
  }
  /* Mobile touch tap/hover: scale in place without translateY or rotateY so it NEVER overlaps the row above */
  .shelf-book-card:hover,
  .shelf-book-card:active {
    transform: scale(1.035) !important;
    z-index: 40 !important;
    box-shadow: 
      0 16px 32px -4px rgba(0, 0, 0, 0.6),
      0 4px 12px rgba(0, 0, 0, 0.4),
      4px 0 0 -1px #fff,
      7px 0 0 -1px #d6cec0,
      10px 0 0 -1px #ede7db !important;
  }
  .shelf-book-badge {
    bottom: 8px;
    left: 8px;
    right: 8px;
    padding: 6px 8px;
  }
  .shelf-book-badge h4 {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shelf-book-badge p {
    font-size: 9px;
  }

  /* Mobile floating dock */
  .dock-container {
    bottom: 12px;
    padding: 3px 6px;
    gap: 4px;
    max-width: 95vw;
    border-radius: 999px;
  }
  .dock-bar {
    gap: 4px;
  }
  .dock-counter {
    font-size: 11px;
    min-width: 65px;
    padding: 0 4px;
  }
  .glass-btn {
    padding: 6px 9px;
    font-size: 11px;
  }
  .glass-icon-btn {
    width: 34px;
    height: 34px;
    padding: 0;
  }
  .dock-btn-text {
    display: none; /* Hide label text on mobile dock */
  }

  /* Content readability on mobile */
  .page-content-wrapper {
    padding: 20px 16px;
  }
  .story-heading {
    font-size: 21px;
    line-height: 1.2;
  }
  .story-paragraph {
    font-size: 13px;
    line-height: 1.45;
  }
  .jumbo-greeting-pill {
    padding: 6px 12px;
  }
  .jumbo-greet-word {
    font-size: 20px;
  }
}

/* Text container safety for longer appendices */
.story-text-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}
.story-text-container::-webkit-scrollbar {
  display: none;
}

/* Flip to cover buttons */
.btn-flip-to-cover {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  font-size: 13.5px !important;
  padding: 10px 22px !important;
  border-radius: 999px !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
  pointer-events: auto !important;
  z-index: 150 !important;
}

.btn-flip-to-cover svg {
  pointer-events: none !important;
}

.btn-flip-to-cover:hover {
  transform: translateY(-2px) scale(1.04) !important;
  box-shadow: 0 8px 22px rgba(0,0,0,0.3) !important;
}

.btn-read-again {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  font-size: 13.5px !important;
  padding: 10px 22px !important;
  border-radius: 999px !important;
  transition: all 0.2s ease !important;
  pointer-events: auto !important;
  z-index: 150 !important;
}
.btn-read-again:hover {
  transform: translateY(-2px) scale(1.03) !important;
  background: rgba(0, 0, 0, 0.12) !important;
}
.btn-read-again svg {
  pointer-events: none !important;
}

/* FULLSCREEN READING MODE */
:fullscreen,
:-webkit-full-screen,
body.fullscreen-active {
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}

body.fullscreen-active .cutting-mat {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}

/* Header subtle fade in fullscreen so reader is immersed in pages */
:fullscreen .app-header,
:-webkit-full-screen .app-header,
body.fullscreen-active .app-header {
  opacity: 0.25;
  transition: opacity 0.3s ease;
}
:fullscreen .app-header:hover,
:-webkit-full-screen .app-header:hover,
body.fullscreen-active .app-header:hover {
  opacity: 1;
}

/* MOBILE LANDSCAPE FULLSCREEN (Enlarged book flips to the right and opens in landscape reading mode) */
body.mobile-landscape-active {
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}

body.mobile-landscape-active .cutting-mat {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}

body.mobile-landscape-active .book-3d {
  transform: rotate(90deg) !important;
}

body.mobile-landscape-active .app-header {
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* In rotated landscape mode, position dock along the left edge (which becomes the bottom edge when the phone is turned horizontally) */
body.mobile-landscape-active .dock-container {
  position: fixed !important;
  left: 0 !important;
  top: 50% !important;
  bottom: auto !important;
  right: auto !important;
  width: 44px !important;
  height: 320px !important;
  transform: translateY(-50%) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 250 !important;
  padding: 0 !important;
  pointer-events: none !important;
}

body.mobile-landscape-active .dock-bar {
  transform: rotate(90deg) !important;
  transform-origin: center center !important;
  gap: 5px !important;
  padding: 4px 8px !important;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7) !important;
  pointer-events: auto !important;
}

body.mobile-landscape-active .dock-counter {
  font-size: 11px !important;
  min-width: 65px !important;
  padding: 0 4px !important;
}

body.mobile-landscape-active .toc-popover.open {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) rotate(90deg) !important;
  max-height: 75vw !important;
  width: 75vh !important;
  z-index: 350 !important;
}

/* NATIVE / PHYSICAL LANDSCAPE FULLSCREEN (when device is physically rotated) */
@media (max-height: 550px) and (orientation: landscape) {
  body.fullscreen-active .app-header {
    opacity: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
  }
  body.fullscreen-active .dock-container {
    bottom: 6px !important;
    padding: 2px 6px !important;
  }
}

/* FLOATING ZOOM INDICATOR PILL */
.book-zoom-indicator {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 5px 14px;
  color: #fff;
  font-family: 'DM Sans', -apple-system, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.book-zoom-indicator.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.btn-reset-zoom {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 999px;
  color: #fff;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  cursor: pointer;
  transition: background 0.15s ease;
  touch-action: manipulation;
}

.btn-reset-zoom:active,
.btn-reset-zoom:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* In rotated landscape mode, position zoom pill along right edge */
body.mobile-landscape-active .book-zoom-indicator {
  top: 50%;
  left: auto;
  right: 14px;
  transform: translateY(-50%) rotate(90deg) translateY(10px);
}

body.mobile-landscape-active .book-zoom-indicator.visible {
  transform: translateY(-50%) rotate(90deg) translateY(0);
}

/* In rotated landscape mode, align toast with landscape reading direction */
body.mobile-landscape-active .paper-toast {
  top: 50% !important;
  left: auto !important;
  right: 18px !important;
  transform: translateY(-50%) rotate(90deg) translateY(-80px) !important;
}

body.mobile-landscape-active .paper-toast.visible {
  transform: translateY(-50%) rotate(90deg) translateY(0) !important;
}
