/* ==========================================================================
   ReadNovel - OLED Dark Mode Reader CSS
   Designed for Mobile & Tablet (Clean, Professional, Zero-Emoji Aesthetic)
   ========================================================================== */

:root {
    --bg-oled: #07090e;
    --bg-surface: #0d1117;
    --bg-card: #151b23;
    --bg-card-hover: #1c2430;
    --bg-elevated: #212836;
    
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    --accent-primary: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.12);
    --shopee-orange: #ee4d2d;
    --shopee-orange-hover: #d73211;
    
    --border-color: #21262d;
    --border-subtle: #161b22;
    
    --font-heading: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --reader-font-size: 1.12rem;
    --reader-line-height: 1.85;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    background-color: #030508;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: hidden;
    height: 100%;
}

body {
    background-color: var(--bg-oled);
    color: var(--text-primary);
    min-height: 100%;
    display: flex;
    justify-content: center;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ================= Mobile/Tablet App Shell Container ================= */
.app-container {
    width: 100%;
    max-width: 520px;
    min-height: 100vh;
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.85);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    padding-bottom: 72px; /* space for bottom nav */
}

/* Top Navigation Bar */
.top-navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(13, 17, 23, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand-box {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}
.brand-icon-svg {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}
.brand-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.2px;
    color: #ffffff;
}
.brand-tagline {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 400;
}
.nav-right-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-icon {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}
.btn-icon:hover, .btn-icon:active {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
}

/* Reading Progress Bar (Fixed on Top) */
.reading-progress-track {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    z-index: 100;
}
.reading-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #38bdf8, #818cf8);
    transition: width 0.08s ease-out;
}

/* ================= Genre Pills ================= */
.genre-scroller {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border-subtle);
}
.genre-scroller::-webkit-scrollbar { display: none; }
.genre-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-family: var(--font-heading);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
}
.genre-pill:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}
.genre-pill.active {
    background: rgba(56, 189, 248, 0.12);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ================= Story Cards Grid ================= */
.story-list-section {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.section-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.story-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    gap: 14px;
    text-decoration: none;
    color: inherit;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}
.story-card:hover, .story-card:active {
    background: var(--bg-card-hover);
    border-color: rgba(56, 189, 248, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Realistic Book Cover Aesthetic */
.story-cover {
    width: 84px;
    height: 118px;
    flex-shrink: 0;
    border-radius: 6px;
    background: var(--cover-base, #1e293b);
    position: relative;
    overflow: hidden;
    box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px 6px 8px 12px;
}
.story-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0%, rgba(0, 0, 0, 0.6) 100%);
}
.book-cover-tag {
    font-size: 0.62rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.4px;
    font-family: var(--font-heading);
}
.book-cover-title {
    font-family: var(--font-heading);
    font-size: 0.76rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.book-cover-author {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    min-width: 0;
}
.story-title {
    font-family: var(--font-heading);
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.story-synopsis {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}
.story-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.author-name-tag {
    color: var(--accent-primary);
    font-weight: 500;
}

/* ================= Story Detail Page ================= */
.story-hero-header {
    padding: 20px 16px;
    display: flex;
    gap: 16px;
    background: linear-gradient(180deg, rgba(21, 27, 35, 0.8) 0%, rgba(13, 17, 23, 0) 100%);
    border-bottom: 1px solid var(--border-color);
}
.story-hero-cover {
    width: 104px;
    height: 148px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--cover-base, #1e293b);
    position: relative;
    overflow: hidden;
    box-shadow: 4px 8px 24px rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px 10px 12px 16px;
}
.story-hero-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 5px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.25) 0%, rgba(0, 0, 0, 0.7) 100%);
}
.story-hero-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
}
.hero-genre-tag {
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-family: var(--font-heading);
    font-weight: 600;
    margin-bottom: 4px;
}
.story-hero-title {
    font-family: var(--font-heading);
    font-size: 1.18rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
    margin-bottom: 6px;
}
.hero-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}
.btn-primary-read {
    background: var(--accent-primary);
    color: #000000;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 10px 16px;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: opacity 0.15s ease;
}
.btn-primary-read:hover, .btn-primary-read:active {
    opacity: 0.9;
}
.btn-secondary-read {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.92rem;
    padding: 10px 16px;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-secondary-read:hover, .btn-secondary-read:active {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}

.story-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}
.stat-item-num {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}
.stat-item-lbl {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Chapter List */
.chapter-list-section {
    padding: 16px;
}
.chapter-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.15s ease;
}
.chapter-item:hover, .chapter-item:active {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}
.chapter-item-num {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.chapter-item-title {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}
.chapter-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ================= Chapter Reader View ================= */
.reader-container {
    padding: 20px 20px 40px;
    flex: 1;
}
.reader-story-title-ref {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--accent-primary);
    text-decoration: none;
    margin-bottom: 8px;
    font-family: var(--font-heading);
}
.reader-chapter-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.35;
    margin-bottom: 6px;
}
.reader-chapter-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

/* Typography Content */
.reader-body-content {
    color: #e6edf3;
    font-family: var(--font-body);
    line-height: var(--reader-line-height);
}
.reader-body-content p {
    margin-bottom: 1.35em;
    text-align: justify;
    text-justify: inter-cluster;
    text-indent: 1.75em;
}

/* Font Size Classes */
.font-sm  { font-size: 1.0rem; line-height: 1.75; }
.font-md  { font-size: 1.15rem; line-height: 1.85; }
.font-lg  { font-size: 1.3rem; line-height: 1.95; }
.font-xl  { font-size: 1.45rem; line-height: 2.05; }

/* Chapter Navigation Footer */
.reader-nav-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}
.btn-nav-chap {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}
.btn-nav-chap:hover, .btn-nav-chap:active {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}
.btn-nav-chap.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ================= Shopee Affiliate Ads Banner Card ================= */
.ad-banner-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin: 22px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.ad-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
}
.ad-sponsor-tag {
    background: rgba(238, 77, 45, 0.12);
    color: var(--shopee-orange);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 700;
    font-family: var(--font-heading);
    letter-spacing: 0.4px;
    font-size: 0.65rem;
}
.ad-placement-title {
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 0.72rem;
}
.ad-body-content {
    display: flex;
    gap: 12px;
    align-items: center;
}
.ad-thumb-box {
    width: 68px;
    height: 68px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: #000;
    border: 1px solid var(--border-color);
}
.ad-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ad-discount-tag {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: var(--shopee-orange);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: var(--font-heading);
}
.ad-details-box {
    flex: 1;
    min-width: 0;
}
.ad-badge-pill {
    display: inline-block;
    font-size: 0.68rem;
    color: var(--accent-primary);
    margin-bottom: 2px;
    font-family: var(--font-heading);
}
.ad-item-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}
.ad-meta-info {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}
.ad-price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.ad-price-val {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--shopee-orange);
    font-size: 1rem;
}
.ad-orig-price {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-decoration: line-through;
}
.ad-cta-btn {
    background: var(--shopee-orange);
    color: #ffffff;
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s ease;
}
.ad-cta-btn:hover, .ad-cta-btn:active {
    background: var(--shopee-orange-hover);
}

/* ================= Bottom Fixed App Bar ================= */
.bottom-app-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 520px;
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 8px 0;
    z-index: 60;
}
.app-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-family: var(--font-heading);
    transition: color 0.15s ease;
}
.app-nav-item:hover, .app-nav-item.active {
    color: var(--accent-primary);
}
.app-nav-icon-svg {
    width: 20px;
    height: 20px;
}

/* ================= Chapter Drawer ================= */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}
.drawer-sheet {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 100%);
    width: 100%;
    max-width: 520px;
    max-height: 75vh;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    z-index: 201;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.85);
}
.drawer-backdrop.open .drawer-sheet {
    transform: translate(-50%, 0);
}
.drawer-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.drawer-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
}
.drawer-body {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.drawer-chap-item {
    padding: 12px 14px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}
.drawer-chap-item:hover, .drawer-chap-item.current {
    background: var(--bg-card);
    color: var(--accent-primary);
}

/* Settings Panel */
.settings-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    display: none;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-family: var(--font-heading);
}
.font-btn-group {
    display: flex;
    gap: 6px;
}
.btn-font-size {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
}
.btn-font-size.active {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
    font-weight: 700;
}
