/* =============================================
   TruyenHay - Premium Web Novel Platform
   Complete Design System v2.0
   ============================================= */

/* ---- Google Font ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Serif:ital,wght@0,400;0,700;1,400&display=swap');

/* ---- CSS Variables ---- */
:root {
    /* Primary Palette */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.12);
    --primary-glow: rgba(99, 102, 241, 0.3);
    --accent: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);

    /* Status */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Light Mode */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    --bg-nav: rgba(255, 255, 255, 0.85);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.03);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50px;

    /* Reader */
    --reader-max-width: 780px;

    /* Transitions */
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Dark Mode ---- */
[data-theme="dark"] {
    --bg-body: #0c0e1a;
    --bg-card: #151829;
    --bg-card-hover: #1c2038;
    --bg-secondary: #1a1e33;
    --bg-tertiary: #232848;
    --bg-nav: rgba(12, 14, 26, 0.9);
    --text-primary: #e8eaf0;
    --text-secondary: #a5adc4;
    --text-muted: #5c6384;
    --border-color: #252a45;
    --border-light: #1e2340;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.03);
    --primary-light: rgba(99, 102, 241, 0.15);
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    color: var(--primary-hover);
}

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

ul {
    list-style: none;
}

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

/* ---- Layout ---- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 640px) {
    .container {
        padding: 0 24px;
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 0 32px;
    }
}

/* ---- Navbar ---- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-nav);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    transition: box-shadow var(--transition);
}

.navbar .container {
    display: flex;
    align-items: center;
    height: 68px;
    gap: 12px;
}

@media (min-width: 768px) {
    .navbar .container {
        gap: 20px;
    }
}

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

.brand-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(99, 102, 241, 0.3));
}

.navbar-nav {
    display: none;
    align-items: center;
    gap: 4px;
    flex: 1;
}

@media (min-width: 768px) {
    .navbar-nav {
        display: flex;
    }
}

.navbar-nav a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    transition: all var(--transition);
    white-space: nowrap;
    min-height: 44px;
    /* Better touch target */
}

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

.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-search {
    position: relative;
    display: none;
}

@media (min-width: 768px) {
    .navbar-search {
        display: flex;
        align-items: center;
    }
}

.navbar-search .search-icon {
    position: absolute;
    left: 12px;
    font-size: 0.85rem;
    opacity: 0.5;
    pointer-events: none;
}

.navbar-search .search-input {
    width: 200px;
    padding: 8px 12px 8px 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: all var(--transition);
}

.navbar-search .search-input:focus {
    width: 260px;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-card);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    /* Touch target */
    min-height: 44px;
    padding: 8px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 1.15rem;
    transition: all var(--transition);
    color: var(--text-secondary);
    text-decoration: none;
}

.btn-icon:hover {
    background: var(--primary-light);
    color: var(--primary);
    transform: scale(1.05);
}

.btn-icon:active {
    transform: scale(0.98);
}

/* Mobile Toggle */
.mobile-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    cursor: pointer;
    position: relative;
    z-index: 1001;
}

@media (min-width: 768px) {
    .mobile-toggle {
        display: none;
    }
}

.mobile-toggle span {
    width: 24px;
    height: 2.5px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition);
}

.mobile-toggle.active span:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.mobile-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-toggle.active span:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 68px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-nav);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: 24px;
    transform: translateX(100%);
    transition: transform var(--transition);
    overflow-y: auto;
    z-index: 999;
}

.mobile-menu.active {
    transform: translateX(0);
}

.mobile-menu nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-menu nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 1rem;
    transition: all var(--transition);
    min-height: 56px;
}

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

/* ---- Search Autocomplete ---- */
.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: none;
    overflow: hidden;
    z-index: 100;
}

.search-results.show {
    display: block;
    animation: slideDown 0.2s ease;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border-light);
    text-decoration: none;
    color: var(--text-primary);
}

.search-result-item:hover {
    background: var(--primary-light);
}

.search-result-item img {
    width: 36px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
}

.search-result-item .title {
    font-weight: 600;
    font-size: 0.88rem;
}

.search-result-item .author {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ---- Hero Section ---- */
.hero {
    background: var(--accent-gradient);
    padding: 70px 0 80px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 30% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(168, 85, 247, 0.2) 0%, transparent 50%);
    pointer-events: none;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-body);
    clip-path: ellipse(55% 100% at 50% 100%);
}

.hero h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    color: white;
    margin-bottom: 12px;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.hero p {
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    margin-bottom: 32px;
    position: relative;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-search {
    max-width: 520px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.hero-search .search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    opacity: 0.5;
    z-index: 1;
    pointer-events: none;
}

.hero-search .search-input {
    width: 100%;
    padding: 16px 24px 16px 52px;
    border: none;
    border-radius: var(--radius-full);
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    outline: none;
    transition: all var(--transition);
}

[data-theme="dark"] .hero-search .search-input {
    background: rgba(21, 24, 41, 0.95);
    color: var(--text-primary);
}

.hero-search .search-input:focus {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
}

/* ---- Sections ---- */
.section {
    padding: 40px 0;
}

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

.section-title {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.section-title .icon {
    font-size: 1.3rem;
}

.section-more {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: gap var(--transition);
}

.section-more:hover {
    gap: 8px;
}

/* ---- Story Grid (Cards) ---- */
.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

@media (min-width: 480px) {
    .story-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: 20px;
    }
}

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

.story-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
    text-decoration: none;
    color: var(--text-primary);
    border: 1px solid transparent;
}

.story-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    color: var(--text-primary);
}

.story-card:active {
    transform: translateY(-6px) scale(1.01);
}

.story-card .cover {
    position: relative;
    width: 100%;
    padding-top: 140%;
    overflow: hidden;
    background: var(--bg-tertiary);
}

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

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

.badge-status {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
}

.badge-ongoing {
    background: rgba(16, 185, 129, 0.85);
    color: white;
}

.badge-completed {
    background: rgba(99, 102, 241, 0.85);
    color: white;
}

.story-card .info {
    padding: 12px;
}

.story-card .info .title {
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.story-card .info .meta {
    display: flex;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---- Story List ---- */
.story-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.story-list-item {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card);
    text-decoration: none;
    color: var(--text-primary);
    transition: background var(--transition);
    align-items: center;
}

.story-list-item:hover {
    background: var(--primary-light);
}

.story-list-item .cover {
    width: 48px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

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

.story-list-item .info {
    flex: 1;
    min-width: 0;
}

.story-list-item .info .title {
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-list-item .latest-chapter {
    font-size: 0.82rem;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 2px;
}

.story-list-item .meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ---- Genre Grid ---- */
.genre-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.genre-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
    text-decoration: none;
}

.genre-tag:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.genre-tag .count {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ---- Story Detail Page ---- */
.story-detail {
    padding: 30px 0;
}

.story-detail-header {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    padding: 28px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
}

.story-detail-cover {
    width: 220px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.story-detail-cover img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 3/4;
    object-fit: cover;
}

.story-detail-info {
    flex: 1;
    min-width: 0;
}

.story-detail-info h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 12px;
    line-height: 1.3;
}

.story-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.story-detail-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.story-detail-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.story-detail-genres a {
    display: inline-block;
    padding: 5px 14px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition);
}

.story-detail-genres a:hover {
    background: var(--primary);
    color: white;
}

.story-detail-desc {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: 20px;
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.story-detail-desc.expanded {
    max-height: none;
}

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

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    min-height: 48px;
    /* Better touch target */
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

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

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

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

.btn-secondary.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

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

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

.btn-lg {
    padding: 16px 32px;
    font-size: 1rem;
    border-radius: var(--radius-lg);
    min-height: 56px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8125rem;
    min-height: 40px;
}

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

.chapter-list-wrapper h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.chapter-list {
    display: flex;
    flex-direction: column;
}

.chapter-list li {
    border-bottom: 1px solid var(--border-light);
}

.chapter-list li:last-child {
    border-bottom: none;
}

.chapter-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all var(--transition);
    border-radius: var(--radius-sm);
    text-decoration: none;
}

.chapter-list li a:hover {
    background: var(--primary-light);
    color: var(--primary);
    padding-left: 16px;
}

.vip-icon {
    font-size: 0.88rem;
    margin-right: 6px;
}

/* ---- Comments ---- */
.comments-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
}

.comments-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.comment-form {
    margin-bottom: 20px;
}

.comment-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
    margin-bottom: 10px;
    font-size: 0.92rem;
}

.comment-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-item {
    display: flex;
    gap: 12px;
}

.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.comment-body {
    flex: 1;
    min-width: 0;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.comment-username {
    font-weight: 600;
    font-size: 0.88rem;
}

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

.comment-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    word-break: break-word;
}

/* ---- Reader Page ---- */
.reader-toolbar {
    position: sticky;
    top: 64px;
    z-index: 50;
    background: var(--bg-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 0;
}

.reader-toolbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.reader-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.reader-controls .btn-icon {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
}

.reader-content {
    max-width: 780px;
    margin: 0 auto;
    padding: 40px 20px 60px;
}

.reader-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 30px;
    text-align: center;
    color: var(--text-primary);
}

.chapter-content {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 18px;
    line-height: 2;
    color: var(--text-secondary);
    word-break: break-word;
}

.chapter-content p {
    margin-bottom: 1.2em;
    text-align: justify;
}

.reader-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 30px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 30px;
}

.reader-nav .btn {
    min-width: 140px;
}

/* Floating Reader Nav */
.reader-floating-nav {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    z-index: 60;
    backdrop-filter: blur(20px);
}

.reader-floating-nav .btn {
    border-radius: var(--radius-full);
    padding: 10px 18px;
    font-size: 0.82rem;
}

/* ---- VIP Unlock ---- */
.vip-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.3s ease;
}

.vip-modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 36px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: scaleIn 0.3s ease;
}

.vip-modal h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.vip-modal p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.vip-timer {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 20px;
    font-variant-numeric: tabular-nums;
}

.vip-modal .btn {
    width: 100%;
    margin-bottom: 10px;
}

/* ---- Form Card ---- */
.form-card {
    max-width: 440px;
    margin: 50px auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.form-card h2 {
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 11px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.92rem;
    outline: none;
    transition: all var(--transition);
}

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

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

/* ---- Flash Messages ---- */
.flash {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 16px;
    animation: slideDown 0.3s ease;
}

.flash-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.flash-error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.flash-info {
    background: rgba(59, 130, 246, 0.12);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 30px 0;
}

.pagination a,
.pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    transition: all var(--transition);
    text-decoration: none;
}

.pagination a {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.pagination a:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.pagination .active {
    background: var(--accent-gradient);
    color: white;
    border: none;
}

/* ---- Ad Slots ---- */
.ad-slot {
    margin: 16px 0;
    text-align: center;
    min-height: 10px;
}

.ad-slot:empty {
    display: none;
}

/* ---- Footer ---- */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 48px 0 24px;
    margin-top: 40px;
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 30px;
}

.footer-brand {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.footer-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.footer h4 {
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
}

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

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    animation: slideRight 0.3s ease;
    max-width: 340px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

/* ---- Admin Layout ---- */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    padding: 24px 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 100;
}

.admin-sidebar .brand {
    font-size: 1.15rem;
    font-weight: 800;
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.admin-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
}

.admin-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}

.admin-sidebar nav a:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.admin-sidebar nav a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.admin-main {
    flex: 1;
    padding: 28px 32px;
    margin-left: 250px;
}

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

.admin-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 22px;
    border: 1px solid var(--border-color);
    transition: transform var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 2px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Admin Table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.admin-table th {
    text-align: left;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
}

.admin-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.admin-table tr:hover td {
    background: var(--primary-light);
}

.admin-table a {
    font-weight: 500;
}

/* ---- Animations ---- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

    100% {
        background-position: calc(200px + 100%) 0;
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .navbar .container {
        height: 56px;
    }

    .navbar-nav {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--bg-card);
        flex-direction: column;
        padding: 16px;
        border-bottom: 1px solid var(--border-color);
        box-shadow: var(--shadow-lg);
        gap: 4px;
    }

    .navbar-nav.show {
        display: flex;
        z-index: 999;
        animation: slideDown 0.25s ease;
    }

    .navbar-nav a {
        padding: 12px 16px;
        font-size: 1rem;
    }

    .navbar-search {
        display: none;
    }

    .mobile-toggle {
        display: flex;
    }

    .hero {
        padding: 50px 0 60px;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    .hero p {
        font-size: 0.95rem;
    }

    .hero-search .search-input {
        padding: 14px 20px 14px 48px;
        font-size: 0.92rem;
    }

    .section {
        padding: 28px 0;
    }

    .section-title {
        font-size: 1.15rem;
    }

    .story-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .story-card .info {
        padding: 8px;
    }

    .story-card .info .title {
        font-size: 0.8rem;
    }

    .story-card .info .meta {
        font-size: 0.7rem;
    }

    .story-detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px;
        gap: 20px;
    }

    .story-detail-cover {
        width: 180px;
    }

    .story-detail-meta {
        justify-content: center;
    }

    .story-detail-genres {
        justify-content: center;
    }

    .story-actions {
        justify-content: center;
    }

    .reader-content {
        padding: 24px 16px 50px;
    }

    .reader-content h1 {
        font-size: 1.2rem;
    }

    .chapter-content {
        font-size: 16px;
        line-height: 1.85;
    }

    .reader-floating-nav {
        bottom: 16px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .form-card {
        margin: 24px auto;
        padding: 24px;
    }

    /* Admin responsive */
    .admin-sidebar {
        width: 60px;
        padding: 16px 0;
    }

    .admin-sidebar .brand {
        font-size: 1.2rem;
        padding: 0 10px 16px;
        text-align: center;
        overflow: hidden;
    }

    .admin-sidebar nav a span,
    .admin-sidebar nav a {
        font-size: 0;
        padding: 12px;
        justify-content: center;
    }

    .admin-sidebar nav a::before {
        font-size: 1.2rem;
    }

    .admin-main {
        margin-left: 60px;
        padding: 16px;
    }

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

    .admin-table {
        font-size: 0.8rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    .story-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .story-card .cover {
        padding-top: 130%;
    }

    .story-card .info .title {
        font-size: 0.75rem;
    }

    .story-card .info .meta {
        display: none;
    }

    .story-detail-cover {
        width: 150px;
    }

    .story-detail-info h1 {
        font-size: 1.25rem;
    }

    .btn-lg {
        padding: 11px 20px;
        font-size: 0.88rem;
    }
}

/* ---- Print ---- */
@media print {

    .navbar,
    .footer,
    .reader-toolbar,
    .reader-floating-nav,
    .ad-slot,
    .story-actions {
        display: none !important;
    }

    .chapter-content {
        font-size: 14px;
        line-height: 1.8;
        color: black;
    }
}

/* ---- Skeleton/Loading ---- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ---- Anti-copy ---- */
.chapter-content {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* ---- Dark Mode Theme Toggle Animation ---- */
.theme-toggle {
    position: relative;
    overflow: hidden;
}

.theme-toggle::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity var(--transition);
}

.theme-toggle:hover::after {
    opacity: 1;
}

/* ---- Scroll Progress Bar ---- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--accent-gradient);
    z-index: 9999;
    transition: width 0.1s linear;
}

/* ---- Floating Side Nav (Reader) ---- */
.floating-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
}

.floating-nav.prev {
    left: 16px;
}

.floating-nav.next {
    right: 16px;
}

.floating-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    font-size: 1.2rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--transition);
}

.floating-nav a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.1);
    box-shadow: 0 4px 20px var(--primary-glow);
}

/* ---- Reader Bottom Nav ---- */
.reader-bottom-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    max-width: var(--reader-max-width);
    margin: 0 auto;
    padding: 30px 20px;
    border-top: 1px solid var(--border-color);
}

/* ---- Reader Text ---- */
.reader-text {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 18px;
    line-height: 2;
    color: var(--text-secondary);
    word-break: break-word;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

.reader-text p {
    margin-bottom: 1.2em;
    text-align: justify;
}

/* ---- Search Page Filters ---- */
.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    align-items: center;
}

.search-filters .form-control {
    max-width: 200px;
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-box .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.4;
    pointer-events: none;
}

.search-box .form-control {
    width: 100%;
    max-width: none;
    padding-left: 40px;
}

/* ---- Profile Page ---- */
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 28px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.profile-info h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-info p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.profile-stats {
    display: flex;
    gap: 24px;
    margin-top: 8px;
}

.profile-stats span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.profile-stats strong {
    color: var(--primary);
    font-weight: 700;
}

/* Tabs */
.tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-nav a,
.tab-nav button {
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
}

.tab-nav a:hover,
.tab-nav button:hover,
.tab-nav a.active,
.tab-nav button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ---- Admin Form ---- */
.admin-form {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.admin-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.admin-form .form-group {
    margin-bottom: 16px;
}

.admin-form .form-actions {
    display: flex;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    margin-top: 10px;
}

.admin-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.admin-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

/* Weekly chart placeholder */
.chart-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.chart-container h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.chart-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 160px;
    padding-top: 20px;
}

.chart-bar .bar {
    flex: 1;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    min-height: 4px;
    position: relative;
    transition: height 0.5s ease;
}

.chart-bar .bar .label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ---- Genres Page Grid ---- */
.genres-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.genres-page-grid .genre-tag {
    justify-content: space-between;
    width: 100%;
}

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

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

.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .floating-nav {
        display: none;
    }

    .reader-bottom-nav {
        flex-wrap: wrap;
    }

    .search-filters {
        flex-direction: column;
    }

    .search-filters .form-control {
        max-width: 100%;
        width: 100%;
    }

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

    .profile-stats {
        justify-content: center;
    }

    .admin-form .form-row {
        grid-template-columns: 1fr;
    }
}