/* --- Dark Mode Toggle Styles --- */
.fixed-mode-btn {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    z-index: 99999 !important;
    background: #333 !important;
    color: white !important;
    border: 0px solid #fff !important;
    padding: 10px 18px !important;
    border-radius: 30px !important;
    cursor: pointer !important;
    font-weight: bold !important;
    display: block !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
}

.fixed-mode-btn:hover {
    background: #dc2626 !important;
    transform: scale(1.05);
}

/* --- THE FINAL DARK MODE FIX --- */
body.dark-mode,
body.dark-mode .admin-layout {
    background-color: #121212 !important;
    color: #e0e0e0 !important;
}

/* 1. Force Header & Logo to White */
body.dark-mode header {
    background: #1a1a1a !important;
    border-bottom-color: #333 !important;
}

body.dark-mode .logo h1,
body.dark-mode .logo p,
body.dark-mode .admin-header h1 {
    color: #ffffff !important;
}

body:not(.dark-mode) .logo h1 {
    /* #1a1a1a is very dark. 
       #444444 or #555555 is roughly 80% less 'heavy' 
    */
    color: #444444 !important;

    /* Keep the sharpening properties we set earlier */
    font-weight: 500 !important;
    -webkit-font-smoothing: subpixel-antialiased;
    letter-spacing: -0.02em;
}

body:not(.dark-mode) .logo p {
    color: #777777;
    /* Soften the subtext as well */
}

/* 2. Remove the "White Boxes" everywhere (Main site & Admin) */
body.dark-mode .main-content,
body.dark-mode .sidebar-section,
body.dark-mode .admin-content,
body.dark-mode .article-item,
body.dark-mode .real-estate-ad,
body.dark-mode .form-section,
body.dark-mode .real-estate-ads,
body.dark-mode .korean-business-ad {
    background-color: #1e1e1e !important;
    /* Using a subtle dark gray instead of transparent */
    background: #1e1e1e !important;
    box-shadow: none !important;
    border: 1px solid #333 !important;
}

/* 3. Fix invisible Admin Form text */
body.dark-mode .form-group label,
body.dark-mode .form-section h3,
body.dark-mode .help-text {
    color: #ffffff !important;
}

body.dark-mode .form-control {
    background: #2d2d2d !important;
    color: #ffffff !important;
    border: 1px solid #444 !important;
}

/* 4. Fix Dashboard "Quick Access" box */
body.dark-mode div[style*="background: #f8f9fa"] {
    background-color: #252525 !important;
    color: #ffffff !important;
}

/* --- UNIVERSAL LOGO COLOR FIX --- */
body.dark-mode header .logo h1,
body.dark-mode header .logo p,
body.dark-mode .admin-sidebar h2,
body.dark-mode .admin-header h1 {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

/* Remove the specific white backgrounds shown in your screenshots */
body.dark-mode .real-estate-ads,
body.dark-mode .admin-content,
body.dark-mode div[style*="background: white"],
body.dark-mode div[style*="background: #ffffff"] {
    background-color: #1a1a1a !important;
    border: 1px solid #333 !important;
}

/* Add these at the bottom of your <style> tag */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

body.dark-mode .article-content,
body.dark-mode .related-item {
    background: #1e1e1e !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
}

body.dark-mode .article-title,
body.dark-mode .related-content h4 a {
    color: #ffffff !important;
}

body.dark-mode .article-body,
body.dark-mode .related-summary {
    color: #cccccc !important;
}

body.dark-mode .article-header {
    border-bottom-color: #333;
}

body.dark-mode .article-navigation {
    border-top-color: #333 !important;
}

body.dark-mode .article-navigation a div,
body.dark-mode .article-navigation span {
    color: #ffffff !important;
}

body.dark-mode .article-navigation div div:first-child {
    color: #aaa !important;
    /* PREVIOUS/NEXT labels */
}

@font-face {
    font-family: 'CR';
    src: url('/fonts/CR.woff2') format('woff2'),
        url('/fonts/CR.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: white;
    color: black;
    padding: 20px 0;
    border-bottom: 0px solid #eee;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.logo {
    text-align: center;
    padding: 5x 0;
}

/* Update your Logo Styles in style.css */
.logo h1 {
    font-family: 'CR', 'Times New Roman', serif !important;
    /* Increased size from 2.8rem to 3.4rem */
    font-size: 3.4rem !important;
    margin: 0;
    line-height: 1.1;

    /* Keep the sharpening fixes */
    font-weight: 500 !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #f9f9f9 !important;
    letter-spacing: -0.02em;
}

.logo p {
    /* Slightly larger subtext to match the bigger heading */
    font-size: 1rem;
    color: #bbb;
    margin: 2px 0 0 0;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* Apply the Logo Font to the Main Footer Text */
.footer-logo .logo-main {
    /* Keeping your specific 'CR' font */
    font-family: 'CR', 'Times New Roman', serif !important;
    font-size: 2.5rem;
    margin: 0;

    /* LIGHT BLEED FIX: 
       Using 90-95% white makes the vector lines look much crisper 
       than pure #ffffff on a dark background. */
    color: rgba(255, 255, 255, 0.92);

    /* SHARPENING: 
       This reduces the 'weight' the browser adds to bold text */
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    /* KERN FIX: 
       Serif fonts in logos often look better with slightly 
       tighter letter spacing to feel 'vectored'. */
    letter-spacing: -0.02em;

    /* DISABLE SHADOWS: 
       Ensure no inherited text-shadow is adding to the blur. */
    text-shadow: none !important;
}

/* Subtext adjustment to match the clean logo look */
.footer-logo .logo-subtext {
    letter-spacing: 2px;
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Target the maple leaf specifically */
.maple-leaf-icon {
    /* This complex filter shifts black/dark SVG colors to exactly #dc2626 */
    filter: invert(21%) sepia(91%) saturate(6146%) hue-rotate(354deg) brightness(90%) contrast(96%) !important;

    /* Ensure existing size/position rules remain */
    width: 0.7em;
    height: 0.7em;
    vertical-align: 2px;
    margin: 0 4px;
    display: inline-block;
}

/* Navigation */
nav {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    padding: 15px 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    position: relative;
    /* Default position */
}

nav.fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
}

/* Add body class when nav is fixed */
body.nav-fixed {
    padding-top: 70px;
    /* Adjust this value to match your nav height */
}


/* Main Layout - Add consistent top spacing */
main {
    padding: 40px 0;
    min-height: calc(100vh - 200px);
    /* Prevent content jumping */
}

/* 1. Reset the Nav and Container */
nav {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    /* Keep your gradient or current color */
    padding: 0 !important;
    /* CRITICAL: Remove padding so red block touches edges */
    height: 50px;
    /* Adjust height to your preference */
}

nav .container {
    height: 100%;
    display: flex;
    align-items: center;
}

nav ul {
    display: flex;
    height: 100%;
    list-style: none;
    margin: 0;
    padding: 0;
}

nav ul li {
    height: 100%;
    /* Ensure list items take full height */
}

/* 2. Style the links as full-height blocks */
nav ul li a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    /* Fills the vertical space */
    padding: 0 20px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s;
    border-radius: 0 !important;
    /* Square edges for the "block" look */
}

/* 3. THE ACTIVE HIGHLIGHT: The Solid Red Block */
/* Replace #dc2626 with your specific brand red if different */
nav ul li a.active-tab {
    background-color: #dc2626 !important;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
    /* Subtle depth at bottom */
}

/* 1. Reset the Navigation Container */
nav {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    padding: 0 !important;
    /* REMOVE padding so blue can touch edges */
    height: 50px !important;
    /* Set a strict height */
    overflow: hidden;
    /* Prevents the blue from seeping out */
}

/* 2. Reset the List and Items */
nav ul {
    display: flex !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none;
    align-items: stretch;
    /* Forces children to fill full height */
}

nav ul li {
    height: 100% !important;
    margin: 0 !important;
}

/* 3. Style the Link to be the "Block" */
nav ul li a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    height: 100% !important;
    /* Fills the 50px height exactly */
    padding: 0 20px !important;
    color: white;
    text-decoration: none;
}

/* 4. The Active State */
/* Update your active-tab rule */
/* --- High-Priority Navigation Highlights --- */

/* This targets the link directly to ensure the blue block covers the red bar */
nav ul li a.active-tab {
    background-color: #1a365d !important;
    /* Your signature Blue */
    background: #1a365d !important;
    /* Overrides the red gradient */
    color: #ffffff !important;
    /* Force white text */

    /* Ensure it fills the full 50px height of your nav bar */
    height: 100% !important;
    display: flex !important;
    align-items: center;
    justify-content: center;

    /* Optional: subtle depth */
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2) !important;
}

/* Ensure the hover effect doesn't flicker when on the active tab */
nav ul li a.active-tab:hover {
    background-color: #244a7d !important;
    opacity: 1 !important;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    margin-bottom: 20px;
}

.page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 15px;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    text-decoration: none;
    font-weight: bold;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.page-btn:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fff5f5;
}

.page-btn.active {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
}

/* Dark Mode Support */
body.dark-mode .page-btn {
    background: #1e1e1e;
    border-color: #333;
    color: #eee;
}

body.dark-mode .page-btn:hover {
    background: #2a2a2a;
    border-color: #dc2626;
}

body.dark-mode .page-btn.active {
    background: #dc2626;
    color: white;
}

/* IMPORTANT FIX: Add spacing between nav and content */
.content-layout {
    display: grid;
    grid-template-columns: 2fr 300px;
    gap: 30px;
    align-items: start;
    margin-top: 20px;
    /* This adds the missing space at the top */
}

/* Alternative solution: Always add top spacing */
.content-wrapper {
    margin-top: 20px;
    /* Consistent spacing from navigation */
}

nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    justify-content: center;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 0px;
    font-weight: 500;
}

nav a:hover {
    background: #1a365d;
}

/* Main Layout - Articles on left/center, ads on right */
main {
    padding: 40px 0;
}

.content-layout {
    display: grid;
    grid-template-columns: 2fr 300px;
    gap: 30px;
    align-items: start;
}

/* Main Content - Now takes up more space */
.main-content {
    background: white;
    border-radius: 0px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.section-header {
    margin-bottom: 30px;
    border-bottom: 3px solid #dc2626;
    padding-bottom: 15px;
}

.section-header h2 {
    color: #333 !important;
    font-size: 1.8rem;
}

/* Override for Dark Mode */
body.dark-mode .section-header h2 {
    color: #ffffff !important;
}

/* Articles List */
.articles-list {
    display: flex;
    flex-direction: column;
    gap: 0px !important;
    /* Reduced from 25px to 10px for minimal spacing */
}

.article-item {
    display: flex;
    gap: 10px;
    padding: 15px !important;
    border: none !important;
    /* Keep subtle border */
    border-radius: 0px !important;
    transition: all 0.3s;
    border-bottom: 1px solid #eee;
    /* Light grey for light mode */
    padding-bottom: 20px;
    margin-bottom: 20px;

    height: 180px !important;
    overflow: hidden;
}

/* Remove the red border from featured articles */
.article-item.featured {
    background: #fff;
    /* Optional: Add a subtle indicator for featured articles instead */
    position: relative;
}

.article-image {
    flex-shrink: 0;
    width: 200px;
    height: 130px !important;
    overflow: hidden;
    border-radius: 0px !important;
}

.article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0 !important;
}

.article-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.article-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.category {
    background: #dc2626;
    color: white;
    padding: 3px 8px;
    border-radius: 0px;
    font-size: 0.75rem;
    font-weight: 500;
}


.date,
.views {
    color: #666;
}

.article-content h3 {
    margin-bottom: 10px;
    line-height: 1.4;
}

.article-content h3 a {
    color: #333;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 600;
}

/* This targets the clickable titles inside the articles */
body.dark-mode .article-content h3 a {
    color: #ffffff !important;
}

body.dark-mode .article-content h3 a:hover {
    color: #dc2626 !important;
    /* A brighter red so it's easier to see on dark backgrounds */
}

.article-content h3 a:hover {
    color: #dc2626;
}

/* Force article summaries to exactly 2 lines with ellipses */
.summary {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* Limits to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.6;
    max-height: 3.2em;
    /* line-height * 2 */
    word-break: break-all;
    /* Ensures Korean text wraps correctly */
}

/* Ensure the article item adjusts height naturally */
.article-item {
    height: auto !important;
    min-height: unset !important;
}

.article-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.author {
    color: #888;
}

.read-more {
    color: #dc2626;
    text-decoration: none;
    font-weight: 500;
}

.read-more:hover {
    text-decoration: underline;
}

/* Trending Section Bar */
.trending-middle-bar {
    width: 100%;
    max-width: 1200px;
    margin: 40px auto;
    padding: 30px;
    background: white;
    border: 1px solid #eee;
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Side-by-side lists */
    gap: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Dark Mode adjustment */
body.dark-mode .trending-middle-bar {
    background: #1e1e1e;
    border-color: #333;
    box-shadow: none;
}

.trending-column h3 {
    color: #dc2626;
    font-size: 1.2rem;
    margin-bottom: 20px;
    border-bottom: 2px solid #dc2626;
    padding-bottom: 10px;
    font-weight: bold;
}

.trending-middle-bar .news-list {
    list-style: none;
    padding: 0;
}

.trending-middle-bar .news-list li {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}

body.dark-mode .trending-middle-bar .news-list li {
    border-bottom-color: #2a2a2a;
}

.trending-middle-bar .news-rank {
    color: #dc2626;
    font-weight: 900;
    margin-right: 15px;
    width: 20px;
}

.trending-middle-bar .news-list li a {
    text-decoration: none;
    color: #333;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark-mode .trending-middle-bar .news-list li a {
    color: #eee;
}

.trending-middle-bar .news-list li a:hover {
    color: #dc2626;
}

/* Mobile: Stack the columns */
@media (max-width: 768px) {
    .trending-middle-bar {
        grid-template-columns: 1fr;
        gap: 30px;
        margin: 20px auto;
    }

    .trending-list li {
        display: flex !important;
        align-items: flex-start;
        padding: 10px 0;
    }

    .rank {
        /* This is the magic part: it forces the number into a fixed 25px space */
        flex: 0 0 25px; 
        font-weight: 800;
        display: inline-block;
    }

    .trending-link {
        flex: 1;
        display: flex;
        align-items: flex-start;
        /* Prevents the text from wrapping in a way that breaks the line */
        overflow: hidden; 
    }

    .tab-category-prefix {
        flex: 0 0 auto;
        white-space: nowrap;
        margin-right: 8px; /* Space between [Category] and Title */
    }
}

/* =========================================
   Desktop Defaults (Hide mobile elements)
   ========================================= */
.mobile-current-label,
#mobile-menu-btn {
    display: none;
}

/* Ensure the nav container can anchor the absolute dropdown */
.nav-flex-container {
    position: relative; 
}

/* =========================================
   Mobile Overrides (Max-width 768px)
   ========================================= */
@media (max-width: 768px) {
    /* 1. Hide Desktop Elements */
    .search-bar {
        display: none !important;
    }

    /* 2. Show Mobile Elements */
    .mobile-current-label {
        display: block;
        font-weight: bold;
        font-size: 1.1rem;
        /* Assuming your nav bar text color is white, adjust if needed */
        color: #fff; 
    }

    #mobile-menu-btn {
        display: block;
        font-size: 24px;
        cursor: pointer;
        color: #fff; 
        user-select: none;
    }

    /* 3. Transform Desktop Nav into Mobile Dropdown */
    #nav-list {
        display: none; /* Hidden by default on mobile */
        position: absolute;
        top: 100%; /* Drops directly below the nav bar */
        left: 0;
        width: 100%;
        background-color: #ffffff;
        flex-direction: column;
        margin: 0;
        padding: 0;
        list-style: none;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        z-index: 1000;
    }

    /* 4. Show the dropdown when JS adds the 'active' class */
    #nav-list.active {
        display: flex !important;
    }

    /* 5. Style the dropdown links */
    #nav-list li {
        width: 100%;
        text-align: left;
    }

    #nav-list li a {
        display: block;
        padding: 12px 20px;
        color: #333333;
        text-decoration: none;
        border-bottom: 1px solid #eeeeee;
    }

    #nav-list li a:hover {
        background-color: #f8f9fa;
    }
}

/* 1. Default Styles (Light Mode) */
.trending-tabs-box {
    background: #ffffff;
    /* White background */
    border: 1px solid #ddd;
    overflow: hidden;
    width: 100%;
    margin-top: 20px;
}

.trending-tabs-box .tabs-header {
    display: flex;
    background: #f5f5f5;
    /* Light grey header */
    border-bottom: 1px solid #ddd;
}

.trending-tabs-box .tab-btn {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    color: #666;
    /* Subtle grey for inactive */
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.3s;
}

.trending-tabs-box .tab-btn.active {
    color: #dc2626;
    /* Brand Red */
    border-bottom: 3px solid #dc2626;
    background: #fff;
}

.trending-list li {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
}

.trending-list .rank {
    color: #dc2626;
    font-weight: 900;
    width: 35px;
    font-size: 1.1rem;
}

.trending-list li a {
    color: #333;
    /* Dark text for light background */
    text-decoration: none;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 2. Dark Mode Overrides (Triggered by .dark-mode class) */
body.dark-mode .trending-tabs-box {
    background: #1e1e1e;
    border-color: #333;
}

body.dark-mode .trending-tabs-box .tabs-header {
    background: #252525;
    border-bottom: 1px solid #333;
}

body.dark-mode .trending-tabs-box .tab-btn {
    color: #888;
}

body.dark-mode .trending-tabs-box .tab-btn.active {
    color: #fff;
    background: rgba(220, 38, 38, 0.1);
}

body.dark-mode .trending-list li {
    border-bottom: 1px solid #2a2a2a;
}

body.dark-mode .trending-list li a {
    color: #eee;
}

/* Right Sidebar - Ads only */
.right-sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.sidebar-section {
    background: white;
    border-radius: 0px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-section h3 {
    color: #dc2626;
    margin-bottom: 15px;
    font-size: 1.1rem;
    border-bottom: 0px solid #dc2626;
    padding-bottom: 8px;
    text-align: center;
}

/* Ad Sections */
.ad-section {
    text-align: center;
}

.ad-banner {
    margin-top: 15px;
}

.ad-placeholder {
    background: #f0f0f0;
    border: 2px dashed #ccc;
    padding: 40px 20px;
    border-radius: 0px;
    color: #888;
}

.ad-placeholder p {
    font-weight: bold;
    margin-bottom: 5px;
}

/* Real Estate Ads Section at Bottom */
.real-estate-ads {
    margin-top: 50px;
    background: white;
    border-radius: 0px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.real-estate-ads h2 {
    color: #000000 !important;
    font-size: 1.8rem;
    margin-bottom: 30px;
    text-align: center;
    border-bottom: 3px solid #dc2626;
    padding-bottom: 15px;
}

/* Dark Mode Override (Keep White) */
body.dark-mode .real-estate-ads h2 {
    color: #ffffff !important;
}

.real-estate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

.real-estate-ad {
    border: 1px solid #eee;
    border-radius: 0px;
    overflow: hidden;
    transition: all 0.3s;
    background: #fafafa;
}

/* Update the container to have a fixed height */
.real-estate-image {
    width: 100%;
    height: 200px;
    /* This keeps all house boxes the same height */
    overflow: hidden;
    background: #f0f0f0;
    border-bottom: 1px solid #eee;
    display: block;
    /* Remove flex since we aren't centering text anymore */
}

/* Make the link tag act as a container for the image */
.real-estate-image a {
    display: block;
    width: 100%;
    height: 100%;
}

/* Ensure the image fills the space without stretching or distorting */
.real-estate-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* This is the key fix */
    display: block;
    transition: transform 0.3s ease;
}

.real-estate-content {
    padding: 20px;
}

.real-estate-content h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.real-estate-content p {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 10px;
}

.real-estate-price {
    color: #dc2626;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 30px 0;
    margin-top: 60px;
}

.footer-bottom p {
    font-size: 0.75rem !important;
    /* Makes it smaller (default is usually 1rem) */
    opacity: 0.7;
    /* Dims the text slightly for a cleaner look */
    letter-spacing: 0.5px;
    /* Adds a bit of space between letters for readability */
    margin-top: 10px;
    font-weight: 400;
    /* Ensures it isn't bold */
}

/* Korean Business Ads */
/* --- Clean Business Ads (Minimalist) --- */

/* Fix the sidebar container background for these ads */
body.dark-mode .sidebar-section,
.sidebar-section {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* This is the box for the ad */
.ad-link {
    display: block !important;
    width: 100% !important;
    margin-bottom: 20px !important;
    text-decoration: none !important;
}

/* This forces the full image to be visible */
.ad-link img {
    width: 100% !important;
    height: auto !important;
    /* Let height adjust naturally */
    max-height: 180px !important;
    /* Limits how "tall" the ad can get */
    object-fit: contain !important;
    /* SHOWS THE WHOLE PHOTO */
    display: block !important;
    background-color: transparent !important;
    /* Removes any dark boxes behind the photo */
    border-radius: 0px;
}

/* Non-clickable ad container */
.ad-link-no-click {
    display: block !important;
    width: 100% !important;
    margin-bottom: 20px !important;
}

.ad-link-no-click img {
    width: 100% !important;
    height: auto !important;
    max-height: 180px !important;
    object-fit: contain !important;
    display: block !important;
    border-radius: 0px;
    cursor: default;
    /* Shows it's not clickable */
}

/* --- Tighter Sidebar Ad Spacing --- */

/* --- UNIVERSAL SIDEBAR ADS (Matching Index) --- */

.uniform-ad-column {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    /* Space between ads */
    width: 100% !important;
}

.uniform-ad-item {
    width: 100% !important;
}

.ad-link-wrapper {
    display: block !important;
    width: 100% !important;
    line-height: 0;
    /* Removes bottom ghost padding */
    text-decoration: none !important;
}

.ad-link-wrapper img {
    width: 100% !important;
    height: auto !important;
    /* Let the height be determined by the image ratio */
    display: block !important;
    border-radius: 0px;
    transition: opacity 0.2s ease;
}

.ad-link-wrapper:hover img {
    opacity: 0.9;
}

/* Remove or Comment Out the old .ad-link { height: 160px } rule 
   if it exists elsewhere, as it forces the "Too Big/Stretched" look */
.ad-link,
.ad-link-no-click {
    display: block !important;
    width: 100% !important;
    /* Ensure no margin-bottom is pushing ads away */
    margin-bottom: 0 !important;
}

.ad-link img,
.ad-link-no-click img {
    width: 100% !important;
    height: auto !important;
    max-height: 180px !important;
    object-fit: contain !important;
    display: block !important;
}

/* Dark Mode adjustment for the subtle border */
body.dark-mode .ad-link {
    border-color: #333;
}

/* --- UNIVERSAL LINK RESET --- */

/* 1. Remove blue color and underlines from ALL ad links */


/* 4. Fix for other text (address, phone) so they don't turn blue if wrapped in <a> */
.business-contact a,
.real-estate-contact a {
    color: inherit !important;
    text-decoration: none !important;
}

/* Responsive Design */
@media (max-width: 1024px) {

    /* 1. Set the main layout to flex-column */
    .content-layout {
        display: flex;
        flex-direction: column;
    }

    /* 2. Show Articles FIRST */
    .main-content {
        order: 1;
        width: 100%;
    }

    /* 3. Show Real Estate Ads SECOND */
    /* This targets the section directly */
    .real-estate-ads {
        order: 2;
        width: 100%;
        margin-top: 40px;
    }

    /* 4. Show Sidebar LAST */
    .right-sidebar {
        order: 3;
        position: static;
        display: flex;
        flex-direction: column;
        width: 100%;
        margin-top: 40px;
    }

    /* Override any previous "order: -1" rules */
    .right-sidebar {
        order: 3 !important;
    }
}

@media (max-width: 768px) {

    /* Ensure the grid doesn't break on small screens */
    .real-estate-grid {
        grid-template-columns: 1fr;
    }

    /* Make article images full width on mobile */
    .article-item {
        flex-direction: column;
    }

    .article-image {
        width: 100%;
        height: 200px;
    }
}

@media (max-width: 1024px) {
    .content-layout {
        grid-template-columns: 1fr;
    }

    .right-sidebar {
        order: -1;
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* Ensure the title has enough space from the image */
.business-content {
    padding: 20px !important;
    /* Adds the padding you like from the homepage */
}

.business-name {
    margin-bottom: 8px;
    /* Gap between name and category */
}

@media (max-width: 768px) {
    .article-item {
        flex-direction: column;
    }

    .article-image {
        width: 100%;
        height: 200px;
    }

    .real-estate-grid {
        grid-template-columns: 1fr;
    }

    nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    nav a {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    nav .container {
        flex-direction: column;
        /* Stack links and search bar vertically on mobile */
        gap: 15px;
    }

    nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        /* Tighter gap for mobile */
    }

    .search-bar-container {
        width: 100%;
        justify-content: center;
    }
}

/* Remove shadows from article boxes in dark mode */
body.dark-mode .article-item,
body.dark-mode .article-content {
    box-shadow: none !important;
    background-color: #1e1e1e !important;
    /* Keep the subtle dark gray background */
    margin-bottom: 0px !important;
    /* Keep your 2mm gap */
    outline: none !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid #333;
    /* Darker grey for dark mode */
}

body.dark-mode .article-content {
    background: transparent !important;
    border: none !important;
}

body.dark-mode .article-item.featured {
    border: none !important;
}

/* If the line is specifically at the bottom of the content */
body.dark-mode .article-footer {
    border-top: none !important;
}

/* Ensure the outer box has a clean, dark border instead */
body.dark-mode .article-item {
    margin-bottom: 15px;
}

/* 1. Change Height to Min-Height */
.article-item {
    min-height: 180px !important;
    /* Minimum uniform size */
    height: auto !important;
    /* Allows it to grow if text is long */
    display: flex;
    align-items: stretch;
    /* Makes text and image area match height */
    padding: 20px !important;
    overflow: visible !important;
    /* Prevents the "slicing" effect */
}

/* 2. Fix the Text Area */
.article-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-left: 20px;
    /* Ensure no hidden overflow here */
    overflow: visible;
}

/* 3. Improved Line Clamping */
.summary {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* Show exactly 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* This handles the "..." correctly */

    line-height: 1.6;
    /* Better spacing for Korean text */
    /* REMOVE max-height entirely to prevent slicing */

    margin-top: 10px;
    margin-bottom: 15px !important;
    color: #aaa !important;
}

/* 4. Ensure the footer stays at the bottom */
.article-footer {
    margin-top: auto;
    /* Pushes "자세히 보기" to the bottom of the box */
    padding-top: 10px;
}

.view-more-ads-btn {
    display: inline-block;
    padding: 12px 35px;
    background: #dc2626 !important;
    /* Solid Brand Red */
    color: #ffffff !important;
    /* White Text */
    border: none !important;
    border-radius: 0px;
    text-decoration: none;
    font-weight: bold;
    box-shadow: none !important;
    /* Remove the pinkish glow */
    transition: background 0.3s ease;
}

.view-more-ads-btn:hover {
    background: #991b1b !important;
    /* Darker Red on Hover */
    color: #ffffff !important;
}

/* Ensure Button stays red in Dark Mode */
body.dark-mode .view-more-ads-btn {
    background: #dc2626 !important;
    color: #ffffff !important;
}

/* --- Force Sidebar to stay on the right --- */
.content-layout {
    display: grid !important;
    /* This creates two columns: the first one takes remaining space, the second is 300px */
    grid-template-columns: 1fr 300px !important;
    gap: 30px;
    align-items: start;
}

/* Ensure the sidebar container has width */
.right-sidebar {
    width: 300px !important;
    display: block !important;
}

/* On Mobile, stack them instead of hiding */
@media (max-width: 1024px) {
    .content-layout {
        grid-template-columns: 1fr !important;
    }

    .right-sidebar {
        width: 100% !important;
    }
}

/* --- FINAL CLEAN SIDEBAR ADS --- */
/* 1. Reset the layout to ensure it's on the right */
.content-layout {
    display: grid !important;
    grid-template-columns: 1fr 300px !important;
    gap: 30px;
    align-items: start;
    width: 100%;
}

/* 2. Ensure the sidebar container is visible */
.right-sidebar {
    width: 300px !important;
    display: block !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

/* 3. The Ad Column */
.uniform-ad-column {
    display: flex !important;
    flex-direction: column;
    gap: 20px;
}

/* 4. The Individual Ad Tile */
.ad-link {
    display: block !important;
    width: 100%;
    height: 160px;
    /* Force uniform height */
    overflow: hidden;
    border-radius: 0px;
    background: #252525;
    /* Dark placeholder if image fails */
    border: 1px solid #333;
    /* Clean border for dark mode */
}

.ad-link img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    /* Crops image to fit the tile perfectly */
    display: block !important;
    opacity: 1 !important;
    /* Force visibility */
    visibility: visible !important;
}

.ad-link:hover img {
    transform: scale(1.05);
    filter: brightness(1.1);
    transition: all 0.3s ease;
}

/* Mobile Fix */
@media (max-width: 1024px) {
    .content-layout {
        grid-template-columns: 1fr !important;
    }

    .right-sidebar {
        width: 100% !important;
        margin-top: 30px;
    }
}

/* Enhanced Modal Styles */
.modal-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    /* Dark background for the image frame */
    min-height: 300px;
}

.full-res-ad {
    max-width: 100%;
    height: auto;
    display: block;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.modal-footer-hint {
    padding: 15px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

body.dark-mode .modal-footer-hint {
    background: #252525;
    border-top: 1px solid #333;
    color: #888;
}

.modal-footer-hint p {
    font-size: 0.85rem;
    margin: 0;
    color: #666;
}

/* Animation for the popup */
.modal-content {
    animation: modalFadeIn 0.3s ease-out;
}

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

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

/* --- UNIVERSAL WEATHER WIDGET STYLES --- */
.weather-star-style {
    position: absolute;
    top: 15px;
    left: 20px;
    display: flex;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1;
    z-index: 100;

    /* DEFAULT (Light Mode Colors) */
    color: #1a1a1a;
}

#weather-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    /* Forces the space to stay open */
    margin-right: 8px;
    vertical-align: middle;
}

#weather-icon img {
    width: 100% !important;
    height: 100% !important;
    display: block !important;

    filter: drop-shadow(0px 0px 1px rgba(0, 0, 0, 0.5)) drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.15)) !important;

    transition: filter 0.3s ease;
}

.city-label {
    font-size: 1rem;
    color: #333;
    /* Dark Gray for Light Mode */
    margin-right: 4px;
}

.weather-temp {
    font-size: 1rem;
    color: #000000;
    /* Black for Light Mode */
}

.separator {
    color: #ccc;
    /* Subtle gray bar */
    margin: 0 12px;
    font-weight: 300;
}

.date-text {
    font-size: 1rem;
    color: #666;
    /* Medium gray for Light Mode */
    letter-spacing: -0.2px;
}

/* --- DARK MODE OVERRIDES --- */
body.dark-mode .city-label {
    color: #eeeeee !important;
}

body.dark-mode .weather-temp {
    color: #ffffff !important;
}

body.dark-mode .date-text {
    color: #aaaaaa !important;
}

body.dark-mode .separator {
    color: #444444 !important;
}

body.dark-mode #weather-icon img {
    filter: brightness(1) invert(0);
    /* Reset filter for dark background */
}

@media (max-width: 768px) {

    /* 1. Reset the Header Container */
    header .container {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        padding-top: 10px !important;
    }

    /* 2. Bring the Widget Back & Center It */
    .weather-star-style {
        position: relative !important;
        /* Removes it from the "invisible" corner */
        top: 0 !important;
        left: 0 !important;
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
        margin: 0 auto 10px auto !important;
        /* Space between widget and logo */

        /* THE COLOR FIX: Make sure we can see it on white background */
        color: #1a1a1a !important;
        transform: scale(0.85);
        /* Keeps it from being too bulky */
    }

    /* Force visibility for all text parts in light mode */
    .weather-star-style span,
    .weather-star-style .city-label,
    .weather-star-style .weather-temp,
    .weather-star-style .date-text {
        color: #333 !important;
    }

    /* DARK MODE MOBILE: Flip colors back to white */
    body.dark-mode .weather-star-style span,
    body.dark-mode .weather-star-style .city-label,
    body.dark-mode .weather-star-style .weather-temp,
    body.dark-mode .weather-star-style .date-text {
        color: #ffffff !important;
    }

    /* 3. Logo & Tagline Adjustments */
    .logo h1 {
        font-size: 2.0rem !important;
        margin-bottom: 0 !important;
    }

    .logo p {
        font-size: 0.8rem !important;
        /* Smaller tagline as requested */
        margin-top: 2px !important;
        opacity: 0.7;
    }

    header {
        padding: 10px 0 !important;
    }
}

/* --- FIXED REAL ESTATE TITLES --- */

/* 1. Light Mode Styles */
.real-estate-content h3 a {
    color: #000000 !important;
    /* Force Black in Light Mode */
    text-decoration: none !important;
    font-weight: bold;
    transition: color 0.2s ease;
}

.real-estate-content h3 a:hover {
    color: #dc2626 !important;
    /* Force Red on Hover */
}

/* 2. Dark Mode Styles */
body.dark-mode .real-estate-content h3 a {
    color: #ffffff !important;
    /* Force White in Dark Mode */
}

body.dark-mode .real-estate-content h3 a:hover {
    color: #dc2626 !important;
    /* Force Red on Hover in Dark Mode */
}

/* 3. Business Ads Titles (Optional - if you want them to match) */
.business-name a {
    color: #000000 !important;
    text-decoration: none;
}

body.dark-mode .business-name a {
    color: #ffffff !important;
}

.business-name a:hover,
body.dark-mode .business-name a:hover {
    color: #dc2626 !important;
}

/* 1. Reset the container to be completely flat */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px !important;
    margin: 40px auto;
    padding: 25px 0 !important;

    /* KILL the 3D/Box look */
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;

    /* Keep only the flat top line */
    border-top: 1px solid #333 !important;
    width: 100%;
}

/* 2. Remove any styling from the inner list wrapper */
.page-numbers-list {
    display: flex;
    gap: 6px !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* 3. Button Styling - Flat and Uniform */
.page-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    min-width: 36px;
    padding: 0 12px;
    border-radius: 4px;
    font-size: 0.85rem;

    /* Flat border, no shadows */
    border: 1px solid #444 !important;
    background-color: #1a1a1a !important;
    box-shadow: none !important;
    color: #eee !important;
    transition: all 0.2s ease;
}

/* 4. Active State - Solid Red Shade */
.page-link.active {
    background-color: #dc2626 !important;
    /* Signature Red */
    border-color: #dc2626 !important;
    color: #fff !important;
    font-weight: bold;
}

.page-link:hover:not(.active) {
    background-color: #333 !important;
    border-color: #666 !important;
}

/* 5. Fix Article Summary Truncation */
.summary {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
    max-height: 3em;
    /* Exactly 2 lines */
    word-break: break-all;
}

/* Mobile Adjustments */

@media (max-width: 768px) {

    /* 1. Make the Header Logo BIGGER */
    .logo h1 {
        font-size: 2.8rem !important;
        /* Increased from 2.0rem */
        line-height: 1.1;
    }

    /* 2. Make the Footer Logo SMALLER */
    .footer-logo .logo-main {
        font-size: 1.8rem !important;
        /* Decreased from 2.5rem */
        letter-spacing: -0.01em;
    }

    /* 3. Adjust Subtext accordingly */
    .logo p {
        font-size: 0.85rem !important;
        opacity: 0.8;
    }

    .footer-logo .logo-subtext {
        font-size: 0.7rem !important;
        letter-spacing: 1px;
    }

    .footer-contact-row {
        font-size: 0.72rem !important;
        /* Kept on one line */
    }

    .footer-location {
        font-size: 0.65rem !important;
        /* Shrunk for better balance */
        opacity: 0.8;
        /* Slightly dimmed to look cleaner */
        margin-top: 2px;
    }

    nav ul li {
        flex: 0 0 auto;
        height: 100% !important;
    }

    nav ul li a {
        padding: 0 18px !important;
        font-size: 0.95rem;
        white-space: nowrap;
        height: 100% !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* 3. The Highlight Fix (The Blue Block on Mobile) */
    /* If your nav.ejs uses 'active' instead of 'active-tab', change the class name below */
    nav ul li a.active-tab,
    nav ul li a.active {
        background-color: #1a365d !important;
        /* Your signature Blue */
        background: #1a365d !important;
        color: #ffffff !important;

        /* Ensures the blue block covers the full vertical height of the scroll bar */
        height: 100% !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
}

/* --- DESKTOP HIGHLIGHT REINFORCEMENT --- */
    nav ul li a.active-tab,
    nav ul li a.active {
    background-color: #1a365d !important;
    color: white !important;


}

/* --- COLUMN FIX --- */
@media screen and (max-width: 768px) {
    /* Hide the table header entirely */
    .column-table thead {
        display: none;
    }

    .column-table, 
    .column-table tbody, 
    .column-table tr, 
    .column-table td {
        display: block;
        width: 100%;
    }

    .column-table tr {
        margin-bottom: 15px;
        border: 1px solid #eee;
        padding: 12px;
        border-radius: 8px;
        background: #fff;
        position: relative;
    }

    body.dark-mode .column-table tr {
        border-color: #333;
        background: #1a1a1a;
    }

    .column-table td {
        border: none;
        padding: 4px 0;
        text-align: left;
    }

    /* Style the Title prominently */
    .col-title {
        font-size: 1.1rem;
        margin-bottom: 8px;
        line-height: 1.4;
    }

    /* Format Number and Name as a "meta" line */
    .col-num, .col-name, .col-date {
        display: inline-block;
        width: auto;
        font-size: 0.85rem;
        color: #888;
    }

    .col-num::after {
        content: " | ";
        margin: 0 5px;
    }

    .col-name::after {
        content: " • ";
        margin: 0 5px;
    }

    /* Add labels if necessary using data-attributes (Optional) */
    /* Example: .col-date::before { content: "Date: "; } */
}

/* =========================================
   Mobile Hamburger Nav Overrides (Max-width 768px)
   ========================================= */
.mobile-current-label,
#mobile-menu-btn {
    display: none;
}

.nav-flex-container {
    position: relative; 
}

@media (max-width: 768px) {
    .search-bar {
        display: none !important;
    }

    .mobile-current-label {
        display: block;
        font-weight: bold;
        font-size: 1.1rem;
        color: #fff; 
    }

    #mobile-menu-btn {
        display: block;
        font-size: 24px;
        cursor: pointer;
        color: #fff; 
        user-select: none;
    }

    #nav-list {
        display: none !important; /* Force hide by default */
        position: absolute;
        top: 100%; 
        left: 0;
        width: 100%;
        background-color: #ffffff;
        flex-direction: column;
        margin: 0;
        padding: 0;
        list-style: none;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        z-index: 1000;
    }

    #nav-list.active {
        display: flex !important; /* Reveal when clicked */
    }

    #nav-list li {
        width: 100%;
        text-align: left;
        height: auto !important; /* Override desktop fixed heights */
    }

    #nav-list li a {
        display: block !important;
        padding: 12px 20px !important;
        color: #333333 !important;
        text-decoration: none;
        border-bottom: 1px solid #eeeeee;
        height: auto !important;
    }

    #nav-list li a:hover {
        background-color: #f8f9fa !important;
    }
}

/* --- MOBILE ARTICLE COLUMN TABLE  --- */
@media screen and (max-width: 768px) {
    /* 1. Ensure the article container itself is locked */
    .article-body {
        max-width: 100%;
        overflow-x: hidden; /* Hard stop for page-wide scrolling */
    }

    /* 2. The Table Wrapper - This is the "Safety Box" */
    .table-responsive-wrapper {
        width: 100%;
        overflow-x: auto; /* Fallback scroll */
        -webkit-overflow-scrolling: touch;
        margin: 20px 0;
    }

    /* 3. The Table Fix */
    .article-body table {
        width: 100% !important;
        table-layout: fixed; /* Forces columns to stay in bounds */
        border-collapse: collapse;
    }

    /* 4. Fix the vertical text from your screenshot */
    .article-body td, 
    .article-body th {
        /* We allow wrapping now, but with controlled word breaks */
        word-break: keep-all; 
        overflow-wrap: break-word;
        font-size: 0.75rem !important; /* Smaller font to fit more words */
        padding: 6px 4px !important;
        line-height: 1.3 !important;
        height: auto !important;
    }
}

/* =========================================
   THE ABSOLUTE FINAL MOBILE NAV OVERRIDE
   Paste this at the VERY BOTTOM of your CSS file
   ========================================= */
@media (max-width: 768px) {
    /* 1. Force the red bar to be horizontal & allow dropdown to show */
    nav {
        overflow: visible !important; 
        height: 50px !important;
        min-height: 50px !important;
    }
    
    /* Hyper-aggressive selector to overpower any homepage-specific CSS */
    body nav > .nav-flex-container,
    body nav > .container {
        display: flex !important;
        flex-direction: row !important; 
        justify-content: space-between !important; 
        align-items: center !important;
        height: 50px !important;
        padding: 0 20px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 2. Left side: Category Name */
    .mobile-current-label {
        display: block !important;
        color: #ffffff !important;
        font-size: 1.1rem !important;
        font-weight: bold !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 3. Right side: Hamburger Icon */
    #mobile-menu-btn {
        display: block !important;
        color: #ffffff !important;
        font-size: 28px !important;
        line-height: 1 !important;
        cursor: pointer !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 4. The Dropdown Menu Structure */
    #nav-list {
        display: none !important; 
        position: absolute !important;
        top: 50px !important; 
        left: 0 !important;
        width: 100% !important;
        flex-direction: column !important;
        z-index: 999999 !important; 
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        box-shadow: 0 10px 20px rgba(0,0,0,0.5) !important;
        
        /* Light mode default background */
        background-color: #ffffff !important; 
    }

    #nav-list.active {
        display: flex !important; 
    }

    #nav-list li {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        display: block !important;
    }

    /* 5. Dropdown Texts and Colors (Light Mode) */
    #nav-list li a {
        display: block !important;
        width: 100% !important;
        padding: 10px 20px !important;
        text-align: left !important;
        font-size: 1.1rem !important;
        text-decoration: none !important;
        box-sizing: border-box !important;
        color: #000000 !important; 
        border-bottom: 1px solid #dddddd !important;
    }

    /* 6. Dark Mode Dropdown Colors (FIXED WHITE LINES) */
    body.dark-mode #nav-list {
        background-color: #1a1a1a !important; /* Turns the whole background box dark */
        border: 0px solid #333333 !important; /* Subtle outer border */
    }

    body.dark-mode #nav-list li a {
        color: #ffffff !important; 
        border-bottom: 1px solid #ffffff !important; /* Replaces thick white lines with subtle dark grey */
    }
    
    /* 7. Active Tab formatting inside the dropdown */
    #nav-list li a.active-tab,
    #nav-list li a.active {
        background-color: #dc2626 !important; 
        color: #ffffff !important;
    }
    
    body.dark-mode #nav-list li a.active-tab,
    body.dark-mode #nav-list li a.active {
        background-color: #dc2626 !important;
        color: #ffffff !important;
        border-bottom: 1px solid #ffffff !important;
    }

    /* Kills the black gap between list items */
    #nav-list {
        gap: 0 !important; 
    }

    #nav-list li {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Fixes the blinding white hover box with invisible text in Dark Mode */
    body.dark-mode #nav-list li a:hover {
        background-color: #2a2a2a !important; /* A nice dark grey on tap */
        color: #ffffff !important;
    }
}


/* =========================================
   DESKTOP NAV TAB ALIGNMENT FIX
   ========================================= */

/* 1. Remove the default padding from the nav bar to kill the top/bottom red gaps */
nav {
    padding: 0 !important;
    height: 50px !important;
    border-top: none !important;
}

/* 2. Force the container to stretch to the exact 50px boundaries */
nav .container {
    height: 50px !important;
    align-items: stretch !important; /* This forces the blue tab to hit the exact top and bottom */
}

/* 3. Target your specific DESKTOP list and force it to stretch */
.nav-list-desktop {
    display: flex !important;
    align-items: stretch !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.nav-list-desktop li {
    height: 100% !important;
    display: flex !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 4. Center the text inside the fully stretched blue tab */
.nav-list-desktop li a {
    display: flex !important;
    align-items: center !important; /* Centers the white text perfectly */
    justify-content: center !important;
    height: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

/* =========================================
   THE ANTI-STRETCH SEARCH BAR SHIELD (DESKTOP ONLY)
   ========================================= */
@media (min-width: 769px) {
    /* Target both class names just to be 100% safe */
    .search-bar,
    .search-bar-desktop {
        align-self: center !important; 
        margin-top: auto !important;    /* Pushes down from the top (kills stretch) */
        margin-bottom: auto !important; /* Pushes up from the bottom (kills stretch) */
        height: 36px !important;        /* Hard lock the height */
        max-height: 36px !important;    /* Double hard lock */
        display: flex !important;       /* Only forces flex on desktop now */
        align-items: center !important; 
    }

    /* Force the exact same lock on the input and button inside */
    .search-bar input,
    .search-bar-desktop input,
    .search-bar button,
    .search-bar-desktop button {
        height: 36px !important;
        max-height: 36px !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        line-height: normal !important; 
    }
}

/* =========================================
   ARTICLE.EJS COMPATIBILITY FIX
   Applies our navigation styles to the new HTML class names
   ========================================= */

/* --- 1. DESKTOP VIEW FOR ARTICLE.EJS --- */
@media (min-width: 769px) {
    /* Hide the mobile elements on desktop */
    .mobile-label-left,
    #hamburger-icon-right {
        display: none !important;
    }

    /* Format the red bar */
    .main-red-bar {
        padding: 0 !important;
        height: 50px !important;
        border-top: none !important;
    }

    /* Make the container stretch */
    .mobile-exclusive-container {
        height: 50px !important;
        display: flex !important;
        align-items: stretch !important;
        padding: 0 20px !important;
    }

    /* Force the list to lay out horizontally and stretch */
    #dropdown-menu-list {
        display: flex !important;
        align-items: stretch !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        list-style: none;
    }

    #dropdown-menu-list li {
        height: 100% !important;
        display: flex !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Center the text in the fully stretched desktop blocks */
    #dropdown-menu-list li a {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        height: 100% !important;
        padding: 0 20px !important;
        color: white !important;
        text-decoration: none !important;
    }
}

/* --- 2. MOBILE VIEW FOR ARTICLE.EJS --- */
@media (max-width: 768px) {
    /* Open the overflow trapdoor */
    .main-red-bar {
        overflow: visible !important;
        height: 50px !important;
    }

    /* Keep label and icon side-by-side */
    .mobile-exclusive-container {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        height: 50px !important;
        padding: 0 20px !important;
        box-sizing: border-box !important;
    }

    /* Style the Category Label */
    .mobile-label-left {
        display: block !important;
        color: #ffffff !important;
        font-size: 1.1rem !important;
        font-weight: bold !important;
    }

    /* Style the Hamburger */
    #hamburger-icon-right {
        display: block !important;
        color: #ffffff !important;
        font-size: 28px !important;
        cursor: pointer !important;
        line-height: 1 !important;
    }

    /* Hide desktop list, format as absolutely positioned dropdown */
    #dropdown-menu-list {
        display: none !important; 
        position: absolute !important;
        top: 50px !important; 
        left: 0 !important;
        width: 100% !important;
        flex-direction: column !important;
        z-index: 999999 !important; 
        margin: 0 !important;
        padding: 0 !important;
        background-color: #ffffff !important; /* Light mode bg */
        list-style: none;
        box-shadow: 0 10px 20px rgba(0,0,0,0.5) !important;
    }

    /* THIS IS CRITICAL: article.ejs uses .open instead of .active */
    #dropdown-menu-list.open {
        display: flex !important;
    }

    #dropdown-menu-list li {
        width: 100% !important;
        height: auto !important;
    }

    /* Dropdown text styling (Light Mode) */
    #dropdown-menu-list li a {
        display: block !important;
        width: 100% !important;
        padding: 10px 20px !important;
        color: #000000 !important;
        text-decoration: none !important;
        border-bottom: 1px solid #dddddd !important;
        box-sizing: border-box !important;
    }

    /* Dark Mode Dropdown Fixes */
    body.dark-mode #dropdown-menu-list {
        background-color: #1a1a1a !important;
    }

    body.dark-mode #dropdown-menu-list li a {
        color: #ffffff !important;
        border-bottom: 1px solid #333333 !important;
    }

    body.dark-mode #dropdown-menu-list li a:hover {
        background-color: #2a2a2a !important;
    }
}