/* ========================================================
   WEBTEXT STORY - Modern Web Novel Stylesheet
   Theme: Clean White with Deep Crimson / Wine Red Gradient
   Professional Vector Iconography & Responsive Layout
   ======================================================== */

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

:root {
  /* Colors - Light Theme (Crisp Clean White + Deep Crimson Red) */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.94);
  --bg-secondary: #f1f5f9;
  --bg-accent: #fff1f2;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-focus: #e11d48;
  
  /* Deep Crimson / Wine Red Palette */
  --primary: #be123c;
  --primary-hover: #9f1239;
  --primary-dark: #881337;
  --primary-light: #ffe4e6;
  --primary-text: #9f1239;
  
  --gradient-crimson: linear-gradient(135deg, #881337 0%, #be123c 50%, #e11d48 100%);
  --gradient-crimson-hover: linear-gradient(135deg, #700f2b 0%, #9f1239 50%, #be123c 100%);
  --gradient-dark: linear-gradient(135deg, #1e1b4b 0%, #31102f 50%, #881337 100%);
  
  --accent: #e11d48;
  --accent-hover: #be123c;
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(136, 19, 55, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(136, 19, 55, 0.18), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-heading: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-reading: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-main: #0b0f19;
  --bg-card: #151c2e;
  --bg-header: rgba(21, 28, 46, 0.94);
  --bg-secondary: #1e293b;
  --bg-accent: #2c0e18;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  
  --border-color: #27354a;
  --border-focus: #f43f5e;
  
  --primary: #f43f5e;
  --primary-hover: #e11d48;
  --primary-light: #4c0519;
  --primary-text: #fecdd3;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ========================================================
   Header & Navigation
   ======================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-header);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 1.25rem;
}

.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--gradient-crimson);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.logo-badge-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--gradient-crimson);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  -webkit-text-fill-color: #ffffff;
  box-shadow: 0 3px 8px rgba(190, 18, 60, 0.35);
}

/* Main Navigation Links (Desktop) */
.nav-main-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-main-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-main);
  transition: var(--transition);
  white-space: nowrap;
}

.nav-main-link i {
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.nav-main-link:hover {
  background-color: var(--bg-secondary);
  color: var(--primary);
}

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

.nav-main-link.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-main-link.active i {
  color: var(--primary);
}

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

.nav-search input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.4rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  outline: none;
  font-size: 0.88rem;
  transition: var(--transition);
}

.nav-search input:focus {
  border-color: var(--primary);
  background-color: var(--bg-card);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.nav-search .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.85rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.guest-nav-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* User Menu Dropdown */
.user-menu {
  position: relative;
}

.user-avatar-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  padding: 0.25rem 0.75rem 0.25rem 0.3rem;
  border-radius: var(--radius-full);
  transition: var(--transition);
}

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

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--primary);
}

.user-name-text {
  font-weight: 600;
  font-size: 0.88rem;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 260px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 0.6rem;
  display: none;
  flex-direction: column;
  z-index: 9999;
  animation: fadeIn 0.15s ease-out;
}

.user-dropdown.show {
  display: flex !important;
}

.user-dropdown-header {
  padding: 0.75rem 0.85rem;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}

.user-dropdown-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.user-dropdown-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 0.4rem 0;
}

.user-dropdown-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: var(--text-light);
  padding: 0.35rem 0.75rem 0.15rem;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  color: var(--text-main);
  transition: var(--transition);
  font-weight: 500;
}

.dropdown-item i {
  font-size: 0.95rem;
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.dropdown-item:hover {
  background-color: var(--bg-secondary);
  color: var(--primary);
}

.dropdown-item:hover i {
  color: var(--primary);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger i {
  color: var(--danger);
}

.dropdown-item.danger:hover {
  background-color: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

/* Mobile Menu Toggle */
.mobile-toggle {
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 38px;
  height: 38px;
  font-size: 1.15rem;
  color: var(--text-main);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.mobile-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Mobile Dropdown Menu Drawer */
.mobile-menu {
  display: none;
  position: absolute;
  top: 68px;
  left: 0;
  width: 100%;
  max-height: calc(100vh - 68px);
  overflow-y: auto;
  background-color: var(--bg-card);
  border-bottom: 2px solid var(--primary);
  padding: 1.25rem;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
  z-index: 120;
  animation: fadeIn 0.2s ease-out;
}

.mobile-menu.show {
  display: flex !important;
}

.mobile-user-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}

.mobile-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--primary);
}

.mobile-menu-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.5px;
  padding: 0.5rem 0.5rem 0.2rem;
}

/* ========================================================
   Buttons & Badges
   ======================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  font-weight: 500;
  font-size: 0.92rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn i {
  font-size: 0.95em;
}

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.75rem 1.6rem;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}

.btn-primary {
  background: var(--gradient-crimson);
  color: #ffffff;
  border: none;
}

.btn-primary:hover {
  background: var(--gradient-crimson-hover);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(190, 18, 60, 0.4);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-outline {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-accent {
  background: var(--gradient-crimson);
  color: #ffffff;
  border: none;
}

.btn-accent:hover {
  background: var(--gradient-crimson-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(190, 18, 60, 0.4);
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1;
}

.badge-primary {
  background-color: var(--primary-light);
  color: var(--primary-text);
}

.badge-ai {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge-free {
  background-color: #d1fae5;
  color: #065f46;
}

.badge-locked {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-gray {
  background-color: var(--bg-secondary);
  color: var(--text-muted);
}

/* ========================================================
   Hero Banner - Deep Crimson Red Gradient
   ======================================================== */
.hero-section {
  padding: 2rem 0 1.25rem;
  position: relative;
}

.hero-banner {
  background: var(--gradient-crimson);
  border-radius: var(--radius-lg);
  padding: 3.25rem 2.5rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
}

.hero-banner::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%);
  top: -120px;
  right: -80px;
  border-radius: 50%;
}

.hero-content {
  max-width: 650px;
  position: relative;
  z-index: 2;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: 2.35rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 0.85rem;
  letter-spacing: -0.5px;
}

.hero-desc {
  font-size: 1.05rem;
  opacity: 0.92;
  margin-bottom: 1.75rem;
  line-height: 1.65;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-btn-white {
  background-color: #ffffff;
  color: #be123c;
  font-weight: 700;
}

.hero-btn-white:hover {
  background-color: #f8fafc;
  color: #881337;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.hero-btn-transparent {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  font-weight: 600;
}

.hero-btn-transparent:hover {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

/* ========================================================
   Categories Bar
   ======================================================== */
.categories-bar {
  padding: 1rem 0;
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 0.5rem;
}

.categories-bar::-webkit-scrollbar {
  height: 4px;
}

.categories-bar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.05rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-muted);
  transition: var(--transition);
}

.cat-pill i {
  font-size: 0.95rem;
  color: var(--primary);
}

.cat-pill:hover, .cat-pill.active {
  background: var(--gradient-crimson);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(190, 18, 60, 0.25);
}

.cat-pill:hover i, .cat-pill.active i {
  color: #ffffff;
}

/* ========================================================
   Story Cards Grid
   ======================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2rem 0 1.25rem;
}

.section-title {
  font-size: 1.45rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-title i {
  color: var(--primary);
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.story-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: relative;
}

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

.story-card-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background-color: var(--bg-secondary);
}

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

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

.story-card-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2;
}

.story-card-views {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.story-card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.story-card-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.8em;
}

.story-card:hover .story-card-title {
  color: var(--primary);
}

.story-card-author {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.story-card-author i {
  color: var(--primary);
  font-size: 0.85rem;
}

.story-card-footer {
  margin-top: auto;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.story-card-footer i {
  color: var(--primary);
}

/* ========================================================
   Story Detail Page
   ======================================================== */
.story-detail-header {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 2.25rem;
  margin: 2rem 0;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2rem;
  box-shadow: var(--shadow-sm);
}

.story-detail-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.story-detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-detail-info {
  display: flex;
  flex-direction: column;
}

.story-detail-title {
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.story-meta-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.story-stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1.25rem;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  width: fit-content;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-item .stat-value {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-item .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.story-description {
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.75;
  margin-bottom: 1.5rem;
  white-space: pre-line;
}

.story-action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: auto;
}

/* Chapter List */
.chapter-list-container {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 1.75rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-sm);
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.2rem;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: var(--transition);
}

.chapter-item:hover {
  border-color: var(--border-focus);
  background-color: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.chapter-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chapter-num {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
  min-width: 65px;
}

.chapter-title {
  font-weight: 500;
}

.chapter-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ========================================================
   Comments Section
   ======================================================== */
.comments-container {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 1.75rem;
  margin-bottom: 3rem;
  box-shadow: var(--shadow-sm);
}

.comment-card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--border-color);
}

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

.comment-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.comment-user img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.comment-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.comment-content {
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-line;
}

/* ========================================================
   Reader Screen
   ======================================================== */
.reader-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s, color 0.2s;
}

.reader-theme-light {
  background-color: #ffffff !important;
  color: #1e293b !important;
}

.reader-theme-sepia {
  background-color: #fbf0d9 !important;
  color: #5f4b32 !important;
}

.reader-theme-dark {
  background-color: #1e1e24 !important;
  color: #e4e4e7 !important;
}

.reader-theme-black {
  background-color: #09090b !important;
  color: #d4d4d8 !important;
}

.reader-header {
  position: sticky;
  top: 0;
  z-index: 90;
  border-bottom: 1px solid rgba(150, 150, 150, 0.25);
  background-color: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: var(--transition);
}

.reader-story-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.reader-font-group {
  display: flex;
  align-items: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
}

.reader-font-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.reader-font-btn:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.reader-theme-group {
  display: flex;
  align-items: center;
  gap: 5px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px 5px;
}

.reader-theme-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.reader-theme-btn:hover {
  transform: scale(1.15);
}

.reader-theme-btn.active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary-light);
  transform: scale(1.12);
}

.reader-container {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
  flex: 1;
}

.reader-chapter-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
}

.reader-chapter-meta {
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.75;
  margin-bottom: 2.5rem;
}

.reader-content {
  font-family: var(--font-reading);
  font-size: 19px;
  line-height: 1.95;
  white-space: pre-line;
  word-break: break-word;
  text-align: justify;
}

.reader-content p {
  margin-bottom: 1.5em;
  text-indent: 1.5em;
}

.reader-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(150, 150, 150, 0.2);
}

/* Lock Screen Box */
.lock-screen-box {
  background: linear-gradient(145deg, var(--bg-card), var(--bg-secondary));
  border: 2px dashed var(--primary);
  border-radius: var(--radius-lg);
  padding: 3.5rem 2rem;
  text-align: center;
  max-width: 580px;
  margin: 3rem auto;
  box-shadow: var(--shadow-xl);
}

.lock-icon-circle {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--gradient-crimson);
  color: #ffffff;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  box-shadow: 0 10px 20px rgba(190, 18, 60, 0.35);
}

.lock-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.lock-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.lock-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ========================================================
   Forms, Auth & Writer Dashboard
   ======================================================== */
.auth-wrapper {
  max-width: 440px;
  margin: 3rem auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-icon-badge {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-crimson);
  color: #ffffff;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 6px 14px rgba(190, 18, 60, 0.3);
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

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

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-main);
  outline: none;
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
  background-color: var(--bg-card);
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.form-editor-textarea {
  min-height: 400px;
  font-family: var(--font-reading);
  font-size: 17px;
  line-height: 1.8;
  padding: 1.25rem;
}

.form-help {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Image Upload Preview */
.cover-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  background-color: var(--bg-secondary);
  transition: var(--transition);
  position: relative;
}

.cover-upload-area:hover {
  border-color: var(--primary);
  background-color: var(--bg-accent);
}

.cover-preview-img {
  max-width: 160px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin: 0 auto 0.75rem;
  display: none;
  box-shadow: var(--shadow-md);
}

/* Dashboard Table */
.dashboard-table-container {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  margin-top: 1.5rem;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.dashboard-table th {
  background-color: var(--bg-secondary);
  padding: 0.9rem 1.2rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.dashboard-table td {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.dashboard-table tr:last-child td {
  border-bottom: none;
}

.dashboard-table tr:hover td {
  background-color: var(--bg-secondary);
}

/* Alert Boxes */
.alert {
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.alert-success {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-danger {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-info {
  background-color: #ffe4e6;
  color: #9f1239;
  border: 1px solid #fecdd3;
}

/* ========================================================
   Footer
   ======================================================== */
.site-footer {
  margin-top: auto;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 0 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.footer-copyright {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
}

/* ========================================================
   AI Toggle & Custom Checkbox
   ======================================================== */
.ai-toggle-card {
  background-color: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  transition: var(--transition);
}

.ai-toggle-card:hover {
  border-color: #6366f1;
  background-color: rgba(99, 102, 241, 0.04);
}

.custom-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  cursor: pointer;
  margin-bottom: 0;
  user-select: none;
}

.custom-checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.custom-checkbox-box {
  width: 22px;
  height: 22px;
  min-width: 22px;
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: var(--transition);
  font-size: 0.75rem;
  margin-top: 2px;
}

.custom-checkbox-label input[type="checkbox"]:checked ~ .custom-checkbox-box {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-color: #4f46e5;
  color: #ffffff;
}

/* ========================================================
   Writing Editor Large Canvas & Toolbar
   ======================================================== */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 0.6rem 0.85rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.editor-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.editor-tool-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition);
}

.editor-tool-btn:hover {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.form-editor-textarea {
  min-height: 550px !important;
  font-size: 1.05rem !important;
  line-height: 1.85 !important;
  font-family: 'Sarabun', -apple-system, sans-serif !important;
  border-radius: 0 0 var(--radius-md) var(--radius-md) !important;
  padding: 1.25rem !important;
  resize: vertical;
}

.form-editor-textarea.zen-mode {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  z-index: 99999;
  border-radius: 0 !important;
  padding: 3.5rem 12% !important;
  background-color: var(--bg-main) !important;
  color: var(--text-main) !important;
  box-shadow: none !important;
}

/* ========================================================
   Social Share Bar
   ======================================================== */
.social-share-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding: 0.85rem 1.25rem;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.social-share-title {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-main);
  margin-right: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  color: #ffffff !important;
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
}

.share-btn-facebook, .share-btn-fb { background-color: #1877f2; }
.share-btn-facebook:hover, .share-btn-fb:hover { background-color: #1465cc; transform: translateY(-1px); }

.share-btn-twitter, .share-btn-tw { background-color: #000000; }
.share-btn-twitter:hover, .share-btn-tw:hover { background-color: #27272a; transform: translateY(-1px); }

.share-btn-line { background-color: #06c755; }
.share-btn-line:hover { background-color: #05a847; transform: translateY(-1px); }

.share-btn-copy {
  background-color: var(--bg-card);
  color: var(--text-main) !important;
  border: 1px solid var(--border-color);
}
.share-btn-copy:hover {
  background-color: var(--primary);
  color: #ffffff !important;
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================================
   Responsive Media Queries
   ======================================================== */
@media (max-width: 992px) {
  .nav-main-links {
    display: none !important;
  }

  .hide-tablet {
    display: none !important;
  }

  .story-detail-header {
    grid-template-columns: 180px 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .navbar {
    height: 60px;
  }
  
  .nav-search {
    display: none;
  }
  
  .mobile-toggle {
    display: flex;
  }
  
  .hero-banner {
    padding: 2.25rem 1.5rem;
    flex-direction: column;
    text-align: center;
  }
  
  .hero-title {
    font-size: 1.85rem;
  }
  
  .hero-buttons {
    justify-content: center;
  }
  
  .story-detail-header {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .story-detail-cover {
    max-width: 200px;
    margin: 0 auto;
  }
  
  .story-meta-row, .story-stats, .story-action-buttons {
    justify-content: center;
    margin-left: auto;
    margin-right: auto;
  }
  
  .reader-header {
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    gap: 0.4rem;
  }

  .reader-story-title {
    max-width: 180px;
    font-size: 0.88rem;
  }

  .reader-toolbar {
    width: 100%;
    justify-content: space-between;
    gap: 0.35rem;
  }

  #chapter-select {
    max-width: 130px !important;
    font-size: 0.8rem !important;
  }
  
  .reader-container {
    padding: 1.5rem 1rem 4rem;
  }
  
  .reader-content {
    font-size: 17px;
  }
}
