/* ==========================================================================
   MAMMA, TI AIUTO IO - Digital Interactive Book & Flipbook
   Autore: Dario Mazzara
   Styling System & Architecture
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Inter:wght@300;400;500;600&family=Merriweather:ital,wght@0,300;0,400;0,700;1,300;1,400&family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,400&display=swap');

/* --- Root & Themes Variables --- */
:root {
  /* Default Theme: Pergamena Calda (Warm Sepia) */
  --bg-app: #1e1a17;
  --bg-desk: #28231f;
  --bg-paper: #f9f5eb;
  --bg-paper-back: #f0ebd9;
  --text-main: #2b231d;
  --text-muted: #6e5f53;
  --text-light: #9c8b7d;
  --accent-gold: #c59b27;
  --accent-leather: #5a2e17;
  --accent-primary: #8a4f28;
  --accent-border: #ded5c2;
  --spine-shadow: rgba(30, 20, 10, 0.35);
  --page-shadow: rgba(0, 0, 0, 0.22);
  --ui-bg: rgba(32, 27, 23, 0.88);
  --ui-surface: #2d2621;
  --ui-border: #443b34;
  --ui-text: #eae4dc;
  --ui-text-muted: #a69b8f;
  --highlight-bg: #ffe599;
  --highlight-color: #2b231d;
  
  --bg-natural: #FDFBF7;
  --bg-natural-card: #FFFFFF;
  --bg-natural-surface: #FAF6EE;
  --text-anthracite: #2C2C2C;
  --accent-salvia: #7D9382;
  --accent-salvia-light: #EEF3EF;
  --accent-dusty-blue: #688896;
  --accent-dusty-light: #EDF3F5;
  --accent-soft-gold: #C5A059;
  --accent-soft-gold-light: #FBF7EE;
  
  --font-serif-title: 'Playfair Display', 'Cormorant Garamond', Georgia, serif;
  --font-serif-body: 'Merriweather', 'Lora', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --book-font-size: 17px;
  --book-line-height: 1.85;
  --book-font-family: var(--font-serif-body);

  --page-width: 480px;
  --page-height: 690px;
  --transition-speed: 0.6s;
}

/* Theme: Notte Profonda (Dark Solemn) */
[data-theme="night"] {
  --bg-app: #0d0e11;
  --bg-desk: #14161a;
  --bg-paper: #1c1e24;
  --bg-paper-back: #18191f;
  --text-main: #dfdbd3;
  --text-muted: #9ba1ad;
  --text-light: #6a7180;
  --accent-gold: #d4af37;
  --accent-leather: #2a2521;
  --accent-primary: #d4af37;
  --accent-border: #2c303c;
  --spine-shadow: rgba(0, 0, 0, 0.65);
  --page-shadow: rgba(0, 0, 0, 0.45);
  --ui-bg: rgba(18, 20, 25, 0.92);
  --ui-surface: #1e222b;
  --ui-border: #323846;
  --ui-text: #eceff4;
  --ui-text-muted: #8c93a4;
  --highlight-bg: #856404;
  --highlight-color: #ffffff;
  --bg-natural: #16181A;
  --bg-natural-card: #1F2226;
  --bg-natural-surface: #272B30;
  --text-anthracite: #E4DFD7;
  --accent-salvia: #8EA694;
  --accent-salvia-light: #242D26;
  --accent-dusty-blue: #82A4B3;
  --accent-dusty-light: #222C32;
  --accent-soft-gold: #D4AF37;
  --accent-soft-gold-light: #2D271D;
}

/* Theme: Luce Editoriale (Crisp Light) */
[data-theme="light"] {
  --bg-app: #ebecee;
  --bg-desk: #dcdfe4;
  --bg-paper: #ffffff;
  --bg-paper-back: #f8f9fa;
  --text-main: #1e2022;
  --text-muted: #5c626b;
  --text-light: #89909c;
  --accent-gold: #b38600;
  --accent-leather: #3f4756;
  --accent-primary: #2d3748;
  --accent-border: #e2e8f0;
  --spine-shadow: rgba(0, 0, 0, 0.15);
  --page-shadow: rgba(0, 0, 0, 0.12);
  --ui-bg: rgba(255, 255, 255, 0.92);
  --ui-surface: #f1f3f7;
  --ui-border: #d2d6df;
  --ui-text: #1a202c;
  --ui-text-muted: #64748b;
  --highlight-bg: #fef08a;
  --highlight-color: #1a202c;
}

/* --- Base & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Texture overlay for wood desk / background */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  position: relative;
  background: radial-gradient(circle at 50% 30%, var(--bg-desk) 0%, var(--bg-app) 100%);
  overflow: hidden;
}

/* --- App Header & Navigation Controls --- */
.app-header {
  height: 56px;
  background: var(--ui-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  color: var(--ui-text);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s ease;
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.book-badge-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.book-title-meta h1 {
  font-family: var(--font-serif-title);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ui-text);
  line-height: 1.15;
}

.book-title-meta .author-sub {
  font-size: 0.75rem;
  color: var(--ui-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.btn-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ui-text);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.btn-icon:hover {
  background: var(--ui-surface);
  border-color: var(--ui-border);
  color: var(--accent-gold);
}

.btn-icon.active {
  background: var(--ui-surface);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.btn-mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 36px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  color: var(--ui-text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-mode-toggle:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Progress bar under header */
.reading-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 101;
}

.reading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), #e8a838);
  width: 0%;
  transition: width 0.3s ease;
}

/* --- Main Viewport: Book Stage --- */
.book-viewport {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2600px;
  overflow: hidden;
  padding: 15px;
}

/* Ambient Book Drop Shadow & Stand */
.book-stage-shadow {
  position: absolute;
  width: calc(var(--page-width) * 2 + 60px);
  height: calc(var(--page-height) + 40px);
  border-radius: 20px;
  box-shadow: 0 35px 70px -15px rgba(0, 0, 0, 0.65),
              0 15px 30px -5px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 1;
}

/* --- Flipbook 3D Structure --- */
.flipbook-container {
  position: relative;
  width: calc(var(--page-width) * 2);
  height: var(--page-height);
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
  z-index: 2;
  user-select: text;
}

/* Spine effect running down the center */
.flipbook-spine {
  position: absolute;
  left: 50%;
  top: 0;
  width: 32px;
  height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.08) 35%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.08) 65%,
    rgba(0, 0, 0, 0.3) 100%
  );
  z-index: 20;
  pointer-events: none;
  border-radius: 2px;
}

/* The Left & Right Page Panels in Flipbook View */
.book-page {
  position: absolute;
  top: 0;
  width: var(--page-width);
  height: var(--page-height);
  background-color: var(--bg-paper);
  box-shadow: 0 4px 15px var(--page-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 42px 46px 40px 46px;
  border: 1px solid var(--accent-border);
  box-sizing: border-box;
  font-family: var(--book-font-family);
  font-size: var(--book-font-size);
  line-height: var(--book-line-height);
  color: var(--text-main);
  transform-origin: left center;
  transition: transform var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1),
              box-shadow var(--transition-speed) ease;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.book-page.page-left {
  left: 0;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
  border-right: none;
  box-shadow: inset -22px 0 25px -10px var(--spine-shadow), -8px 0 25px var(--page-shadow);
}

.book-page.page-right {
  right: 0;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  border-left: none;
  box-shadow: inset 22px 0 25px -10px var(--spine-shadow), 8px 0 25px var(--page-shadow);
}

/* Paper edge layering illusion (fogli accumulati) */
.page-left::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 3px;
  bottom: 3px;
  width: 8px;
  background: repeating-linear-gradient(
    90deg,
    var(--accent-border) 0px,
    var(--accent-border) 1px,
    var(--bg-paper-back) 2px,
    var(--bg-paper-back) 3px
  );
  border-radius: 4px 0 0 4px;
  pointer-events: none;
}

.page-right::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 3px;
  bottom: 3px;
  width: 8px;
  background: repeating-linear-gradient(
    90deg,
    var(--bg-paper-back) 0px,
    var(--bg-paper-back) 1px,
    var(--accent-border) 2px,
    var(--accent-border) 3px
  );
  border-radius: 0 4px 4px 0;
  pointer-events: none;
}

/* Page Header & Running Head */
.page-running-head {
  height: 24px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-light);
  border-bottom: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-body-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-border) transparent;
}

.page-body-content::-webkit-scrollbar {
  width: 4px;
}
.page-body-content::-webkit-scrollbar-thumb {
  background-color: var(--accent-border);
  border-radius: 4px;
}

/* Page Footer & Folio number */
.page-folio-footer {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif-title);
  font-size: 0.88rem;
  color: var(--text-muted);
  border-top: 1px solid var(--accent-border);
  margin-top: 16px;
}

/* --- Editorial Typography & Elements --- */
.chapter-hero {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  position: relative;
}

.chapter-badge-num {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-primary);
  font-weight: 600;
  margin-bottom: 8px;
}

.chapter-main-title {
  font-family: var(--font-serif-title);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  margin-bottom: 12px;
}

.chapter-flourish {
  width: 60px;
  height: 12px;
  margin: 0 auto;
  opacity: 0.7;
}

/* Drop Cap on Chapter Start */
.drop-cap-p::first-letter {
  font-family: var(--font-serif-title);
  font-size: 3.4rem;
  float: left;
  line-height: 0.82;
  margin-top: 4px;
  margin-right: 10px;
  margin-bottom: -4px;
  color: var(--accent-primary);
  font-weight: 700;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.08);
}

.book-p {
  margin-bottom: 1.3em;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.book-p.dialogue {
  padding-left: 1.2em;
  border-left: 2px solid var(--accent-gold);
  font-style: italic;
}

.book-quote-block {
  margin: 24px 0;
  padding: 16px 22px;
  background: rgba(197, 155, 39, 0.07);
  border-left: 3px solid var(--accent-gold);
  border-radius: 0 8px 8px 0;
  font-family: var(--font-serif-title);
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--text-main);
}

/* --- Special Pages: Copertina, Dedica, Premessa, ecc. --- */

/* Front Cover */
.cover-page {
  background: radial-gradient(circle at 50% 30%, #2e2621 0%, #171310 100%) !important;
  color: #f7ecd5 !important;
  border: 1px solid #4a3c30 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  align-items: center !important;
  text-align: center !important;
  padding: 40px 32px !important;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.8), 0 10px 40px rgba(0, 0, 0, 0.6) !important;
  position: relative;
  overflow: hidden;
}

.cover-gold-border {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  bottom: 14px;
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 4px;
  pointer-events: none;
}

.cover-gold-border::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border: 1px dashed rgba(212, 175, 55, 0.25);
}

.cover-header-group {
  z-index: 5;
  margin-top: 10px;
}

.cover-author {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #d4af37;
  font-weight: 500;
  margin-bottom: 12px;
}

.cover-title {
  font-family: var(--font-serif-title);
  font-size: 2.35rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7), 0 0 30px rgba(212, 175, 55, 0.2);
  margin-bottom: 10px;
}

.cover-subtitle {
  font-family: var(--font-serif-body);
  font-size: 0.95rem;
  font-style: italic;
  color: #cfc5b4;
  line-height: 1.4;
  max-width: 320px;
  margin: 0 auto;
}

.cover-illustration-container {
  width: 250px;
  height: 290px;
  border-radius: 12px;
  overflow: hidden;
  border: 3px solid rgba(212, 175, 55, 0.6);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  margin: 14px 0;
  z-index: 5;
  position: relative;
}

.cover-illustration-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-footer-group {
  z-index: 5;
  margin-bottom: 10px;
}

.cover-tagline {
  font-size: 0.82rem;
  color: #d4af37;
  font-style: italic;
  letter-spacing: 0.05em;
}

/* Dedication Page */
.dedication-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px;
}

.dedication-flourish {
  width: 48px;
  height: 48px;
  color: var(--accent-gold);
  margin-bottom: 24px;
}

.dedication-text {
  font-family: var(--font-serif-title);
  font-size: 2.2rem;
  font-style: italic;
  color: var(--text-main);
  letter-spacing: 0.04em;
  line-height: 1.4;
}

/* Back Cover (Quarta di copertina) */
.back-cover-page {
  background: radial-gradient(circle at 50% 50%, #28211c 0%, #15120f 100%) !important;
  color: #eae1d2 !important;
  border: 1px solid #4a3c30 !important;
  padding: 40px 36px !important;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.75) !important;
}

.back-cover-quote {
  font-family: var(--font-serif-title);
  font-size: 1.15rem;
  font-style: italic;
  color: #d4af37;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.back-cover-synopsis p {
  font-size: 0.95rem;
  line-height: 1.75;
  color: #d8cebf;
  margin-bottom: 1.1em;
  text-align: justify;
}

/* --- Flipbook Page Flip Animation & Flipping Class --- */
.page-flip-anim-next {
  animation: flipNext var(--transition-speed) forwards cubic-bezier(0.25, 1, 0.5, 1);
}

.page-flip-anim-prev {
  animation: flipPrev var(--transition-speed) forwards cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes flipNext {
  0% {
    transform: rotateY(0deg);
    box-shadow: 0 4px 15px var(--page-shadow);
  }
  50% {
    box-shadow: -20px 10px 40px rgba(0, 0, 0, 0.4);
  }
  100% {
    transform: rotateY(-180deg);
    box-shadow: 0 4px 15px var(--page-shadow);
  }
}

@keyframes flipPrev {
  0% {
    transform: rotateY(-180deg);
    box-shadow: 0 4px 15px var(--page-shadow);
  }
  50% {
    box-shadow: 20px 10px 40px rgba(0, 0, 0, 0.4);
  }
  100% {
    transform: rotateY(0deg);
    box-shadow: 0 4px 15px var(--page-shadow);
  }
}

/* Interactive Navigation Arrows on Book Margins */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  background: var(--ui-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  transition: all 0.25s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.nav-arrow:hover {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: #111;
  transform: translateY(-50%) scale(1.1);
}

.nav-arrow.arrow-prev {
  left: 20px;
}

.nav-arrow.arrow-next {
  right: 20px;
}

.nav-arrow:disabled {
  opacity: 0.25;
  pointer-events: none;
}

/* --- Bottom Toolbar & Page Slider --- */
.app-footer {
  height: 60px;
  background: var(--ui-bg);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  color: var(--ui-text);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-center {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 500px;
  margin: 0 20px;
}

.page-counter {
  font-family: var(--font-serif-title);
  font-size: 0.95rem;
  color: var(--ui-text);
  white-space: nowrap;
}

.page-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.page-slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

/* --- CONTINUOUS READER VIEW (Modalità Lettura Fluida) --- */
.reader-mode-container {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 40px 20px 80px 20px;
  scroll-behavior: smooth;
  background: var(--bg-paper);
  color: var(--text-main);
}

.reader-content-wrapper {
  max-width: 740px;
  margin: 0 auto;
  font-family: var(--book-font-family);
  font-size: calc(var(--book-font-size) + 1px);
  line-height: var(--book-line-height);
}

.reader-section-block {
  margin-bottom: 70px;
  padding-bottom: 50px;
  border-bottom: 1px solid var(--accent-border);
}

.reader-section-block:last-child {
  border-bottom: none;
}

/* When in Reader View */
.view-continuous .flipbook-container,
.view-continuous .book-stage-shadow,
.view-continuous .nav-arrow {
  display: none !important;
}

.view-continuous .reader-mode-container {
  display: block;
}

/* --- Modals & Drawers --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.open,
.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  color: var(--ui-text);
}

.modal-backdrop.open .modal-card,
.modal-backdrop.active .modal-card {
  transform: translateY(0);
}

/* Specific styling for PIN input in moderation auth form */
.mod-auth-form input {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--accent-border);
  border-radius: 12px;
  background: var(--bg-paper);
  color: var(--text-anthracite, #2C2C2C);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 500;
  text-align: center;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

[data-theme="night"] .mod-auth-form input {
  background: #17191C;
  border-color: #333942;
  color: #E4DFD7;
}

.mod-auth-form input:focus {
  border-color: var(--accent-salvia, #7D9382);
  box-shadow: 0 0 0 4px rgba(125, 147, 130, 0.25);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-serif-title);
  font-size: 1.25rem;
  color: var(--ui-text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Side Drawer (Table of Contents / Indice) */
.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.side-drawer {
  position: absolute;
  top: 0;
  left: 0;
  width: 360px;
  max-width: 85vw;
  height: 100%;
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.5);
  color: var(--ui-text);
}

.drawer-backdrop.open .side-drawer {
  transform: translateX(0);
}

.toc-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.toc-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.toc-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  color: var(--ui-text);
  text-decoration: none;
  font-size: 0.92rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.toc-link:hover {
  background: rgba(212, 175, 55, 0.12);
  color: var(--accent-gold);
  padding-left: 26px;
}

.toc-link.active {
  background: rgba(212, 175, 55, 0.18);
  color: var(--accent-gold);
  border-left: 4px solid var(--accent-gold);
}

.toc-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ui-text-muted);
  width: 60px;
}

.toc-name {
  flex: 1;
  font-weight: 500;
}

/* Settings Controls Inside Modal */
.setting-group {
  margin-bottom: 22px;
}

.setting-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-text-muted);
  margin-bottom: 10px;
  display: block;
}

.theme-options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.theme-pill-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-radius: 10px;
  border: 2px solid var(--ui-border);
  background: var(--ui-bg);
  color: var(--ui-text);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-pill-btn:hover {
  border-color: var(--accent-gold);
}

.theme-pill-btn.active {
  border-color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.15);
  color: var(--accent-gold);
}

.theme-color-preview {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.font-size-control-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-pill {
  flex: 1;
  padding: 8px 14px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-pill:hover {
  background: var(--ui-border);
}

/* Search Bar & Result List */
.search-input-box {
  display: flex;
  align-items: center;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  padding: 8px 14px;
  gap: 10px;
  margin-bottom: 18px;
}

.search-input-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ui-text);
  font-size: 0.95rem;
}

.search-results-list {
  max-height: 380px;
  overflow-y: auto;
}

.search-result-item {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-bottom: 4px;
}

.search-result-item:hover {
  background: rgba(212, 175, 55, 0.12);
}

.search-result-ch {
  font-size: 0.78rem;
  color: var(--accent-gold);
  font-weight: 600;
  margin-bottom: 4px;
}

.search-result-snippet {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ui-text);
}

.search-result-snippet mark {
  background: var(--highlight-bg);
  color: var(--highlight-color);
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

/* --- Responsive Scaling --- */
@media (max-width: 1080px) {
  :root {
    --page-width: 380px;
    --page-height: 560px;
    --book-font-size: 15px;
  }
  .book-page {
    padding: 30px 32px;
  }
  .cover-illustration-container {
    width: 200px;
    height: 230px;
  }
  .cover-title {
    font-size: 1.9rem;
  }
}

@media (max-width: 820px) {
  /* On mobile/tablets, single page flipbook or switch to reader mode */
  :root {
    --page-width: 90vw;
    --page-height: 72vh;
    --book-font-size: 15.5px;
  }
  
  .flipbook-container {
    width: var(--page-width);
  }

  .flipbook-spine {
    display: none;
  }

  .book-stage-shadow {
    width: calc(var(--page-width) + 20px);
    height: calc(var(--page-height) + 20px);
  }

  .book-page.page-left {
    display: none; /* Hide left page in single page view mode */
  }

  .book-page.page-right {
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }

  .header-title-group .author-sub {
    display: none;
  }

  .nav-arrow.arrow-prev {
    left: 6px;
  }

  .nav-arrow.arrow-next {
    right: 6px;
  }
}

/* ==========================================================================
   PORTAL ARCHITECTURE & SECTIONS (Home, Frammenti, Caregiver, Muro delle Parole)
   ========================================================================== */

/* Portal Navigation in Header */
.portal-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 16px;
  background: rgba(0, 0, 0, 0.22);
  padding: 4px 6px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  scrollbar-width: none;
}
.portal-nav::-webkit-scrollbar {
  display: none;
}

.portal-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  color: var(--ui-text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.22s ease;
}

.portal-nav-link:hover {
  color: var(--ui-text);
  background: rgba(255, 255, 255, 0.08);
}

.portal-nav-link.active {
  color: #ffffff;
  background: var(--accent-salvia, #7D9382);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  font-weight: 600;
}

[data-theme="light"] .portal-nav {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .portal-nav-link {
  color: #555555;
}
[data-theme="light"] .portal-nav-link:hover {
  color: #111111;
  background: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .portal-nav-link.active {
  background: var(--accent-salvia, #6C8271);
  color: #ffffff;
}

/* Portal Main & Section Containers */
.portal-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.portal-section {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.portal-section.active {
  display: block;
}

#section-libro.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Common Section Inner Container */
.section-page-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 50px 24px 100px 24px;
}

.section-header-hero {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 46px auto;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-salvia, #7D9382);
  font-weight: 600;
  margin-bottom: 12px;
  background: rgba(125, 147, 130, 0.14);
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(125, 147, 130, 0.25);
}

.hero-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-salvia, #7D9382);
}

.section-hero-title {
  font-family: var(--font-serif-title);
  font-size: 2.3rem;
  color: var(--text-anthracite, #2C2C2C);
  line-height: 1.25;
  margin-bottom: 14px;
}

[data-theme="night"] .section-hero-title {
  color: #E4DFD7;
}

.section-hero-desc {
  font-family: var(--font-serif-body);
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.65;
  font-style: italic;
}

.section-divider-line {
  width: 60px;
  height: 2px;
  background: var(--accent-soft-gold, #C5A059);
  margin: 22px auto 0 auto;
  border-radius: 2px;
}

/* ==========================================================================
   HOME SECTION ("Il Filo della Memoria")
   ========================================================================== */
.home-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px 24px;
  position: relative;
}

.home-hero {
  text-align: center;
  padding: 40px 20px 48px 20px;
  background: radial-gradient(circle at 50% 10%, rgba(253, 251, 247, 0.8), transparent 70%);
  border-radius: 24px;
  margin-bottom: 44px;
}

[data-theme="night"] .home-hero {
  background: radial-gradient(circle at 50% 10%, rgba(36, 40, 44, 0.8), transparent 70%);
}

.hero-title {
  font-family: var(--font-serif-title);
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--text-anthracite, #2C2C2C);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

[data-theme="night"] .hero-title {
  color: #E4DFD7;
}

.hero-subtitle {
  font-family: var(--font-serif-body);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--text-muted);
  max-width: 580px;
  margin: 0 auto 12px auto;
  line-height: 1.5;
}

.hero-author-tag {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-primary);
  margin-bottom: 30px;
}

/* Emblem Card with Quote */
.hero-emblem-card {
  background: var(--bg-paper);
  border: 1px solid var(--accent-border);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 660px;
  margin: 0 auto 34px auto;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.07);
  position: relative;
}

[data-theme="night"] .hero-emblem-card {
  background: #1F2227;
  border-color: #343A44;
}

.emblem-leaf-flourish {
  font-size: 1.5rem;
  color: var(--accent-salvia, #7D9382);
  margin-bottom: 10px;
}

.hero-quote {
  font-family: var(--font-serif-title);
  font-size: 1.6rem;
  font-style: italic;
  color: var(--text-anthracite, #2C2C2C);
  line-height: 1.4;
  margin-bottom: 18px;
}

[data-theme="night"] .hero-quote {
  color: #E4DFD7;
}

.hero-quote-promise {
  border-top: 1px solid var(--accent-border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hero-quote-promise strong {
  font-family: var(--font-serif-title);
  color: var(--accent-soft-gold, #C5A059);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
}

.hero-quote-promise span {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Intro Text */
.hero-intro-text {
  max-width: 700px;
  margin: 0 auto 36px auto;
  text-align: left;
  line-height: 1.8;
  font-family: var(--font-serif-body);
}

.intro-lead {
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--text-anthracite, #2C2C2C);
  margin-bottom: 14px;
  text-align: center;
}

[data-theme="night"] .intro-lead {
  color: #E4DFD7;
}

.intro-body {
  font-size: 1.02rem;
  color: var(--text-muted);
  text-align: justify;
}

/* Hero Action Buttons */
.hero-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 30px;
}

.btn-primary-portal {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-salvia, #7D9382);
  color: #ffffff;
  border: none;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 26px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 16px rgba(125, 147, 130, 0.35);
}

.btn-primary-portal:hover {
  transform: translateY(-2px);
  background: #6D8472;
  box-shadow: 0 6px 20px rgba(125, 147, 130, 0.45);
}

.btn-secondary-portal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-paper);
  color: var(--text-anthracite, #2C2C2C);
  border: 1px solid var(--accent-border);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 12px 22px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.25s ease;
}

[data-theme="night"] .btn-secondary-portal {
  background: #24282D;
  color: #E4DFD7;
  border-color: #3A414A;
}

.btn-secondary-portal:hover {
  border-color: var(--accent-salvia, #7D9382);
  color: var(--accent-salvia, #7D9382);
  transform: translateY(-2px);
}

.hero-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.04);
  padding: 6px 18px;
  border-radius: 20px;
  border: 1px solid var(--accent-border);
  flex-wrap: wrap;
  justify-content: center;
}

[data-theme="night"] .hero-meta-pill {
  background: rgba(255, 255, 255, 0.04);
}

.pill-dot {
  color: var(--accent-soft-gold, #C5A059);
}

/* Home Preview Cards */
.home-sections-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-top: 10px;
}

.preview-card {
  background: var(--bg-paper);
  border: 1px solid var(--accent-border);
  border-radius: 14px;
  padding: 24px 20px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}

[data-theme="night"] .preview-card {
  background: #1F2227;
  border-color: #343A44;
}

.preview-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-salvia, #7D9382);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.preview-icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
}

.preview-card h3 {
  font-family: var(--font-serif-title);
  font-size: 1.15rem;
  color: var(--text-anthracite, #2C2C2C);
  margin-bottom: 8px;
}

[data-theme="night"] .preview-card h3 {
  color: #E4DFD7;
}

.preview-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
  margin-bottom: 14px;
}

.preview-link {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent-salvia, #7D9382);
  transition: color 0.2s;
}

/* ==========================================================================
   FRAMMENTI DI VITA ("I Momenti")
   ========================================================================== */
.moments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

.moment-card {
  background: var(--bg-paper);
  border: 1px solid var(--accent-border);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease;
  position: relative;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
}

[data-theme="night"] .moment-card {
  background: #1F2227;
  border-color: #343A44;
}

.moment-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
  border-color: var(--accent-dusty-blue, #688896);
}

.moment-tag-badge {
  align-self: flex-start;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-dusty-blue, #688896);
  font-weight: 600;
  background: rgba(104, 136, 150, 0.12);
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.moment-title {
  font-family: var(--font-serif-title);
  font-size: 1.45rem;
  color: var(--text-anthracite, #2C2C2C);
  line-height: 1.25;
  margin-bottom: 6px;
}

[data-theme="night"] .moment-title {
  color: #E4DFD7;
}

.moment-subtitle {
  font-family: var(--font-serif-body);
  font-size: 0.95rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--accent-border);
  padding-bottom: 10px;
}

.moment-text {
  font-family: var(--font-serif-body);
  font-size: 0.98rem;
  color: var(--text-main);
  line-height: 1.75;
  flex: 1;
  margin-bottom: 20px;
}

.moment-footer-action {
  border-top: 1px solid var(--accent-border);
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-read-chapter-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--accent-salvia, #7D9382);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-read-chapter-jump:hover {
  background: rgba(125, 147, 130, 0.12);
  text-decoration: underline;
}

/* ==========================================================================
   PAROLE PER I CAREGIVER (Fonte Inesauribile di Consigli)
   ========================================================================== */
.caregiver-toolbar {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.caregiver-search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.caregiver-search-box svg {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.caregiver-search-box input {
  width: 100%;
  padding: 14px 44px 14px 48px;
  font-family: var(--font-sans);
  font-size: 0.98rem;
  background: var(--bg-paper);
  border: 1px solid var(--accent-border);
  border-radius: 14px;
  color: var(--text-main);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  transition: all 0.25s ease;
}

[data-theme="night"] .caregiver-search-box input {
  background: #1F2227;
  border-color: #343A44;
}

.caregiver-search-box input:focus {
  outline: none;
  border-color: var(--accent-salvia, #7D9382);
  box-shadow: 0 0 0 3px rgba(125, 147, 130, 0.22);
}

.caregiver-search-box .btn-clear-search {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.caregiver-search-box .btn-clear-search:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="night"] .caregiver-search-box .btn-clear-search:hover {
  background: rgba(255, 255, 255, 0.12);
}

.caregiver-filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.caregiver-filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.caregiver-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.caregiver-pill {
  padding: 8px 16px;
  font-size: 0.84rem;
  font-weight: 500;
  font-family: var(--font-sans);
  border-radius: 20px;
  border: 1px solid var(--accent-border);
  background: var(--bg-paper);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

[data-theme="night"] .caregiver-pill {
  background: #1F2227;
  border-color: #343A44;
}

.caregiver-pill:hover {
  background: rgba(125, 147, 130, 0.14);
  border-color: var(--accent-salvia, #7D9382);
}

.caregiver-pill.active {
  background: var(--accent-salvia, #7D9382);
  color: #FFFFFF;
  border-color: var(--accent-salvia, #7D9382);
  box-shadow: 0 2px 10px rgba(125, 147, 130, 0.35);
}

.caregiver-stats-bar {
  margin-bottom: 22px;
  padding: 8px 4px;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--accent-border);
}

.caregiver-flow {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.caregiver-card {
  background: var(--bg-paper);
  border: 1px solid var(--accent-border);
  border-radius: 18px;
  padding: 32px 30px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  display: flex;
  gap: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.caregiver-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.08);
}

[data-theme="night"] .caregiver-card {
  background: #1F2227;
  border-color: #343A44;
}

.caregiver-num-badge {
  font-family: var(--font-serif-title);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent-salvia, #7D9382);
  opacity: 0.75;
  line-height: 1;
  min-width: 48px;
  padding-top: 4px;
}

.caregiver-content-group {
  flex: 1;
}

.caregiver-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.caregiver-cat-badge {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(104, 136, 150, 0.12);
  color: var(--accent-dusty-blue, #688896);
  letter-spacing: 0.3px;
}

[data-theme="night"] .caregiver-cat-badge {
  background: rgba(104, 136, 150, 0.25);
  color: #A4C5D6;
}

.caregiver-title {
  font-family: var(--font-serif-title);
  font-size: 1.55rem;
  color: var(--text-anthracite, #2C2C2C);
  line-height: 1.25;
  margin-bottom: 6px;
}

[data-theme="night"] .caregiver-title {
  color: #E4DFD7;
}

.caregiver-subtitle {
  font-family: var(--font-serif-body);
  font-size: 0.98rem;
  font-style: italic;
  color: var(--accent-dusty-blue, #688896);
  margin-bottom: 16px;
}

.caregiver-body {
  font-family: var(--font-serif-body);
  font-size: 1.02rem;
  color: var(--text-main);
  line-height: 1.8;
}

.caregiver-takeaway-box {
  margin-top: 18px;
  padding: 14px 18px;
  background: rgba(197, 155, 39, 0.08);
  border-left: 3px solid var(--accent-gold, #c59b27);
  border-radius: 0 10px 10px 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--text-main);
  line-height: 1.6;
}

[data-theme="night"] .caregiver-takeaway-box {
  background: rgba(197, 155, 39, 0.14);
  border-left-color: #D6A738;
}

@media (max-width: 650px) {
  .caregiver-card {
    flex-direction: column;
    gap: 12px;
    padding: 24px 20px;
  }
  .caregiver-num-badge {
    font-size: 1.6rem;
    min-width: auto;
  }
}

/* ==========================================================================
   IL MURO DELLE PAROLE (Spazio di Condivisione)
   ========================================================================== */
.wall-form-card {
  background: var(--bg-paper);
  border: 1px solid var(--accent-border);
  border-radius: 18px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
}

[data-theme="night"] .wall-form-card {
  background: #1F2227;
  border-color: #343A44;
}

.wall-form-card h3 {
  font-family: var(--font-serif-title);
  font-size: 1.4rem;
  color: var(--text-anthracite, #2C2C2C);
  margin-bottom: 6px;
}

[data-theme="night"] .wall-form-card h3 {
  color: #E4DFD7;
}

.wall-form-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.wall-form .form-group {
  margin-bottom: 16px;
}

.wall-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 6px;
}

.wall-form input, .wall-form textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

[data-theme="night"] .wall-form input, [data-theme="night"] .wall-form textarea {
  background: #17191C;
  border-color: #333942;
  color: #E4DFD7;
}

.wall-form input:focus, .wall-form textarea:focus {
  border-color: var(--accent-salvia, #7D9382);
  box-shadow: 0 0 0 3px rgba(125, 147, 130, 0.2);
}

.wall-form .form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.char-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-submit-wall {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-salvia, #7D9382);
  color: #ffffff;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-submit-wall:hover {
  background: #6B8270;
  transform: translateY(-1px);
}

.wall-messages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.wall-card-item {
  background: var(--bg-paper);
  border: 1px solid var(--accent-border);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
  position: relative;
  transition: transform 0.2s;
}

[data-theme="night"] .wall-card-item {
  background: #1F2227;
  border-color: #343A44;
}

.wall-card-item:hover {
  transform: translateY(-3px);
}

.wall-card-text {
  font-family: var(--font-serif-body);
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.65;
  font-style: italic;
  margin-bottom: 18px;
  flex: 1;
}

.wall-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--accent-border);
  padding-top: 10px;
  font-size: 0.8rem;
}

.wall-card-author {
  font-weight: 600;
  color: var(--accent-salvia, #7D9382);
}

.wall-card-date {
  color: var(--text-muted);
}

/* Feedback Alert on Wall submission */
.wall-feedback-alert {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(125, 147, 130, 0.12);
  border: 1px solid rgba(125, 147, 130, 0.35);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 22px;
  animation: fadeInDown 0.3s ease;
}

[data-theme="night"] .wall-feedback-alert {
  background: rgba(125, 147, 130, 0.18);
  border-color: rgba(125, 147, 130, 0.45);
}

.feedback-alert-icon {
  color: var(--accent-salvia, #7D9382);
  flex-shrink: 0;
  margin-top: 2px;
}

.feedback-alert-text strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text-anthracite, #2C2C2C);
  margin-bottom: 3px;
}

[data-theme="night"] .feedback-alert-text strong {
  color: #E4DFD7;
}

.feedback-alert-text p {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* User Pending Box */
.wall-user-pending-box {
  background: rgba(197, 160, 89, 0.08);
  border: 1px dashed rgba(197, 160, 89, 0.45);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 26px;
}

[data-theme="night"] .wall-user-pending-box {
  background: rgba(197, 160, 89, 0.12);
  border-color: rgba(197, 160, 89, 0.5);
}

.user-pending-header {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent-soft-gold, #B88E3E);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.pending-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #E6A23C;
  display: inline-block;
  box-shadow: 0 0 8px rgba(230, 162, 60, 0.6);
}

.user-pending-item {
  background: var(--bg-paper);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 8px;
  font-size: 0.9rem;
}

[data-theme="night"] .user-pending-item {
  background: #1B1E22;
  border-color: #333942;
}

.user-pending-text {
  font-family: var(--font-serif-body);
  font-style: italic;
  color: var(--text-main);
  margin-bottom: 6px;
}

.user-pending-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.user-pending-status-pill {
  color: #D48806;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Wall Stats & Moderation Guarantee Bar */
.wall-stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--accent-border);
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 10px;
}

.wall-stats-count {
  font-weight: 600;
  color: var(--text-anthracite, #2C2C2C);
}

[data-theme="night"] .wall-stats-count {
  color: #E4DFD7;
}

.wall-moderation-guarantee {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--accent-salvia, #7D9382);
  font-style: italic;
}

/* Wall Author Moderation Trigger */
.wall-author-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px dashed var(--accent-border);
  display: flex;
  justify-content: center;
}

.btn-author-moderation {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--accent-border);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.22s ease;
}

.btn-author-moderation:hover {
  color: var(--text-main);
  border-color: var(--accent-salvia, #7D9382);
  background: rgba(125, 147, 130, 0.08);
}

.pending-mod-badge {
  background: #E6A23C;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Wide Modal Card for Author Dashboard */
.modal-card-wide {
  max-width: 700px;
  width: 94%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

/* Moderation Auth View */
.mod-auth-box {
  text-align: center;
  max-width: 380px;
  margin: 16px auto 24px auto;
}

.mod-lock-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(125, 147, 130, 0.15);
  color: var(--accent-salvia, #7D9382);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
}

.mod-auth-box h4 {
  font-family: var(--font-serif-title);
  font-size: 1.35rem;
  color: var(--text-anthracite, #2C2C2C);
  margin-bottom: 8px;
}

[data-theme="night"] .mod-auth-box h4 {
  color: #E4DFD7;
}

.mod-auth-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.mod-pin-error {
  color: #E05252;
  font-size: 0.82rem;
  margin-bottom: 8px;
  font-weight: 500;
}

.mod-pin-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 14px;
}

.mod-pin-hint code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

[data-theme="night"] .mod-pin-hint code {
  background: rgba(255, 255, 255, 0.1);
}

/* Moderation Dashboard Header */
.mod-dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--accent-border);
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.mod-dash-title {
  font-family: var(--font-serif-title);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-anthracite, #2C2C2C);
  display: block;
}

[data-theme="night"] .mod-dash-title {
  color: #E4DFD7;
}

.mod-dash-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mod-dash-actions {
  display: flex;
  gap: 8px;
}

/* Moderation Tabs */
.mod-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--accent-border);
  padding-bottom: 6px;
  overflow-x: auto;
}

.mod-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.mod-tab-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
}

[data-theme="night"] .mod-tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.mod-tab-btn.active {
  background: var(--accent-salvia, #7D9382);
  color: #ffffff;
  font-weight: 600;
}

.mod-badge-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.1);
  color: inherit;
}

.mod-tab-btn.active .mod-badge-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Tab Pane & Toolbar */
.mod-pane-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 8px;
}

.mod-pane-sub {
  flex: 1;
}

.mod-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 48vh;
  overflow-y: auto;
  padding-right: 4px;
}

.mod-card {
  background: var(--bg-paper);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s;
}

[data-theme="night"] .mod-card {
  background: #1B1E22;
  border-color: #333942;
}

.mod-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.mod-card-author {
  font-weight: 600;
  color: var(--text-anthracite, #2C2C2C);
}

[data-theme="night"] .mod-card-author {
  color: #E4DFD7;
}

.mod-card-date {
  color: var(--text-muted);
}

.mod-card-body {
  font-family: var(--font-serif-body);
  font-size: 0.94rem;
  font-style: italic;
  color: var(--text-main);
  line-height: 1.6;
  background: rgba(0, 0, 0, 0.02);
  padding: 10px 12px;
  border-radius: 8px;
}

[data-theme="night"] .mod-card-body {
  background: rgba(255, 255, 255, 0.03);
}

.mod-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 2px;
  flex-wrap: wrap;
}

.btn-mod-approve {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-salvia, #7D9382);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-mod-approve:hover {
  background: #697F6F;
  transform: translateY(-1px);
}

.btn-mod-bulk-approve {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-salvia, #7D9382);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-mod-bulk-approve:hover {
  background: #697F6F;
}

.btn-mod-reject {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid rgba(224, 82, 82, 0.35);
  color: #D34343;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-mod-reject:hover {
  background: rgba(224, 82, 82, 0.1);
  border-color: #D34343;
}

.btn-mod-restore {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--accent-border);
  color: var(--text-main);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-mod-restore:hover {
  border-color: var(--accent-salvia, #7D9382);
  color: var(--accent-salvia, #7D9382);
}

.btn-pill-danger {
  color: #D34343 !important;
}

.btn-pill-danger:hover {
  border-color: #D34343 !important;
  background: rgba(224, 82, 82, 0.08) !important;
}

.mod-empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Toast feedback notification */
.portal-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ui-surface);
  color: var(--ui-text);
  border: 1px solid var(--ui-border);
  padding: 12px 24px;
  border-radius: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.portal-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive adjustments */
@media (max-width: 860px) {
  .hero-title {
    font-size: 2.3rem;
  }
  .moments-grid {
    grid-template-columns: 1fr;
  }
  .caregiver-card {
    flex-direction: column;
    gap: 12px;
  }
  .portal-nav {
    margin: 0 8px;
  }
  .portal-nav-link span {
    font-size: 0.78rem;
  }
}

/* --- Print Styles (@media print) --- */
@media print {
  body, .app-container {
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
    height: auto !important;
  }

  .app-header, .app-footer, .nav-arrow, .modal-backdrop, .drawer-backdrop, .book-stage-shadow, .flipbook-spine {
    display: none !important;
  }

  .book-viewport {
    perspective: none !important;
    padding: 0 !important;
    display: block !important;
  }

  .flipbook-container {
    display: none !important;
  }

  .reader-mode-container {
    display: block !important;
    padding: 0 !important;
    overflow: visible !important;
    color: #000000 !important;
    background: #ffffff !important;
  }

  .reader-content-wrapper {
    max-width: 100% !important;
  }

  .reader-section-block {
    page-break-before: always;
    page-break-inside: avoid;
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 40px !important;
  }

  .chapter-main-title {
    color: #000000 !important;
  }
}
