/**
 * Truyện Dịch - Main Stylesheet
 * Converted from TailwindCSS to Vanilla CSS
 */

/* ================================================
   CSS Variables (Color Palette & Typography)
   ================================================ */
:root {
    /* Primary Colors */
    --primary: #137fec;
    --primary-hover: #0d6ecc;
    --primary-light: rgba(19, 127, 236, 0.1);
    --primary-shadow: rgba(19, 127, 236, 0.3);
    
    /* Light Theme */
    --bg-light: #f6f7f8;
    --surface-light: #ffffff;
    --border-light: #e5e7eb;
    --text-light: #111418;
    --text-secondary-light: #64748b;
    --text-muted-light: #94a3b8;
    
    /* Dark Theme */
    --bg-dark: #101922;
    --surface-dark: #1e293b;
    --border-dark: #283039;
    --text-dark: #ffffff;
    --text-secondary-dark: #94a3b8;
    --text-muted-dark: #64748b;
    
    /* Status Colors */
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    /* Typography */
    --font-display: 'Newsreader', Georgia, serif;
    --font-body: 'Noto Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-primary: 0 10px 15px -3px var(--primary-shadow);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
}

/* Dynamic theme variables */
body {
    --bg: var(--bg-light);
    --surface: var(--surface-light);
    --border: var(--border-light);
    --text: var(--text-light);
    --text-secondary: var(--text-secondary-light);
    --text-muted: var(--text-muted-light);
}

body.dark {
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --border: var(--border-dark);
    --text: var(--text-dark);
    --text-secondary: var(--text-secondary-dark);
    --text-muted: var(--text-muted-dark);
}

/* ================================================
   Base Styles
   ================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-display);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: var(--font-body);
    font-size: 0.875rem;
}

::selection {
    background: var(--primary);
    color: white;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--text-muted);
    border-radius: 20px;
}

body.dark ::-webkit-scrollbar-thumb {
    background-color: #374151;
}

/* ================================================
   Typography
   ================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.375rem; letter-spacing: -0.015em; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

.font-body {
    font-family: var(--font-body);
}

.text-primary { color: var(--primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }

.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }

.line-clamp-1 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.line-clamp-2 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.line-clamp-3 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ================================================
   Layout Components
   ================================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* Grid */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-12 { grid-template-columns: repeat(12, 1fr); }

@media (min-width: 640px) {
    .sm-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
    .md-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
    .lg-grid-cols-6 { grid-template-columns: repeat(6, 1fr); }
    .lg-grid-cols-12 { grid-template-columns: repeat(12, 1fr); }
}

/* ================================================
   Header / Navigation
   ================================================ */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
    transition: background-color var(--transition-normal);
}

@media (min-width: 1024px) {
    .header {
        padding: 0.75rem 2.5rem;
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}

.logo-icon {
    font-size: 1.875rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.nav-links {
    display: none;
    align-items: center;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .nav-links {
        display: flex;
    }
}

.nav-link {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.nav-link:hover {
    color: var(--primary);
}

/* Search Box */
.search-box {
    display: none;
    position: relative;
    min-width: 160px;
    max-width: 256px;
}

@media (min-width: 768px) {
    .search-box {
        display: flex;
    }
}

.search-box input {
    width: 100%;
    height: 40px;
    padding: 0 1rem 0 2.5rem;
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.25rem;
}

/* ================================================
   Buttons
   ================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: white;
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background-color: var(--bg);
    color: var(--text);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* ================================================
   Cards
   ================================================ */
.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-body {
    padding: var(--spacing-lg);
}

/* Story Card */
.story-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    cursor: pointer;
}

.story-card .cover {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

/* Top gradient overlay to hide watermarks */
.story-card .cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
    z-index: 1;
    pointer-events: none;
}

/* Bottom gradient overlay to hide watermarks */
.story-card .cover::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    z-index: 1;
    pointer-events: none;
}

.story-card .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.story-card:hover .cover img {
    transform: scale(1.05);
}

.story-card .badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 700;
    color: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.story-card .badge.hot { background-color: var(--danger); }
.story-card .badge.new { background-color: var(--primary); }
.story-card .badge.full { background-color: var(--success); }

.story-card .title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    transition: color var(--transition-fast);
}

.story-card:hover .title {
    color: var(--primary);
}

.story-card .author {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ================================================
   Section Headers
   ================================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.375rem;
    font-weight: 700;
}

.section-title .icon {
    font-size: 1.5rem;
}

.section-title .icon.fire { color: var(--danger); }
.section-title .icon.update { color: var(--primary); }
.section-title .icon.ranking { color: var(--warning); }

.view-all-link {
    font-size: 0.875rem;
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
    white-space: nowrap;
}

.view-all-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.section-link {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.section-link:hover {
    color: var(--primary);
}

/* ================================================
   Category Chips
   ================================================ */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.chip:hover, .chip.active {
    border-color: var(--primary);
    color: var(--primary);
    background-color: rgba(var(--primary-rgb), 0.1);
}

.chip.active {
    background-color: var(--primary);
    color: white;
}

/* ================================================
   Home Page Grid (Updates + Rankings)
   ================================================ */
.home-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.home-updates {
    width: 100%;
}

.home-rankings {
    width: 100%;
}

@media (min-width: 1024px) {
    .home-grid {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 2rem;
    }
}

/* ================================================
   Update Table
   ================================================ */
.update-table {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    width: 100%;
}

.update-table .header-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 80px;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background-color: var(--bg);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.update-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 80px;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-fast);
    align-items: center;
}

.update-row:last-child {
    border-bottom: none;
}

.update-row:hover {
    background-color: var(--bg);
}

.update-row > div {
    min-width: 0;
    overflow: hidden;
}

.update-row .story-name {
    display: block;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.875rem;
}

.update-row .story-name:hover {
    color: var(--primary);
}

.update-row .category-tag {
    display: none;
}

.update-row .chapter-link {
    display: block;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.update-row .chapter-link:hover {
    color: var(--primary);
}

.update-row .time {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Mobile: Stack vertically */
@media (max-width: 768px) {
    .update-table .header-row {
        display: none;
    }
    
    .update-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 0.25rem 0.75rem;
        padding: 0.625rem 1rem;
    }
    
    .update-row > div:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }
    
    .update-row > div:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 2;
    }
    
    .update-row > div:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
    }
    
    .update-row .story-name {
        font-size: 0.8125rem;
    }
    
    .update-row .chapter-link {
        font-size: 0.75rem;
        color: var(--text-muted);
    }
    
    .update-row .time {
        font-size: 0.7rem;
    }
}


/* ================================================
   Ranking Sidebar
   ================================================ */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.ranking-item:hover {
    background-color: var(--bg);
}

.ranking-item .rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.ranking-item .rank.gold { background-color: #ef4444; }
.ranking-item .rank.silver { background-color: #f97316; }
.ranking-item .rank.bronze { background-color: #eab308; }
.ranking-item .rank.default { 
    background-color: var(--bg);
    color: var(--text-secondary);
}

body.dark .ranking-item .rank.default {
    background-color: #374151;
}

.ranking-item .info {
    flex: 1;
    min-width: 0;
}

.ranking-item .story-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
}

.ranking-item .story-author {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.ranking-item .views {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Featured Ranking Item (Top 1) */
.ranking-featured {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.ranking-featured .cover {
    width: 80px;
    aspect-ratio: 2 / 3;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
}

.ranking-featured .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ranking-featured .cover .rank {
    position: absolute;
    top: -0.5rem;
    left: -0.5rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    background-color: #ef4444;
    border-radius: var(--radius-full);
    border: 2px solid var(--surface);
}

/* ================================================
   Hero Section
   ================================================ */
.hero {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .hero {
        flex-direction: row;
        gap: 2rem;
        padding: 1.5rem;
    }
}

.hero::before {
    content: '';
    position: absolute;
    top: -5rem;
    right: -5rem;
    width: 20rem;
    height: 20rem;
    background: var(--primary-light);
    border-radius: 50%;
    filter: blur(48px);
    pointer-events: none;
}

.hero .cover {
    width: 120px;
    height: 160px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .hero .cover {
        width: 180px;
        height: 240px;
    }
}

.hero .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero .content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    position: relative;
    z-index: 1;
}

@media (min-width: 768px) {
    .hero .content {
        justify-content: center;
    }
}

.hero .meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hero .featured-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    background-color: var(--primary-light);
    border-radius: var(--radius-sm);
}

.hero .category {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.hero .title {
    font-size: 1.875rem;
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

@media (min-width: 480px) {
    .hero .title {
        font-size: 2.25rem;
    }
}

.hero .description {
    font-family: var(--font-body);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.hero .stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.hero .stats .icon {
    font-size: 1.125rem;
    vertical-align: middle;
    margin-right: 0.25rem;
}

.hero .actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* ================================================
   Story Detail Page
   ================================================ */
.story-header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .story-header {
        flex-direction: row;
        gap: 2rem;
    }
}

.story-header .cover {
    width: 200px;
    aspect-ratio: 2 / 3;
    flex-shrink: 0;
    margin: 0 auto;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

@media (min-width: 768px) {
    .story-header .cover {
        margin: 0;
    }
}

.story-header .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-header .info {
    flex: 1;
    text-align: center;
}

@media (min-width: 768px) {
    .story-header .info {
        text-align: left;
    }
}

.story-header .title {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
    .story-header .title {
        font-size: 3rem;
    }
}

.story-header .author-line {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.story-header .author-line a {
    color: var(--primary);
}

.story-header .rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .story-header .rating {
        justify-content: flex-start;
    }
}

.story-header .rating .stars {
    color: var(--warning);
}

.story-header .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.story-header .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

@media (min-width: 768px) {
    .story-header .stat-item {
        align-items: flex-start;
    }
}

.story-header .stat-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-body);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.story-header .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.story-header .genres {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .story-header .genres {
        justify-content: flex-start;
    }
}

.story-header .genres a {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    background-color: var(--bg);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.story-header .genres a:hover {
    background-color: var(--primary);
    color: white;
}

/* ================================================
   Chapter Content Page
   ================================================ */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: var(--border);
    z-index: 100;
}

.reading-progress .bar {
    height: 100%;
    background-color: var(--primary);
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
    transition: width 100ms linear;
}

.chapter-header {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.chapter-header .chapter-title {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .chapter-header .chapter-title {
        font-size: 2.5rem;
    }
}

.chapter-header .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.chapter-header .meta .icon {
    font-size: 1.125rem;
    vertical-align: middle;
    margin-right: 0.25rem;
}

.reading-toolbar {
    position: sticky;
    top: 4rem;
    z-index: 30;
    max-width: 640px;
    margin: 0 auto 2rem;
}

.reading-toolbar .toolbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
}

.reading-toolbar .toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.reading-toolbar .toolbar-btn:hover {
    background-color: var(--bg);
    color: var(--text);
}

.reading-toolbar .divider {
    width: 1px;
    height: 24px;
    background-color: var(--border);
    margin: 0 0.25rem;
}

.chapter-content {
    font-family: var(--font-display);
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-secondary);
    text-align: justify;
    letter-spacing: 0.01em;
}

@media (min-width: 768px) {
    .chapter-content {
        font-size: 1.25rem;
        line-height: 2;
    }
}

@media (min-width: 1024px) {
    .chapter-content {
        font-size: 1.375rem;
        line-height: 2.1;
    }
}

body.dark .chapter-content {
    color: #d0d6dc;
}

.chapter-content p {
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .chapter-content p {
        margin-bottom: 1.75rem;
    }
}

.chapter-content blockquote {
    margin: 2rem 0;
    padding: 1.5rem;
    background-color: var(--bg);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.chapter-content blockquote p {
    margin-bottom: 0;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-style: italic;
    color: var(--text-muted);
}

/* Animate spin for loading */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.chapter-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    margin-top: 4rem;
}

/* 3 buttons layout */
.chapter-nav.three-buttons {
    grid-template-columns: 1fr auto 1fr;
}

@media (max-width: 639px) {
    .chapter-nav.three-buttons {
        grid-template-columns: 1fr 1fr;
    }
    .chapter-nav.three-buttons .nav-btn:nth-child(2) {
        grid-column: 1 / -1;
        order: 3;
    }
}

@media (min-width: 768px) {
    .chapter-nav {
        grid-template-columns: 1fr auto 1fr;
    }
}

.chapter-nav .nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 48px;
    padding: 0 1.5rem;
    font-weight: 500;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.chapter-nav .nav-btn:hover {
    background-color: var(--bg);
    border-color: var(--text-muted);
}

.chapter-nav .nav-btn.primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-primary);
}

.chapter-nav .nav-btn.primary:hover {
    background-color: var(--primary-hover);
    color: white;
}

.chapter-nav .nav-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.chapter-nav .nav-btn .icon {
    font-size: 1.25rem;
    transition: transform var(--transition-fast);
}

.chapter-nav .nav-btn:hover .icon.left {
    transform: translateX(-4px);
}

.chapter-nav .nav-btn:hover .icon.right {
    transform: translateX(4px);
}

/* ================================================
   Breadcrumb
   ================================================ */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .separator {
    color: var(--border);
}

.breadcrumb .current {
    font-weight: 500;
    color: var(--text);
}

/* ================================================
   Footer
   ================================================ */
.footer {
    margin-top: auto;
    padding: 2.5rem 0;
    background-color: var(--surface);
    border-top: 1px solid var(--border);
}

.footer .footer-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@media (min-width: 768px) {
    .footer .footer-content {
        flex-direction: row;
        justify-content: space-between;
    }
}

.footer .brand {
    max-width: 320px;
}

.footer .brand-desc {
    margin-top: 1rem;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.footer .social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.footer .social-links a {
    color: var(--text-muted);
    font-size: 1.5rem;
}

.footer .social-links a:hover {
    color: var(--primary);
}

.footer .links-section {
    display: flex;
    flex-wrap: wrap;
    gap: 3rem;
}

.footer .links-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer .links-column h4 {
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.footer .links-column a {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer .copyright {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    margin-top: 2.5rem;
}

.footer .copyright p {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ================================================
   Badges
   ================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
}

.badge-primary {
    background-color: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background-color: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* ================================================
   Utility Classes
   ================================================ */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.top-0 { top: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }

.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.m-0 { margin: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.border { border: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.cursor-pointer { cursor: pointer; }
.pointer-events-none { pointer-events: none; }

.transition { transition: all var(--transition-normal); }
.transition-colors { transition: color var(--transition-fast), background-color var(--transition-fast); }

/* Responsive visibility */
@media (max-width: 639px) {
    .sm-hidden { display: none !important; }
}

@media (min-width: 640px) {
    .sm-block { display: block; }
    .sm-flex { display: flex; }
    .sm-hidden-up { display: none !important; }
}

@media (max-width: 767px) {
    .md-hidden { display: none !important; }
}

@media (min-width: 768px) {
    .md-block { display: block; }
    .md-flex { display: flex; }
    .md-hidden-up { display: none !important; }
}

/* lg-hidden: Hide on large screens (>=1024px) - for mobile-only elements */
@media (min-width: 1024px) {
    .lg-hidden { display: none !important; }
}

@media (min-width: 1024px) {
    .lg-block { display: block; }
    .lg-flex { display: flex; }
    .lg-hidden-up { display: none !important; }
}

/* ================================================
   Material Symbols (Icons)
   ================================================ */
/* Hide icon text until font is loaded */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
    /* Prevent icon names from showing before font loads */
    font-size: 24px;
    width: 24px;
    height: 24px;
    overflow: hidden;
    display: inline-block;
}

/* Adjust size for icons that need different sizing */
.material-symbols-outlined.logo-icon {
    font-size: 1.875rem;
    width: 1.875rem;
    height: 1.875rem;
    overflow: hidden;
}

.icon-filled {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ================================================
   Reading History Section (Compact 150px cards)
   ================================================ */
.reading-history-section .story-card {
    width: 150px;
    max-width: 150px;
    flex-shrink: 0;
}

.reading-history-section .story-card .cover {
    width: 150px;
    height: 200px;
    overflow: hidden;
}

.reading-history-section .story-card .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reading-history-section .story-card .title {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.reading-history-section .story-card .author {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* Override grid for reading history - use flex instead */
.reading-history-section .grid {
    display: flex !important;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ================================================
   Pagination Navigation
   ================================================ */
.pagination-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 1rem 0;
}

.pagination-nav .btn-sm {
    min-width: 36px;
    height: 36px;
    padding: 0 0.75rem;
}

/* ================================================
   Ranking List
   ================================================ */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.ranking-item:hover {
    background: var(--bg);
    border-color: var(--primary);
    transform: translateX(4px);
}

.rank-number {
    font-size: 1.25rem;
    font-weight: 700;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    flex-shrink: 0;
}

.ranking-item.rank-gold .rank-number {
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #000;
}

.ranking-item.rank-silver .rank-number {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #000;
}

.ranking-item.rank-bronze .rank-number {
    background: linear-gradient(135deg, #cd7f32, #b47228);
    color: #fff;
}

.rank-cover {
    width: 60px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}

.rank-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rank-info {
    flex: 1;
    min-width: 0;
}

.rank-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .ranking-item {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .rank-number {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .rank-cover {
        width: 50px;
        height: 65px;
    }
    
    .rank-title {
        font-size: 0.875rem;
    }
    
    .rank-meta {
        font-size: 0.75rem;
    }
}
