/* =============================================================================
   CLASSIC LIBRARY AESTHETIC
   ============================================================================= */

/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* CSS Variables - Classic Library Palette */
:root {
  /* Classic Library Colors */
  --navy-dark: #1a2332;
  --navy-medium: #2a3b4f;
  --burgundy: #8b2635;
  --burgundy-light: #a13545;
  --cream: #f5f1e8;
  --cream-dark: #e8e0d0;
  --gold: #d4af37;
  --gold-dark: #b8962d;
  --brown-dark: #2c1810;
  --brown-medium: #4a2f20;

  /* Neutrals */
  --white: #ffffff;
  --black: #0a0a0a;
  --gray-light: #d4d0c8;
  --gray-medium: #8a8680;
  --gray-dark: #3d3a35;

  /* Semantic Colors */
  --error-red: #c92a2a;
  --success-green: #2f5233;

  /* Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
}

/* =============================================================================
   BASE STYLES & TYPOGRAPHY
   ============================================================================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 24px;
  color: var(--brown-dark);
  background: var(--cream);
  overflow: hidden;
}

h1 {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 42px;
  font-weight: 700;
  line-height: 52px;
  color: var(--navy-dark);
  letter-spacing: -0.02em;
}

h2 {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
  color: var(--navy-dark);
  letter-spacing: -0.01em;
}

h3 {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 26px;
  color: var(--brown-dark);
}

small {
  font-size: 13px;
  line-height: 20px;
  color: var(--gray-medium);
}

/* =============================================================================
   LAYOUT: TWO-VIEW SYSTEM
   ============================================================================= */

.app-container {
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* Library View (Full Screen) - Clean Modern Design */
.library-view {
  height: 100vh;
  width: 100%;
  background: linear-gradient(180deg, #fcfcfc 0%, #f8f8f8 100%);
  display: flex;
  flex-direction: column;
  position: relative;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
}

.library-header {
  padding: var(--space-8) var(--space-12);
  border-bottom: 1px solid #ebebeb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  position: relative;
  z-index: 10;
}

.library-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 36px;
  font-weight: 600;
  color: #0f0f0f;
  margin: 0;
  letter-spacing: -0.02em;
}

.library-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-8) var(--space-12);
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Clean scrollbar for library */
.library-content::-webkit-scrollbar {
  width: 8px;
}

.library-content::-webkit-scrollbar-track {
  background: transparent;
}

.library-content::-webkit-scrollbar-thumb {
  background: #d4d4d4;
  border-radius: 4px;
}

.library-content::-webkit-scrollbar-thumb:hover {
  background: #a3a3a3;
}

/* =============================================================================
   CHAPTERS VIEW
   ============================================================================= */

/* Chapters View (Full Screen) */
.chapters-view {
  height: 100vh;
  width: 100%;
  background: var(--cream);
  overflow-y: auto;
  position: relative;
}

.chapters-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 100px var(--space-8) var(--space-12) var(--space-8);
}

/* Book Info Section */
.chapters-book-info {
  display: flex;
  gap: var(--space-8);
  padding: var(--space-8);
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: var(--space-8);
}

.chapters-book-cover {
  width: 200px;
  height: 280px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.chapters-book-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chapters-book-title {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 40px;
  color: var(--navy-dark);
  margin: 0;
}

.chapters-book-author {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: var(--gray-medium);
  margin: 0;
}

/* Progress Stats */
.chapters-stats {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.chapters-stat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chapters-stat-value {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--brown-dark);
}

.chapters-stat-separator {
  color: var(--gray-medium);
  font-size: 14px;
}

/* Progress Bar */
.chapters-progress-container {
  margin-top: var(--space-4);
}

.chapters-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--gray-light);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.chapters-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--burgundy), var(--burgundy-light));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.chapters-progress-text {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-medium);
}

/* Book Description */
.chapters-book-description {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 22px;
  color: var(--brown-dark);
  margin-top: var(--space-4);
}

/* Chapter List Section */
.chapters-list-section {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: var(--space-8);
}

.chapters-list-title {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--navy-dark);
  margin: 0 0 var(--space-6) 0;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Individual Chapter Item */
.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  background: var(--cream);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chapter-item:hover {
  background: var(--cream-dark);
  border-color: var(--burgundy);
  transform: translateX(4px);
}

.chapter-item.completed {
  background: linear-gradient(135deg, rgba(139, 38, 53, 0.05), rgba(161, 53, 69, 0.05));
  border-left: 3px solid var(--burgundy);
}

.chapter-item-title {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--brown-dark);
  flex: 1;
}

.chapter-item-pages {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-medium);
  margin-left: var(--space-4);
  line-height: 1.5;
}

.chapter-item.completed .chapter-item-title {
  color: var(--burgundy);
}

/* Chapter stats display */
.chapter-item-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.chapter-item-stats {
  padding: 0 var(--space-6);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
}

.chapter-stats-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.chapter-stat-item {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--brown-dark);
  line-height: 1.5;
}

.chapter-stat-separator {
  color: var(--gray-light);
  font-size: 12px;
}

.chapter-stats-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: var(--space-2);
}

.chapter-stats-btn:hover {
  background: #f0f0f0;
  border-color: rgba(0, 0, 0, 0.2);
  color: #000;
}

/* Typing View (Full Screen) */
.typing-view {
  height: 100vh;
  width: 100%;
  background: var(--cream);
  overflow-y: auto;
  padding: var(--space-12) var(--space-16);
  position: relative;
}

/* Back Button - positioned within typing header */
.typing-view .back-button {
  position: relative;
  padding: 10px 18px;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  box-shadow: none;
  letter-spacing: -0.01em;
}

.typing-view .back-button:hover {
  background: #f0f0f0;
  border-color: rgba(0, 0, 0, 0.2);
  color: #000;
  box-shadow: none;
}

/* Back Button for chapters view - matches typing view style */
.chapters-view .back-button {
  position: fixed;
  top: var(--space-6);
  left: var(--space-6);
  padding: 10px 18px;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  box-shadow: none;
  letter-spacing: -0.01em;
}

.chapters-view .back-button:hover {
  background: #f0f0f0;
  border-color: rgba(0, 0, 0, 0.2);
  color: #000;
  box-shadow: none;
}

/* Upload Button */
.upload-button {
  padding: 12px 24px;
  background: linear-gradient(135deg, #0f0f0f 0%, #2a2a2a 100%);
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', sans-serif;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.upload-button:hover {
  background: linear-gradient(135deg, #2a2a2a 0%, #404040 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.upload-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Library Header Actions */
.library-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

/* User Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid #ebebeb;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.user-menu:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: #d4d4d4;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ebebeb;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  padding: 6px 12px;
  background: #f5f5f5;
  border: 1px solid #d4d4d4;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.logout-button:hover {
  background: #ebebeb;
  border-color: #a3a3a3;
  color: #333;
}

.logout-button:active {
  transform: scale(0.98);
}

/* Sign In Button */
.signin-button {
  padding: 8px 16px;
  background: #ffffff;
  border: 1.5px solid #d4d4d4;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.signin-button:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.signin-button:active {
  transform: scale(0.98) translateY(0);
}

/* Guest Mode Banner */
.guest-banner {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideDown 0.3s ease-out;
}

.guest-banner-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  max-width: 1200px;
  margin: 0 auto;
}

.guest-banner-icon {
  font-size: 24px;
}

.guest-banner-text {
  color: white;
  font-size: 15px;
  font-weight: 400;
}

.guest-banner-text strong {
  font-weight: 600;
}

.guest-signup-btn {
  padding: 8px 20px;
  background: white;
  color: #667eea;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.guest-signup-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.guest-signup-btn:active {
  transform: scale(0.98);
}

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

/* Guest Auth Buttons (Header) */
.guest-auth-buttons {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.auth-button {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.login-button {
  background: transparent;
  color: #333;
  border: 1.5px solid #d1d5db;
}

.login-button:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.signup-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

.signup-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

.auth-button:active {
  transform: scale(0.98);
}

/* Library Tabs */
.library-tabs {
  display: flex;
  gap: var(--space-8);
  margin-bottom: var(--space-6);
  border-bottom: 1.5px solid #ebebeb;
}

.tab-btn {
  padding: 14px 4px;
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  bottom: -1.5px;
  letter-spacing: -0.01em;
}

.tab-btn:hover {
  color: #0f0f0f;
}

.tab-btn.active {
  color: #0f0f0f;
  border-bottom-color: #0f0f0f;
}

/* Search Bar */
.search-container {
  position: relative;
  margin-bottom: var(--space-8);
}

.book-search {
  width: 100%;
  padding: 14px var(--space-4);
  background: white;
  border: 1.5px solid #ebebeb;
  border-radius: 12px;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  color: #0f0f0f;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.book-search:focus {
  outline: none;
  border-color: #0f0f0f;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 0 3px rgba(0, 0, 0, 0.03);
}

.book-search::placeholder {
  color: #999;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  color: #a3a3a3;
  transition: color 0.2s ease;
}

.search-container:focus-within .search-icon {
  color: #737373;
}

/* Book Sections */
.book-section {
  margin-bottom: var(--space-8);
}

.section-header {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #737373;
  padding: 0 0 var(--space-2) 0;
  margin: 0 0 var(--space-4) 0;
}

.empty-section {
  text-align: center;
  color: #a3a3a3;
  padding: var(--space-16) var(--space-4);
  font-size: 15px;
  font-family: 'Inter', sans-serif;
}

/* Book List - Grid Layout (Vertical Cards) */
.book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 28px;
  padding: var(--space-4) 0;
}

.book-item {
  background: white;
  border: 1px solid #f0f0f0;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.book-item:hover {
  border-color: #e0e0e0;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-4px);
}

.book-item.active {
  border-color: #0f0f0f;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
}

.book-item.recent {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Book Cover (Larger, on top) - Fixed 2:3 aspect ratio */
.book-cover {
  width: 100%;
  padding-bottom: 150%; /* 2:3 aspect ratio (height = 1.5 × width) */
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  background: #f8f8f8;
}

.book-cover img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-cover-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 56px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.book-item:nth-child(6n+1) .book-cover-placeholder {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
}

.book-item:nth-child(6n+2) .book-cover-placeholder {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
}

.book-item:nth-child(6n+3) .book-cover-placeholder {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.book-item:nth-child(6n+4) .book-cover-placeholder {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.book-item:nth-child(6n+5) .book-cover-placeholder {
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
}

.book-item:nth-child(6n+6) .book-cover-placeholder {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

.book-item-content {
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.book-title-text {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #0f0f0f;
  line-height: 1.45;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  min-height: 2.9em; /* Reserve space for 2 lines */
}

.book-author-text {
  font-size: 13px;
  color: #666;
  display: block;
  font-weight: 450;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.book-meta {
  font-size: 12px;
  color: #999;
  margin-top: auto;
  padding-top: 8px;
  font-weight: 500;
}

.book-delete-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #ebebeb;
  color: #666;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(8px);
}

.book-item:hover .book-delete-btn {
  opacity: 1;
}

.book-delete-btn:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.35);
}

/* Book Progress Indicators */
.book-progress-info {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid #f3f3f3;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.book-continue-badge {
  display: inline-block;
  padding: 5px 10px;
  background: linear-gradient(135deg, #0f0f0f 0%, #2a2a2a 100%);
  color: white;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-radius: 6px;
  width: fit-content;
  margin-bottom: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.book-progress-text {
  font-size: 12px;
  color: #666;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.book-progress-bar {
  width: 100%;
  height: 5px;
  background: #f3f3f3;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.book-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0f0f0f 0%, #2a2a2a 100%);
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Book Completion Stats */
.book-completion-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.completion-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.completion-count {
  color: #0f0f0f;
  font-weight: 600;
}

.completion-percent {
  color: #666;
  font-variant-numeric: tabular-nums;
}

.completion-bar {
  width: 100%;
  height: 6px;
  background: #f3f3f3;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.completion-fill {
  height: 100%;
  background: linear-gradient(90deg, #0f0f0f 0%, #2a2a2a 100%);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.book-current-position {
  font-size: 11px;
  color: #888;
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: -0.01em;
}

/* Responsive Grid */
@media (max-width: 600px) {
  .book-list {
    grid-template-columns: 1fr;
  }
}

/* Monty Logo */
.monty-logo {
  position: fixed;
  top: 24px;
  right: 32px;
  width: 48px;
  height: 48px;
  z-index: 100;
  opacity: 0.9;
  transition: opacity 0.2s ease;
}

.monty-logo:hover {
  opacity: 1;
}

/* =============================================================================
   MAIN CONTENT (Typing View) - Clean Minimalist / Digital Paper
   ============================================================================= */

.main-content {
  background: #fafaf8; /* Soft, warm off-white */
  overflow-y: auto;
  padding: var(--space-12) var(--space-16);
}

/* Empty State */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.empty-state-content {
  text-align: center;
  max-width: 400px;
}

.empty-state-icon {
  color: var(--gray-light);
  margin-bottom: var(--space-6);
}

.empty-state-title {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--navy-dark);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  font-size: 14px;
  color: var(--brown-medium);
  line-height: 22px;
}

/* Typing Interface */
.typing-interface {
  max-width: 800px; /* Slightly narrower for better readability */
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

/* Book Header - Minimal and elegant */
.book-header {
  margin-bottom: var(--space-12);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06); /* Very subtle divider */
  text-align: center;
}

.book-title {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: var(--space-3);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.book-author {
  font-size: 15px;
  font-style: normal;
  color: #666;
  font-weight: 400;
}

/* Typing View Header */
.typing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) 0;
  margin-bottom: var(--space-6);
}

.summary-btn {
  padding: 10px 18px;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: none;
  letter-spacing: -0.01em;
}

.summary-btn:hover {
  background: #f0f0f0;
  border-color: rgba(0, 0, 0, 0.2);
  color: #000;
  box-shadow: none;
}

/* Chapter Title Header */
.chapter-title-header {
  margin: var(--space-8) 0 var(--space-6) 0;
  text-align: center;
}

.chapter-title-text {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.75);
  letter-spacing: 0.3px;
  margin: 0;
  padding: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Compact meta line above the typing text (chapter + page) */
.typing-meta {
  margin: 0 0 var(--space-4);
  text-align: center;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12.5px;
  color: rgba(15, 23, 42, 0.55);
  letter-spacing: 0.2px;
}

/* Kindle-style reading progress bar */
.reading-progress {
  position: fixed;
  /* Slightly inset so it's visible against the browser chrome */
  top: 10px;
  left: 14px;
  right: 14px;
  height: 3px;
  width: auto;
  background: rgba(15, 23, 42, 0.10);
  z-index: 200;
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
}

.reading-progress-bar {
  height: 100%;
  width: 0%;
  background: rgba(15, 23, 42, 0.38);
  transition: width 120ms linear;
  border-radius: 999px;
}

.focus-exit {
  display: none;
  position: fixed;
  top: 26px;
  right: 14px;
  z-index: 5000;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.22);
  background: rgba(255, 255, 255, 0.96);
  color: rgba(15, 23, 42, 0.9);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12.5px;
  cursor: pointer;
  opacity: 0.75;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  transition: opacity 160ms ease, transform 160ms ease;
}

.focus-exit:hover {
  opacity: 1;
  transform: translateY(-1px);
}

/* Text Display - Maximum readability */
.text-display {
  background: white;
  padding: var(--space-16) var(--space-12);
  margin-bottom: var(--space-8);
  min-height: 500px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.text-content {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: var(--typing-font-size, 20px);
  line-height: var(--typing-line-height, 1.8);
  letter-spacing: 0.01em;
  color: #2a2a2a;
  white-space: pre-wrap;
  word-wrap: break-word;
  /* Prevent subtle width changes from ligatures/kerning when spans split text while typing */
  font-variant-ligatures: none;
  font-kerning: none;
  /* Keep glyph rendering consistent even when background highlights appear */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

/* Ensure highlighted spans don't introduce different font metrics */
.text-content span {
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  vertical-align: baseline;
}

/* Text Highlighting - Subtle and refined */
.completed {
  color: #b0b0b0;
}

.current {
  /* Elegant focus highlight (calm, modern) */
  background: #dbeafe;
  color: #0f172a;
  /* Padding can affect line-wrapping near the edge; keep layout stable */
  padding: 0;
  border-radius: 3px;
  box-shadow: none;
}

.upcoming {
  color: #2a2a2a;
}

.typed-ok {
  color: #b0b0b0; /* similar to .completed */
}

.typed-bad {
  /* Light error wash to avoid high-contrast AA "jitter" */
  background: rgba(220, 38, 38, 0.20);
  color: #7f1d1d;
  padding: 0;
  border-radius: 3px;
}

.error {
  background: rgba(220, 38, 38, 0.20);
  color: #7f1d1d;
  padding: 0;
  border-radius: 3px;
}

/* Page Controls - Clean and minimal */
.page-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--space-4) 0;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  margin-top: var(--space-6);
}

.mode-help {
  margin: 10px 0 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.04); /* slate-900 @ 4% */
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: rgba(15, 23, 42, 0.72);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12.5px;
  line-height: 1.2;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.mode-help strong {
  color: rgba(15, 23, 42, 0.9);
  font-weight: 600;
}

.mode-help.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.page-info {
  font-size: 13px;
  color: #888;
  display: flex;
  gap: var(--space-2);
  font-family: 'Inter', -apple-system, sans-serif;
}

.page-separator {
  color: #ccc;
}

.page-actions {
  display: flex;
  gap: var(--space-2);
}

.typing-mini-btn {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: none;
  letter-spacing: -0.01em;
}

.typing-mini-btn:hover {
  background: #f0f0f0;
  border-color: rgba(0, 0, 0, 0.2);
  color: #000;
}

/* Focus mode: hide UI chrome */
.typing-view.focus-mode .typing-header,
.typing-view.focus-mode #stats-bar,
.typing-view.focus-mode .page-controls,
.typing-view.focus-mode #mode-help,
.typing-view.focus-mode #page-indicators,
.typing-view.focus-mode #chapter-title-header {
  display: none !important;
}

.typing-view.focus-mode #focus-exit {
  display: inline-flex;
}

.page-jump-input {
  width: 120px;
  padding: 8px var(--space-3);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  transition: all 0.15s ease;
  font-family: 'Inter', -apple-system, sans-serif;
}

.page-jump-input:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

.page-jump-btn,
.page-nav-btn,
.typing-mode-toggle {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: none;
  letter-spacing: -0.01em;
}

.page-jump-btn:hover,
.page-nav-btn:hover,
.typing-mode-toggle:hover {
  background: #f0f0f0;
  border-color: rgba(0, 0, 0, 0.2);
  color: #000;
  box-shadow: none;
}

/* Hidden Typing Input */
.typing-input {
  position: fixed;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* Stats Bar - Minimal and elegant */
.stats-bar {
  display: flex;
  gap: var(--space-12);
  padding: var(--space-6) 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  margin: var(--space-4) 0 var(--space-6);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Inter', -apple-system, sans-serif;
}

.stat-value {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 28px;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: -0.02em;
  /* Prevent number width changes from causing subtle layout shift */
  font-variant-numeric: tabular-nums;
}

/* Pause Indicator */
.pause-indicator {
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--gray-medium);
  padding: 12px 20px;
  border-radius: 8px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 16px;
  animation: pausePulse 2s ease-in-out infinite;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

@keyframes pausePulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* =============================================================================
   MODALS
   ============================================================================= */

.dictionary-modal,
.summary-modal,
.stats-modal,
.book-selection-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 35, 50, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  animation: fadeIn 0.2s ease;
}

.dictionary-content,
.summary-content,
.stats-content,
.book-selection-content {
  background: var(--cream);
  border: 2px solid var(--burgundy);
  border-radius: 12px;
  padding: var(--space-8);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

.dictionary-header,
.summary-header,
.stats-header,
.book-selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--cream-dark);
  margin-bottom: var(--space-6);
}

.dictionary-header h2,
.summary-header h2,
.stats-header h2,
.book-selection-header h2 {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy-dark);
  margin: 0;
}

.dict-close-btn,
.summary-close-btn,
.stats-close-btn,
.book-selection-close-btn {
  width: 36px;
  height: 36px;
  background: var(--cream-dark);
  border: 2px solid var(--gray-light);
  color: var(--brown-medium);
  font-size: 20px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dict-close-btn:hover,
.summary-close-btn:hover,
.stats-close-btn:hover,
.book-selection-close-btn:hover {
  background: var(--burgundy);
  border-color: var(--burgundy);
  color: var(--cream);
}

.dict-phonetic {
  color: var(--burgundy);
  font-size: 15px;
  margin-bottom: var(--space-4);
  font-style: italic;
}

.dict-body,
.summary-body {
  color: var(--brown-dark);
  line-height: 1.7;
}

.stats-body {
  color: var(--brown-dark);
}

.dict-loading,
.summary-loading,
.stats-loading {
  text-align: center;
  color: var(--brown-medium);
  padding: var(--space-8);
  font-size: 14px;
}

.dict-error,
.summary-error {
  text-align: center;
  color: var(--error-red);
  padding: var(--space-8);
}

.dict-pos {
  font-weight: 700;
  color: var(--navy-dark);
  font-size: 15px;
  margin-bottom: var(--space-2);
  margin-top: var(--space-4);
}

.dict-definition {
  margin-bottom: var(--space-3);
  padding-left: var(--space-4);
}

.dict-definition-text {
  color: var(--brown-dark);
  line-height: 1.7;
  margin-bottom: var(--space-1);
}

.dict-example {
  color: var(--brown-medium);
  font-style: italic;
  margin-top: var(--space-1);
  padding-left: var(--space-3);
  border-left: 3px solid var(--gold);
}

.dict-synonyms {
  margin-top: var(--space-2);
  color: var(--brown-medium);
  font-size: 14px;
}

.dict-synonyms strong {
  color: var(--navy-dark);
}

.summary-chapter-title {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--burgundy);
  margin-bottom: var(--space-4);
}

.summary-body p {
  margin-bottom: var(--space-3);
}

/* Book Selection Modal */
.book-selection-body {
  color: var(--brown-dark);
}

.book-info h3 {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--navy-dark);
  margin: 0 0 var(--space-2) 0;
}

.book-info p {
  color: var(--brown-medium);
  margin: 0 0 var(--space-6) 0;
  font-size: 15px;
}

.description-section,
.cover-section {
  margin-bottom: var(--space-6);
}

.description-section label,
.cover-section label {
  display: block;
  font-weight: 600;
  color: var(--navy-dark);
  margin-bottom: var(--space-3);
  font-size: 15px;
}

.description-section textarea {
  width: 100%;
  padding: var(--space-4);
  border: 2px solid var(--gray-light);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--brown-dark);
  background: var(--cream-light);
  resize: vertical;
  line-height: 1.6;
}

.description-section textarea:focus {
  outline: none;
  border-color: var(--burgundy);
}

.cover-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.cover-option {
  position: relative;
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  aspect-ratio: 2/3;
}

.cover-option:hover {
  border-color: var(--gold);
  transform: scale(1.05);
}

.cover-option.selected {
  border-color: var(--burgundy);
  box-shadow: 0 4px 12px rgba(139, 0, 0, 0.3);
}

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

.cover-option .cover-source {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(26, 35, 50, 0.85);
  color: var(--cream);
  font-size: 11px;
  padding: 4px;
  text-align: center;
}

.action-section {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 2px solid var(--cream-dark);
}

.action-section .primary-btn,
.action-section .secondary-btn {
  flex: 1;
  padding: var(--space-4);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-section .primary-btn {
  background: var(--burgundy);
  color: var(--cream);
  border: 2px solid var(--burgundy);
}

.action-section .primary-btn:hover {
  background: var(--burgundy-dark);
  border-color: var(--burgundy-dark);
}

.action-section .secondary-btn {
  background: var(--cream-dark);
  color: var(--brown-dark);
  border: 2px solid var(--gray-light);
}

.action-section .secondary-btn:hover {
  background: var(--gray-light);
  border-color: var(--brown-medium);
}

/* Page stats list in modal */
.page-stats-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.page-stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  background: white;
  border: 1px solid var(--cream-dark);
  border-radius: 8px;
  transition: all 0.15s ease;
}

.page-stat-item:hover {
  border-color: var(--gray-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.page-stat-number {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--brown-dark);
  min-width: 80px;
}

.page-stat-metrics {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

.page-stat-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.page-stat-label {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.page-stat-value {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--brown-dark);
}

/* =============================================================================
   LOADING & NOTIFICATIONS
   ============================================================================= */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 35, 50, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-spinner {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(212, 175, 55, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#loading-text {
  color: var(--cream);
  margin-top: var(--space-6);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.notification {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--navy-dark);
  color: var(--cream);
  padding: var(--space-4) var(--space-6);
  border-radius: 10px;
  border: 2px solid var(--gold);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 3000;
  animation: slideIn 0.3s ease;
  font-size: 14px;
  font-weight: 500;
}

.notification.error {
  background: var(--error-red);
  border-color: var(--error-red);
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

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

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 1024px) {
  .library-content {
    padding: var(--space-8) var(--space-8);
  }

  .main-content {
    padding: var(--space-8) var(--space-6);
  }
}

@media (max-width: 768px) {
  .library-header {
    padding: var(--space-6) var(--space-6);
  }

  .library-title {
    font-size: 32px;
  }

  .library-header-actions {
    gap: var(--space-3);
  }

  .user-menu {
    padding: 6px 12px;
    gap: var(--space-2);
  }

  .user-name {
    display: none; /* Hide name on mobile */
  }

  .user-avatar {
    width: 28px;
    height: 28px;
  }

  .logout-button {
    padding: 6px 10px;
    font-size: 12px;
  }

  .upload-button {
    padding: 10px 18px;
    font-size: 13px;
  }

  .library-content {
    padding: var(--space-6) var(--space-6);
  }

  .book-list {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: var(--space-6) var(--space-4);
  }

  .typing-interface {
    max-width: 100%;
  }

  .text-display {
    padding: var(--space-8) 0;
  }

  .stats-bar {
    flex-wrap: wrap;
    gap: var(--space-4);
  }

  .stat {
    flex: 1 1 45%;
  }

  .chapter-nav {
    flex-wrap: wrap;
  }

  .page-controls {
    flex-direction: column;
    gap: var(--space-3);
  }
}

/* =============================================================================
   SIGN-IN VIEW
   ============================================================================= */

.signin-view {
  height: 100vh;
  width: 100%;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.signin-container {
  max-width: 480px;
  width: 90%;
}

.signin-content {
  background: white;
  border-radius: 24px;
  padding: var(--space-16) var(--space-12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.signin-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 48px;
  font-weight: 600;
  color: #0f0f0f;
  margin: 0 0 var(--space-3) 0;
  letter-spacing: -0.02em;
}

.signin-subtitle {
  font-size: 18px;
  color: #666;
  margin: 0 0 var(--space-12) 0;
  font-weight: 400;
}

.signin-features {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-12);
  padding: 0 var(--space-6);
}

.feature {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-align: left;
}

.feature-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.feature-text {
  font-size: 15px;
  color: #333;
  font-weight: 500;
}

/* Auth Mode Toggle */
.auth-mode-toggle {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-6) 0 var(--space-5) 0;
  padding: 4px;
  background: #f5f5f5;
  border-radius: 10px;
}

.auth-tab {
  flex: 1;
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.auth-tab.active {
  background: white;
  color: #333;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.auth-tab:hover:not(.active) {
  color: #333;
}

/* Email Auth Form */
.email-auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.form-group {
  width: 100%;
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  background: white;
  border: 1.5px solid #e5e5e5;
  border-radius: 10px;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  color: #333;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.auth-input:focus {
  outline: none;
  border-color: #999;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.auth-input::placeholder {
  color: #999;
}

.auth-submit-btn {
  width: 100%;
  padding: 14px;
  background: #333;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  margin-top: var(--space-2);
}

.auth-submit-btn:hover {
  background: #1a1a1a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.auth-submit-btn:active {
  transform: scale(0.98);
}

/* Auth Divider */
.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: var(--space-5) 0;
  color: #999;
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #e5e5e5;
}

.auth-divider span {
  padding: 0 var(--space-3);
}

.google-signin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: 14px var(--space-6);
  background: white;
  border: 2px solid #ebebeb;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.google-signin-btn:hover {
  background: #f8f8f8;
  border-color: #d4d4d4;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.google-signin-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.google-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.signin-terms {
  margin-top: var(--space-8);
  font-size: 13px;
  color: #999;
  line-height: 1.6;
}

.signin-terms a {
  color: #0f0f0f;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.signin-terms a:hover {
  border-bottom-color: #0f0f0f;
}

/* =============================================================================
   LIBRARY FOOTER
   ============================================================================= */

.library-footer {
  padding: var(--space-8) var(--space-12);
  border-top: 1px solid #ebebeb;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-top: auto;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}

.footer-link {
  color: #666;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  cursor: pointer;
}

.footer-link:hover {
  color: #0f0f0f;
  text-decoration: underline;
}

.footer-separator {
  color: #d4d4d4;
  font-weight: 300;
}

.footer-text {
  color: #999;
  font-weight: 400;
}

/* Legal Modal */
.legal-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 35, 50, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  animation: fadeIn 0.2s ease;
}

.legal-content {
  background: var(--cream);
  border: 2px solid var(--burgundy);
  border-radius: 12px;
  padding: var(--space-8);
  max-width: 700px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

.legal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--cream-dark);
  margin-bottom: var(--space-6);
}

.legal-header h2 {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy-dark);
  margin: 0;
}

.legal-close-btn {
  width: 36px;
  height: 36px;
  background: var(--cream-dark);
  border: 2px solid var(--gray-light);
  color: var(--brown-medium);
  font-size: 20px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.legal-close-btn:hover {
  background: var(--burgundy);
  border-color: var(--burgundy);
  color: var(--cream);
}

.legal-body {
  color: var(--brown-dark);
  line-height: 1.7;
  font-size: 15px;
}

.legal-body h3 {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--navy-dark);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.legal-body h4 {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--brown-dark);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.legal-body p {
  margin-bottom: var(--space-4);
  color: var(--brown-dark);
  line-height: 1.7;
}

.legal-body ul {
  margin: var(--space-3) 0 var(--space-4) var(--space-6);
  padding: 0;
}

.legal-body li {
  margin-bottom: var(--space-2);
  color: var(--brown-dark);
  line-height: 1.6;
}

.legal-body a {
  color: var(--burgundy);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.legal-body a:hover {
  border-bottom-color: var(--burgundy);
}

.legal-updated {
  font-size: 13px;
  color: var(--gray-medium);
  font-style: italic;
  margin-bottom: var(--space-4);
}

.legal-email {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  background: var(--cream-dark);
  padding: var(--space-2) var(--space-3);
  border-radius: 4px;
  display: inline-block;
  margin: var(--space-2) 0;
}

.legal-contact {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--cream-dark);
  font-size: 14px;
  color: var(--brown-medium);
}

/* Scrollbar for legal modal */
.legal-content::-webkit-scrollbar {
  width: 8px;
}

.legal-content::-webkit-scrollbar-track {
  background: var(--cream-dark);
  border-radius: 4px;
}

.legal-content::-webkit-scrollbar-thumb {
  background: var(--burgundy);
  border-radius: 4px;
}

.legal-content::-webkit-scrollbar-thumb:hover {
  background: var(--burgundy-light);
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

.hidden {
  display: none !important;
}

