/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f0d1b;
  --bg-secondary: #1a1625;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #e8e4f0;
  --text-secondary: #9b93ab;
  --text-muted: #6b6478;
  --accent: #8b5cf6;
  --accent-light: #a78bfa;
  --accent-glow: rgba(139, 92, 246, 0.25);
  --gradient-accent: linear-gradient(135deg, #8b5cf6, #6366f1);
  --gradient-bg: linear-gradient(160deg, #0f0d1b 0%, #1a1625 40%, #1e1533 100%);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px var(--accent-glow);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--gradient-bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: #c4b5fd;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== NAVBAR ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 13, 27, 0.75);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-glass);
}

.navbar {
  padding: 0;
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.nav-logo:hover {
  color: var(--text-primary);
}

.logo-icon {
  font-size: 1.6rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo-text {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-menu {
  display: flex;
  gap: 28px;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color var(--transition);
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gradient-accent);
  border-radius: 1px;
  transition: width var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link:hover::after {
  width: 100%;
}

/* ===== HERO SECTION ===== */
.hero-section {
  padding: 3rem 0 1.5rem;
  text-align: center;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #e8e4f0, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 400;
  margin-bottom: 2rem;
}

/* ===== SEARCH ===== */
.search-section {
  margin-bottom: 1rem;
}

.search-container {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  max-width: 700px;
  margin: 0 auto;
}

.search-input {
  flex: 1;
  min-width: 240px;
  padding: 14px 20px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: all var(--transition);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-sm);
}

.search-btn,
.show-all-btn {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.search-btn {
  background: var(--gradient-accent);
  color: white;
  box-shadow: var(--shadow-sm);
}

.search-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow), var(--shadow-md);
}

.show-all-btn {
  background: var(--bg-glass);
  color: var(--accent-light);
  border: 1px solid var(--accent);
}

.show-all-btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

/* ===== NOVELS GRID ===== */
.novels-section {
  padding: 2rem 0 4rem;
}

.novels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 2rem;
}

/* ===== NOVEL CARDS ===== */
.novel-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}

.novel-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(139, 92, 246, 0.2);
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(139, 92, 246, 0.08);
}

.novel-card-header {
  margin-bottom: 0.75rem;
}

.novel-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.novel-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.novel-title a:hover {
  color: var(--accent-light);
}

.novel-author {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.novel-genre {
  margin-bottom: 0.75rem;
}

.genre-tag {
  display: inline-block;
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-light);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.novel-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-meta {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.novel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn-primary,
.btn-secondary {
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  text-decoration: none;
  display: inline-block;
  flex: 1;
  min-width: 100px;
}

.btn-primary {
  background: var(--gradient-accent);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow), var(--shadow-md);
  color: white;
}

.btn-secondary {
  background: transparent;
  color: var(--accent-light);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.btn-secondary:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--accent);
  color: var(--accent-light);
  transform: translateY(-2px);
}

/* ===== LOADING & EMPTY STATES ===== */
.loading-spinner {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-glass);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.3rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.error-state .btn-primary {
  margin-top: 1rem;
  display: inline-block;
  flex: none;
}

/* ===== NOVEL DETAIL PAGE ===== */
.novel-detail-page {
  padding: 2rem 0 4rem;
}

.novel-header {
  padding: 2rem 0;
}

.novel-header-content {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.cover-placeholder-large {
  width: 180px;
  height: 250px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  flex-shrink: 0;
}

.novel-info-large {
  flex: 1;
}

.novel-title-large {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.novel-author-large {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.genre-tag-large {
  display: inline-block;
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-light);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(139, 92, 246, 0.2);
  margin-right: 8px;
}

.status-badge-large {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.novel-description-large {
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 1rem 0;
}

.novel-stats-large {
  display: flex;
  gap: 2rem;
  margin-top: 1.5rem;
}

.stat {
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-light);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== CHAPTERS SECTION ===== */
.chapters-section {
  padding: 2rem 0;
}

.chapters-container {
  max-width: 800px;
  margin: 0 auto;
}

.chapters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.chapters-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.chapter-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(139, 92, 246, 0.2);
  transform: translateX(4px);
}

.chapter-title {
  font-size: 1rem;
  font-weight: 600;
}

.chapter-title a {
  color: var(--text-primary);
}

.chapter-title a:hover {
  color: var(--accent-light);
}

.chapter-date {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.chapter-actions .btn-secondary.btn-small {
  padding: 8px 16px;
  font-size: 0.8rem;
  min-width: auto;
  flex: none;
}

.no-chapters {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

/* ===== NAVIGATION SECTION ===== */
.navigation-section {
  padding: 2rem 0;
}

.navigation-container {
  max-width: 800px;
  margin: 0 auto;
}

.btn-outline {
  display: inline-block;
  padding: 11px 20px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-light);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all var(--transition);
}

.btn-outline:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--accent);
  color: var(--accent-light);
}

/* ===== CHAPTER READING PAGE ===== */
.chapter-reading-page {
  padding: 1rem 0 4rem;
  max-width: 800px;
  margin: 0 auto;
}

.chapter-header {
  margin-bottom: 1.5rem;
}

.breadcrumb {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.breadcrumb a {
  color: var(--accent-light);
}

.chapter-title-main {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.chapter-subtitle {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.chapter-navigation {
  margin-bottom: 2rem;
}

.chapter-navigation .nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
}

.btn-nav {
  display: inline-block;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent-light);
  border: 1px solid rgba(139, 92, 246, 0.3);
  text-decoration: none;
  transition: all var(--transition);
}

.btn-nav:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--accent);
  color: var(--accent-light);
}

.chapter-selector label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-right: 8px;
}

.chapter-selector select {
  padding: 8px 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
}

.chapter-content-section {
  margin-bottom: 2rem;
}

.chapter-content {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.reading-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-glass);
  flex-wrap: wrap;
  gap: 1rem;
}

.font-controls,
.theme-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.font-controls label,
.theme-controls label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.font-controls button,
.theme-controls button {
  padding: 6px 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition);
}

.font-controls button:hover,
.theme-controls button:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

#font-size-display {
  color: var(--text-secondary);
  font-size: 0.85rem;
  min-width: 40px;
  text-align: center;
}

.chapter-text {
  font-size: 16px;
  line-height: 1.9;
  color: var(--text-primary);
}

.chapter-text p {
  margin-bottom: 1.2rem;
}

.chapter-text h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--accent-light);
}

.chapter-text blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.bottom-nav {
  margin-top: 2rem;
}

.chapter-progress {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.end-message {
  color: var(--accent-light);
  font-weight: 600;
}

/* ===== ERROR PAGE ===== */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.error-container {
  max-width: 500px;
  padding: 3rem;
}

.error-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}

.error-code {
  font-size: 5rem;
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.error-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.error-message {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.error-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.error-actions .btn-primary,
.error-actions .btn-secondary {
  flex: none;
  min-width: auto;
}

/* ===== FOOTER ===== */
.footer {
  border-top: 1px solid var(--border-glass);
  background: rgba(15, 13, 27, 0.5);
  padding: 2rem 0;
  margin-top: auto;
}

.footer-container {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-sub {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  opacity: 0.6;
}

/* ===== DARK THEME TOGGLE (for chapter reader) ===== */
body.dark-theme {
  /* already dark by default */
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .hero-title {
    font-size: 1.8rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .novels-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .search-container {
    flex-direction: column;
    width: 100%;
  }

  .search-input {
    width: 100%;
    min-width: auto;
  }

  .search-btn,
  .show-all-btn {
    width: 100%;
  }

  .novel-header-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .novel-stats-large {
    justify-content: center;
  }

  .chapter-navigation .nav-container {
    flex-direction: column;
    text-align: center;
  }

  .novel-actions {
    flex-direction: column;
  }

  .reading-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .chapter-reading-page {
    padding: 1rem 16px 4rem;
  }
}

@media (max-width: 480px) {
  .nav-menu {
    gap: 16px;
  }

  .nav-logo {
    font-size: 1.1rem;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .novel-card {
    padding: 1.25rem;
  }

  .error-code {
    font-size: 3.5rem;
  }
}