/*
Theme Name: NovelHub
Theme URI: https://yoursite.com
Author: Your Name
Author URI: https://yoursite.com
Description: A modern, clean theme for novel reading websites with dark mode support and mobile optimization
Version: 3.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: novelhub
*/

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

/* =============================================================================
   THEME COLOR VARIANTS
   ============================================================================= */

/* Light Mode (default) */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
    
    /* Mobile touch targets */
    --touch-target: 44px;
}

/* Dark Mode (Standard) */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* Dark Mode - Darker */
[data-theme="darker"] {
    --bg-primary: #0a0e1a;
    --bg-secondary: #141824;
    --bg-card: #141824;
    --text-primary: #e2e8f0;
    --text-secondary: #8892a6;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --border: #1e293b;
    --shadow: rgba(0, 0, 0, 0.5);
}

/* Dark Mode - Gray */
[data-theme="gray"] {
    --bg-primary: #18181b;
    --bg-secondary: #27272a;
    --bg-card: #27272a;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --border: #3f3f46;
    --shadow: rgba(0, 0, 0, 0.4);
}

/* Dark Mode - Pure Black (OLED) */
[data-theme="black"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #a3a3a3;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --border: #1a1a1a;
    --shadow: rgba(0, 0, 0, 0.8);
}

/* =============================================================================
   BASE STYLES - MOBILE FIRST
   ============================================================================= */

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Improve touch scrolling on iOS */
body {
    -webkit-overflow-scrolling: touch;
}

/* Better text rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* =============================================================================
   HEADER & NAVIGATION - MOBILE OPTIMIZED
   ============================================================================= */

.site-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.site-nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem clamp(1rem, 3vw, 2rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-logo {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.site-logo:active {
    transform: scale(0.98);
}

.site-logo svg {
    width: clamp(24px, 5vw, 32px);
    height: clamp(24px, 5vw, 32px);
}

.nav-menu {
    display: flex;
    gap: 2rem;
    align-items: center;
    list-style: none;
}

.nav-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    padding: 0.5rem;
    display: block;
}

.nav-menu a:hover {
    color: var(--accent);
}

.nav-menu a:active {
    transform: scale(0.95);
}

/* Theme Switcher Dropdown */
.theme-dropdown {
    position: relative;
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--touch-target);
}

.theme-toggle:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.theme-toggle:active {
    transform: scale(0.98);
}

.theme-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem;
    min-width: 220px;
    box-shadow: 0 10px 30px var(--shadow);
    display: none;
    z-index: 1000;
    color: var(--text-primary) !important;
}

.theme-dropdown-menu.show {
    display: block;
    animation: slideDown 0.2s ease;
}

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

.theme-dropdown-menu .theme-option {
    color: var(--text-primary) !important;
}

.theme-dropdown-menu .theme-option .theme-option-desc {
    color: var(--text-secondary) !important;
}

.theme-dropdown-menu .theme-option.active {
    background: var(--accent);
    color: #fff !important;
}

.theme-dropdown-menu .theme-option.active .theme-option-desc {
    color: rgba(255,255,255,0.9) !important;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    text-decoration: none;
    min-height: var(--touch-target);
}

.theme-option:hover {
    background: var(--bg-secondary);
}

.theme-option:active {
    transform: scale(0.98);
}

.theme-option.active {
    background: var(--accent);
    color: white;
}

.theme-option-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.theme-option-details {
    flex: 1;
}

.theme-option-name {
    font-weight: 600;
    font-size: 0.9rem;
    display: block;
}

.theme-option-desc {
    font-size: 0.75rem;
    opacity: 0.9;
    display: block;
}

/* =============================================================================
   HERO SECTION - MOBILE OPTIMIZED
   ============================================================================= */

.hero-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 3vw, 2rem);
    text-align: center;
}

.hero-title {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.hero-description {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

.search-bar {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: clamp(0.875rem, 2vw, 1rem) clamp(1.25rem, 3vw, 1.5rem);
    padding-left: clamp(2.5rem, 5vw, 3rem);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: clamp(0.9rem, 2vw, 1rem);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* =============================================================================
   FILTERS - MOBILE OPTIMIZED
   ============================================================================= */

.filters {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-btn {
    padding: 0.5rem clamp(0.75rem, 2vw, 1rem);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    line-height: 1;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    min-height: var(--touch-target);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.filter-btn:active {
    transform: translateY(0) scale(0.98);
}

.filter-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}

/* =============================================================================
   NOVELS CONTAINER & GRID - RESPONSIVE
   ============================================================================= */

.novels-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
}

.section-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.novels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: clamp(1rem, 2vw, 2rem);
    margin-bottom: 4rem;
}

/* Tighter grid on mobile */
@media (max-width: 640px) {
    .novels-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
        gap: 0.85rem;
    }
}

/* =============================================================================
   NOVEL CARDS - MOBILE OPTIMIZED
   ============================================================================= */

.novel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: clamp(12px, 2vw, 16px);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.novel-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px var(--shadow);
}

.novel-card:active {
    transform: translateY(-4px);
}

.novel-cover {
    width: 100%;
    height: clamp(220px, 45vw, 400px);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.novel-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.3) 100%);
}

.cover-badge {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    font-size: clamp(0.7rem, 1.5vw, 0.75rem);
    background: rgba(0,0,0,.55);
    color: #fff;
    border: 1px solid rgba(255,255,255,.15);
    backdrop-filter: blur(4px);
    line-height: 1;
    z-index: 2;
}

.novel-info {
    padding: clamp(1rem, 2vw, 1.5rem);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.novel-title {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.novel-title a {
    color: var(--text-primary);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.novel-author {
    color: var(--text-secondary);
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    margin-bottom: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.novel-meta {
    display: flex;
    gap: clamp(0.5rem, 2vw, 1rem);
    font-size: clamp(0.8rem, 1.8vw, 0.875rem);
    color: var(--text-secondary);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.novel-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.novel-meta .novel-rating .rating-count {
    font-size: 0.8em;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 0.1rem;
}

.novel-meta .novel-bookmarks {
    font-weight: 600;
}

/* Tags / Genres */
.novel-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tag {
    background: var(--bg-secondary);
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: clamp(0.7rem, 1.5vw, 0.75rem);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    text-decoration: none;
    display: inline-block;
    line-height: 1;
    transition: all .2s ease;
}

.tag:hover,
.tag:focus-visible {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.tag:active {
    transform: scale(0.95);
}

.genre-tag {
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: clamp(0.8rem, 2vw, 0.875rem);
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all .15s ease;
    min-height: var(--touch-target);
    display: inline-flex;
    align-items: center;
}

.genre-tag:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.genre-tag:active {
    transform: translateY(0) scale(0.98);
}

.genre-tag:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99,102,241,.25);
}

.read-btn {
    width: 100%;
    padding: clamp(0.65rem, 2vw, 0.75rem);
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    margin-top: auto;
    font-size: clamp(0.9rem, 2vw, 1rem);
    min-height: var(--touch-target);
}

.read-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

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

.bookmark-btn {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--accent);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    min-height: var(--touch-target);
}

.bookmark-btn:hover {
    background: var(--accent);
    color: white;
}

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

.bookmark-btn.bookmarked {
    background: var(--accent);
    color: white;
}

/* =============================================================================
   FEATURED NOVELS SECTION - MOBILE OPTIMIZED
   ============================================================================= */

.featured-scroll-container {
    position: relative;
    margin-bottom: 4rem;
}

.featured-novels-scroll {
    display: flex;
    gap: clamp(1rem, 2vw, 1.5rem);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1rem 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    transition: opacity .2s ease;
    scroll-snap-type: x mandatory;
}

.featured-novels-scroll.is-loading {
    opacity: .4;
    pointer-events: none;
}

.featured-novels-scroll::-webkit-scrollbar {
    height: 8px;
}

.featured-novels-scroll::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.featured-novels-scroll::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

.featured-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.featured-controls .filter-btn {
    padding: 0.5rem clamp(0.7rem, 2vw, 0.9rem);
    font-size: clamp(0.8rem, 1.8vw, 0.9rem);
}

.featured-novel-card {
    min-width: clamp(160px, 35vw, 200px);
    max-width: clamp(160px, 35vw, 200px);
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    scroll-snap-align: start;
}

.featured-novel-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px var(--shadow);
}

.featured-novel-card:active {
    transform: translateY(-4px);
}

.featured-novel-cover {
    width: 100%;
    height: clamp(200px, 40vw, 280px);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: clamp(2rem, 5vw, 2.5rem);
    position: relative;
}

.featured-novel-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.3) 100%);
}

.featured-novel-info {
    padding: clamp(0.85rem, 2vw, 1rem);
}

.featured-novel-info .novel-title {
    font-size: clamp(0.9rem, 2vw, 1rem);
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.featured-novel-info .novel-title a {
    color: var(--text-primary);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.featured-novel-info .novel-author {
    font-size: clamp(0.8rem, 1.8vw, 0.85rem);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.featured-novel-info .novel-meta {
    display: flex;
    gap: clamp(0.5rem, 1.5vw, 0.75rem);
    font-size: clamp(0.75rem, 1.6vw, 0.8rem);
    flex-wrap: wrap;
}

.featured-cover-link,
.novel-cover-link {
    display: block;
    text-decoration: none;
}

/* =============================================================================
   STATISTICS SECTION - MOBILE OPTIMIZED
   ============================================================================= */

.stats {
    max-width: 1400px;
    margin: 4rem auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: clamp(1rem, 2vw, 2rem);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: clamp(1.5rem, 3vw, 2rem);
    border-radius: 16px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px var(--shadow);
}

.stat-card:active {
    transform: translateY(-2px);
}

.stat-number {
    font-size: clamp(2rem, 5vw, 2.5rem);
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

/* =============================================================================
   FOOTER - MOBILE OPTIMIZED
   ============================================================================= */

.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: clamp(2rem, 4vw, 3rem) clamp(1rem, 3vw, 2rem);
    margin-top: 4rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: clamp(1.5rem, 3vw, 2rem);
}

.footer-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: clamp(1rem, 2.5vw, 1.15rem);
}

.footer-section a {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
    padding: 0.25rem 0;
}

.footer-section a:hover {
    color: var(--accent);
}

.footer-section a:active {
    transform: scale(0.98);
}

.footer-section ul {
    list-style: none;
}

.footer-bottom {
    max-width: 1400px;
    margin: 2rem auto 0;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
    font-size: clamp(0.85rem, 2vw, 0.95rem);
}

/* =============================================================================
   USER PROFILE & DASHBOARD - MOBILE OPTIMIZED
   ============================================================================= */

.user-dashboard {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
}

.profile-header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: clamp(1.5rem, 3vw, 2rem);
    margin-bottom: 2rem;
    display: flex;
    gap: clamp(1rem, 3vw, 2rem);
    align-items: center;
    flex-wrap: wrap;
}

.profile-avatar {
    width: clamp(80px, 15vw, 100px);
    height: clamp(80px, 15vw, 100px);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: clamp(2rem, 5vw, 2.5rem);
    font-weight: 700;
    flex-shrink: 0;
}

.profile-info {
    flex: 1;
    min-width: 200px;
}

.profile-info h2 {
    margin-bottom: 0.5rem;
    font-size: clamp(1.5rem, 4vw, 2rem);
}

.profile-tabs {
    display: flex;
    gap: clamp(0.5rem, 2vw, 1rem);
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.profile-tab {
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 1.5rem);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.profile-tab.active {
    color: var(--accent);
}

.profile-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.profile-tab:active {
    transform: scale(0.98);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.bookmarked-novels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: clamp(1rem, 2vw, 2rem);
}

@media (max-width: 640px) {
    .bookmarked-novels {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
        gap: 0.85rem;
    }
}

.reading-history-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(1rem, 2vw, 1.5rem);
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.history-item:last-child {
    border-bottom: none;
}

/* =============================================================================
   COMMENTS SECTION - MOBILE OPTIMIZED
   ============================================================================= */

.comments-area {
    max-width: 900px;
    margin: 3rem auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
}

.comments-title {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.comment-list {
    list-style: none;
    padding: 0;
}

.comment {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(1rem, 2vw, 1.5rem);
    margin-bottom: 1rem;
}

.comment-author {
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-size: clamp(0.95rem, 2vw, 1.05rem);
}

.comment-meta {
    font-size: clamp(0.8rem, 1.8vw, 0.875rem);
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.comment-content {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: clamp(0.95rem, 2vw, 1rem);
}

.comment-reply-link {
    color: var(--accent);
    text-decoration: none;
    font-size: clamp(0.8rem, 1.8vw, 0.875rem);
    font-weight: 600;
    padding: 0.25rem 0;
    display: inline-block;
}

.comment-reply-link:active {
    transform: scale(0.98);
}

.comment-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(1.5rem, 3vw, 2rem);
    margin-top: 2rem;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form textarea {
    width: 100%;
    padding: clamp(0.65rem, 2vw, 0.75rem);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.comment-form textarea {
    min-height: 150px;
    resize: vertical;
    font-family: inherit;
}

.comment-form input[type="submit"] {
    background: var(--accent);
    color: white;
    border: none;
    padding: clamp(0.65rem, 2vw, 0.75rem) 2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: clamp(0.9rem, 2vw, 1rem);
    min-height: var(--touch-target);
}

.comment-form input[type="submit"]:hover {
    background: var(--accent-hover);
}

.comment-form input[type="submit"]:active {
    transform: scale(0.98);
}

/* =============================================================================
   CONTACT FORM - MOBILE OPTIMIZED
   ============================================================================= */

.contact-form-container {
    max-width: 700px;
    margin: 2rem auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
}

.contact-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: clamp(1.5rem, 3vw, 2rem);
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: clamp(0.65rem, 2vw, 0.75rem);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.form-group textarea {
    min-height: 200px;
    resize: vertical;
}

.submit-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: clamp(0.85rem, 2vw, 1rem) 2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    font-size: clamp(0.95rem, 2vw, 1rem);
    min-height: var(--touch-target);
}

.submit-btn:hover {
    background: var(--accent-hover);
}

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

.form-message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.form-message.success {
    background: #10b981;
    color: white;
}

.form-message.error {
    background: #ef4444;
    color: white;
}

/* =============================================================================
   READING PROGRESS - MOBILE OPTIMIZED
   ============================================================================= */

.reading-progress-bar {
    background: var(--bg-secondary);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #ec4899);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: clamp(0.8rem, 1.8vw, 0.875rem);
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* =============================================================================
   ESTIMATED READING TIME
   ============================================================================= */

.reading-time {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 999px;
    font-size: clamp(0.8rem, 1.8vw, 0.875rem);
    color: var(--text-secondary);
}

/* =============================================================================
   ADS - RESPONSIVE
   ============================================================================= */

.ad-container {
    margin: 1.5rem auto;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.ad-container.ad-header {
    margin-top: 0.5rem;
}

@media (max-width: 640px) {
    .ad-header {
        display: none;
    }
}

/* =============================================================================
   MOBILE & DPI OPTIMIZATION
   ============================================================================= */

/* Real <img> inside covers for proper srcset/sizes handling */
.novel-cover-img,
.featured-novel-cover-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Fallback state (no thumbnail) */
.novel-cover--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: clamp(2rem, 5vw, 2.5rem);
}

/* Hairline borders on high-DPI */
@media (min-resolution: 2dppx) {
    .novel-card,
    .featured-novel-card {
        border-width: 0.5px;
    }
}

/* =============================================================================
   PAGE TEMPLATE STYLES
   ============================================================================= */

.page-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 clamp(1rem, 3vw, 1.5rem);
}

.page-title {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-weight: 800;
    margin-bottom: 1rem;
}

.page-article {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(1.25rem, 3vw, 1.5rem);
}

.page-article .entry-content {
    color: var(--text-primary);
}

.page-article .entry-content h2,
.page-article .entry-content h3 {
    color: var(--text-primary);
    margin-top: 1.25rem;
}

.page-article .entry-content p {
    margin: 0.75rem 0;
    line-height: 1.7;
}

.page-article .entry-content a {
    color: var(--accent);
}

.page-nav {
    margin-top: 1rem;
}

/* =============================================================================
   RESPONSIVE BREAKPOINTS
   ============================================================================= */

/* Small devices (phones) */
@media (max-width: 640px) {
    html {
        font-size: 15px;
    }

    .hero-section {
        padding: 2rem 1rem;
    }

    .nav-menu {
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

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

    .profile-tabs {
        gap: 0.5rem;
    }

    .profile-tab {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
}

/* Medium devices (tablets) */
@media (min-width: 641px) and (max-width: 1024px) {
    html {
        font-size: 16px;
    }

    .novels-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

/* Large devices (desktops) */
@media (min-width: 1025px) {
    html {
        font-size: 16px;
    }

    .novels-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    /* Hover effects only on desktop */
    .novel-card:hover {
        transform: translateY(-8px);
    }

    .stat-card:hover {
        transform: translateY(-4px);
    }
}

/* Extra large devices */
@media (min-width: 1400px) {
    .novels-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* Landscape orientation optimization */
@media (orientation: landscape) and (max-height: 640px) {
    .hero-section {
        padding: 1.5rem 1rem;
    }

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

    .hero-description {
        margin-bottom: 1rem;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
    }

    .novel-cover,
    .featured-novel-cover {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Print styles */
@media print {
    .site-header,
    .site-footer,
    .filters,
    .search-bar,
    .action-buttons,
    .bookmark-btn,
    .ad-container {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .chapter-text-content,
    .legal-content {
        border: none;
        box-shadow: none;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* iOS-Style Spring Animations */
:root {
    --spring-easing: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --smooth-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Global Smooth Transitions */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Enhanced Button Animations */
button, .btn, .read-btn, .filter-btn, .nav-btn {
    transform-origin: center;
    will-change: transform;
}

button:active, .btn:active, .read-btn:active {
    transform: scale(0.96) !important;
    transition: transform 0.1s var(--spring-easing) !important;
}

/* Card Hover Effects - iOS Style */
.novel-card, .featured-novel-card {
    transition: transform 0.4s var(--smooth-easing),
                box-shadow 0.4s var(--smooth-easing);
}

.novel-card:hover, .featured-novel-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px var(--shadow), 
                0 0 0 1px rgba(99, 102, 241, 0.1);
}

@media (hover: none) {
    .novel-card:active, .featured-novel-card:active {
        transform: scale(0.98);
    }
}

/* Enhanced Scroll Animations */
@media (prefers-reduced-motion: no-preference) {
    .novels-grid > * {
        animation: fadeInUp 0.6s var(--smooth-easing) both;
    }
    
    .novels-grid > *:nth-child(1) { animation-delay: 0.05s; }
    .novels-grid > *:nth-child(2) { animation-delay: 0.1s; }
    .novels-grid > *:nth-child(3) { animation-delay: 0.15s; }
    .novels-grid > *:nth-child(4) { animation-delay: 0.2s; }
    .novels-grid > *:nth-child(5) { animation-delay: 0.25s; }
    .novels-grid > *:nth-child(6) { animation-delay: 0.3s; }
}

/* Ripple Effect for Buttons */
.read-btn, .bookmark-btn, .btn-primary {
    position: relative;
    overflow: hidden;
}

.read-btn::after, .bookmark-btn::after, .btn-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.read-btn:active::after, .bookmark-btn:active::after, .btn-primary:active::after {
    width: 300px;
    height: 300px;
}

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

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

/* Loading Skeleton */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    animation: shimmer 2s infinite;
    background: linear-gradient(
        to right,
        var(--bg-secondary) 0%,
        var(--bg-primary) 20%,
        var(--bg-secondary) 40%,
        var(--bg-secondary) 100%
    );
    background-size: 1000px 100%;
}

/* Enhanced Focus States */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
    transition: outline 0.2s var(--smooth-easing);
}

/* Micro-interactions */
input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.3);
    box-shadow: 0 0 0 8px rgba(99, 102, 241, 0.2);
}

input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.3);
    box-shadow: 0 0 0 8px rgba(99, 102, 241, 0.2);
}

/* Notification Badge Pulse */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.9;
    }
}

.notification-badge {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Smooth Theme Transitions */
html {
    transition: background-color 0.3s var(--smooth-easing);
}

body {
    transition: background-color 0.3s var(--smooth-easing),
                color 0.3s var(--smooth-easing);
}

/* Enhanced Mobile Touch Feedback */
@media (max-width: 768px) {
    button:active, .filter-btn:active, .theme-option:active {
        transform: scale(0.95);
        transition: transform 0.1s ease-out;
    }
}
