/* ========================================================
   THE COZY NOOK - Hand-drawn Cozy Bookshelf Stylesheet
   Restored from approved prototype handdrawn_cozy_shelf.html
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Gaegu:wght@400;700&family=Patrick+Hand&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --ink: #2c221e;
  --paper: #fbf5e8;
  --paper-warm: #f4ecdc;
  --wood: #d4a373;
  --wood-dark: #b07d56;
  --wood-shadow: #8c5836;
  --terracotta: #e07a5f;
  --matcha: #81b29a;
  --honey: #f2cc8f;
  --periwinkle: #9d8189;
  --sky: #8ecae6;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Patrick Hand', cursive, sans-serif;
  background-color: #f7f1e5;
  background-image: 
    radial-gradient(#e5dbc9 1px, transparent 1px),
    radial-gradient(#e5dbc9 1px, #f7f1e5 1px);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  color: var(--ink);
  overflow-x: hidden;
  min-height: 100vh;
}

.font-gaegu { font-family: 'Gaegu', cursive; }
.font-lora { font-family: 'Lora', Georgia, serif; }

/* Hand-drawn wobbly border magic */
.wobbly-border {
  border: 2.5px solid var(--ink);
  border-radius: 255px 18px 225px 15px / 15px 225px 18px 255px;
}

.wobbly-pill {
  border: 2px solid var(--ink);
  border-radius: 255px 25px 225px 25px / 25px 225px 25px 255px;
}

/* UIverse Handcrafted Tactile Button */
.hand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--honey);
  border: 2.5px solid var(--ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  box-shadow: 3px 3px 0px var(--ink);
  padding: 8px 18px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}

.hand-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0px var(--ink);
}

.hand-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px var(--ink);
}

.hand-btn-terracotta {
  background-color: var(--terracotta);
  color: #fff;
}

.hand-btn-matcha {
  background-color: var(--matcha);
  color: #fff;
}

.hand-btn-honey {
  background-color: var(--honey);
  color: var(--ink);
}

.hand-btn-sm {
  padding: 5px 12px;
  font-size: 0.95rem;
}

/* Tactile Paper Tags */
.paper-tag {
  background: #fffdf7;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0px var(--ink);
  border-radius: 4px;
}

/* Handcrafted Wooden Bookcase Frame & Shelves */
.wooden-bookcase {
  position: relative;
  background: linear-gradient(180deg, #a87449 0%, #99653c 100%);
  border: 3px solid var(--ink);
  border-radius: 14px 14px 10px 10px;
  box-shadow: 7px 7px 0px var(--ink);
  padding: 0 18px 18px 18px;
  transition: background 0.25s ease;
}

.bookcase-crown {
  height: 18px;
  margin: 0 -18px;
  background: linear-gradient(180deg, #b98558 0%, #966238 100%);
  border-bottom: 2.5px solid var(--ink);
  border-radius: 11px 11px 0 0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.bookcase-bay {
  position: relative;
  height: 292px;
  max-height: 292px;
  padding: 8px 10px 2px 10px;
  background-color: #f4e8d6;
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(138, 90, 54, 0.05) 0px,
      rgba(138, 90, 54, 0.05) 2px,
      transparent 2px,
      transparent 48px
    );
  border-left: 2.5px solid var(--ink);
  border-right: 2.5px solid var(--ink);
  box-shadow:
    inset 0 16px 22px rgba(44, 34, 30, 0.16),
    inset 12px 0 16px rgba(44, 34, 30, 0.11),
    inset -12px 0 16px rgba(44, 34, 30, 0.11);
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 4px;
  overflow: visible;
}

/* Solid Wooden Shelf Plank spanning between the bookcase walls */
.sketch-shelf {
  position: relative;
  background: linear-gradient(180deg, #c69264 0%, #ad794d 35%, #966239 100%);
  border: 2.5px solid var(--ink);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    0 5px 0px #704726,
    0 7.5px 0px var(--ink);
  height: 26px;
  z-index: 5;
}

/* Wood Stain Finish 2: Deep Library Walnut */
.wooden-bookcase.wood-walnut {
  background: linear-gradient(180deg, #5c3d28 0%, #482e1d 100%);
}
.wooden-bookcase.wood-walnut .bookcase-crown {
  background: linear-gradient(180deg, #6b4730 0%, #4a301f 100%);
}
.wooden-bookcase.wood-walnut .bookcase-bay {
  background-color: #e6d5bf;
  box-shadow:
    inset 0 18px 24px rgba(32, 20, 12, 0.24),
    inset 14px 0 18px rgba(32, 20, 12, 0.16),
    inset -14px 0 18px rgba(32, 20, 12, 0.16);
}
.wooden-bookcase.wood-walnut .sketch-shelf {
  background: linear-gradient(180deg, #734d34 0%, #593a26 40%, #42291a 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.2),
    0 5px 0px #2e1b10,
    0 7.5px 0px var(--ink);
}

/* Wood Stain Finish 3: Cottage Sage Pine */
.wooden-bookcase.wood-sage {
  background: linear-gradient(180deg, #74927f 0%, #5f7c6a 100%);
}
.wooden-bookcase.wood-sage .bookcase-crown {
  background: linear-gradient(180deg, #86a591 0%, #64816f 100%);
}
.wooden-bookcase.wood-sage .bookcase-bay {
  background-color: #f4f1e6;
  box-shadow:
    inset 0 16px 22px rgba(36, 52, 42, 0.15),
    inset 12px 0 16px rgba(36, 52, 42, 0.10),
    inset -12px 0 16px rgba(36, 52, 42, 0.10);
}
.wooden-bookcase.wood-sage .sketch-shelf {
  background: linear-gradient(180deg, #88a793 0%, #718f7c 40%, #5a7564 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    0 5px 0px #415749,
    0 7.5px 0px var(--ink);
}

.plank-plate {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #fdf6e4;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  padding: 0px 9px;
  font-size: 10.5px;
  font-weight: 700;
  color: #3d2e24;
  letter-spacing: 0.03em;
  box-shadow: 1px 1px 0px var(--ink);
  user-select: none;
}

/* Wood grain hand-drawn squiggles */
.wood-knot {
  position: absolute;
  width: 14px;
  height: 6px;
  border: 1.5px solid rgba(44, 34, 30, 0.4);
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
}

/* ===================================================
   HAND-DRAWN BOOKS ON SHELF
   =================================================== */
.doodle-book {
  position: relative;
  cursor: pointer;
  transform-origin: bottom center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
  flex-shrink: 0;
  user-select: none;
}

.doodle-book:hover {
  transform: translateY(-22px) rotate(2deg) scale(1.05);
  z-index: 30;
}

.doodle-book:hover .hover-tooltip {
  opacity: 1;
  transform: translate(-50%, -10px);
}

/* Style 1: Handcrafted Vector Book Spine */
.book-body {
  border: 2.5px solid #231815;
  box-shadow:
    inset 3.5px 0 0 rgba(255, 255, 255, 0.22),
    inset -3.5px 0 0 rgba(0, 0, 0, 0.14),
    2.5px 3px 0px #231815;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  padding: 5px 4px;
  position: relative;
  overflow: visible;
}

/* Fixed-aspect Top & Bottom SVG Ornament Caps (never stretch or squish) */
.vector-cap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  pointer-events: none;
}

.vector-cap svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* Center compartment zone holding the vector plaque/cameo/medallion */
.vector-center-zone {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 1px;
  position: relative;
}

/* Ornate Vector Plaque Variants */
.vector-plaque {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 3px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease;
}

.vector-plaque.plaque-rect {
  border-radius: 4px;
  border: 1.6px solid var(--plaque-stroke, currentColor);
  background: var(--plaque-bg, rgba(255, 253, 247, 0.2));
}

.vector-plaque.plaque-double {
  border-radius: 3px;
  border: 1.8px solid var(--plaque-stroke, currentColor);
  background: var(--plaque-bg, rgba(255, 253, 247, 0.3));
  box-shadow: inset 0 0 0 2px transparent, inset 0 0 0 3px var(--plaque-stroke, currentColor);
  padding: 8px 4px;
}

.vector-plaque.plaque-cameo {
  border-radius: 999px;
  border: 2.2px solid var(--plaque-stroke, currentColor);
  background: var(--plaque-bg, rgba(255, 253, 247, 0.24));
  box-shadow: inset 0 0 0 2.5px var(--spine-bg, transparent), inset 0 0 0 3.7px var(--plaque-inner-stroke, currentColor);
  padding: 12px 4px;
  min-height: 82px;
}

.vector-plaque.plaque-medallion {
  border-radius: 6px;
  border: 1.8px solid var(--plaque-stroke, currentColor);
  background: var(--plaque-bg, rgba(0, 0, 0, 0.22));
  box-shadow: inset 0 0 0 2px var(--spine-bg, transparent), inset 0 0 0 3px var(--plaque-stroke, currentColor);
  padding: 7px 3px;
}

.vector-plaque.plaque-arch {
  border-radius: 9px;
  border: 2px solid var(--plaque-stroke, currentColor);
  background: var(--plaque-bg, rgba(0, 0, 0, 0.2));
  padding: 7px 3px;
}

.vector-plaque.plaque-open {
  border: none;
  background: transparent;
  padding: 4px 2px;
}

.vector-plaque.plaque-stamp {
  border-radius: 3.5px;
  border: 1.8px solid #231815;
  background: var(--plaque-bg, #542e0e);
  padding: 6px 3px;
}

/* Smart Responsive Vector Spine Title & Author Typography */
.spine-title-text {
  font-family: 'Cinzel', 'Lora', Georgia, serif;
  font-weight: 700;
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
  width: 100%;
}

/* Subtle ornamental divider rule inside spine plaque */
.spine-divider {
  width: 56%;
  height: 1.2px;
  background: currentColor;
  opacity: 0.55;
  margin: 3px auto 2px;
  flex-shrink: 0;
}

/* Author compartment inside or below vector plaque */
.spine-author-frame {
  padding: 1px 2px 0;
  text-align: center;
  flex-shrink: 0;
  width: 100%;
}

.spine-author-text {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 8.5px;
  line-height: 1.15;
  opacity: 0.94;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* Style 2: Front-Facing Book Cover */
.book-front-cover {
  width: 140px;
  height: 200px;
  border: 2.5px solid var(--ink);
  border-radius: 6px 10px 10px 6px;
  box-shadow: inset 10px 0 0 rgba(0,0,0,0.18), 3px 3px 0px var(--ink);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

/* Style 3: Leaning Book (rests snugly against adjacent leaning or standing books) */
.doodle-book.is-leaning {
  transform: rotate(8.5deg);
  transform-origin: bottom left;
  margin-right: 26px;
}

/* Consecutive leaning books are parallel, so tuck them right against each other */
.doodle-book.is-leaning:has(+ .doodle-book.is-leaning) {
  margin-right: -3px;
}

.doodle-book.is-leaning:hover {
  transform: translateY(-20px) rotate(8.5deg) scale(1.04);
}

/* Style 4: Stacked Book Layer (Vector Horizontal Stack Styling) */
.stack-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  padding-bottom: 1px;
  margin-right: 4px;
  flex-shrink: 0;
  position: relative;
}

.stack-top-spines {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 168px;
  margin-bottom: 1px;
}

.stack-group > .doodle-book:hover {
  transform: translateY(-4px) scale(1.03);
  z-index: 35;
}

.stack-top-spines .doodle-book:hover {
  transform: translateY(-10px) scale(1.04);
  z-index: 40;
}

.stack-layer {
  border: 2.5px solid #231815;
  border-radius: 5px;
  box-shadow:
    inset 0 2.5px 0 rgba(255, 255, 255, 0.22),
    inset 0 -2.5px 0 rgba(0, 0, 0, 0.14),
    2px 2.5px 0px #231815;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 5px;
  height: 33px;
  width: 168px;
  position: relative;
  overflow: hidden;
}

.stack-vector-endcap {
  width: 24px;
  height: 25px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.stack-vector-endcap svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Ribbon bookmark dangling down (reflects reading progress) */
.dangle-ribbon {
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 11px;
  background: var(--terracotta);
  border: 1.5px solid var(--ink);
  border-top: none;
  border-radius: 0 0 3px 3px;
  z-index: 5;
  transition: height 0.2s ease, background-color 0.2s ease;
}

.dangle-ribbon.in-progress {
  height: 16px;
  bottom: -14px;
}

.dangle-ribbon.is-completed {
  width: 8px;
  height: 18px;
  bottom: -16px;
  background: linear-gradient(180deg, #f9d46b 0%, #e5a93b 100%) !important;
  box-shadow: 0 1px 0 var(--ink);
}

/* Cozy Brass Bookend / Shelf Trinket */
.shelf-bookend {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  margin-left: 2px;
  margin-right: 4px;
  user-select: none;
}

.brass-arch {
  width: 34px;
  height: 62px;
  background: linear-gradient(145deg, #ecc877 0%, #c99a3e 65%, #a47826 100%);
  border: 2.5px solid var(--ink);
  border-radius: 20px 20px 3px 3px;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.35), 2px 2px 0 var(--ink);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brass-arch::after {
  content: '';
  width: 16px;
  height: 36px;
  border: 1.5px solid rgba(44, 34, 30, 0.45);
  border-radius: 10px 10px 2px 2px;
}

.brass-base {
  width: 44px;
  height: 7px;
  background: #9c7121;
  border: 2px solid var(--ink);
  border-radius: 2px;
}

/* Hover Tooltip: Hand-drawn Speech Bubble */
.hover-tooltip {
  position: absolute;
  top: -38px;
  left: 50%;
  transform: translate(-50%, 0);
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0px var(--ink);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 50;
}

.hover-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 5px 0;
  border-style: solid;
  border-color: var(--ink) transparent;
  display: block;
  width: 0;
}

/* Wobbly Tape decoration */
.washi-tape {
  background: rgba(242, 204, 143, 0.65);
  border: 1px dashed rgba(44, 34, 30, 0.3);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  pointer-events: none;
}

/* Hand-drawn Cozy Napping Cat Animation (Authentic Pixel-art from Free Pack) */
.cozy-cat-container {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  margin-top: -44px;
  margin-bottom: -12px; /* Places bottom-aligned cat belly & paws right onto the wooden shelftop plank */
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 20;
}

.cozy-cat-container:hover {
  transform: translateY(-2px) scale(1.03);
}

.cozy-cat-container:active {
  transform: translateY(0px) scale(0.97);
}

.cozy-cat-container:hover .cat-purr-bubble {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.cat-purr-bubble {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #fffdf7;
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: #5c4738;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}

.cat-purr-bubble::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px 4px 0;
  border-style: solid;
  border-color: var(--ink) transparent;
  display: block;
}

/* Pixel Cat Sprite Rendering (4x integer scale: 128x128px) */
.pixel-cat-sprite {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-size: 256px 128px; /* 2 frames of 128x128 */
  background-repeat: no-repeat;
  background-position: 0 0;
  filter: drop-shadow(2px 3px 0px rgba(44, 34, 30, 0.28));
}

/* Sleeping Cat Poses & Animations */
.pose-curled {
  background-image: url('../images/cat_curled.png');
  animation: catSleepBreathe 2.4s steps(1) infinite;
}

.pose-stretched {
  background-image: url('../images/cat_stretched.png');
  animation: catSleepBreathe 2.4s steps(1) infinite;
}

.pose-loaf {
  background-image: url('../images/cat_loaf.png');
  animation: catSleepBreathe 2.4s steps(1) infinite;
}

.pose-sitting {
  background-image: url('../images/cat_sitting.png');
  background-size: 512px 128px; /* 4 frames of 128x128 */
  animation: catTailWag 2s steps(4) infinite;
}

.pose-calico {
  background-image: url('../images/cat_calico_curled.png');
  animation: catSleepBreathe 2.4s steps(1) infinite;
}

.pose-midnight {
  background-image: url('../images/cat_black_curled.png');
  animation: catSleepBreathe 2.4s steps(1) infinite;
}

@keyframes catSleepBreathe {
  0%, 49.9% { background-position: 0 0; }
  50%, 100% { background-position: -128px 0; }
}

@keyframes catTailWag {
  from { background-position: 0 0; }
  to { background-position: -512px 0; }
}

/* Floating Zzz's Cluster */
.zzz-cluster {
  position: absolute;
  top: 52px;
  right: 12px;
  pointer-events: none;
  z-index: 25;
}

.cat-z {
  position: absolute;
  font-family: 'Lora', Georgia, serif;
  font-weight: 700;
  color: #78593e;
  opacity: 0;
}

/* Cat breathing animation (belly rises and falls gently) */
@keyframes catBellyBreathe {
  0%, 100% {
    transform: scale(1, 1);
  }
  50% {
    transform: scale(1.04, 1.05) translateY(-1px);
  }
}

.cat-body-breathing {
  transform-origin: 50px 30px;
  animation: catBellyBreathe 3.4s ease-in-out infinite;
}

/* Cat tail subtle flick/wag while napping */
@keyframes catTailSway {
  0%, 100% {
    transform: rotate(0deg);
  }
  30% {
    transform: rotate(-6deg);
  }
  60% {
    transform: rotate(4deg);
  }
}

.cat-tail-sway {
  transform-origin: 82px 30px;
  animation: catTailSway 5s ease-in-out infinite;
}

/* Floating Zzz animation */
@keyframes floatZ1 {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.6);
  }
  35% {
    opacity: 0.95;
  }
  80% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translate(-10px, -18px) scale(1.1);
  }
}

@keyframes floatZ2 {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.6);
  }
  45% {
    opacity: 0.95;
  }
  85% {
    opacity: 0.7;
  }
  100% {
    opacity: 0;
    transform: translate(-14px, -24px) scale(1.25);
  }
}

@keyframes floatZ3 {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.6);
  }
  40% {
    opacity: 0.95;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translate(-18px, -30px) scale(1.4);
  }
}

.cat-z1 {
  font-size: 11px;
  left: 0;
  top: 0;
  animation: floatZ1 3.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.cat-z2 {
  font-size: 13px;
  left: -6px;
  top: -6px;
  animation: floatZ2 3.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  animation-delay: 1.05s;
}

.cat-z3 {
  font-size: 16px;
  left: -12px;
  top: -14px;
  animation: floatZ3 3.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  animation-delay: 2.1s;
}

/* Book Stage Modal (Pop-out Animation) */
.modal-backdrop {
  background: rgba(44, 34, 30, 0.45);
  backdrop-filter: blur(4px);
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
}

.bounce-in {
  animation: popOpen 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popOpen {
  0% { transform: scale(0.7) translateY(40px) rotate(-3deg); opacity: 0; }
  100% { transform: scale(1) translateY(0) rotate(0deg); opacity: 1; }
}

/* Shelf Filter Pills */
.shelf-pill {
  padding: 4px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 255px 25px 225px 25px / 25px 225px 25px 255px;
  box-shadow: 2px 2px 0px var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.shelf-pill:hover {
  background: #faedcd;
}

.shelf-pill.active {
  background: #f4a261;
  color: var(--ink);
}

/* Search Box */
.search-box-wrap {
  position: relative;
  max-width: 320px;
  width: 100%;
}

.search-box-wrap input {
  width: 100%;
  padding: 6px 36px 6px 14px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 255px 20px 225px 20px / 20px 225px 20px 255px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  box-shadow: 2px 2px 0px var(--ink);
  outline: none;
}

.search-icon-decor {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.toast {
  background: #fffdf9;
  border: 2.5px solid var(--ink);
  box-shadow: 4px 4px 0px var(--ink);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Cozy Soft Scrollbar (replaces clunky default scrollbars) */
.cozy-scroll,
#shelvesContainer div {
  scrollbar-width: thin;
  scrollbar-color: #d6c5b3 transparent;
}

.cozy-scroll::-webkit-scrollbar,
#shelvesContainer div::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.cozy-scroll::-webkit-scrollbar-track,
#shelvesContainer div::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}

.cozy-scroll::-webkit-scrollbar-thumb,
#shelvesContainer div::-webkit-scrollbar-thumb {
  background: #d6c5b3;
  border-radius: 999px;
}

.cozy-scroll::-webkit-scrollbar-thumb:hover,
#shelvesContainer div::-webkit-scrollbar-thumb:hover {
  background: #b59d84;
}

.cozy-scroll::-webkit-scrollbar-button,
#shelvesContainer div::-webkit-scrollbar-button {
  display: none;
}

/* ===================================================
   COZY HOUSEPLANTS GREENHOUSE TRAY & SHELF DECORATOR
   =================================================== */
.pixel-art-img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  user-select: none;
  -webkit-user-drag: none;
}

.plant-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  max-height: 224px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  padding: 4px 2px;
}

.plant-tray-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  background: #fdf8ee;
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 2px 2px 0px var(--ink);
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.plant-tray-item:hover {
  background: #e9f5db;
  transform: translateY(-2px);
  box-shadow: 3px 4px 0px var(--ink);
}

.plant-tray-item:active {
  cursor: grabbing;
  transform: translateY(0px) scale(0.96);
}

.plant-tray-item img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  filter: drop-shadow(1.5px 2px 0px rgba(44, 34, 30, 0.25));
}

.plant-tray-name {
  font-size: 11px;
  font-weight: 700;
  color: #3d2e24;
  text-align: center;
  line-height: 1.1;
  margin-top: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Placed Plant on the Bookcase */
.placed-plant {
  position: absolute;
  cursor: grab;
  user-select: none;
  touch-action: none;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: filter 0.15s ease;
}

.placed-plant:hover {
  z-index: 48;
  filter: drop-shadow(0 0 4px rgba(255, 253, 247, 0.65));
}

.placed-plant.is-dragging {
  cursor: grabbing;
  z-index: 60;
  opacity: 0.92;
  transform: scale(1.06);
}

.placed-plant-sprite {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  filter: drop-shadow(2px 3px 0px rgba(44, 34, 30, 0.32));
  transition: width 0.15s ease, height 0.15s ease, transform 0.15s ease;
}

.placed-plant-sprite.is-flipped {
  transform: scaleX(-1);
}

/* Hover & Active Action Toolbar on Placed Plant */
.plant-action-bar {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fffdf9;
  border: 2px solid var(--ink);
  box-shadow: 2px 3px 0px var(--ink);
  border-radius: 999px;
  padding: 3px 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  z-index: 55;
}

/* Invisible hover bridge so moving the cursor from plant to toolbar never drops hover */
.plant-action-bar::after {
  content: '';
  position: absolute;
  left: -14px;
  right: -14px;
  top: 100%;
  height: 34px;
  background: transparent;
}

.placed-plant:hover .plant-action-bar,
.placed-plant.is-hovered .plant-action-bar,
.placed-plant.is-active .plant-action-bar {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.placed-plant.is-active {
  z-index: 52;
  filter: drop-shadow(0 0 5px rgba(255, 253, 247, 0.85));
}

.placed-plant.is-dragging .plant-action-bar {
  opacity: 0 !important;
  pointer-events: none !important;
}

.plant-ctrl-btn {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  background: #f4e8d6;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.12s ease;
  user-select: none;
}

.plant-ctrl-btn img {
  display: block;
  pointer-events: none;
}

.plant-ctrl-btn:hover {
  background: #deb887;
  transform: scale(1.08);
}

.plant-ctrl-btn.btn-del:hover {
  background: #e07a5f;
  color: #fff;
  border-color: #2c221e;
}

.plant-ctrl-btn.btn-del:hover img {
  filter: brightness(0) invert(1);
}

/* Floating Drag Ghost when dragging from Tray onto Bookcase */
.plant-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(3px 5px 0px rgba(44, 34, 30, 0.35));
  transform: translate(-50%, -85%) scale(1.08);
}

/* Curated Decor Category & Target Spot Pills */
.decor-cat-pill,
.plant-preset-pill,
.plant-spot-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  background: #fdf8ee;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 2px 9px;
  box-shadow: 1.5px 1.5px 0px var(--ink);
  cursor: pointer;
  transition: all 0.14s ease;
  user-select: none;
}

.decor-cat-pill:hover,
.plant-preset-pill:hover,
.plant-spot-pill:hover {
  background: #faedcd;
  transform: translateY(-1px);
}

.decor-cat-pill.active {
  background: var(--honey);
  color: var(--ink);
  transform: translateY(1px);
  box-shadow: 0.5px 0.5px 0px var(--ink);
}

.plant-preset-pill.active,
.plant-spot-pill.active {
  background: var(--matcha);
  color: var(--ink);
  transform: translateY(1px);
  box-shadow: 0.5px 0.5px 0px var(--ink);
}

/* Interactive "+ Plant Spot" Guide Markers on the Bookcase */
.shelf-plant-spot-marker {
  position: absolute;
  width: 58px;
  height: 58px;
  border: 2px dashed rgba(61, 90, 69, 0.65);
  background: rgba(226, 240, 203, 0.38);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #2d4734;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  line-height: 1.1;
  cursor: pointer;
  z-index: 32;
  user-select: none;
  transition: all 0.18s ease;
  padding: 3px;
}

.shelf-plant-spot-marker:hover,
.shelf-plant-spot-marker.is-targeted {
  background: rgba(197, 228, 165, 0.78);
  border-color: var(--ink);
  border-style: solid;
  box-shadow: 2px 2px 0px var(--ink);
  transform: translateY(-2px) scale(1.04);
}

/* ===================================================
   MOBILE RETRACTABLE SIDE PANEL & TABLET/PHONE SCALING
   =================================================== */

.mobile-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 34, 30, 0.42);
  backdrop-filter: blur(2px);
  z-index: 65;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.mobile-sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* On Mobile (< 768px), transform the Top Header into a Retractable Left Side Panel Drawer */
@media (max-width: 767px) {
  .cozy-nav-panel {
    position: fixed !important;
    top: 12px;
    bottom: 12px;
    left: 12px;
    width: min(84vw, 292px);
    margin-bottom: 0 !important;
    padding: 18px 16px !important;
    border-radius: 18px !important;
    border: 3px solid var(--ink) !important;
    box-shadow: 6px 7px 0px var(--ink) !important;
    z-index: 70;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: visible;
    transform: translateX(calc(-100% - 14px));
    transition: transform 0.34s cubic-bezier(0.32, 1.25, 0.64, 1);
  }

  .cozy-nav-panel.is-open {
    transform: translateX(0);
  }

  /* Tactile pull-tab protruding on the right edge of the retracted mobile side panel */
  .mobile-pull-tab {
    position: absolute;
    top: 84px;
    right: -38px;
    width: 38px;
    height: 46px;
    background: #fffdf9;
    border: 2.5px solid var(--ink);
    border-left: none;
    border-radius: 0 12px 12px 0;
    box-shadow: 3px 3px 0px var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 900;
    color: var(--ink);
    cursor: pointer;
    z-index: 72;
  }

  .mobile-pull-tab:active {
    background: #faedcd;
  }

  .cozy-nav-filters {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px !important;
    flex: 1;
    overflow-y: auto;
  }

  .search-box-wrap {
    max-width: 100%;
  }

  .cozy-shelf-pills {
    flex-direction: column;
    align-items: stretch !important;
    overflow-x: visible !important;
    gap: 6px !important;
  }

  .cozy-shelf-pills .shelf-pill {
    width: 100%;
    text-align: left;
    padding: 7px 14px;
    font-size: 0.98rem;
  }
}

/* Tablet Bookcase Scaling (640px - 1023px) */
@media (max-width: 1023px) {
  .bookcase-bay {
    height: 268px;
    max-height: 268px;
    padding: 8px 8px 2px 8px;
  }

  .stack-top-spines {
    width: 152px;
  }

  .stack-layer {
    width: 152px;
    height: 30px;
  }
}

/* Phone Bookcase, Spine, Stack & Mochi Scaling (< 640px) */
@media (max-width: 639px) {
  .wooden-bookcase {
    padding: 0 11px 13px 11px;
    border-width: 2.5px;
    box-shadow: 5px 5px 0px var(--ink);
  }

  .bookcase-crown {
    height: 15px;
    margin: 0 -11px;
  }

  .bookcase-bay {
    height: 236px;
    max-height: 236px;
    padding: 6px 6px 2px 6px;
    gap: 3px;
  }

  .sketch-shelf {
    height: 22px;
  }

  .plank-plate {
    font-size: 9.5px;
    padding: 0 7px;
  }

  /* 3x Integer Pixel Scale (96x96px) for Mochi on Phones so he stays razor-sharp and fits the crown */
  .cozy-cat-container {
    margin-top: -32px;
    margin-bottom: -9px;
  }

  .pixel-cat-sprite {
    width: 96px;
    height: 96px;
    background-size: 192px 96px;
  }

  .pose-sitting {
    background-size: 384px 96px;
    animation: catTailWagMobile 2s steps(4) infinite;
  }

  @keyframes catSleepBreatheMobile {
    0%, 49.9% { background-position: 0 0; }
    50%, 100% { background-position: -96px 0; }
  }

  @keyframes catTailWagMobile {
    from { background-position: 0 0; }
    to { background-position: -384px 0; }
  }

  .pose-curled,
  .pose-stretched,
  .pose-loaf,
  .pose-calico,
  .pose-midnight {
    animation: catSleepBreatheMobile 2.4s steps(1) infinite;
  }

  .zzz-cluster {
    top: 38px;
    right: 8px;
  }

  /* Proportionally Scaled Horizontal Book Stacks on Phones */
  .stack-top-spines {
    width: 132px;
    gap: 2px;
  }

  .stack-layer {
    width: 132px;
    height: 27px;
    padding: 1px 4px;
    border-width: 2px;
  }

  .stack-vector-endcap {
    width: 19px;
    height: 20px;
  }

  /* Proportionally Scaled Front-Facing Covers & Leaning Books on Phones */
  .book-front-cover {
    width: 112px;
    height: 162px;
    padding: 8px;
  }

  .doodle-book.is-leaning {
    margin-right: 18px;
  }

  .book-body {
    padding: 4px 3px;
    border-width: 2px;
  }

  .vector-plaque {
    padding: 4px 2px;
  }

  .vector-plaque.plaque-cameo {
    padding: 8px 3px;
    min-height: 64px;
  }

  .spine-author-text {
    font-size: 7.5px;
  }

  .brass-arch {
    width: 28px;
    height: 50px;
  }

  .brass-base {
    width: 36px;
    height: 6px;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .toast-container {
    bottom: 14px;
    right: 14px;
    left: 14px;
  }
}
