body {
  font-family: 'Georgia', serif;
  margin: 0;
  padding: 0;
}

.container {
  max-width: 720px;
  margin: auto;
  padding: 2em;
}

h1, h2, h3, h4, label, select, button {
  font-family: 'Helvetica Neue', sans-serif;
}

button, select, input[type="text"] {
  border-radius: 999px !important;
  padding: 0.75em 1.2em;
  font-size: 1em;
  border: 1px solid #ccc;
  margin: 0.5em 0;
  display: inline-block;
  background: #fff;
  cursor: pointer;
}

.chapter-page {
  margin-bottom: 2em;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2em;
}

.chapter-nav button {
  border-radius: 999px;
}

.page-indicator {
  text-align: center;
  color: #666;
  margin: 1em 0;
}

.responsive-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
  border-radius: 12px;
}

/* Remove or override the global img rule to avoid double margins and width conflicts */
img:not(.responsive-image) {
  max-width: 45%;
  margin: 2em auto;
  display: block;
  border-radius: 12px;
}

.note {
  font-style: italic;
  text-align: center;
  color: #666;
  margin-top: -1em;
  margin-bottom: 2em;
}

/* Themes */
.theme-lucraezia, .theme-lucraezia #page-content {
  background: #f5e6d3 !important; /* beige */
  color: #2c1f13 !important;
}
.theme-jax, .theme-jax #page-content {
  background: #0e0e0e !important; /* black */
  color: #f2f2f2 !important;
}
.theme-yara, .theme-yara #page-content {
  background: #dbe9f4 !important; /* light blue */
  color: #1e2d3c !important;
}
.theme-thayer, .theme-thayer #page-content {
  background: #e0f0e0 !important; /* pastel green */
  color: #2c4c2c !important;
}

/* Update button styles for each theme */
.theme-lucraezia button {
  background: #e6d5c0;
  color: #2c1f13;
  border: 1px solid #d4c0a8;
}

.theme-jax button {
  background: #1a1a1a;
  color: #f2f2f2;
  border: 1px solid #333;
}

.theme-yara button {
  background: #c5dcec;
  color: #1e2d3c;
  border: 1px solid #a8c5d9;
}

.theme-thayer button {
  background: #c5e0c5;
  color: #2c4c2c;
  border: 1px solid #a8d0a8;
}

/* Update select styles for each theme */
.theme-lucraezia select {
  background: #e6d5c0;
  color: #2c1f13;
  border: 1px solid #d4c0a8;
}

.theme-jax select {
  background: #1a1a1a;
  color: #f2f2f2;
  border: 1px solid #333;
}

.theme-yara select {
  background: #c5dcec;
  color: #1e2d3c;
  border: 1px solid #a8c5d9;
}

.theme-thayer select {
  background: #c5e0c5;
  color: #2c4c2c;
  border: 1px solid #a8d0a8;
}

/* Update card styles for each theme */
.theme-lucraezia .card {
  background: rgba(230, 213, 192, 0.9);
  color: #2c1f13;
}

.theme-jax .card {
  background: rgba(26, 26, 26, 0.9);
  color: #f2f2f2;
}

.theme-yara .card {
  background: rgba(197, 220, 236, 0.9);
  color: #1e2d3c;
}

.theme-thayer .card {
  background: rgba(197, 224, 197, 0.9);
  color: #2c4c2c;
}

/* Always make the card white, but set text color per theme */
.chapter-card {
  background: #fff !important;
  border-radius: 30px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
  padding: 2.2em 2em 2.5em 2em;
  margin: 2.5em auto 2.5em auto;
  max-width: 720px;
  width: 100%;
  font-size: 1.08em;
}

/* Text color for each theme */
.theme-lucraezia .chapter-card,
.theme-yara .chapter-card,
.theme-thayer .chapter-card {
  color: #2c1f13;
}

/* Page background is set by the theme class on body or #page-content */
.theme-lucraezia, .theme-lucraezia #page-content {
  background: #f5e6d3 !important;
}
.theme-jax, .theme-jax #page-content {
  background: #0e0e0e !important;
}
.theme-yara, .theme-yara #page-content {
  background: #dbe9f4 !important;
}
.theme-thayer, .theme-thayer #page-content {
  background: #e0f0e0 !important;
}

#page-content {
  max-width: 800px;
  margin: 2em auto;
  padding: 2em;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08);
  color: #222;
}

.block {
  margin-bottom: 2em;
  background: transparent;
  color: inherit;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1em auto;
  border-radius: 10px;
}

audio {
  display: block;
  margin: 1em auto;
  width: 100%;
  max-width: 600px;
}

.audio-caption {
  font-style: italic;
  text-align: center;
  color: inherit;
  margin-top: 0.5em;
  margin-bottom: 1.5em;
  font-size: 0.9em;
}

/* Compact and elegant chapter card layout */
.chapter-card, .main-text-card, .chapter-content-card {
  background: #fff;
  border-radius: 30px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
  padding: 2.2em 2em 2.5em 2em;
  margin: 2.5em auto 2.5em auto;
  max-width: 720px;
  width: 100%;
  font-size: 1.08em;
  color: #222;
}

.chapter-card img,
.main-text-card img,
.chapter-content-card img {
  margin: 1.2em auto 1.5em auto;
  display: block;
  max-width: 80%;
  border-radius: 18px;
}

.chapter-card p,
.main-text-card p,
.chapter-content-card p {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
  line-height: 1.8;
  white-space: pre-line;
}

.chapter-card blockquote,
.main-text-card blockquote,
.chapter-content-card blockquote {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
  line-height: 1.8;
}

@media (max-width: 900px) {
  .chapter-card, .main-text-card, .chapter-content-card {
    padding: 1.2em 0.5em 1.5em 0.5em;
    max-width: 98vw;
    font-size: 1em;
  }
  .chapter-card img,
  .main-text-card img,
  .chapter-content-card img {
    max-width: 100%;
    border-radius: 12px;
  }
}

/* Share page constellation and inscription styles */
.share-constellation {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 18px;
  justify-items: center;
  align-items: center;
  margin: 2em auto 1.5em auto;
  max-width: 420px;
  width: 100%;
}
.share-constellation img {
  width: 100%;
  max-width: 180px;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.share-inscription {
  font-family: 'Georgia', serif;
  font-size: 1.3em;
  text-align: center;
  margin: 1.2em auto 1.5em auto;
  font-style: italic;
}

@media (max-width: 600px) {
  /* Navigation buttons */
  .nav-button {
    font-size: 1em !important;
    padding: 0.7em 1em !important;
    min-width: 100px !important;
    max-width: 140px !important;
    height: auto !important;
    min-height: 44px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    border-radius: 28px !important;
    line-height: 1.2 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    margin: 0 2px !important;
  }
  
  /* Ensure text containers don't overflow */
  .chapter-card,
  .main-text-card,
  .chapter-content-card {
    padding: 1em !important;
    margin: 0.5em 0 !important;
  }
  
  /* Main text readability */
  p, li {
    font-size: 1.13em !important;
    line-height: 1.7 !important;
    margin-bottom: 1.1em !important;
  }
  
  /* Social share grid buttons */
  .share-social-grid button, .share-social-grid .social-btn, .share-social-btn {
    min-width: 120px !important;
    max-width: 160px !important;
    font-size: 1em !important;
    padding: 0.7em 0.5em !important;
    height: 48px !important;
  }
  .share-social-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    padding: 0 2vw !important;
  }
  /* Unique Experiences and Deep Cut images */
  .chapter-card .special-moments img,
  .chapter-card .deepcut-img,
  .chapter-card .unique-experience-img,
  .chapter-card img {
    width: 100% !important;
    max-width: 98vw !important;
    height: auto !important;
    min-height: 160px !important;
    border-radius: 12px !important;
  }
  .chapter-card .special-moments,
  .chapter-card .deepcut-img-grid {
    grid-template-columns: 1fr !important;
    gap: 1em !important;
  }
  #page-content,
  .chapter-card,
  .main-text-card,
  .chapter-content-card {
    max-width: 100vw !important;
    width: 100vw !important;
    box-sizing: border-box !important;
    padding-left: 4vw !important;
    padding-right: 4vw !important;
    overflow-x: hidden !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }
  p, h1, h2, h3, h4, h5, h6, li, div, span {
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }
  body {
    overflow-x: hidden !important;
  }
  .chapter-card, .main-text-card, .chapter-content-card, #page-content {
    font-size: 1.05em !important;
    padding: 0.8em 2vw !important;
    margin: 0.5em 0 !important;
    max-height: none !important;
    overflow-y: visible !important;
  }
  p, li {
    font-size: 1.05em !important;
    line-height: 1.6 !important;
    margin-bottom: 1em !important;
  }

  /* Heading images: smaller on mobile */
  .heading-image {
    max-width: 70vw !important;
    max-height: 18vh !important;
    margin: 1em auto !important;
    border-radius: 10px !important;
  }
  /* Header text: slightly smaller on mobile */
  h1, h2, h3 {
    font-size: 1.2em !important;
  }

  /* Paywall: allow scrolling if content overflows */
  #paywall-content {
    max-height: 90vh !important;
    overflow-y: auto !important;
    padding-bottom: 2em !important;
  }
}

/* Responsive Paywall Modal */
#paywall-overlay {
  position: fixed !important;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.8);
  display: flex !important;
  align-items: flex-start !important;
  justify-content: center !important;
  z-index: 10000;
  overscroll-behavior: none !important;
  touch-action: none !important;
}

#paywall-content {
  max-height: 90vh !important;
  overflow-y: auto !important;
  margin-top: 2em !important;
  margin-bottom: 2em !important;
}

@media (max-width: 900px) {
  .chapter-card, .main-text-card, .chapter-content-card {
    padding: 1.2em 0.5em 1.5em 0.5em;
    max-width: 98vw;
    font-size: 1em;
  }
}

@media (max-width: 600px) {
  #paywall-content {
    font-size: 1em;
    padding: 0.8em 0.3em;
    max-width: 98vw;
    width: 98vw;
    max-height: 95vh;
    overflow-y: auto;
  }
  #paywall-overlay {
    align-items: flex-start;
  }
  .chapter-card, .main-text-card, .chapter-content-card, #page-content {
    padding: 1em 2vw;
    margin: 0.5em 0;
    max-width: 100vw;
    width: 100vw;
    font-size: 1em;
    max-height: 90vh;
    overflow-y: auto;
  }
  p, li {
    font-size: 1.05em !important;
    line-height: 1.7 !important;
    margin-bottom: 1.1em !important;
  }
}

.chapter-card, .main-text-card, .chapter-content-card, #page-content {
  box-sizing: border-box;
  max-width: 720px;
  width: 100%;
  margin: 2.5em auto;
  padding: 2.2em 2em 2.5em 2em;
  font-size: 1.08em;
  max-height: none !important;
  overflow-y: visible !important;
}

/* Ensure paywall is scrollable on all screens */
#paywall-content {
  max-height: 90vh !important;
  overflow-y: auto !important;
  padding-bottom: 2em !important;
}

@media (min-width: 1100px) {
  .chapter-card, .main-text-card, .chapter-content-card, #page-content {
    max-width: 1000px !important;
    font-size: 1.05em !important;
    padding-left: 3vw !important;
    padding-right: 3vw !important;
  }
}
