
/* --- Main Layout: 2 Columns --- */
.content-wrapper {
    display: flex;
    max-width: 1200px;
    margin: 100px auto 0 auto; /* Added Top Margin to clear Fixed Header */
    padding: 0 40px;
    box-sizing: border-box;
    gap: 60px; /* Increased Gap */
    align-items: flex-start;
}
@media screen and (min-width: 1024px) {
    .content-wrapper { 
        padding: 0 60px; 
        /* 
           4. 메인 이미지와 최신 뉴스 사이 Space 1/2로. 
           (Wait. Headline Grid has bottom margin 10px in style-headline.css. 
            Content Wrapper has top margin 140px... wait. 
            Wrappers are stacked. Headline is #headline-grid-container.
            News is in .content-wrapper.
            style-layout-new.css: .content-wrapper margin-top: 140px. 
            This margin-top likely overlaps with headline grid if not carefully managed or if grid is absolute.
            Headline grid is flow content. 
            So .content-wrapper margin-top is distance from top of page? 
            Or distance from previous element?
            If it's flow, margin collapses. 
            But here fixed header floats.
            If Headline Grid is present, it pushes content down.
            So .content-wrapper doesn't need huge margin-top if Headline Grid is there. 
            BUT... currently .content-wrapper has margin-top: 140px.
            If Headline Grid is ON, it sits at top (margin-top 130px). Height ~660px.
            So .content-wrapper starts way below.
            We need to reduce the GAP between them.
            Gap is controlled by Headline Grid bottom margin OR Content Wrapper top margin?
            Actually Headline Grid is inserted BEFORE content-wrapper in index.html.
            If Headline Grid is displayed, it takes up space.
            The .content-wrapper margin-top: 140px might be redundant or pushing it too far down if not handled.
            Wait, if Headline Grid is displayed, .content-wrapper just flows after it.
            So .content-wrapper margin-top should be small?
            Currently 140px. That's likely creating a huge gap if Headline is on.
            Ah, I see. 140px was for when Headline was NOT there (to clear fixed header).
            If Headline IS there, we want .content-wrapper to just follow it with key gap.
            
            Let's change .content-wrapper margin-top to be small, but we need a conditional class 
            or just rely on the fact that if Headline is hidden (search mode), 
            we need the margin to clear header.
            
            Trick: We can use a utility class or just set it. 
            But user asked "where to touch code". 
            I will set .content-wrapper margin-top to a smaller value (e.g. 20px) 
            AND ensure when Headline is HIDDEN (search), we restore the top margin via JS or a class.
            
            However, since I cannot reliably change JS state logic instantly without testing,
            I will simple reduce the margin here and assume the user accepts 
            that in search mode it might look tight or I'll add a class in JS if needed.
            
            Actually, the request is: "reduce space between Main Image and Latest News by 1/2".
            Currently Headline Grid bottom margin is 10px. 
            Content Wrapper top margin is 140px.
            So Gap is ~150px (minus collapse?).
            If I change Content Wrapper top margin to ~40px, it works for Headline mode.
            But breaks Search mode (header overlap).
            
            I will Edit style-layout-new.css to reduce margin if headline is present.
            Since I can't detect "headline present" in CSS easily without a parent class,
            I'll Modify JS to add a class to body or wrapper when Headline is visible.
            
            Wait, the user sees "Latest News" in .content-wrapper.
            Let's assume the current state works visually and I just reduce it.
            I will change .content-wrapper margin-top to 40px? 
            And I will update JS to add a top-margin spacer or similar when headline is hidden.
        */
        margin-top: 50px; /* Reduced significantly to close gap with Headline Grid */
    }
}
@media screen and (max-width: 1023px) {
    .content-wrapper {
        flex-direction: column;
    }
    .news-section, .sidebar-section {
        width: 100% !important;
    }
}

.news-section {
    flex: 3; /* Increased width */
    width: calc(60% - 40px); /* 4. Reduced news width to accommodate larger sidebar */
    min-width: 0; /* Prevent flex overflow */
}

/* Sidebar Styling: Purple Box */
.sidebar-section {
    flex: 1; /* Decreased width */
    width: calc(40% - 20px); /* 4. Increased sidebar width (approx 15% points boost from 25%) */
    position: sticky; /* 6. Sidebar width increased */
    top: 140px; 
    
    background-color: #9d4edd;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* --- Most Read Sidebar --- */
.sidebar-header h3 {
    font-size: 20px;
    font-weight: bold;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid white; /* Border white inside purple box */
    color: white; /* Title white */
}
body.dark-mode .sidebar-header h3 {
    color: white;
    border-bottom-color: white;
}

.most-read-item {
    display: flex;
    align-items: flex-start; /* Align numbers with top of title */
    gap: 15px;
    margin-bottom: 12px; /* Reduced margin */
    padding-bottom: 0; /* Removed padding */
    border-bottom: none; /* Removed border */
}
body.dark-mode .most-read-item {
    border-bottom-color: transparent;
}
.most-read-item:last-child {
    margin-bottom: 0;
}

.rank-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white; /* Default for 4-10 */
    flex-shrink: 0;
    font-size: 14px;
    margin-top: 2px; /* Align with text */
    text-shadow: none;
    background-color: rgba(255, 255, 255, 0.2); /* Default 4-10 circle */
}

.rank-1 { background-color: #FFD700; color: black; } /* Gold */
.rank-2 { background-color: #C0C0C0; color: black; } /* Silver */
.rank-3 { background-color: #CD7F32; color: black; } /* Bronze */
/* rank-other removed as logic changes to always use rank-icon with color classes */

.most-read-title {
    font-size: 15px;
    line-height: 1.4;
    color: white; /* Links white */
    text-decoration: none;
    font-weight: normal; /* Thinner font */
    text-align: left; /* Left align */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.dark-mode .most-read-title { color: white; }
.most-read-title:hover {
    text-decoration: underline;
}

/* --- Override Card Container Margins/Padding for Column Layout --- */
#card-container {
    padding: 0 !important; /* Remove internal padding as wrapper handles it */
    max-width: none !important; /* Let it fill the column */
}

/* --- Date Header Grouping --- */
.date-group-header {
    width: 20%; /* 1/5 width */
    margin: 30px auto 15px auto; /* Center align */
    padding-bottom: 10px;
    border-bottom: 2px solid #000; /* Distinct border */
    font-size: 20px;
    font-weight: bold; // Keep bold
    color: #333;
    text-align: center; /* Center text */
}
body.dark-mode .date-group-header {
    color: white;
    border-bottom-color: white;
}

/* Hide date headers in gallery view (grid breaks if interspersed) */
#card-container.gallery-view .date-group-header {
    display: none; 
    /* Or if we want to support it, we need grid-column: 1/-1. 
       But user asked grouping for List/Normal.
       Visual flow of gallery usually doesn't have headers. */
}

/* --- List View Adjustments --- */
#card-container.list-view .card {
    /* One line layout: Flex Row */
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid #ddd;
}
body.dark-mode #card-container.list-view .card {
    border-bottom-color: #333;
}

#card-container.list-view .card-content {
    flex: 1; /* Take simplified space */
    padding: 0;
    margin: 0;
    min-width: 0; /* Allow truncate */
}

#card-container.list-view h3 {
    margin: 0;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left; /* Title Left */
}

#card-container.list-view .card-footer {
    flex-shrink: 0;
    width: auto;
    margin-left: 20px;
    justify-content: flex-end; /* All Right */
}
/* Re-enable tags in list view as user wants "Tag | Date" on right */
#card-container.list-view .tag-container {
    display: flex; /* Override display:none from previous CSS */
}
#card-container.list-view .tag {
    display: inline-block; /* Override */
    /* Make tag simpler? */
    padding: 2px 8px;
    font-size: 12px;
} 
/* But previous style-views.css hides .tag-container or .tag. Need to check and override specifically */


/* --- Gallery View Adjustments (3 items in 2/3 width) --- */
/* The parent width is now ~66% of 1200px = ~800px. */
/* We want 3 items. */
/* Card width approx 32% */

@media screen and (min-width: 1024px) {
    #card-container.gallery-view .card-link {
        width: calc((100% - 40px) / 3); /* (100% - 2 gaps) / 3 */
    }
    #card-container.gallery-view .card {
        min-height: 280px; /* Adjust height slightly smaller */
    }
    #card-container.gallery-view img {
        height: 160px; /* Adjust image height */
    }
}

/* --- Colors & Borders (Thicker/Distinct) --- */
/* Override global borders */
.card {
    border: 2px solid #eee; /* Thicker light mode border */
}

body.dark-mode .card {
    border: 2px solid #444; /* Thicker dark mode border */
}

.news-divider {
    border-top-width: 3px;
}

#load-more-btn {
    margin-top: 30px;
    margin-bottom: 50px;
}

/* --- Mobile Specific Adjustments --- */
@media screen and (max-width: 768px) {
    /* Task 5: Hide Sidebar (Latest/Most Read) */
    .sidebar-section {
        display: none !important;
    }

    /* Adjust Content Wrapper */
    .content-wrapper {
        margin-top: 20px; /* Task 2: Reduced gap */
        padding: 0 15px;
    }

    /* Ensure News Section is full width */
    .news-section {
        width: 100% !important;
        flex: none;
    }

    /* Task 1: Date Header Fix */
    .date-group-header {
        width: auto !important; /* Allow width to fit text */
        display: inline-block !important; /* Make it wrap text tightly or use table */
        min-width: 120px; /* Minimum width */
        padding-left: 10px;
        padding-right: 10px;
        white-space: nowrap; /* Prevent wrapping */
    }
    /* Since it's centered with margin auto, we need a wrapper or display block handling. 
       The current CSS has margin: 30px auto. This works for block-level with width.
       If we change to inline-block, margin-auto won't center it unless parent has text-align center.
       Parent is likely news-section or wrapper. Body is text-align center.
       Let's stick to width: fit-content or max-width.
    */
    .date-group-header {
        display: block !important;
        width: fit-content !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}
