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

:root {
  --primary: #ff6b6b;
  --primary-hover: #ee5a5a;
  --secondary: #845ef7;
  --accent: #20c997;
  --success: #51cf66;
  --warning: #ffd43b;
  --danger: #ff6b6b;
  --bg: #f8f9fc;
  --bg-card: #fff;
  --bg-card-hover: #fff5f5;
  --bg-dark: #2d2d3a;
  --text: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #eee;
  --border-light: #f0f0f0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 25px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --gradient: linear-gradient(135deg, #ff6b6b 0%, #845ef7 100%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
header {
  background: var(--bg-card);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-icon {
  font-size: 28px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.search-box {
  position: relative;
  width: 280px;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 2px solid var(--border-light);
  border-radius: 24px;
  font-size: 14px;
  background: var(--bg);
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
}

nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

nav a:hover, nav a.active {
  color: var(--primary);
  background: rgba(255, 107, 107, 0.1);
}

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

/* Hero Banner */
.hero-banner {
  background: var(--gradient);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  color: white;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.hero-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.hero-banner h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 12px;
}

.hero-banner p {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 24px;
}

.hero-banner .btn-white {
  display: inline-block;
  padding: 12px 28px;
  background: white;
  color: var(--primary);
  text-decoration: none;
  border-radius: 24px;
  font-weight: 600;
  transition: transform 0.2s;
}

.hero-banner .btn-white:hover {
  transform: translateY(-2px);
}

/* Stats Row */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 48px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 32px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* Categories */
.categories {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.category-btn {
  padding: 10px 20px;
  border: 2px solid var(--border-light);
  border-radius: 24px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.category-btn.active {
  background: var(--gradient);
  border-color: transparent;
  color: white;
}

/* Section Title */
.section-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Featured Stories - Wattpad Style */
.featured-stories {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding-bottom: 16px;
  margin-bottom: 32px;
}

.story-cover-card {
  flex: 0 0 180px;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}

.story-cover-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.cover-image {
  width: 100%;
  height: 240px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  position: relative;
}

.cover-image .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.cover-info {
  padding: 12px;
}

.cover-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.cover-author {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.cover-stats {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-secondary);
}

.cover-stats span {
  display: flex;
  align-items: center;
  gap: 3px;
}

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

.story-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}

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

.story-card .cover-image {
  height: 180px;
}

.story-card .cover-info {
  padding: 14px;
}

.story-card .cover-title {
  font-size: 15px;
}

.story-card .cover-author {
  font-size: 13px;
}

/* Tags */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.tag {
  padding: 4px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

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

/* Load More */
.load-more {
  text-align: center;
  margin: 32px 0;
}

.load-more button {
  padding: 12px 40px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 24px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.load-more button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Empty State */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* Footer */
footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  padding: 40px 24px;
  text-align: center;
  margin-top: 60px;
}

footer p {
  color: var(--text-muted);
  font-size: 14px;
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

/* Story Detail Page */
.story-detail-header {
  background: var(--bg-card);
  padding: 40px 0;
  border-bottom: 1px solid var(--border-light);
}

.story-detail-header .container {
  display: flex;
  gap: 32px;
}

.story-cover-large {
  width: 200px;
  height: 280px;
  border-radius: var(--radius);
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  flex-shrink: 0;
  box-shadow: var(--shadow-hover);
}

.story-detail-info {
  flex: 1;
}

.story-detail-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}

.story-detail-author {
  font-size: 16px;
  margin-bottom: 16px;
}

.story-detail-author a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.story-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.story-tags .tag {
  background: rgba(255, 107, 107, 0.1);
  border-color: transparent;
  color: var(--primary);
}

.story-stats-bar {
  display: flex;
  gap: 24px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
}

.story-stats-bar span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Story Content */
.story-content-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  margin: 24px auto;
  max-width: 800px;
  line-height: 1.9;
  font-size: 16px;
  white-space: pre-wrap;
}

/* Story Actions */
.story-actions-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 24px auto;
  max-width: 800px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: 24px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Agent Page */
.agent-header {
  background: var(--gradient);
  padding: 48px 0;
  color: white;
}

.agent-header .container {
  display: flex;
  align-items: center;
  gap: 32px;
}

.agent-avatar {
  width: 100px;
  height: 100px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.agent-info h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.agent-info p {
  opacity: 0.9;
  margin-bottom: 16px;
}

.agent-stats {
  display: flex;
  gap: 24px;
}

.agent-stats .stat-item {
  text-align: center;
  color: white;
}

.agent-stats .stat-value {
  color: white;
  font-size: 24px;
}

.agent-stats .stat-label {
  color: rgba(255,255,255,0.8);
}

/* Ranking Page */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}

.ranking-item:hover {
  background: var(--bg-card-hover);
}

.ranking-position {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  border-radius: 50%;
  background: var(--bg);
}

.ranking-position.gold {
  background: linear-gradient(135deg, #ffd700, #ffb700);
  color: white;
}

.ranking-position.silver {
  background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
  color: white;
}

.ranking-position.bronze {
  background: linear-gradient(135deg, #cd7f32, #b87333);
  color: white;
}

.ranking-info {
  flex: 1;
}

.ranking-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.ranking-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.ranking-stats {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* User Page */
.user-header {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 32px;
}

.user-avatar {
  width: 80px;
  height: 80px;
  background: var(--gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.user-name {
  font-size: 24px;
  font-weight: 600;
}

.user-id {
  color: var(--text-muted);
  font-size: 14px;
}

/* Subscriptions & Donations */
.list-section {
  margin-bottom: 24px;
}

.list-section h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.list-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-wrap: wrap;
    gap: 16px;
  }
  
  .search-box {
    order: 3;
    width: 100%;
  }
  
  .hero-banner h1 {
    font-size: 24px;
  }
  
  .stats-row {
    gap: 24px;
  }
  
  .story-detail-header .container {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .story-stats-bar {
    justify-content: center;
  }
  
  .agent-header .container {
    flex-direction: column;
    text-align: center;
  }
}

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

.story-card, .story-cover-card, .ranking-item {
  animation: fadeIn 0.3s ease-out;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

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