:root {
    --brand-primary: #2563eb;
    --brand-dark: #0f172a;
    --brand-muted: #64748b;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --radius: 12px;
}

/* 1. Reset & Global Box Sizing */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* Crucial: includes padding in width calculations */
}

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--bg-main);
    color: var(--brand-dark);
    line-height: 1.5;
    /* Prevents horizontal scroll on the entire page */
    overflow-x: hidden;
    padding: 1rem;
}

/* 2. Responsive Container */
.container {
    max-width: 650px;
    margin: 0 auto;
    width: 100%;
}

h1 {
    text-align: center;
    margin: 2rem 0;
    font-weight: 800;
    font-size: 2rem;
    color: var(--brand-dark);
}

/* 3. The Feed Wrapper */
#article-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

/* 4. The Card - Defensive Layout */
.article {
    background: var(--card-bg);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);

    /* These three lines force the card to stay within the container
       even if there is a long unbreakable string inside. */
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* 5. Typography & Overflow Protection */
.article p {
    margin-bottom: 0.75rem;

    /* THE NUCLEAR FIX FOR LONG URLs:
       'anywhere' forces a break at the edge of the card. */
    overflow-wrap: anywhere;
    word-break: break-word;

    /* Ensures summaries with newlines display correctly but still wrap */
    white-space: pre-wrap;
}

/* Styling the Header (Source) */
.article p:first-child strong {
    color: var(--brand-primary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.25rem;
}

/* Styling the Title */
.article p:nth-child(2) strong {
    font-size: 1.25rem;
    line-height: 1.3;
    display: block;
    color: var(--brand-dark);
}

/* Footer (Date) */
.article small {
    display: block;
    color: var(--brand-muted);
    font-size: 0.8rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
}

/* 6. HTMX Loading State */
.htmx-request {
    opacity: 0.6;
    transition: opacity 0.2s ease;
}