:root {
    /* Professional and trustworthy color system */
    --primary-color: #ba1826; 
    --secondary-color: #2b2d42; 
    --bg-color: #f8f9fa; 
    --text-color: #333333; 
    --text-muted: #6c757d; 
    --card-bg: #ffffff;
    --border-color: #e9ecef;
}

/* Ensure no horizontal scrolling on any device */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7; 
    -webkit-font-smoothing: antialiased; 
}

/* Container limits width but uses box-sizing to prevent overflow from padding */
.container {
    max-width: 1100px; 
    margin: 0 auto;
    padding: 0 20px; /* Slightly reduced padding */
    box-sizing: border-box; /* Crucial for preventing horizontal scroll */
    width: 100%;
}

/* More compact header to leave room for ad slots */
header {
    background-color: var(--card-bg);
    color: var(--secondary-color);
    text-align: center;
    padding: 0px 0 0px 0; /* Significantly reduced vertical padding */
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

header h1 {
    margin: 0 0 5px 0;
    font-size: 2rem; /* Slightly smaller font size */
    font-weight: 700;
    letter-spacing: -0.5px;
}

header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 1rem; /* Slightly smaller */
    font-weight: 300;
}

.site-nav {
    margin-top: 14px;
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.site-nav a,
.footer-links a {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.9rem;
}

.site-nav a:hover,
.footer-links a:hover {
    text-decoration: underline;
}

.ad-slot {
    width: 100%;
    margin: 0 auto 24px;
    min-height: 120px;
    background: #f3f4f6;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    padding: 8px;
}

.ad-slot-list {
    max-width: 1100px;
}

.ad-slot-detail {
    max-width: 728px;
    margin-top: 28px;
}

.ad-slot .adsbygoogle {
    min-height: 90px;
}

/* Ad Slot Placeholder (Example structure for future use) */
.ad-slot-header {
    width: 100%;
    max-width: 728px; /* Standard leaderboard ad size */
    height: 90px;
    background-color: #eaeaea;
    margin: 0 auto 20px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.8rem;
    border: 1px dashed #ccc;
    box-sizing: border-box;
}

/* Article List Grid */
.article-grid {
    display: grid;
    /* Adjust minmax to fit smaller screens better without scrolling */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 20px; /* Reduced gap slightly */
    padding-bottom: 40px;
    box-sizing: border-box;
    width: 100%;
}

.card {
    background: var(--card-bg);
    border-radius: 10px; /* Slightly smaller radius */
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);
}

.card img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-bottom: 1px solid var(--border-color);
    display: block;
}

.card-body {
    padding: 20px; /* Reduced padding */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-body h3 {
    margin: 0 0 10px 0;
    color: var(--secondary-color);
    font-size: 1.15rem;
    line-height: 1.4;
}

.card-body p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Detail View (Immersive Reading) */
.detail-view {
    background: var(--card-bg);
    padding: 40px 50px; /* Reduced padding */
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.05);
    margin-bottom: 60px;
    max-width: 800px; 
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    width: 100%; /* Ensure it doesn't overflow container */
}

#back-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 20px; 
    cursor: pointer;
    margin-bottom: 25px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

#back-btn:hover {
    background: var(--bg-color);
    color: var(--secondary-color);
    border-color: #d1d5db;
}

/* Detail Content Typography */
#detail-content {
    color: var(--text-color);
    /* Prevent long words or URLs from breaking the layout */
    word-wrap: break-word; 
    overflow-wrap: break-word;
}

#detail-content h2 {
    color: var(--secondary-color);
    margin-top: 1.8em;
    margin-bottom: 0.8em;
    font-size: 1.4rem;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 8px;
}

#detail-content p {
    margin-bottom: 1.4em;
    font-size: 1rem;
}

#detail-content ul, #detail-content ol {
    margin-bottom: 1.4em;
    padding-left: 1.5em;
}

#detail-content li {
    margin-bottom: 0.5em;
}

#detail-content img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    margin: 20px 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    display: block;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--card-bg);
    margin-top: 40px;
    box-sizing: border-box;
    width: 100%;
}

.footer-links {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.medical-disclaimer {
    margin-top: 10px;
    font-size: 0.78rem;
}

.legal-page {
    max-width: 860px;
    margin: 30px auto 50px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 28px;
    box-sizing: border-box;
}

.legal-page h1 {
    margin-top: 0;
    color: var(--secondary-color);
}

.legal-page h2 {
    margin-top: 1.6em;
    color: var(--secondary-color);
}

.legal-page p,
.legal-page li {
    color: var(--text-color);
}

/* Responsive adjustments for Tablets and Mobile */
@media (max-width: 850px) {
    .detail-view {
        padding: 30px; /* Tighter padding for tablets */
    }
}

@media (max-width: 600px) {
    /* Ensure padding is zero on the container itself if detail view has padding, 
       or adjust detail view padding to fit mobile screens perfectly */
    .container {
        padding: 0 15px; 
    }

    .detail-view {
        padding: 20px 15px; 
        border-radius: 8px; /* Slightly rounded for mobile */
        box-shadow: 0 2px 10px rgba(0,0,0,0.05); /* Lighter shadow */
        margin-bottom: 30px;
    }
    
    header {
        padding: 20px 15px 15px 15px;
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 1.6rem;
    }

    .site-nav {
        gap: 10px;
    }

    .article-grid {
        grid-template-columns: 1fr; /* Force single column on very small screens */
        gap: 15px;
    }

    /* Adjust ad slot for mobile */
    .ad-slot,
    .ad-slot-header {
        max-width: 320px; /* Standard mobile ad width */
        min-height: 60px;
    }
    
    #detail-content h2 {
        font-size: 1.25rem;
    }

    .legal-page {
        padding: 18px 14px;
    }
}