:root {
  --font-serif: 'Merriweather', 'Literata', Georgia, Cambria, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --theme-bg: #faf8f5;
  --theme-text: #2d3748;
  --theme-card-bg: #ffffff;
  --theme-border: #e2e8f0;
  --theme-accent: #3182ce;
  --highlight-yellow: rgba(250, 204, 21, 0.45);
  --highlight-green: rgba(74, 222, 128, 0.45);
  --highlight-purple: rgba(192, 132, 252, 0.45);
  --highlight-orange: rgba(251, 146, 60, 0.45);
}

body.theme-sepia {
  --theme-bg: #fbf0d9;
  --theme-text: #2d3748;
  --theme-card-bg: #fdf6e7;
  --theme-border: #e6dcbe;
}

body.theme-dark {
  --theme-bg: #1a202c;
  --theme-text: #e2e8f0;
  --theme-card-bg: #2d3748;
  --theme-border: #4a5568;
}

body.theme-white {
  --theme-bg: #ffffff;
  --theme-text: #1a202c;
  --theme-card-bg: #f7fafc;
  --theme-border: #e2e8f0;
}

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

body {
  margin: 0;
  padding: 0;
  background-color: var(--theme-bg);
  color: var(--theme-text);
  font-family: var(--font-serif);
  line-height: 1.9;
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
  overflow-x: hidden;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* Disable Unwanted Contextual Popups & Selection on General UI */
body, .app-container, .navbar, .mobile-bottom-dock, .sidebar-toc, .margin-drawer, 
.mobile-settings-sheet, .sheet-header, .settings-group,
button, .tab-btn, .reaction-pill, .color-dot, .brand-logo, .user-badge,
.presence-badge-wrapper, .floating-toolbar, .co-breathing-widget, .zen-breathing-modal,
.chapter-nav-btn, .starter-pill, .safe-space-badge, .reflection-header-row,
h1, h2, h3, h4, h5, h6, .chapter-heading, .book-title, .book-card {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Allow text selection, typing & editing in all input fields and textareas */
input, textarea, select, [contenteditable="true"], .nickname-input, #nicknameInput, .reflection-textarea {
  -webkit-user-select: text !important;
  user-select: text !important;
  -webkit-touch-callout: default !important;
  pointer-events: auto !important;
  touch-action: auto !important;
}

.input-error {
  border-color: #e53e3e !important;
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.2) !important;
  animation: shakeInput 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeInput {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* On Desktop: Allow precise text selection for highlighting text with mouse */
@media (min-width: 901px) {
  .paragraph-content {
    user-select: text;
    -webkit-user-select: text;
  }
}

/* Typography Enhancements (Baseline UI) */
h1, h2, h3, h4, .chapter-heading, .book-title {
  text-wrap: balance;
}

p, .paragraph-content, .note-card, .reflection-section p {
  text-wrap: pretty;
}

.reaction-pill, .dock-badge, .note-card span, #fontSizeDisplay, .lang-btn {
  font-variant-numeric: tabular-nums;
}

/* Accessible Focus Outlines */
button:focus-visible, 
a:focus-visible, 
input:focus-visible, 
textarea:focus-visible, 
div[tabindex="0"]:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

/* Reduced Motion Preference (WCAG & Motion Performance) */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* App Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  min-width: 0;
}

/* Top Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--theme-card-bg);
  border-bottom: 1px solid var(--theme-border);
  padding: max(12px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) 12px max(24px, env(safe-area-inset-left, 0px));
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 13px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--theme-text);
  cursor: pointer;
  flex-shrink: 0;
}

/* Header Right Actions */
.header-right-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Presence Capsule / Badge Wrapper */
.presence-badge-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 9px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
  position: relative;
}
.presence-badge-wrapper:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.presence-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--theme-muted);
}

/* Live Radar Indicator Dot */
.presence-radar-dot {
  width: 7px;
  height: 7px;
  background-color: #38a169;
  border-radius: 50%;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.presence-radar-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background-color: rgba(56, 161, 105, 0.4);
  animation: presenceRadarWave 2s infinite ease-out;
}
@keyframes presenceRadarWave {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Avatars Stack */
.presence-avatars-list {
  display: inline-flex;
  align-items: center;
}

.presence-avatar-item {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  border: 2px solid var(--theme-card-bg);
  margin-left: -6px;
  transition: transform 0.15s ease, z-index 0.15s ease;
  position: relative;
  flex-shrink: 0;
}
.presence-avatar-item:first-child {
  margin-left: 0;
}
.presence-avatar-item:hover {
  transform: translateY(-2px) scale(1.18);
  z-index: 10;
}

/* Recent Companion Avatar (Solution 2) */
.presence-avatar-recent {
  opacity: 0.68;
  border: 1.5px dashed rgba(255, 255, 255, 0.9) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  filter: saturate(0.85);
  cursor: pointer;
}
.presence-avatar-recent:hover {
  opacity: 1;
  filter: saturate(1);
  border-style: solid !important;
  transform: translateY(-2px) scale(1.18);
  z-index: 10;
}
body.theme-sepia .presence-avatar-recent {
  border-color: rgba(92, 70, 41, 0.6) !important;
}
body.theme-dark .presence-avatar-recent {
  border-color: rgba(255, 255, 255, 0.65) !important;
}

/* More Badge (+N) */
.presence-more-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #ffffff;
  background: #4a5568;
  border: 2px solid var(--theme-card-bg);
  margin-left: -6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
  letter-spacing: -0.5px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.presence-more-badge:hover {
  transform: translateY(-2px) scale(1.15);
  background: #2d3748;
  z-index: 10;
}

.presence-single-status {
  font-size: 11px;
  color: var(--theme-muted);
}

/* User Badge in Header */
.user-badge {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  max-width: 140px;
  flex-shrink: 0;
}
.user-badge strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Blinking & Pulsing Animation when a user enters */
@keyframes presenceJoinBlink {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(72, 187, 120, 0);
    border-color: transparent;
  }
  15% {
    transform: scale(1.08);
    box-shadow: 0 0 0 8px rgba(72, 187, 120, 0.4), 0 0 16px rgba(72, 187, 120, 0.6);
    border-color: #38a169;
    background: rgba(72, 187, 120, 0.18);
  }
  30% {
    transform: scale(0.98);
    box-shadow: 0 0 0 2px rgba(72, 187, 120, 0.2);
  }
  45% {
    transform: scale(1.06);
    box-shadow: 0 0 0 8px rgba(72, 187, 120, 0.4), 0 0 16px rgba(72, 187, 120, 0.5);
    border-color: #38a169;
    background: rgba(72, 187, 120, 0.15);
  }
  60% {
    transform: scale(0.99);
  }
  75% {
    transform: scale(1.04);
    box-shadow: 0 0 0 5px rgba(72, 187, 120, 0.25);
    border-color: #38a169;
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(72, 187, 120, 0);
    border-color: transparent;
  }
}

.presence-join-blink {
  animation: presenceJoinBlink 2.4s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

/* Avatar Pop-In Animation */
@keyframes avatarPopIn {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(-15deg);
  }
  60% {
    transform: scale(1.25) rotate(5deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}
.presence-avatar-new {
  animation: avatarPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Toast Alert for New Joiner */
.presence-toast-container {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 1800;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.presence-toast {
  background: var(--theme-card-bg);
  color: var(--theme-text);
  border: 1px solid var(--theme-border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: auto;
  backdrop-filter: none !important;
  max-width: 360px;
}

body.theme-sepia .presence-toast {
  background: #fdf6e7 !important;
  border: 1.5px solid #dfcfb2 !important;
  color: #2c221a !important;
}

body.theme-dark .presence-toast {
  background: #1e293b !important;
  border: 1.5px solid #334155 !important;
  color: #f1f5f9 !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

body.theme-white .presence-toast {
  background: #ffffff !important;
  border: 1.5px solid #e2e8f0 !important;
  color: #1a202c !important;
}

.presence-toast.interactive-presence-toast {
  padding: 8px 12px;
}

.presence-toast-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.presence-toast-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.presence-toast-title {
  font-size: 12px;
  line-height: 1.35;
  color: var(--theme-text);
  font-weight: 500;
}

.presence-toast-title strong {
  color: var(--theme-accent);
  font-weight: 700;
}

.presence-toast-sub {
  font-size: 10.5px;
  opacity: 0.75;
  color: var(--theme-text);
}

.presence-toast-greet-btn {
  font-size: 11px !important;
  padding: 4px 10px !important;
  min-height: 30px !important;
  flex-shrink: 0;
  border-radius: 12px !important;
}

.presence-toast-close-btn {
  background: transparent;
  border: none;
  color: var(--theme-text);
  opacity: 0.5;
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.presence-toast-close-btn:hover {
  opacity: 1;
}

.presence-toast.presence-toast-fadeout {
  animation: toastFadeOut 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideDown {
  from { opacity: 0; transform: translateY(-14px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastFadeOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-10px) scale(0.94); }
}

/* Welcome & Encouragement Toast Notification (Healing & Mindful Aesthetic) */
.welcome-toast-container {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1900;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  width: 92%;
  max-width: 460px;
}

.welcome-toast {
  background: linear-gradient(135deg, rgba(254, 252, 247, 0.96) 0%, rgba(244, 249, 245, 0.95) 100%);
  color: #2d3748;
  border: 1px solid rgba(72, 187, 120, 0.32);
  box-shadow: 0 16px 36px -6px rgba(47, 133, 90, 0.14), 0 4px 16px rgba(0, 0, 0, 0.05), inset 0 1px 1px rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  padding: 16px 20px;
  font-family: var(--font-sans);
  pointer-events: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: welcomeSlideDown 0.45s cubic-bezier(0.16, 1, 0.3, 1), welcomeFadeOut 0.5s 6.5s forwards;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

body.theme-dark .welcome-toast {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.96) 0%, rgba(20, 36, 32, 0.96) 100%);
  color: #e2e8f0;
  border-color: rgba(72, 187, 120, 0.35);
  box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

body.theme-sepia .welcome-toast {
  background: linear-gradient(135deg, rgba(253, 246, 231, 0.97) 0%, rgba(246, 240, 224, 0.95) 100%);
  border-color: rgba(214, 158, 46, 0.35);
  color: #2d3748;
}

@keyframes welcomeSlideDown {
  from { opacity: 0; transform: translateY(-24px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes welcomeFadeOut {
  to { opacity: 0; transform: translateY(-12px) scale(0.97); pointer-events: none; }
}

.welcome-toast-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(72, 187, 120, 0.12);
  color: #276749;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.2px;
}
body.theme-dark .welcome-toast-badge {
  background: rgba(72, 187, 120, 0.2);
  color: #9ae6b4;
}

.welcome-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.welcome-toast-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #22543d;
  display: flex;
  align-items: center;
  gap: 6px;
}
body.theme-dark .welcome-toast-title {
  color: #68d391;
}
body.theme-sepia .welcome-toast-title {
  color: #744210;
}

.welcome-toast-close {
  background: none;
  border: none;
  color: #718096;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}
.welcome-toast-close:hover {
  color: var(--theme-text);
  background: rgba(0, 0, 0, 0.06);
}

.welcome-toast-body {
  font-size: 13px;
  line-height: 1.6;
  color: #4a5568;
  font-family: var(--font-serif);
}
body.theme-dark .welcome-toast-body {
  color: #cbd5e0;
}
body.theme-sepia .welcome-toast-body {
  color: #4a5568;
}

.reader-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  max-width: 1560px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  min-width: 0;
}

/* Book Cover Card in Sidebar */
.book-card {
  display: flex;
  flex-direction: column;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.book-card-main {
  display: flex;
  gap: 12px;
  align-items: center;
}

.book-cover-picture {
  display: inline-block;
  flex-shrink: 0;
  width: 54px;
  height: 74px;
}

.book-cover-img {
  width: 54px;
  height: 74px;
  aspect-ratio: 1521 / 2299;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  transition: transform 0.2s ease;
  background-color: var(--theme-border);
  display: block;
}
.book-cover-img:hover {
  transform: scale(1.05);
}

.book-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}

.book-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--theme-text);
  line-height: 1.3;
}

.book-author {
  margin: 2px 0 0 0;
  font-size: 11.5px;
  color: var(--theme-muted, #718096);
}

.book-lang-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--theme-border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.book-lang-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--theme-muted, #718096);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.book-lang-switch {
  display: flex;
  background: rgba(0, 0, 0, 0.04);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--theme-border);
  gap: 3px;
  width: 100%;
  box-sizing: border-box;
}

.lang-btn {
  flex: 1;
  font-size: 11.5px;
  padding: 6px 4px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--theme-text);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.lang-btn:hover {
  color: var(--theme-accent);
}

.lang-btn.active {
  background: var(--theme-card-bg);
  color: var(--theme-accent);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.lang-pill-group .theme-pill.active {
  background: var(--theme-accent);
  color: white;
  border-color: var(--theme-accent);
  font-weight: 700;
}

/* Chapter 1 Hero Book Cover Display */
.chapter-cover-hero {
  text-align: center;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--theme-border);
  display: flex;
  justify-content: center;
}

.chapter-cover-hero picture {
  display: inline-block;
  max-width: 240px;
  width: 100%;
}

.chapter-cover-hero img {
  max-width: 240px;
  width: 100%;
  aspect-ratio: 1521 / 2299;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s ease;
  background-color: var(--theme-border);
  display: block;
  margin: 0 auto;
}
.chapter-cover-hero img:hover {
  transform: scale(1.03);
}

/* Sidebar & TOC */
.sidebar-toc {
  border-right: 1px solid var(--theme-border);
  padding: 20px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  overflow-y: auto;
  height: calc(100dvh - 60px);
  position: sticky;
  top: 60px;
}

.toc-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #718096;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.toc-item {
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 6px;
  color: var(--theme-text);
  opacity: 0.85;
  transition: all 0.15s ease;
  line-height: 1.4;
}
.toc-item:hover {
  background: var(--theme-border);
  opacity: 1;
}
.toc-item.active {
  background: var(--theme-accent);
  color: white !important;
  opacity: 1;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(49, 130, 206, 0.3);
}

/* Reader Main Content */
.reader-main {
  padding: 40px 60px 100px 60px;
  max-width: 800px;
  margin: 0 auto;
  font-size: 17px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: calc(100dvh - 60px);
  overflow-wrap: break-word;
  word-break: break-word;
}

#chapterBody {
  min-height: 70vh;
}

.chapter-heading {
  font-family: var(--font-sans);
  font-size: clamp(1.3rem, 1.15rem + 1vw, 1.65rem);
  font-weight: 700;
  margin-bottom: 30px;
  min-height: 38px;
  line-height: 1.35;
  color: var(--theme-text);
  border-bottom: 2px solid var(--theme-border);
  padding-bottom: 16px;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Skeleton Loading State to eliminate Cumulative Layout Shift */
.reader-skeleton-loader {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 0 36px 0;
}

.skeleton-line {
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--theme-border) 25%, rgba(150, 150, 150, 0.08) 50%, var(--theme-border) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

.skeleton-line.w-hero { height: 260px; width: 180px; margin: 0 auto 24px auto; border-radius: 12px; }
.skeleton-line.w-90 { width: 90%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-95 { width: 95%; }
.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-85 { width: 85%; }
.skeleton-line.w-60 { width: 60%; }

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.paragraph-block {
  margin-bottom: 22px;
  position: relative;
  border-radius: 6px;
  padding: 4px 8px;
  transition: background 0.15s, outline 0.15s;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}
.paragraph-block:hover {
  background: rgba(0, 0, 0, 0.025);
}
.paragraph-block.is-active-selected {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
  background: rgba(49, 130, 206, 0.06) !important;
}

@keyframes resumePulse {
  0% {
    background-color: var(--highlight-yellow);
    box-shadow: 0 0 0 4px rgba(236, 201, 75, 0.35);
    border-radius: 6px;
  }
  60% {
    background-color: var(--highlight-yellow);
    box-shadow: 0 0 0 3px rgba(236, 201, 75, 0.2);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
  }
}

.paragraph-block.reading-resume-pulse {
  animation: resumePulse 2.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.paragraph-content {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  word-wrap: break-word;
}

.paragraph-content p {
  margin: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  word-wrap: break-word;
}

.paragraph-content a {
  color: var(--theme-accent);
  overflow-wrap: anywhere;
  word-break: break-all;
  word-wrap: break-word;
}

.paragraph-content a[href^="javascript:jumpToHighlight"] {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px 3px 2px 0;
  background: var(--theme-sidebar);
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  font-size: 0.86em;
  font-weight: 500;
  text-decoration: none;
  color: var(--theme-accent);
  transition: all 0.15s ease;
  word-break: normal;
  white-space: nowrap;
  vertical-align: middle;
}

.paragraph-content a[href^="javascript:jumpToHighlight"]:hover,
.paragraph-content a[href^="javascript:jumpToHighlight"]:active {
  background: var(--theme-accent);
  color: #ffffff !important;
  border-color: var(--theme-accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.paragraph-content blockquote {
  margin: 0;
  padding: 12px 18px;
  border-left: 4px solid var(--theme-accent);
  background: rgba(0, 0, 0, 0.03);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  overflow-wrap: break-word;
  word-break: break-word;
}

.paragraph-content ul, .paragraph-content ol {
  margin: 8px 0;
  padding-left: 24px;
  max-width: 100%;
  box-sizing: border-box;
}

.paragraph-content li {
  margin-bottom: 6px;
  overflow-wrap: break-word;
  word-break: break-word;
  word-wrap: break-word;
}

.paragraph-content table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.paragraph-content th, .paragraph-content td {
  padding: 8px 12px;
  border: 1px solid var(--theme-border);
  white-space: normal;
  min-width: 120px;
}
.paragraph-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px auto;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--theme-border, rgba(0, 0, 0, 0.06));
}
.paragraph-content pre {
  max-width: 100%;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.04);
  padding: 12px;
  border-radius: 6px;
  -webkit-overflow-scrolling: touch;
}
.paragraph-content code {
  word-break: break-word;
  overflow-wrap: break-word;
  font-family: monospace;
  font-size: 0.9em;
}

.paragraph-content h1, .paragraph-content h2, .paragraph-content h3, .paragraph-content h4 {
  font-family: var(--font-sans);
  margin-top: 18px;
  margin-bottom: 10px;
  line-height: 1.35;
  color: var(--theme-text);
  overflow-wrap: break-word;
  word-break: break-word;
}
.paragraph-content h1 { font-size: 22px; font-weight: 700; }
.paragraph-content h2 { font-size: 20px; font-weight: 700; }
.paragraph-content h3 { font-size: 17px; font-weight: 600; color: #4a5568; }
.paragraph-content h4 { font-size: 15px; font-weight: 600; }
.paragraph-content hr {
  border: none;
  border-top: 1px solid var(--theme-border);
  margin: 20px 0;
}

.paragraph-reactions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
}
.reaction-pill {
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  padding: 2px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.reaction-pill:hover {
  border-color: var(--theme-accent);
}

/* Floating Action Toolbar */
.floating-toolbar {
  position: absolute;
  display: none;
  background: #1f2937;
  color: white;
  border-radius: 30px;
  padding: 6px 14px;
  font-family: var(--font-sans);
  font-size: 12px;
  gap: 10px;
  align-items: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  z-index: 1000;
  transform: translate(-50%, -100%);
  margin-top: -10px;
  animation: popIn 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -85%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -100%) scale(1); }
}

.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.4);
  transition: transform 0.15s;
}
.color-dot:hover { transform: scale(1.25); border-color: white; }

.toolbar-btn {
  background: none;
  border: none;
  color: #e5e7eb;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.1s;
}
.toolbar-btn:hover { background: rgba(255,255,255,0.15); color: white; }

/* Right Margin Drawer */
.margin-drawer {
  border-left: 1px solid var(--theme-border);
  padding: 20px 18px;
  font-family: var(--font-sans);
  font-size: 13px;
  overflow-y: auto;
  height: calc(100dvh - 60px);
  position: sticky;
  top: 60px;
  background: var(--theme-card-bg);
}

/* Modern Segmented Control Tab Navigation */
.tab-nav {
  display: flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar {
  display: none;
}
.tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--theme-text);
  opacity: 0.68;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 0;
}
.tab-btn:hover {
  opacity: 0.95;
  background: rgba(0, 0, 0, 0.04);
}
.tab-btn.active {
  opacity: 1;
  background: white;
  color: var(--theme-text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
body.theme-dark .tab-nav {
  background: rgba(255, 255, 255, 0.08);
}
body.theme-dark .tab-btn.active {
  background: #2d3748;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Note & Interactive Cards */
.note-card {
  background: var(--theme-bg);
  border: 1px solid var(--theme-border);
  border-radius: 12px;
  padding: 13px 15px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.note-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-color: var(--theme-accent);
}
.note-quote-context {
  font-size: 12px;
  font-style: italic;
  color: #718096;
  background: rgba(0,0,0,0.025);
  border-left: 3px solid #ecc94b;
  padding: 5px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
  line-height: 1.4;
  cursor: pointer;
}
.note-quote-context:hover {
  color: var(--theme-accent);
}
.jump-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(49, 130, 206, 0.08);
  color: #3182ce;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.jump-pill-btn:hover {
  background: rgba(49, 130, 206, 0.18);
}

/* Spotlight pulse animation when jumping to paragraph */
@keyframes spotlightPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(49, 130, 206, 0.4); }
  50% { transform: scale(1.008); box-shadow: 0 0 0 8px rgba(49, 130, 206, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(49, 130, 206, 0); }
}
.paragraph-spotlight {
  animation: spotlightPulse 1.2s ease-in-out;
  outline: 2px solid var(--theme-accent) !important;
  border-radius: 8px;
}

/* Reflection Box (Trạm Dừng Chân & Lắng Đọng) */
.reflection-section {
  margin-top: 48px;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 16px;
  padding: 24px;
  font-family: var(--font-sans);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.reflection-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.safe-space-badge {
  font-size: 11px;
  font-weight: 600;
  color: #2b6cb0;
  background: rgba(49, 130, 206, 0.1);
  padding: 3px 10px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sentence-starters-wrapper {
  margin-bottom: 12px;
}

.starters-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--theme-muted, #718096);
  margin-bottom: 6px;
}

.sentence-starter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.starter-pill {
  background: rgba(0, 0, 0, 0.03);
  border: 1px dashed var(--theme-border);
  color: var(--theme-text);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
}

.starter-pill:hover {
  background: rgba(49, 130, 206, 0.08);
  border-color: var(--theme-accent);
  color: var(--theme-accent);
  transform: translateY(-1px);
}

.reflection-textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--theme-border);
  border-radius: 10px;
  font-size: 14.5px;
  font-family: var(--font-sans);
  background: var(--theme-bg);
  color: var(--theme-text);
  resize: vertical;
  line-height: 1.6;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.reflection-textarea:focus {
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15);
}

.reflection-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.reflection-privacy-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.privacy-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--theme-text);
  cursor: pointer;
  user-select: none;
}

.privacy-checkbox-label input[type="checkbox"] {
  accent-color: var(--theme-accent);
  cursor: pointer;
  width: 15px;
  height: 15px;
}

.reflection-submit-btn {
  background: var(--theme-accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 9px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 10px -2px rgba(49, 130, 206, 0.3);
}

.reflection-submit-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px -2px rgba(49, 130, 206, 0.4);
}

.reflection-card {
  background: var(--theme-bg);
  border: 1px solid var(--theme-border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 12px;
  transition: all 0.15s ease;
}

.reflection-card:hover {
  border-color: rgba(49, 130, 206, 0.3);
}

.badge-host {
  background: rgba(234, 179, 8, 0.15);
  color: #b45309;
  border: 1px solid rgba(234, 179, 8, 0.4);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10.5px;
  font-weight: 700;
  margin-left: 6px;
}

.badge-anon {
  background: rgba(72, 187, 120, 0.15);
  color: #276749;
  border: 1px solid rgba(72, 187, 120, 0.3);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10.5px;
  font-weight: 600;
  margin-left: 6px;
}

.badge-private {
  background: rgba(159, 122, 234, 0.15);
  color: #6b46c1;
  border: 1px solid rgba(159, 122, 234, 0.3);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10.5px;
  font-weight: 600;
  margin-left: 6px;
}

/* Item Like / Heart Encouragement Button */
.note-footer, .reflection-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px dashed var(--theme-border);
}

.item-like-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--theme-border);
  border-radius: 16px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--theme-muted, #718096);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  min-height: 28px;
}

.item-like-btn:hover {
  background: rgba(229, 62, 62, 0.08);
  border-color: rgba(229, 62, 62, 0.3);
  color: #e53e3e;
  transform: translateY(-1px);
}

.item-like-btn.is-liked {
  background: rgba(229, 62, 62, 0.12);
  border-color: rgba(229, 62, 62, 0.35);
  color: #e53e3e;
}

.item-like-btn.is-liked .like-heart-icon {
  transform: scale(1.15);
  filter: drop-shadow(0 1px 2px rgba(229, 62, 62, 0.3));
}

.like-heart-icon {
  font-size: 12.5px;
  display: inline-block;
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.item-like-btn.pop-anim .like-heart-icon {
  animation: heartPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes heartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.45); }
  100% { transform: scale(1.15); }
}

.like-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

body.theme-dark .item-like-btn:hover,
body.theme-dark .item-like-btn.is-liked {
  background: rgba(229, 62, 62, 0.2);
  border-color: rgba(229, 62, 62, 0.45);
  color: #fc8181;
}

/* User Identity Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  animation: modalOverlayFade 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalOverlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalFadeScale {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-card {
  background: var(--theme-card-bg);
  color: var(--theme-text);
  padding: 32px;
  border-radius: 20px;
  max-width: 440px;
  width: 92%;
  max-height: 90dvh;
  overflow-y: auto;
  font-family: var(--font-sans);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--theme-border);
}

/* Cozy & Mindful Identity Modal Card */
.identity-modal-card {
  background: var(--theme-card-bg);
  color: var(--theme-text);
  border: 1.5px solid var(--theme-border);
  border-radius: 26px;
  padding: 32px 28px 26px 28px;
  max-width: 460px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(0, 0, 0, 0.05);
  position: relative;
  animation: modalFadeScale 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

body.theme-sepia .identity-modal-card {
  background: #fdf6e7;
  border-color: #e6dcbe;
  box-shadow: 0 24px 60px -12px rgba(90, 60, 20, 0.32), 0 0 0 1px rgba(120, 90, 40, 0.1);
}

body.theme-white .identity-modal-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

body.theme-dark .identity-modal-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.identity-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.identity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: rgba(72, 187, 120, 0.14);
  color: #276749;
  border: 1px solid rgba(72, 187, 120, 0.3);
}

body.theme-sepia .identity-badge {
  background: rgba(180, 130, 60, 0.12);
  color: #744210;
  border-color: rgba(180, 130, 60, 0.25);
}

body.theme-dark .identity-badge {
  background: rgba(72, 187, 120, 0.2);
  color: #68d391;
  border-color: rgba(72, 187, 120, 0.4);
}

.identity-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--theme-text);
  opacity: 0.65;
  padding: 6px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.identity-close-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

body.theme-dark .identity-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.identity-title {
  margin: 0 0 10px 0;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  color: var(--theme-text);
  line-height: 1.35;
  text-wrap: balance;
}

.identity-intro {
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--theme-text);
  opacity: 0.88;
  line-height: 1.6;
  margin: 0 0 14px 0;
}

.identity-intro strong {
  font-weight: 600;
  color: var(--theme-text);
}

.identity-note-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 18px;
  font-family: var(--font-sans);
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--theme-border);
  color: var(--theme-text);
  opacity: 0.9;
}

body.theme-sepia .identity-note-box {
  background: rgba(180, 140, 75, 0.09);
  border-color: #e6dcbe;
  color: #5a3c14;
}

body.theme-dark .identity-note-box {
  background: rgba(255, 255, 255, 0.04);
  border-color: #334155;
  color: #cbd5e0;
}

.identity-note-icon {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.identity-note-text {
  flex: 1;
}

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

.identity-label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--theme-text);
  margin-bottom: 6px;
  font-family: var(--font-sans);
}

.identity-input-wrapper {
  position: relative;
}

.identity-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--theme-border);
  border-radius: 12px;
  font-size: 15px;
  font-family: var(--font-sans);
  outline: none;
  background: var(--theme-bg);
  color: var(--theme-text);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.identity-input::placeholder {
  color: var(--theme-text);
  opacity: 0.45;
}

.identity-input:focus {
  border-color: #38a169;
  box-shadow: 0 0 0 3px rgba(56, 161, 105, 0.2);
}

body.theme-sepia .identity-input:focus {
  border-color: #8c6239;
  box-shadow: 0 0 0 3px rgba(140, 98, 57, 0.2);
}

body.theme-dark .identity-input:focus {
  border-color: #48bb78;
  box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.25);
}

.identity-error-text {
  color: #e53e3e;
  font-size: 12px;
  margin: 6px 0 0 0;
  font-weight: 500;
  font-family: var(--font-sans);
}

body.theme-dark .identity-error-text {
  color: #fc8181;
}

.identity-submit-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(135deg, #2f855a 0%, #276749 100%);
  box-shadow: 0 4px 14px rgba(47, 133, 90, 0.28);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.identity-submit-btn:hover {
  background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(47, 133, 90, 0.36);
}

.identity-submit-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(47, 133, 90, 0.2);
}

body.theme-sepia .identity-submit-btn {
  background: linear-gradient(135deg, #8c6239 0%, #6e4823 100%);
  box-shadow: 0 4px 14px rgba(110, 72, 35, 0.28);
}

body.theme-sepia .identity-submit-btn:hover {
  background: linear-gradient(135deg, #9d7043 0%, #7d532b 100%);
  box-shadow: 0 6px 18px rgba(110, 72, 35, 0.36);
}

body.theme-dark .identity-submit-btn {
  background: linear-gradient(135deg, #38a169 0%, #276749 100%);
  box-shadow: 0 4px 14px rgba(56, 161, 105, 0.35);
}

.identity-btn-sparkle {
  font-size: 14px;
  display: inline-block;
  animation: btnSparklePulse 2s ease-in-out infinite;
}

@keyframes btnSparklePulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.2); opacity: 1; }
}

.identity-footer {
  text-align: center;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--theme-text);
  opacity: 0.65;
  line-height: 1.45;
  font-family: var(--font-sans);
}

.identity-threads-link {
  color: #2b6cb0;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.15s;
}

.identity-threads-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

body.theme-sepia .identity-threads-link {
  color: #8c6239;
}

body.theme-dark .identity-threads-link {
  color: #63b3ed;
}

@media (max-width: 600px) {
  .identity-modal-card {
    padding: 24px 18px 20px 18px;
    border-radius: 20px;
    width: 95%;
  }
  .identity-title {
    font-size: 18px;
  }
  .identity-intro {
    font-size: 13px;
  }
  .identity-input {
    font-size: 16px;
    min-height: 44px;
  }
  .identity-submit-btn {
    font-size: 15px;
    min-height: 48px;
  }
}

/* Readers List Modal Custom Styles */
.readers-modal-card {
  max-width: 520px;
  padding: 24px;
  border-radius: 18px;
}
.readers-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 14px;
}
.readers-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60dvh;
  overflow-y: auto;
  padding-right: 4px;
}
.reader-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  transition: all 0.15s ease;
}
.reader-card-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e0;
  transform: translateY(-1px);
}
.reader-avatar-wrapper {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.reader-online-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #48bb78;
  border: 2px solid white;
}
.reader-offline-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #a0aec0;
  border: 2px solid white;
}
.reader-details {
  flex: 1;
  margin-left: 12px;
  min-width: 0;
}
.reader-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.reader-name {
  font-weight: 700;
  font-size: 13.5px;
  color: #1a202c;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.threads-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #3182ce;
  background: rgba(49, 130, 206, 0.08);
  padding: 2px 7px;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.15s;
}
.threads-badge:hover {
  background: rgba(49, 130, 206, 0.18);
}
.reader-sub-info {
  font-size: 11.5px;
  color: #718096;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.reader-stats-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.reader-stat-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 6px;
  background: #edf2f7;
  color: #4a5568;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Readers Modal Tab Group */
.readers-modal-tab-group {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}
.readers-modal-tab-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #718096;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.readers-modal-tab-btn.active {
  background: white;
  color: var(--theme-accent, #2b6cb0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
body.theme-dark .readers-modal-tab-group {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}
body.theme-dark .readers-modal-tab-btn {
  color: #a0aec0;
}
body.theme-dark .readers-modal-tab-btn.active {
  background: #2d3748;
  color: #63b3ed;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Reader Book Tag */
.reader-book-tag {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: 11px;
  color: var(--theme-accent, #3182ce);
  background: rgba(49, 130, 206, 0.1);
  padding: 1px 6px;
  border-radius: 6px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.theme-dark .reader-book-tag {
  background: rgba(99, 179, 237, 0.15);
  color: #90cdf4;
}

/* Book Popularity Ranking Card Items */
.book-ranking-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  transition: all 0.15s ease;
  gap: 12px;
}
.book-ranking-card-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e0;
  transform: translateY(-1px);
}
body.theme-dark .book-ranking-card-item {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}
body.theme-dark .book-ranking-card-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}
.book-rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.book-rank-1 {
  background: linear-gradient(135deg, #ecc94b, #d69e2e);
  color: #744210;
  box-shadow: 0 2px 4px rgba(214, 158, 46, 0.3);
}
.book-rank-2 {
  background: linear-gradient(135deg, #e2e8f0, #cbd5e0);
  color: #4a5568;
}
.book-rank-3 {
  background: linear-gradient(135deg, #ed8936, #dd6b20);
  color: white;
}
.book-rank-other {
  background: rgba(0, 0, 0, 0.05);
  color: #718096;
}
body.theme-dark .book-rank-other {
  background: rgba(255, 255, 255, 0.08);
  color: #a0aec0;
}
.book-ranking-info {
  flex: 1;
  min-width: 0;
}
.book-ranking-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.book-ranking-title {
  font-weight: 700;
  font-size: 13.5px;
  color: #1a202c;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.theme-dark .book-ranking-title {
  color: #e2e8f0;
}
.book-ranking-author {
  font-size: 11.5px;
  color: #718096;
  margin-top: 2px;
}
body.theme-dark .book-ranking-author {
  color: #a0aec0;
}
.book-ranking-stats-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #4a5568;
  margin-top: 4px;
  flex-wrap: wrap;
}
body.theme-dark .book-ranking-stats-row {
  color: #cbd5e0;
}
.book-ranking-stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.04);
}
body.theme-dark .book-ranking-stat-badge {
  background: rgba(255, 255, 255, 0.06);
}
.book-switch-action-btn {
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--theme-border, #cbd5e0);
  background: white;
  color: var(--theme-accent, #3182ce);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.book-switch-action-btn:hover {
  background: var(--theme-accent, #3182ce);
  color: white;
  border-color: var(--theme-accent, #3182ce);
}
.book-switch-action-btn.active {
  background: rgba(72, 187, 120, 0.15);
  border-color: #48bb78;
  color: #276749;
  cursor: default;
}
body.theme-dark .book-switch-action-btn {
  background: #2d3748;
  color: #90cdf4;
  border-color: #4a5568;
}
body.theme-dark .book-switch-action-btn:hover {
  background: #3182ce;
  color: white;
}

/* Desktop Leaderboard Button */
.desktop-leaderboard-btn {

  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--theme-border);
  padding: 4px 10px;
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--theme-text);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
.desktop-leaderboard-btn:hover {
  background: rgba(234, 179, 8, 0.15);
  border-color: #eab308;
  transform: translateY(-1px);
  color: #b45309;
}

/* Leaderboard Modal Custom Styles */
.leaderboard-card {
  max-width: 540px;
  padding: 22px;
  border-radius: 20px;
  background: var(--theme-card-bg);
  color: var(--theme-text);
  border: 1px solid var(--theme-border);
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  overflow: hidden;
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--theme-border);
  margin-bottom: 12px;
}

.leaderboard-tabs {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.lb-tab-btn {
  flex: 1;
  padding: 8px 6px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--theme-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  white-space: nowrap;
}
.lb-tab-btn.active {
  background: var(--theme-card-bg);
  color: var(--theme-text);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.leaderboard-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 52dvh;
}

/* Podium Top 3 */
.podium-container {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  align-items: flex-end;
  gap: 8px;
  margin: 4px 0 14px 0;
  padding: 14px 10px 12px 10px;
  background: linear-gradient(180deg, rgba(234, 179, 8, 0.08) 0%, rgba(0, 0, 0, 0.02) 100%);
  border-radius: 16px;
  border: 1px solid rgba(234, 179, 8, 0.2);
}

.podium-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.podium-crown {
  font-size: 22px;
  margin-bottom: -4px;
  filter: drop-shadow(0 2px 4px rgba(234, 179, 8, 0.4));
  animation: crownFloat 2s ease-in-out infinite alternate;
}
@keyframes crownFloat {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

.podium-avatar-wrapper {
  position: relative;
  margin-bottom: 6px;
}
.podium-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  border: 2.5px solid white;
}
.podium-rank-1 .podium-avatar {
  width: 54px;
  height: 54px;
  font-size: 20px;
  border-color: #facc15;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.45);
}
.podium-rank-2 .podium-avatar {
  border-color: #cbd5e1;
}
.podium-rank-3 .podium-avatar {
  border-color: #d97706;
}

.podium-rank-tag {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: white;
  border: 1.5px solid white;
}
.tag-gold { background: #eab308; }
.tag-silver { background: #94a3b8; }
.tag-bronze { background: #d97706; }

.podium-name {
  font-size: 11.5px;
  font-weight: 700;
  max-width: 85px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.podium-points {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--theme-accent);
  background: rgba(49, 130, 206, 0.1);
  padding: 2px 6px;
  border-radius: 10px;
  white-space: nowrap;
}
.podium-subtext {
  font-size: 9px;
  color: var(--theme-muted);
  margin-top: 2px;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Leaderboard List (Rank #4+) */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 12px;
  transition: all 0.15s ease;
}
.lb-row-item:hover {
  transform: translateX(2px);
  background: rgba(0, 0, 0, 0.02);
}
.lb-row-item.is-current-user {
  border-color: var(--theme-accent);
  background: rgba(49, 130, 206, 0.05);
}

.lb-rank-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--theme-muted);
  width: 20px;
  text-align: center;
}

.lb-avatar-small {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.lb-user-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin: 0 10px;
  min-width: 0;
}
.lb-user-name {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.lb-user-badges {
  display: inline-flex;
  gap: 2px;
}

.lb-user-meta {
  font-size: 10px;
  color: var(--theme-muted);
}

.lb-score-pill {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--theme-accent);
  text-align: right;
  flex-shrink: 0;
}

/* Collective Field Banner */
.collective-field-banner {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.08) 0%, rgba(139, 92, 246, 0.1) 50%, rgba(59, 130, 246, 0.08) 100%);
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.field-banner-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  gap: 6px;
}
.field-banner-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--theme-text);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field-banner-pct {
  font-size: 11px;
  font-weight: 800;
  color: #8b5cf6;
  white-space: nowrap;
  flex-shrink: 0;
}
.field-progress-track {
  width: 100%;
  height: 5px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  overflow: hidden;
}
.field-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f97316 0%, #8b5cf6 50%, #3b82f6 100%);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.field-banner-desc {
  font-size: 10px;
  color: var(--theme-muted);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Sticky Personal Rank Card */
.leaderboard-personal-card {
  margin-top: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(59, 130, 246, 0.08) 100%);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 8px;
}
.personal-rank-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--theme-accent);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}
.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(139, 92, 246, 0.15);
  color: #7c3aed;
  padding: 1.5px 6px;
  border-radius: 8px;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
body.theme-dark .stage-pill {
  background: rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
}
.stage-progress-wrapper {
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.stage-progress-track {
  flex: 1;
  height: 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  overflow: hidden;
}
.stage-progress-fill {
  height: 100%;
  background: #8b5cf6;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.personal-suggestion {
  font-size: 10.5px;
  color: var(--theme-text);
  line-height: 1.3;
  margin-top: 2px;
  opacity: 0.9;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 600px) {
  .leaderboard-card {
    max-height: 90dvh;
    padding: 14px 12px 10px 12px;
    width: 95%;
  }
  .leaderboard-header {
    padding-bottom: 8px;
    margin-bottom: 8px;
  }
  .leaderboard-tabs {
    margin-bottom: 8px;
    padding: 3px;
    gap: 4px;
  }
  .lb-tab-btn {
    padding: 6px 3px;
    font-size: 11px;
  }
  .podium-container {
    padding: 10px 4px 8px 4px;
    margin: 2px 0 8px 0;
    gap: 4px;
  }
  .podium-avatar {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }
  .podium-rank-1 .podium-avatar {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }
  .podium-name {
    font-size: 11px;
    max-width: 80px;
  }
  .podium-points {
    font-size: 10.5px;
  }
  .podium-subtext {
    font-size: 9px;
    max-width: 80px;
  }
  .leaderboard-personal-card {
    padding: 7px 10px;
  }
}

/* Reading Progress Bar */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--theme-accent);
  z-index: 1001;
  width: 0%;
  transition: width 0.1s ease-out;
}

/* Chapter Navigation Footer */
.chapter-nav-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 40px 0 30px 0;
  padding-top: 24px;
  border-top: 1px solid var(--theme-border);
}

.chapter-nav-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--theme-border);
  background: var(--theme-card-bg);
  color: var(--theme-text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.chapter-nav-btn:hover {
  background: var(--theme-border);
  transform: translateY(-1px);
}
.chapter-nav-btn.primary {
  background: var(--theme-accent);
  color: white;
  border-color: var(--theme-accent);
}
.chapter-nav-btn.primary:hover {
  opacity: 0.95;
  box-shadow: 0 4px 10px rgba(49, 130, 206, 0.3);
}

/* Drawer Overlay & Mobile Headers */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 1400;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.drawer-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-drawer-top {
  display: none;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--theme-border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.mobile-drawer-top h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--theme-text);
}
.sheet-close-btn {
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: bold;
  color: var(--theme-text);
  cursor: pointer;
}

/* Mobile Quick Settings Sheet */
.mobile-settings-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--theme-card-bg);
  border-top: 1px solid var(--theme-border);
  border-radius: 20px 20px 0 0;
  padding: 20px 24px 34px 24px;
  z-index: 1500;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
  transform: translateY(105%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-sans);
}
.mobile-settings-sheet.active {
  transform: translateY(0);
}

.settings-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.settings-sheet-header h4 {
  margin: 0;
  font-size: 16px;
}

.settings-group {
  margin-bottom: 16px;
}
.settings-label {
  display: block;
  font-size: 12px;
  color: #718096;
  font-weight: 600;
  margin-bottom: 8px;
}

.theme-pill-group {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.theme-pill {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--theme-border);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-pill.sepia { background: #fbf0d9; color: #2d3748; }
.theme-pill.white { background: #ffffff; color: #1a202c; }
.theme-pill.dark { background: #1a202c; color: #e2e8f0; }

.book-switch-pill-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.book-switch-btn {
  text-align: center;
  font-size: 12px;
  line-height: 1.3;
  padding: 8px 6px;
  white-space: normal;
  word-break: break-word;
  transition: all 0.2s ease;
}
@media (max-width: 480px) {
  .book-switch-pill-group {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .book-switch-btn {
    padding: 10px 12px;
    font-size: 13px;
    justify-content: flex-start;
  }
}

.font-controls-group {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--theme-bg);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--theme-border);
}
.font-btn {
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  padding: 6px 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--theme-text);
}
.font-family-btn {
  margin-left: auto;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--theme-text);
}

/* Mobile Bottom Navigation Dock */
.mobile-bottom-dock {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--theme-card-bg);
  border-top: 1px solid var(--theme-border);
  z-index: 1200;
  justify-content: space-around;
  align-items: center;
  padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
  padding-left: max(0px, env(safe-area-inset-left, 0px));
  padding-right: max(0px, env(safe-area-inset-right, 0px));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

body.theme-sepia .mobile-bottom-dock {
  background: #fdf6e7;
  border-color: #e6dcbe;
  box-shadow: 0 -4px 20px rgba(120, 90, 40, 0.08);
}
body.theme-white .mobile-bottom-dock {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}
body.theme-dark .mobile-bottom-dock {
  background: #0f172a;
  border-color: #1e293b;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.dock-btn {
  flex: 1;
  height: 100%;
  min-height: 48px;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--theme-text);
  opacity: 0.8;
  cursor: pointer;
  position: relative;
  transition: opacity 0.15s ease, transform 0.12s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}
.dock-btn:active {
  transform: scale(0.90);
  opacity: 1;
}
.dock-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.dock-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  transition: stroke 0.2s, transform 0.2s;
}
.dock-label {
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0.1px;
}
.dock-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 16px);
  background: #e53e3e;
  color: white;
  border-radius: 10px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 800;
  box-shadow: 0 2px 5px rgba(229, 62, 62, 0.4);
}

/* Modern Vector Icons */
.ui-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
}
.brand-logo svg {
  color: var(--theme-accent);
  transition: transform 0.2s ease;
}
.brand-logo:hover svg {
  transform: rotate(-5deg) scale(1.1);
}
.chapter-nav-btn svg {
  stroke-width: 2.2;
  transition: transform 0.15s ease;
}
.chapter-nav-btn:hover svg {
  transform: translateX(-3px);
}
.chapter-nav-btn.primary:hover svg {
  transform: translateX(3px);
}
.tab-btn svg {
  margin-right: 5px;
  vertical-align: -2px;
}
.theme-pill svg {
  margin-right: 4px;
}
.desktop-theme-switcher button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--theme-text);
  opacity: 0.75;
  transition: all 0.15s;
}
.desktop-theme-switcher button:hover {
  opacity: 1;
  background: rgba(0,0,0,0.06);
}
.sheet-close-btn, .modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: 1px solid var(--theme-border);
  background: rgba(0, 0, 0, 0.04);
  color: var(--theme-text);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.sheet-close-btn:hover, .modal-close:hover {
  background: rgba(0, 0, 0, 0.09);
  transform: rotate(90deg) scale(1.05);
}
.sheet-close-btn:active, .modal-close:active {
  transform: scale(0.92);
  background: rgba(0, 0, 0, 0.12);
}
body.theme-dark .sheet-close-btn,
body.theme-dark .modal-close {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
  .navbar {
    padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
    flex-wrap: nowrap !important;
    gap: 6px;
    overflow: hidden;
  }
  .desktop-theme-switcher {
    display: none !important;
  }
  .desktop-leaderboard-btn {
    display: none !important;
  }
  .presence-label {
    display: none;
  }
  .brand-logo {
    gap: 8px;
    font-size: 14px;
    flex-shrink: 0;
    min-width: 0;
  }
  .brand-name {
    display: none !important;
  }
  .header-book-badge {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 14px;
    max-width: 165px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: -0.2px;
  }
  .header-right-actions {
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: nowrap !important;
  }
  .presence-badge-wrapper {
    padding: 2px 6px;
    gap: 3px;
    max-width: 105px;
    flex-shrink: 0;
    flex-wrap: nowrap !important;
  }
  .presence-avatars-list {
    flex-wrap: nowrap !important;
    flex-shrink: 0;
  }
  .presence-avatar-item, .presence-more-badge {
    width: 24px;
    height: 24px;
    font-size: 11px;
    margin-left: -5px;
  }
  .presence-avatar-item:first-child {
    margin-left: 0;
  }
  .user-badge {
    padding: 2px !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    flex-shrink: 0;
  }
  .user-badge strong {
    display: none !important;
  }
  .presence-toast-container {
    top: 54px;
    right: 12px;
    left: 12px;
    align-items: center;
  }
  
  .reader-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    min-width: 0;
  }

  .reader-main {
    padding: 20px max(14px, env(safe-area-inset-right, 0px)) 120px max(14px, env(safe-area-inset-left, 0px));
    font-size: 16.5px;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .chapter-heading {
    font-size: clamp(1.2rem, 1.05rem + 1.2vw, 1.45rem);
    margin-bottom: 18px;
    padding-bottom: 12px;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .paragraph-block {
    padding: 4px 2px;
    margin-bottom: 18px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }

  .paragraph-content {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }

  .paragraph-content ul, .paragraph-content ol {
    padding-left: 18px;
    margin: 6px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Full Screen Gapless Drawer Transformation on Mobile */
  .sidebar-toc {
    display: none;
    visibility: hidden;
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    background: var(--theme-bg);
    z-index: 1600;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
    padding: max(16px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(84px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
    border-right: none;
    overscroll-behavior: contain;
  }
  .sidebar-toc.active {
    display: block;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  .sheet-handle {
    display: none;
  }

  .margin-drawer {
    display: none;
    visibility: hidden;
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    background: var(--theme-bg);
    border-radius: 0;
    border: none;
    z-index: 1600;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
    padding: max(16px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) max(84px, env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
    overscroll-behavior: contain;
  }
  .margin-drawer.active {
    display: flex;
    flex-direction: column;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
  .margin-drawer #notesTabContent {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
  }

  .mobile-drawer-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--theme-border);
  }
  .mobile-drawer-top h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--theme-text);
  }

  .mobile-bottom-dock {
    display: flex;
  }

  /* Prevent Mobile Chrome Contextual / Touch-to-Search Across Entire Reader on Mobile */
  .reader-main, 
  .paragraph-block, 
  .paragraph-content, 
  .chapter-heading, 
  .reflection-section,
  .reflection-section p,
  .reflections-list,
  .sentence-starters-wrapper {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
  }
}

/* Lock background scroll when drawer is active */
body.drawer-open {
  overflow: hidden !important;
  touch-action: none;
}

/* Greeting / High-Five Button & Particle Animation */
.greet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(72, 187, 120, 0.12);
  color: #276749;
  border: 1px solid rgba(72, 187, 120, 0.3);
  padding: 4px 9px;
  min-height: 28px;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  font-family: var(--font-sans);
}
.greet-btn:hover {
  background: rgba(72, 187, 120, 0.22);
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 2px 8px rgba(72, 187, 120, 0.2);
}
.greet-btn:active {
  transform: scale(0.94);
}
.greet-btn.is-sent {
  background: rgba(0, 0, 0, 0.05);
  color: var(--theme-muted);
  border-color: transparent;
  pointer-events: none;
}
body.theme-dark .greet-btn {
  background: rgba(72, 187, 120, 0.18);
  color: #9ae6b4;
  border-color: rgba(72, 187, 120, 0.35);
}

.podium-greet-btn {
  margin-top: 4px;
  font-size: 11px;
  padding: 3px 8px;
  min-height: 26px;
  border-radius: 12px;
}

/* Floating Greeting Particle */
.floating-greeting-particle {
  position: fixed;
  pointer-events: none;
  z-index: 2500;
  font-size: 24px;
  animation: particleFlyUp 1.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes particleFlyUp {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.6) rotate(0deg);
  }
  20% {
    opacity: 1;
    transform: translateY(-20px) scale(1.2) rotate(10deg);
  }
  80% {
    opacity: 0.9;
    transform: translateY(-80px) scale(1) rotate(-8deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-120px) scale(0.8) rotate(15deg);
  }
}

/* Received Greeting Toast */
.greeting-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 360px;
  width: 90%;
}
@media (max-width: 768px) {
  .greeting-toast-container {
    bottom: 80px;
    right: 50%;
    transform: translateX(50%);
    max-width: 92%;
  }
}

.greeting-toast {
  background: linear-gradient(135deg, rgba(254, 252, 247, 0.98) 0%, rgba(240, 249, 243, 0.97) 100%);
  color: #2d3748;
  border: 1.5px solid rgba(72, 187, 120, 0.4);
  box-shadow: 0 16px 36px -4px rgba(47, 133, 90, 0.2), 0 4px 12px rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  padding: 12px 14px;
  font-family: var(--font-sans);
  pointer-events: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: greetingSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1), greetingFadeOut 0.4s 7.5s forwards;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
body.theme-dark .greeting-toast {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.98) 0%, rgba(20, 36, 32, 0.98) 100%);
  color: #e2e8f0;
  border-color: rgba(72, 187, 120, 0.45);
}

@keyframes greetingSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes greetingFadeOut {
  to { opacity: 0; transform: translateY(10px) scale(0.95); pointer-events: none; }
}

/* Collective Resonance Gratitude Toast */
.resonance-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  pointer-events: none;
}
@media (max-width: 768px) {
  .resonance-toast-container {
    top: 58px;
    bottom: auto;
    right: 50%;
    transform: translateX(50%);
    max-width: 92%;
    width: 92%;
    z-index: 10005;
  }
}

.resonance-toast {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 243, 255, 0.98) 100%);
  color: #1e1b4b;
  border: 1.5px solid rgba(139, 92, 246, 0.45);
  box-shadow: 0 16px 36px -4px rgba(139, 92, 246, 0.25), 0 4px 12px rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  padding: 12px 14px;
  font-family: var(--font-sans);
  pointer-events: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.resonance-toast.is-leaving {
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
}
body.theme-dark .resonance-toast {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
  color: #e0e7ff;
  border-color: rgba(139, 92, 246, 0.55);
}
body.theme-dark .resonance-toast {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
  color: #e0e7ff;
  border-color: rgba(139, 92, 246, 0.55);
}

.resonance-toast-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}
.resonance-toast-content {
  flex: 1;
  min-width: 0;
}
.resonance-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}
.resonance-toast-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--theme-text);
}
.resonance-pts-badge {
  background: linear-gradient(135deg, #f97316 0%, #8b5cf6 100%);
  color: white;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}
.resonance-toast-body {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--theme-muted);
}
.resonance-toast-close {
  background: transparent;
  border: none;
  color: var(--theme-muted);
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.resonance-toast-close:hover {
  color: var(--theme-text);
  background: rgba(0, 0, 0, 0.06);
}

/* ==========================================================================
   Co-Breathing Bubble & Zen Breathing Modal (Mindful Coherence)
   ========================================================================== */

/* Floating Co-Breathing Widget */
.co-breathing-widget {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.co-breathing-widget.is-scrolling {
  opacity: 0.18;
  transform: translateY(6px) scale(0.92);
  pointer-events: none;
}

.co-breathing-bubble {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fbf0d9; /* 100% Solid Opaque (Sepia) */
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}

body.theme-white .co-breathing-bubble {
  background: #ffffff; /* 100% Solid Opaque (White) */
  border-color: #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

body.theme-dark .co-breathing-bubble {
  background: #1e293b; /* 100% Solid Opaque (Dark) */
  border-color: #334155;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.co-breathing-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18), 0 0 16px rgba(72, 187, 120, 0.4);
}

.co-breathing-bubble:active {
  transform: scale(0.94);
}

/* Inner Pulsating Breathing Orb */
.co-breathing-orb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  transition: transform 0.1s linear, background 0.3s;
  will-change: transform;
}

body.theme-sepia .co-breathing-orb {
  background: linear-gradient(135deg, #d69e2e 0%, #38a169 100%);
}

body.theme-dark .co-breathing-orb {
  background: linear-gradient(135deg, #68d391 0%, #319795 100%);
}

/* Outer Glowing Synchronized Halo */
.co-breathing-halo {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid rgba(72, 187, 120, 0.5);
  pointer-events: none;
  opacity: 0.6;
  transition: transform 0.1s linear, opacity 0.1s linear;
  will-change: transform, opacity;
}

/* Mini Mobile Reader Count Badge */
.co-breathing-mobile-badge {
  display: none;
  position: absolute;
  top: -4px;
  right: -4px;
  background: #38a169;
  color: white;
  border-radius: 10px;
  padding: 1px 5px;
  font-size: 9.5px;
  font-weight: 800;
  border: 1.5px solid #fbf0d9;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  line-height: 1.2;
}

body.theme-white .co-breathing-mobile-badge {
  border-color: #ffffff;
}

body.theme-dark .co-breathing-mobile-badge {
  border-color: #1e293b;
  background: #48bb78;
}

/* Tooltip on hover / tap (Desktop Only) */
.co-breathing-tooltip {
  background: #fbf0d9; /* 100% Solid Opaque (Sepia) */
  color: var(--theme-text);
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.2s;
}

body.theme-white .co-breathing-tooltip {
  background: #ffffff;
  border-color: #e2e8f0;
}

body.theme-dark .co-breathing-tooltip {
  background: #1e293b;
  border-color: #334155;
}

.co-breathing-tooltip:hover {
  background: rgba(72, 187, 120, 0.12);
  border-color: rgba(72, 187, 120, 0.5);
}

.co-breathing-spark-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(72, 187, 120, 0.15);
  color: #276749;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 700;
}
body.theme-dark .co-breathing-spark-count {
  color: #9ae6b4;
}

/* Golden Breath Spark Ripple Animation */
@keyframes sparkRipple {
  0% {
    transform: scale(0.6);
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(236, 201, 75, 0.8);
  }
  100% {
    transform: scale(2.8);
    opacity: 0;
    box-shadow: 0 0 0 24px rgba(236, 201, 75, 0);
  }
}

.breath-spark-active {
  animation: sparkRipple 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Fullscreen Zen Breathing Modal */
.zen-breathing-modal {
  position: fixed;
  inset: 0;
  z-index: 2200;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.35s ease-out;
}

.zen-breathing-modal.is-open {
  display: flex;
  opacity: 1;
}

.zen-breathing-card {
  background: var(--theme-card-bg);
  color: var(--theme-text);
  border: 1.5px solid var(--theme-border);
  border-radius: 28px;
  padding: 36px 30px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
  transform: scale(0.92);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

body.theme-sepia .zen-breathing-card {
  background: #fdf6e7;
  border-color: #e6dcbe;
  box-shadow: 0 24px 60px -12px rgba(90, 60, 20, 0.35), 0 0 0 1px rgba(120, 90, 40, 0.1);
}

body.theme-white .zen-breathing-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

body.theme-dark .zen-breathing-card {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.zen-breathing-modal.is-open .zen-breathing-card {
  transform: scale(1);
}

.zen-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: var(--theme-text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

body.theme-dark .zen-modal-close {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.zen-modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
  color: var(--theme-text);
}

.zen-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 161, 105, 0.15);
  color: #22543d;
  border: 1px solid rgba(56, 161, 105, 0.25);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: 0.2px;
}

body.theme-dark .zen-badge {
  background: rgba(72, 187, 120, 0.22);
  color: #86efac;
  border-color: rgba(72, 187, 120, 0.35);
}

.zen-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px 0;
  font-family: var(--font-sans);
  color: var(--theme-text);
}

body.theme-sepia .zen-title {
  color: #1a202c;
}

body.theme-dark .zen-title {
  color: #f8fafc;
}

.zen-subtext {
  font-size: 13px;
  color: #718096;
  margin: 0 0 26px 0;
  font-family: var(--font-serif);
  line-height: 1.55;
}

body.theme-sepia .zen-subtext {
  color: #4a5568;
}

body.theme-dark .zen-subtext {
  color: #94a3b8;
}

/* Big Zen Breathing Circle Area (Fixed Isolated Stage) */
.zen-circle-stage {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 20px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.zen-circle-outer-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed rgba(72, 187, 120, 0.4);
  animation: rotateOuterRing 60s linear infinite;
  pointer-events: none;
}

body.theme-sepia .zen-circle-outer-ring {
  border-color: rgba(56, 161, 105, 0.45);
}

@keyframes rotateOuterRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.zen-circle-pulse-orb {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, #38a169 0%, #2f855a 70%, #276749 100%);
  box-shadow: 0 0 35px rgba(56, 161, 105, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  transform-origin: center center;
  transition: transform 0.08s linear, background 0.3s;
  will-change: transform;
  user-select: none;
}

body.theme-sepia .zen-circle-pulse-orb {
  background: radial-gradient(circle, #38a169 0%, #2f855a 70%, #276749 100%);
  box-shadow: 0 0 35px rgba(56, 161, 105, 0.45);
}

body.theme-dark .zen-circle-pulse-orb {
  background: radial-gradient(circle, #48bb78 0%, #38a169 70%, #276749 100%);
  box-shadow: 0 0 35px rgba(72, 187, 120, 0.5);
}

.zen-circle-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  pointer-events: none;
}

.zen-countdown-num {
  font-size: 13px;
  font-weight: 800;
  opacity: 0.95;
  font-variant-numeric: tabular-nums;
  display: inline-block;
  min-width: 32px;
  text-align: center;
  line-height: 1.2;
}

/* Fixed Text Containers to Prevent Any Layout Shift */
.zen-phase-indicator {
  font-size: 17px;
  font-weight: 700;
  font-family: var(--font-sans);
  color: var(--theme-text);
  height: 26px;
  line-height: 26px;
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  transition: color 0.3s;
}

body.theme-sepia .zen-phase-indicator {
  color: #1a202c;
}

body.theme-dark .zen-phase-indicator {
  color: #f8fafc;
}

.zen-phase-sub {
  font-size: 12.5px;
  color: #718096;
  font-family: var(--font-serif);
  height: 38px;
  line-height: 1.45;
  margin: 0 0 18px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  padding: 0 10px;
}

body.theme-sepia .zen-phase-sub {
  color: #4a5568;
}

body.theme-dark .zen-phase-sub {
  color: #94a3b8;
}

/* 5-Cycle Dots */
.zen-cycle-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 16px;
  margin: 0 0 20px 0;
}

.zen-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.theme-dark .zen-dot {
  background: rgba(255, 255, 255, 0.15);
}

.zen-dot.active {
  background: #38a169;
  transform: scale(1.35);
  box-shadow: 0 0 8px rgba(72, 187, 120, 0.6);
}

/* Science Note */
.zen-science-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(56, 161, 105, 0.08);
  border: 1px dashed rgba(56, 161, 105, 0.25);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 0 0 18px 0;
  text-align: left;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--theme-text);
}

body.theme-sepia .zen-science-note {
  background: #f7eed7;
  border-color: #dfd3b2;
  color: #3b4554;
}

body.theme-white .zen-science-note {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #334155;
}

body.theme-dark .zen-science-note {
  background: rgba(15, 23, 42, 0.6);
  border-color: #334155;
  color: #cbd5e1;
}

.zen-science-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

.zen-science-text {
  flex: 1;
}

.zen-science-text strong {
  color: #22543d;
  font-weight: 700;
}

body.theme-dark .zen-science-text strong {
  color: #86efac;
}

/* Actions Footer */
.zen-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 44px;
}

.zen-btn {
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.zen-btn-primary {
  background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(56, 161, 105, 0.3);
}

.zen-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(56, 161, 105, 0.4);
}

.zen-btn-secondary {
  background: rgba(0, 0, 0, 0.05);
  color: var(--theme-text);
  border: 1px solid var(--theme-border);
}

body.theme-sepia .zen-btn-secondary {
  background: #f7eed7;
  color: #2d3748;
  border-color: #e2d7ba;
}

body.theme-white .zen-btn-secondary {
  background: #f7fafc;
  color: #2d3748;
  border-color: #e2e8f0;
}

body.theme-dark .zen-btn-secondary {
  background: #0f172a;
  color: #e2e8f0;
  border-color: #334155;
}

.zen-btn-secondary:hover {
  filter: brightness(0.96);
}

/* Mobile Adjustments */
@media (max-width: 900px) {
  .co-breathing-widget {
    bottom: 76px;
    right: 16px;
    left: auto;
    gap: 0;
  }
  .co-breathing-tooltip {
    display: none !important;
  }
  .co-breathing-bubble {
    width: 38px;
    height: 38px;
  }
  .co-breathing-orb {
    width: 19px;
    height: 19px;
  }
  .co-breathing-mobile-badge {
    display: flex;
  }
  .zen-breathing-card {
    padding: 28px 20px;
    border-radius: 22px;
  }
  .zen-circle-stage {
    width: 150px;
    height: 150px;
  }
  .zen-circle-pulse-orb {
    width: 84px;
    height: 84px;
  }
}

/* ==========================================================================
   Milestone 1,000 Readers Gratitude Modal & Banner
   ========================================================================== */
.milestone-modal-card {
  background: var(--theme-card-bg);
  color: var(--theme-text);
  border: 1.5px solid var(--theme-border);
  border-radius: 28px;
  padding: 36px 32px 30px 32px;
  max-width: 520px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.05);
  position: relative;
  text-align: center;
  animation: modalFadeScale 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

body.theme-sepia .milestone-modal-card {
  background: #fdf6e7;
  border-color: #e6dcbe;
  box-shadow: 0 28px 64px -12px rgba(90, 60, 20, 0.35), 0 0 0 1px rgba(120, 90, 40, 0.12);
}

body.theme-white .milestone-modal-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

body.theme-dark .milestone-modal-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.milestone-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
}

.milestone-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.3);
  margin-bottom: 20px;
}

body.theme-sepia .milestone-badge {
  background: rgba(180, 100, 20, 0.12);
  color: #8c420b;
  border-color: rgba(180, 100, 20, 0.28);
}

body.theme-dark .milestone-badge {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

.milestone-heart-icon {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 16px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.milestone-spark-orbit {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.25) 0%, rgba(245, 158, 11, 0) 70%);
  animation: pulseHalo 3s ease-in-out infinite;
}

.milestone-icon-center {
  font-size: 38px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 10px rgba(217, 119, 6, 0.3));
}

.milestone-title {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-serif);
  margin: 0 0 16px 0;
  line-height: 1.35;
  color: var(--theme-text);
}

.milestone-body {
  text-align: left;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--theme-text);
  font-family: var(--font-serif);
}

.milestone-lead {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
}

.milestone-body p {
  margin: 0 0 12px 0;
}

.milestone-body strong {
  color: var(--theme-accent);
}

.milestone-quote-card {
  margin: 18px 0;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.03);
  border-left: 3.5px solid var(--theme-accent);
  text-align: left;
}

body.theme-sepia .milestone-quote-card {
  background: #f5ebd2;
  border-left-color: #b45309;
}

body.theme-white .milestone-quote-card {
  background: #f8fafc;
  border-left-color: #0284c7;
}

body.theme-dark .milestone-quote-card {
  background: #0f172a;
  border-left-color: #38bdf8;
}

.milestone-quote-text {
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0 0 6px 0 !important;
  color: var(--theme-text);
}

.milestone-quote-author {
  font-size: 12px;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--theme-muted);
}

.milestone-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.milestone-primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 24px;
  border: none;
  font-size: 14.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: var(--theme-accent);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

body.theme-sepia .milestone-primary-btn {
  background: #744210;
  color: #fffaf0;
}

body.theme-white .milestone-primary-btn {
  background: #0284c7;
  color: #ffffff;
}

body.theme-dark .milestone-primary-btn {
  background: #0284c7;
  color: #ffffff;
}

.milestone-primary-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.milestone-primary-btn:active {
  transform: translateY(1px);
}

/* Readers List Milestone Banner */
.readers-milestone-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  margin: 0 0 14px 0;
  border-radius: 16px;
  background: rgba(217, 119, 6, 0.08);
  border: 1px solid rgba(217, 119, 6, 0.22);
  cursor: pointer;
  transition: all 0.2s ease;
}

body.theme-sepia .readers-milestone-banner {
  background: #f7eed6;
  border-color: #dfd0ab;
}

body.theme-white .readers-milestone-banner {
  background: #fef3c7;
  border-color: #fde68a;
}

body.theme-dark .readers-milestone-banner {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}

.readers-milestone-banner:hover {
  filter: brightness(0.97);
  transform: translateY(-1px);
}

.readers-milestone-left {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.readers-milestone-icon {
  font-size: 20px;
  line-height: 1;
}

.readers-milestone-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--theme-text);
  font-family: var(--font-sans);
}

.readers-milestone-desc {
  font-size: 11px;
  color: var(--theme-muted);
  font-family: var(--font-sans);
  margin-top: 1px;
}

.readers-milestone-arrow {
  font-size: 18px;
  font-weight: 600;
  color: var(--theme-muted);
  padding-left: 6px;
}

@media (max-width: 640px) {
  .milestone-modal-card {
    padding: 26px 20px 22px 20px;
    border-radius: 22px;
  }
  .milestone-title {
    font-size: 18px;
  }
  .milestone-body {
    font-size: 14px;
  }
  .milestone-heart-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 12px;
  }
  .milestone-icon-center {
    font-size: 32px;
  }
}

/* ==========================================================================
   🌿 COMPANION WHISPERS (Lời Nhắn Bạn Đồng Hành Cùng Henry)
   ========================================================================== */

.companion-whisper-card {
  position: fixed;
  right: 16px;
  bottom: 76px;
  z-index: 1050;
  max-width: 370px;
  width: calc(100vw - 32px);
  border-radius: 18px;
  padding: 16px 18px 14px 18px;
  font-family: var(--font-sans);
  box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Theme Solid Opaque Backgrounds (Chống Xuyên Thấu) */
body.theme-sepia .companion-whisper-card {
  background: #fdf6e7 !important;
  border: 1.5px solid #dfcfb2;
  color: #2c221a;
}

body.theme-dark .companion-whisper-card {
  background: #1e293b !important;
  border: 1.5px solid #334155;
  color: #f8fafc;
}

body.theme-white .companion-whisper-card {
  background: #ffffff !important;
  border: 1.5px solid #e2e8f0;
  color: #1e293b;
}

body.has-active-whisper .co-breathing-widget {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.85);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Auto Dimming while scrolling */
.companion-whisper-card.is-dimmed {
  opacity: 0.22 !important;
  transform: translateY(4px) scale(0.98);
}

/* Animations */
@keyframes whisperSlideUp {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes whisperFadeDown {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
  }
}

.companion-whisper-card.slide-up-in {
  animation: whisperSlideUp 0.36s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.companion-whisper-card.fade-out-down {
  animation: whisperFadeDown 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Card Header */
.whisper-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.whisper-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.whisper-meta {
  flex: 1;
  min-width: 0;
}

.whisper-sender {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.whisper-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
  color: inherit;
  margin-top: 1px;
}

.whisper-close-btn {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: inherit;
  opacity: 0.55;
  font-size: 14px;
  transition: opacity 0.2s, background 0.2s;
  padding: 0;
}

.whisper-close-btn:hover,
.whisper-close-btn:active {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

body.theme-dark .whisper-close-btn:hover,
body.theme-dark .whisper-close-btn:active {
  background: rgba(255, 255, 255, 0.1);
}

/* Card Body */
.whisper-body {
  margin-bottom: 12px;
}

.whisper-text {
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  opacity: 0.92;
  font-weight: 450;
}

/* Card Footer & Action Button */
.whisper-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.whisper-action-btn {
  background: #319795;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 6px rgba(49, 151, 149, 0.3);
  min-height: 36px;
}

.whisper-action-btn:hover {
  background: #285e61;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(49, 151, 149, 0.4);
}

.whisper-action-btn:active {
  transform: translateY(0);
}

.whisper-action-btn.action-completed {
  background: #38a169 !important;
  box-shadow: none !important;
  cursor: default;
}

/* Progress indicator bar */
.whisper-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: #319795;
  width: 100%;
  animation: whisperProgress 10s linear forwards;
  opacity: 0.65;
}

@keyframes whisperProgress {
  from { width: 100%; }
  to { width: 0%; }
}

@media (max-width: 480px) {
  .companion-whisper-card {
    right: 12px;
    bottom: 74px;
    width: calc(100vw - 24px);
    padding: 14px 16px 12px 16px;
    border-radius: 16px;
  }
  .whisper-text {
    font-size: 12.5px;
    line-height: 1.55;
  }
  .whisper-action-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ==========================================================================
   Sidebar Threads Practice Circle Banner
   ========================================================================== */
.sidebar-threads-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 12px 0 16px 0;
  border-radius: 14px;
  background: rgba(49, 151, 149, 0.08);
  border: 1px solid rgba(49, 151, 149, 0.22);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-select: none;
}

.sidebar-threads-banner:hover {
  background: rgba(49, 151, 149, 0.15);
  border-color: rgba(49, 151, 149, 0.4);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(49, 151, 149, 0.12);
}

.sidebar-threads-banner:active {
  transform: translateY(0);
}

body.theme-sepia .sidebar-threads-banner {
  background: rgba(180, 100, 20, 0.08);
  border-color: rgba(180, 100, 20, 0.22);
}
body.theme-sepia .sidebar-threads-banner:hover {
  background: rgba(180, 100, 20, 0.14);
  border-color: rgba(180, 100, 20, 0.38);
}

body.theme-dark .sidebar-threads-banner {
  background: rgba(56, 178, 172, 0.12);
  border-color: rgba(56, 178, 172, 0.28);
}
body.theme-dark .sidebar-threads-banner:hover {
  background: rgba(56, 178, 172, 0.2);
  border-color: rgba(56, 178, 172, 0.45);
}

.threads-banner-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(49, 151, 149, 0.12);
}
body.theme-sepia .threads-banner-icon {
  background: rgba(180, 100, 20, 0.12);
}
body.theme-dark .threads-banner-icon {
  background: rgba(56, 178, 172, 0.2);
}

.threads-banner-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.threads-banner-tag {
  font-size: 11px;
  font-weight: 600;
  color: #2c7a7b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
body.theme-sepia .threads-banner-tag {
  color: #8c420b;
}
body.theme-dark .threads-banner-tag {
  color: #4fd1c5;
}

.threads-banner-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--theme-text);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.threads-banner-arrow {
  color: var(--theme-muted);
  display: flex;
  align-items: center;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.sidebar-threads-banner:hover .threads-banner-arrow {
  transform: translateX(3px);
  color: var(--theme-text);
}

/* ==========================================================================
   Threads Practice Circle Modal Card (Solid Opaque 100%)
   ========================================================================== */
.threads-modal-card {
  background: var(--theme-card-bg);
  color: var(--theme-text);
  border: 1.5px solid var(--theme-border);
  border-radius: 26px;
  padding: 32px 28px 26px 28px;
  max-width: 530px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.05);
  position: relative;
  text-align: left;
  animation: modalFadeScale 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-overflow-scrolling: touch;
}

body.theme-sepia .threads-modal-card {
  background: #fdf6e7;
  border-color: #e6dcbe;
  box-shadow: 0 28px 64px -12px rgba(90, 60, 20, 0.35), 0 0 0 1px rgba(120, 90, 40, 0.12);
}

body.theme-white .threads-modal-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

body.theme-dark .threads-modal-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.threads-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
}

.threads-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: rgba(49, 151, 149, 0.12);
  color: #2c7a7b;
  border: 1px solid rgba(49, 151, 149, 0.28);
  margin-bottom: 16px;
}
body.theme-sepia .threads-badge {
  background: rgba(180, 100, 20, 0.12);
  color: #8c420b;
  border-color: rgba(180, 100, 20, 0.28);
}
body.theme-dark .threads-badge {
  background: rgba(56, 178, 172, 0.18);
  color: #4fd1c5;
  border-color: rgba(56, 178, 172, 0.35);
}

.threads-author-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.threads-avatar-ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #319795, #2c7a7b);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(49, 151, 149, 0.3);
  flex-shrink: 0;
}
body.theme-sepia .threads-avatar-ring {
  background: linear-gradient(135deg, #d97706, #b45309);
  box-shadow: 0 4px 10px rgba(217, 119, 6, 0.3);
}

.threads-avatar-icon {
  font-size: 19px;
  line-height: 1;
}

.threads-author-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.threads-author-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--theme-text);
  font-family: var(--font-sans);
}

.threads-author-handle {
  font-size: 12px;
  color: var(--theme-muted);
  font-family: var(--font-sans);
}

.threads-title {
  font-family: var(--font-serif);
  font-size: 18.5px;
  font-weight: 700;
  color: var(--theme-text);
  line-height: 1.4;
  margin: 0 0 14px 0;
}

.threads-body {
  font-size: 13.8px;
  line-height: 1.68;
  color: var(--theme-text);
  margin-bottom: 20px;
}

.threads-body p {
  margin: 0 0 12px 0;
}

.threads-lead {
  font-weight: 600;
  color: var(--theme-text);
}

.threads-highlight-box {
  background: rgba(0, 0, 0, 0.035);
  border: 1px dashed var(--theme-border);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 14px 0;
}
body.theme-sepia .threads-highlight-box {
  background: rgba(180, 100, 20, 0.05);
  border-color: rgba(180, 100, 20, 0.2);
}
body.theme-dark .threads-highlight-box {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

.threads-highlight-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--theme-text);
  margin-bottom: 8px;
}

.threads-steps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.threads-step-tag {
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  color: var(--theme-text);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.theme-sepia .threads-step-tag {
  background: #fcf4e2;
}
body.theme-dark .threads-step-tag {
  background: #0f172a;
}

.threads-reasons-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 14px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.threads-reasons-list li {
  font-size: 13.2px;
  line-height: 1.55;
  color: var(--theme-text);
  padding-left: 4px;
}

.threads-outro {
  font-style: italic;
  color: var(--theme-muted);
  margin-top: 10px;
}

.threads-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 18px;
}

.threads-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 46px;
  padding: 12px 20px;
  border-radius: 14px;
  background: #18181b;
  color: #ffffff !important;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  text-decoration: none;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
body.theme-sepia .threads-primary-btn {
  background: #5c3a1e;
  box-shadow: 0 4px 14px rgba(92, 58, 30, 0.3);
}
body.theme-dark .threads-primary-btn {
  background: #38bdf8;
  color: #0f172a !important;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.threads-primary-btn:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
body.theme-dark .threads-primary-btn:hover {
  background: #7dd3fc;
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.5);
}

.threads-primary-btn:active {
  transform: translateY(0);
}

.threads-secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 12px;
  background: transparent;
  color: var(--theme-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
}

.threads-secondary-btn:hover {
  color: var(--theme-text);
  background: rgba(0, 0, 0, 0.04);
}
body.theme-dark .threads-secondary-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 480px) {
  .threads-modal-card {
    padding: 24px 20px 20px 20px;
    border-radius: 20px;
  }
  .threads-title {
    font-size: 17px;
  }
  .threads-steps-grid {
    grid-template-columns: 1fr;
  }
  .threads-body {
    font-size: 13.2px;
  }
}

/* ==========================================================================
   Personal Gratitude Letter Modal (Dedicated & Pure Gratitude Theme)
   ========================================================================== */
.gratitude-letter-overlay {
  z-index: 2100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.gratitude-letter-card {
  background: var(--theme-card-bg);
  color: var(--theme-text);
  border: 1.5px solid var(--theme-border);
  border-radius: 24px;
  padding: 32px 28px 24px 28px;
  max-width: 530px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.05);
  position: relative;
  text-align: left;
  animation: modalFadeScale 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-overflow-scrolling: touch;
}

body.theme-sepia .gratitude-letter-card {
  background: #fdf6e7;
  border-color: #e6dcbe;
  box-shadow: 0 28px 64px -12px rgba(90, 60, 20, 0.35), 0 0 0 1px rgba(120, 90, 40, 0.12);
}

body.theme-white .gratitude-letter-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

body.theme-dark .gratitude-letter-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.gratitude-letter-close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
}

.gratitude-letter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.28);
  margin-bottom: 16px;
}

body.theme-sepia .gratitude-letter-badge {
  background: rgba(180, 100, 20, 0.12);
  color: #8c420b;
  border-color: rgba(180, 100, 20, 0.28);
}

body.theme-dark .gratitude-letter-badge {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
}

.gratitude-letter-author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.gratitude-avatar-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d97706, #b45309);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
  flex-shrink: 0;
}

body.theme-dark .gratitude-avatar-ring {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.gratitude-avatar-icon {
  font-size: 20px;
  line-height: 1;
}

.gratitude-author-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--theme-text);
  font-family: var(--font-sans);
  line-height: 1.25;
}

.gratitude-author-handle {
  font-size: 12px;
  color: var(--theme-muted);
  font-family: var(--font-sans);
  margin-top: 2px;
}

.gratitude-letter-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--theme-text);
  line-height: 1.4;
  margin: 0 0 16px 0;
}

.gratitude-letter-body {
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--theme-text);
  white-space: pre-line;
  margin-bottom: 22px;
  padding: 18px 20px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px dashed var(--theme-border);
}

body.theme-sepia .gratitude-letter-body {
  background: rgba(180, 100, 20, 0.04);
  border-color: #e2d5ba;
}

body.theme-dark .gratitude-letter-body {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.gratitude-letter-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gratitude-letter-confirm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 11px 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.35);
  transition: all 0.2s ease;
}

.gratitude-letter-confirm-btn:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 8px 22px rgba(217, 119, 6, 0.45);
  filter: brightness(1.05);
}

.gratitude-letter-confirm-btn:active {
  transform: translateY(0);
}

@media (max-width: 480px) {
  .gratitude-letter-card {
    padding: 24px 20px 20px 20px;
    border-radius: 20px;
  }
  .gratitude-letter-title {
    font-size: 17px;
  }
  .gratitude-letter-body {
    font-size: 13.5px;
    padding: 14px 16px;
  }
}

/* ==========================================================================
   Multi-Book Support & Book Selection Modal Styles
   ========================================================================== */

.header-book-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(214, 158, 46, 0.15);
  color: var(--theme-accent);
  border: 1px solid rgba(214, 158, 46, 0.3);
  margin-left: 4px;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

.book-change-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(180, 130, 60, 0.08);
  border: 1px solid rgba(180, 130, 60, 0.22);
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--theme-accent);
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
  align-self: flex-start;
  width: auto;
  max-width: fit-content;
}

.book-change-btn svg,
.book-change-svg {
  width: 13px !important;
  height: 13px !important;
  min-width: 13px !important;
  max-width: 13px !important;
  min-height: 13px !important;
  max-height: 13px !important;
  stroke: currentColor;
  stroke-width: 2.2;
  flex-shrink: 0 !important;
  display: inline-block;
  vertical-align: middle;
  transition: transform 0.2s ease;
}

.book-change-btn:hover {
  background: var(--theme-accent);
  color: #ffffff;
  border-color: var(--theme-accent);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(180, 130, 60, 0.25);
}

.book-change-btn:hover svg {
  transform: rotate(15deg);
}

.book-change-btn:active {
  transform: scale(0.95);
}

body.theme-dark .book-change-btn {
  background: rgba(214, 158, 46, 0.12);
  border-color: rgba(214, 158, 46, 0.3);
  color: #ecc94b;
}

.book-select-modal-card {
  max-width: 660px !important;
  width: 94% !important;
  background: var(--theme-card-bg) !important;
  border: 1px solid var(--theme-border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  position: relative;
  max-height: 88dvh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  border-radius: 24px;
  padding: 20px 20px 16px 20px;
}

.book-select-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  width: 100% !important;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--theme-border);
  flex-shrink: 0;
}

.book-select-header-text {
  flex: 1;
  min-width: 0;
}

.book-select-tag-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.book-select-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(214, 158, 46, 0.15);
  color: var(--theme-accent);
  font-weight: 700;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 12px;
  letter-spacing: 0.2px;
}

.book-select-count-text {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--theme-text-muted);
}

.book-select-heading {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--theme-text);
  margin: 0;
  line-height: 1.25;
}

.book-select-close-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--theme-border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.book-select-close-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: scale(1.05);
}

.theme-dark .book-select-close-btn {
  background: rgba(255, 255, 255, 0.06);
}

.book-select-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  padding-bottom: 8px;
  overscroll-behavior: contain;
  flex: 1;
}

.book-select-card {
  display: flex;
  gap: 14px;
  padding: 13px 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.02);
  border: 1.5px solid var(--theme-border);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.theme-dark .book-select-card {
  background: rgba(255, 255, 255, 0.03);
}

.book-select-card:hover {
  transform: translateY(-2px);
  border-color: var(--theme-accent);
  background: rgba(214, 158, 46, 0.05);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.book-select-card:active {
  transform: scale(0.985);
}

.book-select-card.active {
  border-color: var(--theme-accent);
  background: rgba(214, 158, 46, 0.08);
  box-shadow: 0 0 0 1.5px var(--theme-accent), 0 6px 18px rgba(214, 158, 46, 0.12);
}

/* 3D Realistic Book Cover */
.book-select-cover {
  flex-shrink: 0;
  width: 72px;
  height: 102px;
  border-radius: 4px 7px 7px 4px;
  overflow: hidden;
  position: relative;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.15), 3px 5px 14px rgba(0, 0, 0, 0.14);
  background: #2a2a2a;
}

.book-select-card:hover .book-select-cover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

/* Book Spine Visual Highlight */
.book-select-cover::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.22) 0%, rgba(255, 255, 255, 0.25) 30%, rgba(0, 0, 0, 0.08) 70%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}

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

.book-select-details {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.book-select-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--theme-accent);
  margin-bottom: 2px;
  letter-spacing: 0.1px;
}

.book-select-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--theme-text);
  margin: 0 0 2px 0;
  line-height: 1.28;
}

.book-select-author {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--theme-text-muted);
  margin: 0 0 4px 0;
  line-height: 1.2;
}

.book-select-desc {
  font-size: 11.5px;
  line-height: 1.42;
  color: var(--theme-text);
  opacity: 0.85;
  margin: 0 0 6px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-select-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 2px;
}

.book-select-badge {
  font-size: 10px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 7px;
  border-radius: 8px;
  color: var(--theme-text-muted);
  white-space: nowrap;
}

.theme-dark .book-select-badge {
  background: rgba(255, 255, 255, 0.06);
}

.book-select-action-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--theme-accent);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.book-select-card.active .book-select-action-label {
  color: #10b981;
}

@media (max-width: 600px) {
  .modal-card {
    padding: 24px 18px 20px 18px;
    border-radius: 24px;
    max-width: 95%;
    max-height: 88dvh;
    position: relative;
  }

  /* Native Bottom Sheet Drag Handle Indicator */
  .settings-sheet-header::before,
  .sidebar-toc-header::before,
  .margin-drawer-header::before,
  .book-select-modal-card::before,
  .identity-modal-card::before,
  .readers-modal-card::before,
  .leaderboard-card::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--theme-border);
    margin: 0 auto 10px auto;
    opacity: 0.8;
  }

  .book-select-modal-card {
    padding: 12px 12px 10px 12px !important;
    border-radius: 20px !important;
    max-height: 90dvh !important;
    width: 95% !important;
  }

  .book-select-header {
    padding-bottom: 8px;
    gap: 8px;
  }

  .book-select-tag-bar {
    gap: 6px;
    margin-bottom: 2px;
  }

  .book-select-badge-pill {
    font-size: 11.5px;
    padding: 2px 7px;
  }

  .book-select-count-text {
    font-size: 11px;
  }

  .book-select-heading {
    font-size: 14.5px;
  }

  .book-select-close-btn {
    width: 30px;
    height: 30px;
  }

  .book-select-grid {
    gap: 10px;
    margin-top: 8px;
    max-height: calc(90dvh - 75px) !important;
    padding-bottom: 6px;
  }

  .book-select-card {
    padding: 10px 10px;
    gap: 10px;
    border-radius: 14px;
  }

  .book-select-cover {
    width: 62px;
    height: 90px;
    border-radius: 3px 6px 6px 3px;
  }

  .book-select-tag {
    font-size: 10px;
    margin-bottom: 1px;
  }

  .book-select-title {
    font-size: 13px;
    margin-bottom: 1px;
    line-height: 1.25;
  }

  .book-select-author {
    font-size: 10.5px;
    margin-bottom: 3px;
  }

  .book-select-desc {
    font-size: 11px;
    line-height: 1.38;
    margin-bottom: 4px;
    -webkit-line-clamp: 2;
  }

  .book-select-footer {
    gap: 4px;
    padding-top: 1px;
  }

  .book-select-badge {
    font-size: 9px;
    padding: 2px 5px;
  }

  .book-select-action-label {
    font-size: 10.5px;
  }
}

@media (max-width: 480px) {
  .header-book-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    border-radius: 12px;
    max-width: 140px;
    font-size: 11px;
    font-weight: 600;
  }
  .header-book-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
  }
  .header-book-icon {
    font-size: 11px;
  }
  .header-book-arrow {
    font-size: 9px;
  }
}

/* ==========================================================================
   Book Password Protection Modal & Lock Badges
   ========================================================================== */

.book-lock-pill {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #fbbf24;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.book-protected-badge {
  background: rgba(217, 119, 6, 0.12) !important;
  color: #b45309 !important;
  border: 1px solid rgba(217, 119, 6, 0.25) !important;
}

body.theme-dark .book-protected-badge {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #fbbf24 !important;
  border-color: rgba(245, 158, 11, 0.3) !important;
}

.book-password-card {
  max-width: 440px;
  width: 92%;
  padding: 26px 24px;
  border-radius: 24px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.35);
  animation: modalFadeScale 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

body.theme-sepia .book-password-card {
  background: #fdf6e7 !important;
  border: 1.5px solid #e6dcbe !important;
  color: #2c2518;
}

body.theme-white .book-password-card {
  background: #ffffff !important;
  border: 1.5px solid #e2e8f0 !important;
  color: #1a202c;
}

body.theme-dark .book-password-card {
  background: #1e293b !important;
  border: 1.5px solid #334155 !important;
  color: #e2e8f0;
}

.book-password-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.book-password-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 700;
  color: #b45309;
  background: rgba(217, 119, 6, 0.12);
  padding: 5px 12px;
  border-radius: 20px;
}

body.theme-dark .book-password-badge {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.16);
}

.book-password-body {
  margin-bottom: 22px;
}

.book-password-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.035);
  margin-bottom: 14px;
  border: 1px solid var(--theme-border);
}

body.theme-dark .book-password-meta {
  background: rgba(255, 255, 255, 0.04);
}

.book-password-thumb {
  width: 52px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.book-password-info {
  min-width: 0;
}

.book-password-bookname {
  margin: 0 0 4px 0;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--theme-text);
}

.book-password-author {
  margin: 0;
  font-size: 12.5px;
  color: var(--theme-text-subtle, #718096);
}

.book-password-desc {
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 16px 0;
  color: var(--theme-text-subtle, #4a5568);
}

body.theme-dark .book-password-desc {
  color: #94a3b8;
}

.book-password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.book-password-input {
  width: 100%;
  padding: 12px 42px 12px 14px;
  font-size: 15px;
  border-radius: 12px;
  border: 1.5px solid var(--theme-border);
  background: var(--theme-bg);
  color: var(--theme-text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-user-select: text !important;
  user-select: text !important;
}

.book-password-input:focus {
  border-color: var(--theme-accent, #3182ce);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
}

.book-password-input.input-error {
  border-color: #e53e3e !important;
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.2) !important;
}

.book-password-toggle-btn {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--theme-text-subtle, #718096);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.2s;
}

.book-password-toggle-btn:hover {
  color: var(--theme-text);
}

.book-password-error {
  color: #e53e3e;
  font-size: 12.5px;
  margin-top: 8px;
  font-weight: 500;
  line-height: 1.4;
}

.book-password-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.book-password-cancel-btn {
  background: transparent;
  border: 1px solid var(--theme-border);
  color: var(--theme-text-subtle, #718096);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.book-password-cancel-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--theme-text);
}

body.theme-dark .book-password-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.book-password-submit-btn {
  background: var(--theme-accent, #2b6cb0);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(43, 108, 176, 0.25);
  transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
}

.book-password-submit-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(43, 108, 176, 0.35);
}

.book-password-submit-btn:active {
  transform: translateY(0);
}

.book-password-card.shake {
  animation: modalShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes modalShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
  40%, 60% { transform: translate3d(5px, 0, 0); }
}




