:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --success: #10b981;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.03);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --reader-font-size: 19px;
  --reader-line-height: 1.85;
}

/* Reader Color Modes (Bright & Eye-friendly) */
body.theme-white {
  --reader-bg: #ffffff;
  --reader-card: #ffffff;
  --reader-text: #1e293b;
  --reader-highlight: #fef08a;
  --reader-border: #e2e8f0;
}

body.theme-sepia {
  --reader-bg: #fbf7ee;
  --reader-card: #f5eedb;
  --reader-text: #453424;
  --reader-highlight: #fde68a;
  --reader-border: #e8dcc4;
}

body.theme-cream {
  --reader-bg: #fcfbf9;
  --reader-card: #f7f4ed;
  --reader-text: #2c3e50;
  --reader-highlight: #fed7aa;
  --reader-border: #ebd9c7;
}

body.theme-mint {
  --reader-bg: #f3f9f6;
  --reader-card: #e5f4ec;
  --reader-text: #19382c;
  --reader-highlight: #bbf7d0;
  --reader-border: #cde8d9;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Pretendard', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Navbar */
.navbar-custom {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.35rem;
  color: #1e293b;
  text-decoration: none;
}

.brand-badge {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.brand-logo span.accent {
  background: linear-gradient(135deg, #4f46e5, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Hero Section */
.hero-banner {
  background: linear-gradient(135deg, #eef2ff 0%, #fdf2f8 50%, #fffbeb 100%);
  border-bottom: 1px solid var(--border);
  padding: 48px 0 36px;
  position: relative;
  overflow: hidden;
}

.hero-banner::after {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 2.3rem;
  color: #0f172a;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.12rem;
  max-width: 680px;
  line-height: 1.6;
}

.hero-feature-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.feature-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  color: var(--text-main);
  backdrop-filter: blur(8px);
}

/* Filter & Search Bar */
.filter-container {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 30px;
}

.search-input-group {
  position: relative;
  flex: 1;
}

.search-input-group i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input-group input {
  padding-left: 42px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  transition: all 0.2s;
  background: #f8fafc;
}

.search-input-group input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  outline: none;
}

.level-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.level-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  transition: all 0.2s;
  cursor: pointer;
}

.level-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.level-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* Continue Reading Banner */
.continue-reading-card {
  background: linear-gradient(135deg, #ffffff 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

/* Book Cards Grid */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 24px;
}

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #cbd5e1;
}

.book-cover {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.book-cover-icon {
  font-size: 3.5rem;
  opacity: 0.9;
  transition: transform 0.3s;
}

.book-card:hover .book-cover-icon {
  transform: scale(1.1);
}

.book-level-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.9);
  color: #1e293b;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  backdrop-filter: blur(4px);
}

.book-public-domain-tag {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.92);
  color: #ffffff;
  backdrop-filter: blur(4px);
}

.book-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.book-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.22rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
  line-height: 1.35;
}

.book-korean-title {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.book-author {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
}

.book-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.book-meta-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn-read {
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: #ffffff;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-read:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #4f46e5 100%);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transform: translateY(-1px);
}

/* ==========================================================================
   READER VIEW STYLES
   ========================================================================== */
#readerSection {
  background-color: var(--reader-bg);
  min-height: 100vh;
  transition: background-color 0.25s ease;
}

.reader-navbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 10px 0;
}

body.theme-sepia .reader-navbar {
  background: rgba(251, 247, 238, 0.95);
  border-bottom-color: #e8dcc4;
}

body.theme-cream .reader-navbar {
  background: rgba(252, 251, 249, 0.95);
  border-bottom-color: #ebd9c7;
}

body.theme-mint .reader-navbar {
  background: rgba(243, 249, 246, 0.95);
  border-bottom-color: #cde8d9;
}

.reader-progress-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0,0,0,0.06);
}

.reader-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.15s ease;
}

.reader-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.reader-card {
  background: var(--reader-card);
  color: var(--reader-text);
  border-radius: var(--radius-lg);
  padding: 44px 48px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--reader-border);
  transition: all 0.25s ease;
}

@media (max-width: 768px) {
  .reader-card {
    padding: 24px 18px;
    border-radius: var(--radius-md);
  }
}

.reader-header {
  border-bottom: 2px solid var(--reader-border);
  padding-bottom: 20px;
  margin-bottom: 32px;
}

.reader-book-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.reader-chapter-title {
  font-size: 1.25rem;
  font-weight: 600;
  opacity: 0.85;
}

/* Reader Typography & Word Clickability */
.reader-content {
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  word-break: break-word;
}

.font-serif {
  font-family: 'Merriweather', 'Georgia', serif;
}

.font-sans {
  font-family: 'Inter', 'Pretendard', sans-serif;
}

.font-dyslexic {
  font-family: 'Lexend', sans-serif;
  letter-spacing: 0.03em;
}

.reader-content p {
  margin-bottom: 1.6em;
  position: relative;
  transition: background-color 0.2s;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
}

.reader-content p.reading-active {
  background: var(--reader-highlight);
  box-shadow: 0 0 0 4px var(--reader-highlight);
}

/* Clickable Words for Vocabulary Popup */
.word-span {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 1px;
  transition: background-color 0.15s, color 0.15s;
}

.word-span:hover {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  text-decoration: underline dotted;
}

/* TTS Audio Bar (Floating at bottom) */
.audio-player-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  border-radius: var(--radius-full);
  padding: 10px 22px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  backdrop-filter: blur(12px);
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(255,255,255,0.15);
}

.audio-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.1rem;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.audio-btn:hover {
  background: rgba(255,255,255,0.2);
}

.audio-btn.btn-play-pause {
  background: var(--primary);
  color: #ffffff;
}

.audio-btn.btn-play-pause:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.speed-select {
  background: rgba(255,255,255,0.15);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
}

.speed-select option {
  background: #1e293b;
  color: #ffffff;
}

/* Instant Vocabulary Tooltip Popover */
.vocab-tooltip {
  position: absolute;
  z-index: 1050;
  background: #ffffff;
  color: #1e293b;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid #cbd5e1;
  padding: 16px 18px;
  width: 290px;
  font-size: 0.9rem;
  animation: fadeInPop 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1.45;
}

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

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

.vocab-word-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.vocab-pos {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--border-light);
  padding: 2px 6px;
  border-radius: 4px;
}

.vocab-korean {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}

.vocab-english-def {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

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

.btn-vocab-action {
  flex: 1;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-vocab-action:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Vocabulary Notebook Drawer */
.offcanvas-custom {
  border-left: 1px solid var(--border);
}

.vocab-list-item {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  transition: all 0.2s;
}

.vocab-list-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Flashcard Modal */
.flashcard {
  perspective: 1000px;
  height: 240px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.flashcard-front {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  color: var(--primary);
}

.flashcard-back {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  transform: rotateY(180deg);
}

/* Toast */
.custom-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s ease;
}

.custom-toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* AdSense Container */
.ad-slot-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  margin: 28px 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-slot-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* Footer */
footer {
  background: #ffffff;
  border-top: 1px solid var(--border);
  padding: 40px 0 30px;
  margin-top: auto;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
