:root {
    --bg: #050505;
    --card-bg: #121212;
    --glass-bg: rgba(20, 20, 20, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text: #ffffff;
    --text-muted: #999999;
    --accent: #ff4d4d;
    /* Brighter, more vibrant red for better legibility */
    /* News Red */
    --accent-blue: #007aff;
    --accent-glow: rgba(227, 27, 35, 0.3);

    --font-ui: 'Inter', -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, sans-serif;
    --font-news: 'Playfair Display', serif;

    --container-width: 1300px;
    --shadow-premium: 0 10px 40px rgba(0, 0, 0, 0.6);
}

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

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow-x: hidden;
}

/* Light Mode Support - Ultra Aggressive for Full Visibility */
body.dark-mode {
    /* Override CSS variables */
    --bg: #f5f5f5 !important;
    --card-bg: #ffffff !important;
    --glass-bg: rgba(255, 255, 255, 0.95) !important;
    --text: #000000 !important;
    --text-muted: #444444 !important;
    --accent: #e31b23 !important;

    /* Explicitly set body styles */
    background-color: #f5f5f5 !important;
    color: #000000 !important;
}

/* Light Mode - ALL TEXT ELEMENTS */
body.dark-mode,
body.dark-mode *,
body.dark-mode p,
body.dark-mode span,
body.dark-mode div,
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6,
body.dark-mode a,
body.dark-mode li {
    color: #000000 !important;
}

/* Light Mode - Links stay blue/clickable */
body.dark-mode a:not(.article-title) {
    color: #0066cc !important;
}

/* Light Mode - White Cards with dark text */
body.dark-mode .feed-card {
    background: #ffffff !important;
    border: 1px solid #ccc !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15) !important;
}

body.dark-mode .feed-card * {
    color: #000000 !important;
}

body.dark-mode .feed-card .article-title {
    color: #000000 !important;
}

body.dark-mode .feed-card .article-excerpt {
    color: #222222 !important;
}

body.dark-mode .feed-card .article-meta,
body.dark-mode .feed-card .article-date {
    color: #555555 !important;
}

/* Light Mode - Article Content Pages */
body.dark-mode .article-content,
body.dark-mode .article-content *,
body.dark-mode .article-content p,
body.dark-mode .article-content h1,
body.dark-mode .article-content h2,
body.dark-mode .article-content h3,
body.dark-mode .article-body,
body.dark-mode .article-body * {
    color: #000000 !important;
    background-color: transparent !important;
}

/* Light Mode - Article Titles */
body.dark-mode .article-title,
body.dark-mode .article-header h1 {
    color: #000000 !important;
}

/* Light Mode - White Header/Nav with dark text */
body.dark-mode .app-header,
body.dark-mode .nav-bar {
    background: #ffffff !important;
    border-bottom: 1px solid #d0d0d0 !important;
}

/* Light Mode - Hamburger Menu Icon (ULTRA CRITICAL) */
body.dark-mode .menu-toggle,
body.dark-mode .menu-toggle *,
body.dark-mode #menu-toggle,
body.dark-mode button.menu-toggle {
    color: #000000 !important;
    background: transparent !important;
}

body.dark-mode .menu-toggle svg,
body.dark-mode .menu-toggle svg *,
body.dark-mode .menu-toggle path,
body.dark-mode .menu-toggle line,
body.dark-mode .menu-toggle rect {
    stroke: #000000 !important;
    fill: #000000 !important;
    color: #000000 !important;
}

/* Light Mode - Gradient Red Title */
body.dark-mode .brand-section h1,
body.dark-mode .brand-section h1 a {
    background: linear-gradient(135deg, #e31b23 0%, #ff4d4d 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

/* Light Mode - Dark Nav Links */
body.dark-mode .nav-link,
body.dark-mode .sidebar-link,
body.dark-mode .nav-link *,
body.dark-mode .sidebar-link * {
    color: #000000 !important;
}

body.dark-mode .nav-link:hover,
body.dark-mode .sidebar-link:hover {
    background: #e8e8e8 !important;
}

/* Light Mode - Sidebar COMPLETE OVERRIDE */
body.dark-mode .sidebar,
body.dark-mode .sidebar * {
    background: #ffffff !important;
    color: #000000 !important;
}

body.dark-mode .sidebar-header,
body.dark-mode .sidebar-header * {
    color: #e31b23 !important;
}

body.dark-mode .sidebar-link {
    background: transparent !important;
}

/* Light Mode - Footer */
body.dark-mode .site-footer {
    background: #e0e0e0 !important;
    color: #555555 !important;
}

/* Hide hero article on mobile apps (iOS/Android WebView) */
@media (max-width: 768px) {
    .hero-article {
        display: none !important;
    }
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease-in-out, visibility 0.5s;
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-logo {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: breathe 3s ease-in-out infinite;
}

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-family: var(--font-ui);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes breathe {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* Typography Utilities */
.serif {
    font-family: var(--font-news);
}

.bold {
    font-weight: 700;
}

.italic {
    font-style: italic;
}

/* Header & Navigation */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #000;
    border-bottom: 1px solid var(--glass-border);
    padding: 12px 0 0 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 0 24px 12px;
    padding-top: calc(env(safe-area-inset-top) / 2);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.app-header h1 {
    font-family: var(--font-news);
    font-size: 28px;
    /* Fixed size, ignores root font scaling */
    font-weight: 900;
    letter-spacing: -1px;
    color: #fff;
    margin: 0;
    text-transform: uppercase;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.refresh-info {
    font-size: 11px;
    /* Fixed size, ignores root font scaling */
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 8px;
    /* Vertical separation from settings icon */
}

#sync-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#sync-btn:hover {
    background: var(--accent);
    transform: rotate(180deg);
}

/* Nav Bar Styles - Premium Editorial Style */
.nav-bar {
    background: #0a0a0a;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    width: 100%;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0;
    padding: 0 24px;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
    flex-wrap: wrap;
    flex: 1;
}

.nav-menu::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.nav-item {
    position: relative;
    flex-shrink: 0;
}

.nav-link {
    display: block;
    padding: 14px 15px;
    color: #fff;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    opacity: 0.6;
    white-space: nowrap;
}

.nav-link:hover {
    opacity: 1;
    color: var(--accent);
}

.nav-link.active {
    opacity: 1;
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 -3px 0 var(--accent);
}

/* Sidebar Navigation Styles */
.mobile-menu-toggle {
    display: none;
    cursor: pointer;
    color: #fff;
    padding: 10px;
    margin-right: 10px;
}

.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-drawer {
    position: fixed;
    top: 0;
    left: -320px;
    width: 320px;
    height: 100%;
    background: #0a0a0a;
    z-index: 2200;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
}

.sidebar-drawer.active {
    transform: translateX(320px);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: calc(24px + env(safe-area-inset-top));
}

.sidebar-title {
    font-family: var(--font-news);
    font-size: 1.4rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--accent);
}

.close-sidebar {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.close-sidebar:hover {
    opacity: 1;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
}

.sidebar-section-label {
    padding: 0 24px 8px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.sidebar-menu {
    list-style: none;
    margin-bottom: 32px;
}

.sidebar-link {
    display: block;
    padding: 12px 24px;
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent);
}

.sidebar-link.active {
    background: rgba(227, 27, 35, 0.1);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 700;
}

/* Dropdown */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #0f0f0f;
    min-width: 240px;
    display: none;
    flex-direction: column;
    z-index: 2000;
    border: 1px solid var(--glass-border);
    padding: 8px 0;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-premium);
}

.nav-item:hover .dropdown-menu {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

.dropdown-item {
    padding: 12px 24px;
    color: #bbb;
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.2s;
    font-weight: 500;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    padding-left: 28px;
}

.dropdown-item.active {
    color: var(--accent);
    font-weight: 700;
}

/* Search */
.search-container {
    display: flex;
    align-items: center;
}

#article-search {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 8px 18px;
    color: #fff;
    width: 240px;
    font-size: 0.8rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#article-search:focus {
    width: 300px;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.34);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

/* Hero Section */
.hero-news {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-premium);
}

.hero-featured {
    position: relative;
    height: 500px;
    text-decoration: none;
    color: #fff;
}

.hero-image {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1a1a1a;
}

.hero-image img {
    transition: transform 0.6s cubic-bezier(0.2, 0, 0.2, 1);
}

.hero-featured:hover .hero-image img {
    transform: scale(1.03);
}

.hero-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.98) 0%, rgba(0, 0, 0, 0.6) 40%, rgba(0, 0, 0, 0) 100%);
}

.hero-overlay h2 {
    font-family: var(--font-news);
    font-size: 3rem;
    line-height: 1.1;
    font-weight: 900;
    margin-bottom: 15px;
    letter-spacing: -1.5px;
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
}

.hero-sidebar {
    padding: 30px;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    font-weight: 800;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* Feed Grid */
.feed-container {
    max-width: var(--container-width);
    margin: 40px auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.news-card {
    background: transparent;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}

.card-image-wrap {
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 15px;
    aspect-ratio: 16/9;
    background-color: #1a1a1a;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.5s cubic-bezier(0.2, 0, 0.2, 1);
    display: block;
}

.news-card:hover .card-image {
    transform: scale(1.05);
}

.card-content {
    padding: 0;
}

.source-tag {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 900;
    margin-bottom: 8px;
    display: inline-block;
    color: var(--accent);
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.news-card h2 {
    font-family: var(--font-news);
    font-size: 1.4rem;
    line-height: 1.25;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.news-card time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    display: block;
}

/* Reader View */
.reader-mode {
    background: var(--bg);
}

.brand-section h1 {
    font-family: var(--font-news);
    font-size: 2.2rem !important;
    font-weight: 900;
    letter-spacing: -2px;
    background: linear-gradient(90deg, #fff 0%, #888 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

.back-btn {
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.back-btn .arrow {
    font-size: 1.2rem;
    line-height: 0;
    margin-top: -2px;
}

.back-btn:hover {
    opacity: 1;
    background: var(--accent);
    transform: translateX(-3px);
}

.article-reader {
    max-width: 800px;
    margin: 40px auto 40px;
    padding: 0 24px;
    text-align: left;
}

.article-reader h1 {
    font-family: var(--font-news);
    font-size: 3.5rem;
    line-height: 1.1;
    font-weight: 900;
    margin-bottom: 20px;
    letter-spacing: -1.5px;
    color: #fff;
    text-align: left;
}

.article-container {
    max-width: 800px;
    margin: 0 auto 100px;
    padding: 0 24px;
    line-height: 1.6;
    color: #e0e0e0;
}

/* Global link styling - use lighter blue for visibility */
a {
    color: #66b3ff;
    text-decoration: none;
}

a:hover {
    color: #99ccff;
    text-decoration: underline;
}

/* Article content links */
.article-container a {
    color: #66b3ff;
    text-decoration: underline;
    font-weight: 600;
}

.article-container a:hover {
    color: #99ccff;
}

/* Mobile */
@media (max-width: 1024px) {
    .feed-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero-news {
        grid-template-columns: 1fr;
    }

    .hero-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }

    .desktop-only {
        display: none !important;
    }

    .header-top {
        padding: 0 15px 10px;
    }

    .app-header h1 {
        font-size: 1.4rem;
    }

    .article-container img {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 20px auto;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .feed-container {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .hero-overlay h2 {
        font-size: 2rem;
    }

    .article-reader h1 {
        font-size: 2.2rem;
    }

    .article-container p {
        font-size: 1.15rem;
    }
}

/* AdMob Placeholder Styles */
.ad-container-sticky {
    position: sticky;
    bottom: 0;
    width: 100%;
    background: #000;
    border-top: 1px solid var(--glass-border);
    padding: 10px 0;
    display: flex;
    justify-content: center;
    z-index: 999;
}

.ad-placeholder {
    width: 320px;
    height: 50px;
    background: #1a1a1a;
    border: 1px dashed #333;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Pagination Styles */
.pagination {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
    padding: 30px 0;
}

.pagination-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.pagination-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.pagination-info {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Footer Styles */
.site-footer {
    background: #0a0a0a;
    border-top: 1px solid var(--glass-border);
    padding: 40px 24px;
    margin-top: 60px;
}

.footer-content {
    max-width: var(--container-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.85rem;
}

.footer-links a {
    color: #999;
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 500;
}

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

.footer-separator {
    color: #444;
}

.footer-copyright {
    font-size: 0.75rem;
    color: #666;
    text-align: center;
}

@media (max-width: 768px) {
    .site-footer {
        padding: 30px 15px;
    }

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

    .footer-separator {
        display: none;
    }
}