/* =============================================
   ReadBook - Premium Reading Platform
   Main Stylesheet
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

/* ---- CSS Variables ---- */
:root {
  --primary: #FF6F61;
  --primary-dark: #e55a4d;
  --primary-light: #fff0ee;
  --secondary: #2D2D2D;
  --accent: #FFB347;
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface2: #F3F3F3;
  --border: #E5E5E5;
  --text: #1A1A1A;
  --text-muted: #888888;
  --text-light: #B0B0B0;
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #F44336;
  --info: #2196F3;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --font: 'Poppins', sans-serif;
  --font-reader: 'Lora', serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 280px;
  --header-height: 60px;
}

/* Dark mode */
[data-theme="dark"] {
  --bg: #121212;
  --surface: #1E1E1E;
  --surface2: #2A2A2A;
  --border: #333333;
  --text: #F0F0F0;
  --text-muted: #AAAAAA;
  --text-light: #666666;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

/* Sepia mode */
[data-theme="sepia"] {
  --bg: #F5EDD6;
  --surface: #FBF4E3;
  --surface2: #EFE4C8;
  --border: #D9C9A8;
  --text: #3D2B1F;
  --text-muted: #7A6550;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: var(--font); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ---- Typography ---- */
h1,h2,h3,h4,h5,h6 { font-weight: 700; line-height: 1.3; color: var(--text); }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.4rem); }
p { color: var(--text-muted); line-height: 1.7; }

/* ---- Layout ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.page { min-height: calc(100vh - var(--header-height)); padding-top: var(--header-height); }

/* ---- Header / Navbar ---- */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.navbar .container {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 1200px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary) !important;
  text-decoration: none;
}

.navbar-brand i { font-size: 1.5rem; }

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  list-style: none;
}

.navbar-nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
}

.navbar-nav a:hover,
.navbar-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-search {
  flex: 1;
  max-width: 320px;
  position: relative;
}

.nav-search input {
  width: 100%;
  padding: 8px 16px 8px 38px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.nav-search input:focus { border-color: var(--primary); background: var(--surface); }
.nav-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.85rem;
}

/* ---- Hamburger ---- */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
  background: none;
  border: none;
}
.hamburger span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: var(--transition); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255,111,97,0.4); }

.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-dark { background: var(--secondary); color: #fff; }
.btn-dark:hover { background: #444; color: #fff; }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; border-radius: 6px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-full { width: 100%; }

.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 50%; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---- Story Card ---- */
.story-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.story-card .cover {
  position: relative;
  aspect-ratio: 2/3;
  overflow: hidden;
  background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
}

.story-card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.story-card:hover .cover img { transform: scale(1.05); }

.story-card .cover .badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-premium { background: var(--accent); color: #1A1A1A; }
.badge-free { background: var(--success); color: #fff; }
.badge-new { background: var(--info); color: #fff; }

.story-card .info { padding: 12px 10px; }
.story-card .info h4 { font-size: 0.92rem; font-weight: 600; margin-bottom: 4px; line-height: 1.4; }
.story-card .info .author { font-size: 0.78rem; color: var(--text-muted); }
.story-card .info .meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 0.75rem; color: var(--text-light); }
.story-card .info .meta i { color: var(--primary); }

/* ---- Stories Grid ---- */
.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
  margin: 20px 0;
}

@media (min-width: 768px) {
  .stories-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ---- Hero Section ---- */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 60px 0;
  text-align: center;
}

.hero h1 { color: #fff; margin-bottom: 16px; }
.hero p { color: rgba(255,255,255,0.85); font-size: 1.1rem; max-width: 600px; margin: 0 auto 28px; }

/* ---- Section ---- */
.section { padding: 48px 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.section-title { font-size: 1.3rem; font-weight: 700; }

/* ---- Search & Filter ---- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.filter-chip {
  padding: 6px 16px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
  transition: var(--transition);
}

.filter-chip:hover, .filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---- Upload Area ---- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--surface2);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-zone i { font-size: 2.5rem; color: var(--primary); margin-bottom: 16px; }
.upload-zone p { color: var(--text-muted); }
.upload-zone .hint { font-size: 0.8rem; color: var(--text-light); margin-top: 8px; }

/* ---- Form ---- */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.88rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,111,97,0.12); }
.form-control.error { border-color: var(--danger); }

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }

/* ---- Progress Bar ---- */
.progress {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ---- Premium Overlay ---- */
.premium-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
  border-radius: var(--radius-sm);
}

.premium-overlay i { font-size: 2rem; color: var(--accent); }
.premium-overlay h4 { color: #fff; font-size: 1rem; }
.premium-overlay p { color: rgba(255,255,255,0.7); font-size: 0.8rem; text-align: center; }

/* ============================================
   READER PAGE
   ============================================ */
.reader-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* TOC Sidebar */
.toc-sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform var(--transition);
}

.toc-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toc-header h3 { font-size: 0.95rem; font-weight: 700; }

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.toc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  border-left: 3px solid transparent;
}

.toc-item:hover { background: var(--surface2); }
.toc-item.active { background: var(--primary-light); border-left-color: var(--primary); }
.toc-item.active .toc-chapter-title { color: var(--primary); font-weight: 600; }

.toc-chapter-num { font-size: 0.72rem; color: var(--text-light); min-width: 30px; font-weight: 600; }
.toc-chapter-title { font-size: 0.85rem; color: var(--text); flex: 1; line-height: 1.3; }
.toc-lock { font-size: 0.75rem; color: var(--accent); }

/* Reader Content Area */
.reader-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.reader-toolbar .story-info { flex: 1; min-width: 0; }
.reader-toolbar .story-info h4 { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-toolbar .story-info span { font-size: 0.75rem; color: var(--text-muted); }

.reader-settings { display: flex; align-items: center; gap: 8px; }

.reader-settings button {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}
.reader-settings button:hover { border-color: var(--primary); color: var(--primary); }
.reader-settings button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Book Reader Container */
.book-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: stretch;
}

/* Page slide wrapper */
.pages-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.reader-page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 40px clamp(20px, 6vw, 80px);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  will-change: transform;
}

.reader-page.slide-in-right {
  transform: translateX(100%);
  opacity: 0;
}

.reader-page.slide-in-left {
  transform: translateX(-100%);
  opacity: 0;
}

.reader-page.active {
  transform: translateX(0);
  opacity: 1;
}

.reader-page.slide-out-right {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.reader-page.slide-out-left {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

/* Chapter Content */
.chapter-heading {
  text-align: center;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.chapter-heading .chapter-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.chapter-heading h2 {
  font-family: var(--font-reader);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 600;
  color: var(--text);
}

.chapter-content {
  font-family: var(--font-reader);
  font-size: 1.05rem;
  line-height: 1.95;
  color: var(--text);
  max-width: 680px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
}

.chapter-content p { margin-bottom: 1.4em; }

/* Font size controls */
[data-fontsize="small"] .chapter-content { font-size: 0.92rem; }
[data-fontsize="medium"] .chapter-content { font-size: 1.05rem; }
[data-fontsize="large"] .chapter-content { font-size: 1.2rem; }
[data-fontsize="xlarge"] .chapter-content { font-size: 1.38rem; }

[data-linespacing="tight"] .chapter-content { line-height: 1.6; }
[data-linespacing="normal"] .chapter-content { line-height: 1.95; }
[data-linespacing="loose"] .chapter-content { line-height: 2.3; }

/* Nav arrows */
.page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.page-nav .chapter-progress {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Nav button in book (sides) */
.book-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  z-index: 10;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.book-nav-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.book-nav-btn.prev { left: 16px; }
.book-nav-btn.next { right: 16px; }

/* Mobile TOC toggle */
.toc-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
}

/* ---- Settings Panel ---- */
.settings-panel {
  position: absolute;
  top: 60px; right: 16px;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  z-index: 200;
  display: none;
}

.settings-panel.open { display: block; }
.settings-panel h5 { font-size: 0.85rem; font-weight: 700; margin-bottom: 12px; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.settings-row label { font-size: 0.82rem; color: var(--text-muted); }

.theme-btns, .size-btns {
  display: flex;
  gap: 4px;
}

.theme-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.theme-btn.active { border-color: var(--primary); transform: scale(1.15); }
.theme-btn.light { background: #FAFAFA; }
.theme-btn.dark { background: #1E1E1E; }
.theme-btn.sepia { background: #F5EDD6; }

.size-btn {
  padding: 3px 8px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  background: var(--surface2);
  color: var(--text-muted);
  transition: var(--transition);
}
.size-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Author Dashboard ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

/* ---- Profile ---- */
.author-profile-header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}

.author-avatar {
  width: 90px; height: 90px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
  border: 3px solid var(--primary);
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  min-width: 260px;
  max-width: 360px;
  animation: slideInToast 0.3s ease;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0); }

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

/* ---- Loading ---- */
.loading-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- Auth Pages ---- */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo span {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
}

.divider {
  text-align: center;
  position: relative;
  margin: 20px 0;
  color: var(--text-light);
  font-size: 0.82rem;
}

.divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--border);
}

.divider span {
  position: relative;
  background: var(--surface);
  padding: 0 10px;
}

/* ---- Subscribe Page ---- */
.pricing-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.pricing-card.featured {
  border-color: var(--primary);
}

.pricing-card.featured::before {
  content: 'BEST VALUE';
  position: absolute;
  top: 16px; right: -28px;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 36px;
  transform: rotate(45deg);
}

.pricing-price {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin: 16px 0 4px;
}

.pricing-price sup { font-size: 1.2rem; vertical-align: top; margin-top: 8px; }
.pricing-price sub { font-size: 0.9rem; color: var(--text-muted); }

.pricing-features {
  list-style: none;
  margin: 20px 0 24px;
  text-align: left;
}

.pricing-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.pricing-features li:last-child { border: none; }
.pricing-features li i { color: var(--success); }

/* ---- Footer ---- */
.footer {
  background: var(--secondary);
  color: rgba(255,255,255,0.7);
  padding: 40px 0 20px;
  margin-top: 60px;
}

.footer h4 { color: #fff; font-size: 0.95rem; margin-bottom: 12px; }
.footer a { color: rgba(255,255,255,0.6); font-size: 0.85rem; display: block; margin-bottom: 6px; }
.footer a:hover { color: var(--primary); }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 28px; margin-bottom: 32px; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 20px; text-align: center; font-size: 0.8rem; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---- Toggle switch ---- */
.toggle {
  position: relative;
  width: 42px; height: 24px;
  display: inline-block;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  left: 3px; top: 3px;
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th { padding: 10px 14px; text-align: left; font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 2px solid var(--border); background: var(--surface2); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.table tr:hover td { background: var(--surface2); }

/* ---- Chips / Tags ---- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.chip-primary { background: var(--primary-light); color: var(--primary); }
.chip-accent { background: rgba(255,179,71,0.15); color: var(--accent); }
.chip-success { background: rgba(76,175,80,0.12); color: var(--success); }
.chip-danger { background: rgba(244,67,54,0.12); color: var(--danger); }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 4px; justify-content: center; margin: 28px 0; }
.page-btn { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; border: 1.5px solid var(--border); font-size: 0.85rem; cursor: pointer; background: var(--surface); color: var(--text-muted); transition: var(--transition); }
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- PWA Install Banner ---- */
.pwa-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--secondary);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 999;
  transform: translateY(100%);
  transition: transform 0.4s ease;
}
.pwa-banner.show { transform: translateY(0); }
.pwa-banner p { flex: 1; font-size: 0.88rem; }
.pwa-banner .close-pwa { background: none; border: none; color: rgba(255,255,255,0.6); cursor: pointer; padding: 4px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  :root { --sidebar-width: 100%; }

  .hamburger { display: flex; }

  .nav-search { display: none; }

  .navbar-nav {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0;
    background: var(--surface);
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    transform: translateY(-120%);
    opacity: 0;
    transition: var(--transition);
    z-index: 999;
  }

  .navbar-nav.open { transform: translateY(0); opacity: 1; }
  .navbar-nav a { padding: 10px 16px; border-radius: 8px; }

  /* Reader mobile */
  .toc-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0; bottom: 0;
    z-index: 500;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .toc-sidebar.open { transform: translateX(0); }
  .toc-toggle { display: flex; }

  .book-nav-btn { display: none; }

  .reader-page { padding: 24px 16px; }

  .auth-card { padding: 28px 20px; }

  .stories-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }

  .author-profile-header { flex-direction: column; align-items: center; text-align: center; }

  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Utility ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.overflow-hidden { overflow: hidden; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius); }
