/**
 * Relatia Reader - Post-Chapter Screens Styles.
 *
 * Overlay, modal, stars, emojis, transitions for the 3 post-chapter screens.
 */

/* =========================================================================
   Overlay
   ========================================================================= */

.relatia-post-chapter-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: relatiaPostChapterFadeIn 0.2s ease;
}

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

/* =========================================================================
   Modal
   ========================================================================= */

.relatia-post-chapter-modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: relatiaPostChapterSlideUp 0.3s ease;
}

@keyframes relatiaPostChapterSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================================
   Header
   ========================================================================= */

.relatia-post-chapter-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  gap: 12px;
  flex-shrink: 0;
}

.relatia-post-chapter-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  color: #1f2937;
}

.relatia-post-chapter-steps {
  display: flex;
  gap: 6px;
  align-items: center;
}

.relatia-post-chapter-step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: #e5e7eb;
  color: #6b7280;
  transition: background 0.2s, color 0.2s;
}

.relatia-post-chapter-step.active {
  background: #6366f1;
  color: #fff;
}

.relatia-post-chapter-step.completed {
  background: #10b981;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
}

.relatia-post-chapter-step.completed:hover {
  background: #059669;
  transform: scale(1.1);
}

.relatia-post-chapter-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #9ca3af;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.relatia-post-chapter-close:hover {
  color: #374151;
}

/* =========================================================================
   Body
   ========================================================================= */

.relatia-post-chapter-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* =========================================================================
   Stars
   ========================================================================= */

.relatia-post-chapter-stars-section {
  text-align: center;
  margin-bottom: 20px;
  border-radius: 8px;
  padding: 12px;
  transition: box-shadow 0.3s;
}

.relatia-post-chapter-stars-required {
  animation: relatiaStarsShake 0.4s ease;
  box-shadow: 0 0 0 2px #ef4444;
}

@keyframes relatiaStarsShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.relatia-post-chapter-stars-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #374151;
}

.relatia-post-chapter-star-rating {
  display: inline-flex;
  gap: 4px;
}

.relatia-post-chapter-star {
  font-size: 32px;
  cursor: pointer;
  color: #d1d5db;
  transition: color 0.15s, transform 0.1s;
  user-select: none;
}

.relatia-post-chapter-star:hover {
  transform: scale(1.15);
}

.relatia-post-chapter-star.active {
  color: #f59e0b;
}

/* =========================================================================
   Comments
   ========================================================================= */

.relatia-post-chapter-comments {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.relatia-post-chapter-comments textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.relatia-post-chapter-comments textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* =========================================================================
   Characters
   ========================================================================= */

.relatia-post-chapter-characters {
  margin-bottom: 20px;
}

.relatia-post-chapter-characters h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #374151;
}

.relatia-post-chapter-character {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.relatia-post-chapter-character:hover {
  border-color: #c7d2fe;
}

.relatia-post-chapter-character-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.relatia-post-chapter-character-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #9ca3af;
}

.relatia-post-chapter-character-info {
  flex: 1;
  min-width: 0;
}

.relatia-post-chapter-character-name {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
  display: block;
  margin-bottom: 4px;
}

.relatia-post-chapter-character .relatia-post-chapter-star-rating {
  margin-bottom: 4px;
}

.relatia-post-chapter-character .relatia-post-chapter-star {
  font-size: 20px;
}

.relatia-post-chapter-eliminate-label {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.relatia-post-chapter-eliminate-label input[type="checkbox"] {
  margin: 0;
}

/* =========================================================================
   Buttons
   ========================================================================= */

.relatia-post-chapter-btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 12px;
}

.relatia-post-chapter-btn-primary:hover {
  background: #4f46e5;
}

.relatia-post-chapter-btn-secondary {
  display: inline-block;
  padding: 8px 16px;
  background: #e5e7eb;
  color: #374151;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.relatia-post-chapter-btn-secondary:hover {
  background: #d1d5db;
}

/* =========================================================================
   Emotional Screen
   ========================================================================= */

.relatia-post-chapter-question {
  margin-bottom: 20px;
}

.relatia-post-chapter-question-text {
  font-size: 14px;
  color: #374151;
  margin: 0 0 10px;
  font-weight: 500;
}

.relatia-post-chapter-emotion-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.relatia-post-chapter-emotion-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  min-width: 65px;
}

.relatia-post-chapter-emotion-btn:hover {
  border-color: #d8b4fe;
  background: #faf5ff;
}

.relatia-post-chapter-emotion-btn.selected {
  border-color: #7e22ce;
  background: #f3e8ff;
}

.relatia-post-chapter-emotion-icon {
  font-size: 24px;
  line-height: 1;
}

.relatia-post-chapter-emotion-label {
  font-size: 11px;
  color: #6b7280;
  text-transform: capitalize;
}

.relatia-post-chapter-question-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.relatia-post-chapter-question-textarea:focus {
  outline: none;
  border-color: #7e22ce;
  box-shadow: 0 0 0 3px rgba(126, 34, 206, 0.1);
}

.relatia-post-chapter-empty {
  text-align: center;
  color: #9ca3af;
  padding: 20px 0;
}

/* =========================================================================
   Ideas Screen
   ========================================================================= */

.relatia-post-chapter-idea-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.relatia-post-chapter-idea-text {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.relatia-post-chapter-idea-text:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.relatia-post-chapter-idea-form .relatia-post-chapter-btn-secondary {
  align-self: flex-end;
}

.relatia-post-chapter-ideas-list {
  margin-bottom: 16px;
}

.relatia-post-chapter-idea-item {
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
}

.relatia-post-chapter-idea-header {
  margin-bottom: 4px;
}

.relatia-post-chapter-idea-author {
  font-weight: 600;
  font-size: 13px;
  color: #6366f1;
}

.relatia-post-chapter-idea-content {
  font-size: 14px;
  color: #374151;
  margin: 0 0 8px;
  line-height: 1.5;
}

.relatia-post-chapter-idea-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.relatia-post-chapter-reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  transition: border-color 0.15s, background 0.15s;
}

.relatia-post-chapter-reaction-btn:hover {
  border-color: #c7d2fe;
  background: #f5f3ff;
}

.relatia-post-chapter-reaction-btn.active {
  border-color: #6366f1;
  background: #eef2ff;
}

.relatia-post-chapter-reaction-count {
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
}

.relatia-post-chapter-no-ideas {
  text-align: center;
  color: #9ca3af;
  padding: 16px 0;
  font-size: 14px;
}

/* =========================================================================
   Quiz Screen
   ========================================================================= */

.relatia-post-chapter-quiz-question {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.relatia-post-chapter-quiz-question:last-of-type {
  border-bottom: none;
}

.relatia-post-chapter-quiz-label {
  font-size: 12px;
  font-weight: 600;
  color: #6366f1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 4px;
}

.relatia-post-chapter-quiz-text {
  font-size: 15px;
  font-weight: 500;
  color: #1f2937;
  margin: 0 0 10px;
  line-height: 1.5;
}

.relatia-post-chapter-quiz-answers {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.relatia-post-chapter-quiz-answer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  transition: border-color 0.15s, background 0.15s;
}

.relatia-post-chapter-quiz-answer:hover {
  border-color: #c7d2fe;
  background: #f5f3ff;
}

.relatia-post-chapter-quiz-answer input[type="radio"] {
  margin: 0;
  accent-color: #6366f1;
}

.relatia-post-chapter-quiz-answer input[type="radio"]:checked + span {
  font-weight: 600;
  color: #4f46e5;
}

.relatia-post-chapter-quiz-result {
  text-align: center;
  padding: 16px;
  margin-top: 12px;
}

.relatia-post-chapter-hidden {
  display: none;
}

.relatia-post-chapter-quiz-status-pass {
  font-size: 20px;
  font-weight: 700;
  color: #10b981;
  margin: 0 0 4px;
}

.relatia-post-chapter-quiz-status-fail {
  font-size: 20px;
  font-weight: 700;
  color: #ef4444;
  margin: 0 0 4px;
}

.relatia-post-chapter-quiz-passed,
.relatia-post-chapter-quiz-failed {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.relatia-post-chapter-quiz-passed {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.relatia-post-chapter-quiz-failed {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.relatia-post-chapter-quiz-blocked {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
}

.relatia-post-chapter-quiz-retry {
  margin-top: 12px;
}

/* Dark theme quiz */
[data-theme="dark"] .relatia-post-chapter-quiz-question {
  border-bottom-color: #374151;
}

[data-theme="dark"] .relatia-post-chapter-quiz-text {
  color: #f3f4f6;
}

[data-theme="dark"] .relatia-post-chapter-quiz-answer {
  border-color: #374151;
  color: #d1d5db;
}

[data-theme="dark"] .relatia-post-chapter-quiz-answer:hover {
  border-color: #4b5563;
  background: #374151;
}

[data-theme="dark"] .relatia-post-chapter-quiz-passed {
  background: #064e3b;
  border-color: #065f46;
}

[data-theme="dark"] .relatia-post-chapter-quiz-failed {
  background: #7f1d1d;
  border-color: #991b1b;
}

[data-theme="dark"] .relatia-post-chapter-quiz-status-pass {
  color: #34d399;
}

[data-theme="dark"] .relatia-post-chapter-quiz-status-fail {
  color: #f87171;
}

[data-theme="dark"] .relatia-post-chapter-quiz-blocked {
  color: #9ca3af;
}

/* =========================================================================
   Celebration Screen (Book Completed)
   ========================================================================= */

.relatia-post-chapter-celebration {
  text-align: center;
  position: relative;
  overflow: hidden;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.relatia-post-chapter-celebration-content {
  position: relative;
  z-index: 2;
}

.relatia-post-chapter-trophy {
  font-size: 72px;
  line-height: 1;
  margin-bottom: 12px;
  animation: relatiaTrophyBounce 0.6s ease 0.3s both;
}

@keyframes relatiaTrophyBounce {
  0% { transform: scale(0) rotate(-15deg); opacity: 0; }
  50% { transform: scale(1.3) rotate(5deg); opacity: 1; }
  75% { transform: scale(0.9) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.relatia-post-chapter-celebration-title {
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 8px;
  animation: relatiaPostChapterFadeIn 0.4s ease 0.6s both;
}

.relatia-post-chapter-celebration-text {
  font-size: 16px;
  color: #4b5563;
  margin: 0;
  line-height: 1.6;
  animation: relatiaPostChapterFadeIn 0.4s ease 0.8s both;
}

.relatia-post-chapter-celebration-text strong {
  color: #6366f1;
}

.relatia-post-chapter-celebration .relatia-post-chapter-next {
  position: relative;
  z-index: 2;
  animation: relatiaPostChapterFadeIn 0.4s ease 1s both;
}

/* --- Confetti --- */

.relatia-post-chapter-confetti {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.relatia-post-chapter-confetti-piece {
  position: absolute;
  top: -20px;
  opacity: 0;
  will-change: transform, opacity;
}

/* Colors */
.relatia-post-chapter-confetti-piece:nth-child(6n+1) { background: #ff6b6b; }
.relatia-post-chapter-confetti-piece:nth-child(6n+2) { background: #ffd93d; }
.relatia-post-chapter-confetti-piece:nth-child(6n+3) { background: #6bcb77; }
.relatia-post-chapter-confetti-piece:nth-child(6n+4) { background: #4d96ff; }
.relatia-post-chapter-confetti-piece:nth-child(6n+5) { background: #9b59b6; }
.relatia-post-chapter-confetti-piece:nth-child(6n+6) { background: #ff9ff3; }

/* Shapes: rectangles and circles */
.relatia-post-chapter-confetti-piece:nth-child(odd) {
  width: 8px;
  height: 14px;
  border-radius: 2px;
}

.relatia-post-chapter-confetti-piece:nth-child(even) {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Horizontal spread (10 columns) */
.relatia-post-chapter-confetti-piece:nth-child(10n+1) { left: 5%; }
.relatia-post-chapter-confetti-piece:nth-child(10n+2) { left: 14%; }
.relatia-post-chapter-confetti-piece:nth-child(10n+3) { left: 23%; }
.relatia-post-chapter-confetti-piece:nth-child(10n+4) { left: 32%; }
.relatia-post-chapter-confetti-piece:nth-child(10n+5) { left: 42%; }
.relatia-post-chapter-confetti-piece:nth-child(10n+6) { left: 53%; }
.relatia-post-chapter-confetti-piece:nth-child(10n+7) { left: 64%; }
.relatia-post-chapter-confetti-piece:nth-child(10n+8) { left: 74%; }
.relatia-post-chapter-confetti-piece:nth-child(10n+9) { left: 84%; }
.relatia-post-chapter-confetti-piece:nth-child(10n+10) { left: 93%; }

/* Staggered delays */
.relatia-post-chapter-confetti-piece:nth-child(5n+1) { animation-delay: 0s; }
.relatia-post-chapter-confetti-piece:nth-child(5n+2) { animation-delay: 0.15s; }
.relatia-post-chapter-confetti-piece:nth-child(5n+3) { animation-delay: 0.3s; }
.relatia-post-chapter-confetti-piece:nth-child(5n+4) { animation-delay: 0.08s; }
.relatia-post-chapter-confetti-piece:nth-child(5n+5) { animation-delay: 0.22s; }

/* Three fall patterns with different sway */
.relatia-post-chapter-confetti-piece:nth-child(3n+1) {
  animation: relatiaConfettiFall1 2.8s ease-in-out forwards;
}

.relatia-post-chapter-confetti-piece:nth-child(3n+2) {
  animation: relatiaConfettiFall2 3.2s ease-in-out forwards;
}

.relatia-post-chapter-confetti-piece:nth-child(3n) {
  animation: relatiaConfettiFall3 3.5s ease-in-out forwards;
}

@keyframes relatiaConfettiFall1 {
  0% { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg) scale(1); }
  25% { transform: translateY(80px) translateX(15px) rotate(180deg) scale(0.95); }
  50% { transform: translateY(180px) translateX(-10px) rotate(360deg) scale(0.9); }
  75% { transform: translateY(300px) translateX(20px) rotate(540deg) scale(0.85); opacity: 0.7; }
  100% { opacity: 0; transform: translateY(420px) translateX(5px) rotate(720deg) scale(0.8); }
}

@keyframes relatiaConfettiFall2 {
  0% { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg); }
  25% { transform: translateY(90px) translateX(-20px) rotate(-120deg); }
  50% { transform: translateY(200px) translateX(12px) rotate(-240deg); }
  75% { transform: translateY(320px) translateX(-15px) rotate(-420deg); opacity: 0.6; }
  100% { opacity: 0; transform: translateY(440px) translateX(-5px) rotate(-600deg); }
}

@keyframes relatiaConfettiFall3 {
  0% { opacity: 1; transform: translateY(0) translateX(0) rotate(45deg); }
  33% { transform: translateY(130px) translateX(25px) rotate(225deg); }
  66% { transform: translateY(280px) translateX(-18px) rotate(405deg); opacity: 0.5; }
  100% { opacity: 0; transform: translateY(430px) translateX(8px) rotate(630deg); }
}

/* Dark theme celebration */
[data-theme="dark"] .relatia-post-chapter-celebration-title {
  color: #f3f4f6;
}

[data-theme="dark"] .relatia-post-chapter-celebration-text {
  color: #9ca3af;
}

[data-theme="dark"] .relatia-post-chapter-celebration-text strong {
  color: #818cf8;
}

/* --- Share buttons (celebration) --- */

.relatia-post-chapter-share {
  position: relative;
  z-index: 2;
  margin-top: 20px;
  animation: relatiaPostChapterFadeIn 0.4s ease 1.2s both;
}

.relatia-post-chapter-share-label {
  font-size: 13px;
  color: #9ca3af;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.relatia-post-chapter-share-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.relatia-post-chapter-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, opacity 0.15s;
}

.relatia-post-chapter-share-btn:hover {
  transform: scale(1.15);
  opacity: 0.85;
}

.relatia-post-chapter-share-btn img {
  display: block;
}

.relatia-post-chapter-share-tiktok {
  background: #010101;
}

.relatia-post-chapter-share-instagram {
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.relatia-post-chapter-share-x {
  background: #000;
}

.relatia-post-chapter-share-linkedin {
  background: #0A66C2;
}

.relatia-post-chapter-share-whatsapp {
  background: #25D366;
}

.relatia-post-chapter-share-copy {
  background: #6b7280;
}

/* Copied indicator (celebration) */
.relatia-post-chapter-share-copied-indicator {
  display: none;
  font-size: 12px;
  font-weight: 600;
  color: #10b981;
  margin-top: 8px;
  animation: relatiaShareCopiedFadeIn 0.3s ease;
}

.relatia-post-chapter-share-copied-indicator.is-visible {
  display: block;
}

@keyframes relatiaShareCopiedFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

[data-theme="dark"] .relatia-post-chapter-share-label {
  color: #6b7280;
}

/* =========================================================================
   Character Emotion Selector
   ========================================================================= */

.relatia-post-chapter-char-emotion {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0;
  align-items: center;
}

.relatia-post-chapter-char-emotion-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  padding: 0;
  line-height: 1;
}

.relatia-post-chapter-char-emotion-btn:hover {
  border-color: #c7d2fe;
  background: #f5f3ff;
  transform: scale(1.1);
}

.relatia-post-chapter-char-emotion-btn.selected {
  border-color: #6366f1;
  background: #eef2ff;
  transform: scale(1.15);
}

/* =========================================================================
   Keep / Remove Toggle
   ========================================================================= */

.relatia-post-chapter-keep-remove {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.relatia-post-chapter-keep-btn,
.relatia-post-chapter-remove-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  color: #6b7280;
}

.relatia-post-chapter-keep-btn:hover {
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.relatia-post-chapter-remove-btn:hover {
  border-color: #fecaca;
  background: #fef2f2;
}

.relatia-post-chapter-keep-btn.active {
  border-color: #10b981;
  background: #ecfdf5;
  color: #059669;
}

.relatia-post-chapter-remove-btn.active {
  border-color: #ef4444;
  background: #fef2f2;
  color: #dc2626;
}

/* =========================================================================
   Reflection Questions (AI)
   ========================================================================= */

.relatia-post-chapter-reflection-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

.relatia-post-chapter-reflection-section h3 {
  margin: 0 0 16px;
  font-size: 16px;
  color: #374151;
  font-weight: 600;
}

.relatia-post-chapter-reflection {
  margin-bottom: 16px;
}

.relatia-post-chapter-reflection-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.relatia-post-chapter-reflection-text {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.relatia-post-chapter-reflection-text:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* =========================================================================
   Floating Reopen Bubble
   ========================================================================= */

.relatia-post-chapter-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  z-index: 9999999;
  animation: relatiaPostChapterBubbleIn 0.3s ease;
  transition: transform 0.15s, box-shadow 0.15s;
}

.relatia-post-chapter-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
}

.relatia-post-chapter-bubble .material-icons-outlined {
  font-size: 28px;
}

@keyframes relatiaPostChapterBubbleIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* =========================================================================
   Dark theme support
   ========================================================================= */

[data-theme="dark"] .relatia-post-chapter-modal {
  background: #1f2937;
}

[data-theme="dark"] .relatia-post-chapter-header {
  border-bottom-color: #374151;
}

[data-theme="dark"] .relatia-post-chapter-title,
[data-theme="dark"] .relatia-post-chapter-stars-section h3,
[data-theme="dark"] .relatia-post-chapter-characters h3,
[data-theme="dark"] .relatia-post-chapter-character-name,
[data-theme="dark"] .relatia-post-chapter-question-text,
[data-theme="dark"] .relatia-post-chapter-idea-content {
  color: #f3f4f6;
}

[data-theme="dark"] .relatia-post-chapter-close {
  color: #6b7280;
}

[data-theme="dark"] .relatia-post-chapter-close:hover {
  color: #d1d5db;
}

[data-theme="dark"] .relatia-post-chapter-step {
  background: #374151;
  color: #9ca3af;
}

[data-theme="dark"] .relatia-post-chapter-star {
  color: #4b5563;
}

[data-theme="dark"] .relatia-post-chapter-question-textarea,
[data-theme="dark"] .relatia-post-chapter-comments textarea,
[data-theme="dark"] .relatia-post-chapter-idea-text {
  background: #374151;
  border-color: #4b5563;
  color: #f3f4f6;
}

[data-theme="dark"] .relatia-post-chapter-character {
  border-color: #374151;
}

[data-theme="dark"] .relatia-post-chapter-character:hover {
  border-color: #4b5563;
}

[data-theme="dark"] .relatia-post-chapter-character-placeholder {
  background: #374151;
  color: #6b7280;
}

[data-theme="dark"] .relatia-post-chapter-eliminate-label {
  color: #9ca3af;
}

[data-theme="dark"] .relatia-post-chapter-char-emotion-btn {
  border-color: #374151;
  background: #1f2937;
}

[data-theme="dark"] .relatia-post-chapter-char-emotion-btn:hover {
  border-color: #4b5563;
  background: #374151;
}

[data-theme="dark"] .relatia-post-chapter-char-emotion-btn.selected {
  border-color: #6366f1;
  background: #312e81;
}

[data-theme="dark"] .relatia-post-chapter-keep-btn,
[data-theme="dark"] .relatia-post-chapter-remove-btn {
  border-color: #374151;
  background: #1f2937;
  color: #9ca3af;
}

[data-theme="dark"] .relatia-post-chapter-keep-btn.active {
  border-color: #059669;
  background: #064e3b;
  color: #34d399;
}

[data-theme="dark"] .relatia-post-chapter-remove-btn.active {
  border-color: #dc2626;
  background: #7f1d1d;
  color: #f87171;
}

[data-theme="dark"] .relatia-post-chapter-reflection-section {
  border-top-color: #374151;
}

[data-theme="dark"] .relatia-post-chapter-reflection-section h3,
[data-theme="dark"] .relatia-post-chapter-reflection-label {
  color: #f3f4f6;
}

[data-theme="dark"] .relatia-post-chapter-reflection-text {
  background: #374151;
  border-color: #4b5563;
  color: #f3f4f6;
}

[data-theme="dark"] .relatia-post-chapter-emotion-btn {
  border-color: #374151;
  background: #1f2937;
}

[data-theme="dark"] .relatia-post-chapter-emotion-btn:hover {
  border-color: #4b5563;
  background: #374151;
}

[data-theme="dark"] .relatia-post-chapter-emotion-btn.selected {
  border-color: #a855f7;
  background: #581c87;
}

[data-theme="dark"] .relatia-post-chapter-emotion-label {
  color: #9ca3af;
}

[data-theme="dark"] .relatia-post-chapter-idea-item {
  border-color: #374151;
}

[data-theme="dark"] .relatia-post-chapter-reaction-btn {
  border-color: #374151;
  background: #1f2937;
}

[data-theme="dark"] .relatia-post-chapter-reaction-btn:hover {
  border-color: #4b5563;
  background: #374151;
}

[data-theme="dark"] .relatia-post-chapter-reaction-btn.active {
  border-color: #6366f1;
  background: #312e81;
}

[data-theme="dark"] .relatia-post-chapter-btn-secondary {
  background: #374151;
  color: #d1d5db;
}

[data-theme="dark"] .relatia-post-chapter-btn-secondary:hover {
  background: #4b5563;
}

[data-theme="dark"] .relatia-post-chapter-bubble {
  background: #4f46e5;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
}

[data-theme="dark"] .relatia-post-chapter-bubble:hover {
  box-shadow: 0 6px 24px rgba(79, 70, 229, 0.5);
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 480px) {
  .relatia-post-chapter-modal {
    width: 95%;
    max-height: 90vh;
    border-radius: 10px;
  }

  .relatia-post-chapter-header {
    padding: 12px 16px;
  }

  .relatia-post-chapter-body {
    padding: 16px;
  }

  .relatia-post-chapter-star {
    font-size: 28px;
  }

  .relatia-post-chapter-character .relatia-post-chapter-star {
    font-size: 18px;
  }

  .relatia-post-chapter-emotion-btn {
    min-width: 55px;
    padding: 6px 8px;
  }

  .relatia-post-chapter-bubble {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .relatia-post-chapter-bubble .material-icons-outlined {
    font-size: 24px;
  }

  .relatia-post-chapter-char-emotion-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .relatia-post-chapter-keep-btn,
  .relatia-post-chapter-remove-btn {
    padding: 3px 8px;
    font-size: 11px;
  }
}

/* =========================================================================
   Register CTA (guest mode)
   ========================================================================= */

.relatia-post-chapter-register-content {
  text-align: center;
  padding: 2rem;
}

.relatia-post-chapter-register-icon {
  font-size: 64px!important;
  color: var(--relatia-primary, #6366f1);
  display: block;
  margin-bottom: 1rem;
}

.relatia-post-chapter-register h2 {
  margin-bottom: 0.5rem;
}

.relatia-post-chapter-register p {
  margin-bottom: 1.5rem;
  color: #666;
}

.relatia-post-chapter-register .relatia-post-chapter-btn-primary {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.relatia-post-chapter-btn-text {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: transparent;
  color: #6b7280;
  border: none;
  cursor: pointer;
  font-size: 0.9em;
  text-align: center;
}

.relatia-post-chapter-btn-text:hover {
  color: #374151;
  text-decoration: underline;
}

/* =========================================================================
   Level-Up Overlay
   ========================================================================= */

/* Level-up: custom overlay fallback (when popup manager unavailable) */
.relatia-level-up-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: relatiaPostChapterFadeIn 0.2s ease;
}

/* Level-up: popup manager overrides */
#relatia-popup-level-up,
#relatia-popup-level-up .relatia-popup-content {
  max-width: 500px;
}

#relatia-popup-level-up {
  overflow: visible;
}

#relatia-popup-level-up .relatia-popup-content {
  overflow: hidden;
  border-radius: 16px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.relatia-level-up-modal {
  background: #fff;
  border-radius: 16px;
  padding: 40px 32px;
  text-align: center;
  max-width: 480px;
  width: 100%;
  position: relative;
  z-index: 1;
  animation: relatiaPostChapterSlideUp 0.3s ease;
}

.relatia-level-up-emoji {
  font-size: 72px;
  line-height: 1;
  animation: relatiaTrophyBounce 0.6s ease 0.3s both;
}

.relatia-level-up-title {
  font-size: 28px;
  font-weight: 700;
  margin: 12px 0 4px;
  color: #333;
}

.relatia-level-up-name {
  font-size: 18px;
  color: #666;
  margin: 0 0 24px;
}

/* Roadmap row */
.relatia-level-up-roadmap {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 0 20px;
  flex-wrap: wrap;
}

.relatia-level-up-roadmap-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 8px;
  min-width: 60px;
  transition: transform 0.2s;
}

.relatia-level-up-roadmap-emoji { font-size: 28px; }
.relatia-level-up-roadmap-label { font-size: 10px; color: #999; white-space: nowrap; }

/* States */
.relatia-level-up-roadmap-item.achieved .relatia-level-up-roadmap-emoji { opacity: 1; }
.relatia-level-up-roadmap-item.achieved .relatia-level-up-roadmap-label { color: #666; }

.relatia-level-up-roadmap-item.current {
  background: #f0f7ff;
  border: 2px solid #4d96ff;
  transform: scale(1.1);
}
.relatia-level-up-roadmap-item.current .relatia-level-up-roadmap-label {
  color: #4d96ff;
  font-weight: 600;
}

.relatia-level-up-roadmap-item.locked .relatia-level-up-roadmap-emoji {
  opacity: 0.3;
  filter: grayscale(1);
}

.relatia-level-up-next {
  font-size: 14px;
  color: #888;
  margin: 0 0 20px;
}

/* Dark theme level-up */
[data-theme="dark"] .relatia-level-up-modal {
  background: #1f2937;
}

[data-theme="dark"] .relatia-level-up-title {
  color: #f3f4f6;
}

[data-theme="dark"] .relatia-level-up-name {
  color: #9ca3af;
}

[data-theme="dark"] .relatia-level-up-roadmap-item.current {
  background: #1e3a5f;
  border-color: #4d96ff;
}

[data-theme="dark"] .relatia-level-up-roadmap-label {
  color: #6b7280;
}

[data-theme="dark"] .relatia-level-up-roadmap-item.achieved .relatia-level-up-roadmap-label {
  color: #9ca3af;
}

[data-theme="dark"] .relatia-level-up-next {
  color: #6b7280;
}

[data-theme="dark"] #relatia-popup-level-up .relatia-popup-content {
  background: transparent;
}

#relatia-popup-level-up .relatia-popup-close-wrapper {
  color: #94a3b8;
  z-index: 10;
}

#relatia-popup-level-up .relatia-popup-close-wrapper:hover {
  color: #1e293b;
}

[data-theme="dark"] #relatia-popup-level-up .relatia-popup-close-wrapper:hover {
  color: #f1f5f9;
}
