:root {
    --bg-color: #FCF9F2;
    /* Warm off-white, slightly less beige than FT */
    --text-color: #1a1a1a;
    /* Softer black for better contrast on warm bg */
    --accent-color: #5c554b;
    /* Warm grey */
    --border-color: #e8e3dc;
    /* Warm border */
    --masthead-font: 'Playfair Display', serif;
    --body-font: 'Inter', system-ui, -apple-system, sans-serif;
}

html {
    font-size: 90%;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--body-font);
    line-height: 1.5;
    padding: 2rem;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Typography */
h1,
h2,
h3,
h4,
h5 {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
}

/* Layout */
.newspaper-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 4rem);
    /* accounting for 2rem body padding top+bottom */
}

/* Left Column Container */
.left-column {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: 0;
    margin: 0;
}

/* Header / Masthead */
.masthead {
    text-align: left;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--text-color);
    padding-bottom: 0.8rem;
    flex-shrink: 0;
}

.masthead-brand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.8rem;
    margin: 0.5rem 0 1rem 0;
}

.masthead-brand a {
    display: flex;
    align-items: center;
}

.brand-logo {
    height: 38px;
    width: auto;
    mix-blend-mode: multiply;
    display: block;
}

.brand-title {
    font-family: var(--masthead-font);
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -1.5px;
    text-transform: uppercase;
    color: var(--text-color);
    margin: 0;
    line-height: 1;
}

/* Grid Layout */
.content-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 3rem;
    margin-top: 1rem;
    /* reduce from 2rem */
    flex: 1;
    min-height: 0;
    /* Prevents flex children from bursting out */
}

.section-divider {
    border-top: 2px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-bottom: 1.5rem;
}

.sidebar {
    padding-right: 0.5rem;
    border-right: none;
    overflow-y: auto;
    flex: 1;
}

/* Scrollbar for sidebar to keep it clean */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.widget {
    margin-bottom: 2.5rem;
}

.widget-title {
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
}

.widget-subtitle {
    font-size: 0.8rem;
    color: var(--accent-color);
    margin-bottom: 1.2rem;
}

/* Checkboxes for Sidebar */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    cursor: pointer;
    width: 100%;
}

.checkbox-container input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-label {
    user-select: none;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

#topic-filters.sources-list {
    flex-direction: row;
    flex-wrap: wrap;
}

/* Chip Design (Styled like .topic-btn) */
.chip-container {
    display: inline-flex;
    position: relative;
    cursor: pointer;
    font-size: 0.85rem;
}

.chip-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.chip-label {
    display: inline-block;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.03);
    border: none;
    border-radius: 4px;
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
}

.chip-container:hover .chip-label {
    background-color: rgba(0, 0, 0, 0.08);
}

.chip-container input:checked~.chip-label {
    background-color: var(--text-color);
    color: var(--bg-color);
}

.chip-container input:focus~.chip-label {
    outline: 2px solid rgba(0, 0, 0, 0.1);
}

/* Persona Select */
.vintage-select {
    width: 100%;
    padding: 0.5rem;
    background-color: transparent;
    border: 1px solid var(--border-color);
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    color: var(--text-color);
    outline: none;
    cursor: pointer;
}

/* Quick Topics */
.quick-wires-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.topic-btn {
    background: rgba(0, 0, 0, 0.03);
    border: none;
    padding: 0.75rem 1rem;
    font-family: var(--body-font);
    font-size: 0.85rem;
    text-transform: none;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-align: left;
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.2s;
}

.topic-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

/* Vintage Ad Space */
.ad-space {
    border: 2px solid var(--border-color);
    padding: 1rem;
    text-align: center;
    margin-top: 2rem;
}

.ad-space>p {
    font-size: 0.7rem;
    font-family: sans-serif;
    letter-spacing: 2px;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.ad-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.ad-content p {
    font-size: 0.85rem;
    font-style: italic;
}

/* Chat Area Main */
.main-column {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 0;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 4rem;
}

.chat-history::-webkit-scrollbar {
    width: 4px;
}

.chat-history::-webkit-scrollbar-thumb {
    background-color: #ddd;
}

/* Message Styles - Formatted like Newspaper Articles */
.message {
    animation: fadeIn 0.5s ease forwards;
}

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

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

.user-msg {
    align-self: flex-start;
    border: none;
    padding: 0;
    background: transparent;
    box-shadow: none;
    margin-bottom: -1rem;
}

.user-msg .article-body {
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--text-color);
    letter-spacing: -0.4px;
    font-style: normal;
}

.system-msg {
    max-width: 100%;
    column-count: 1;
    text-align: left;
}

.article-headline {
    font-size: 2.2rem;
    letter-spacing: -0.5px;
    margin-bottom: 1rem;
}

.article-author {
    font-family: var(--body-font);
    font-size: 0.75rem;
    border: none;
    margin-bottom: 1.5rem;
    color: var(--accent-color);
}

.article-body {
    font-family: var(--body-font);
    font-size: 1.15rem;
    color: #333;
    line-height: 1.6;
    text-transform: none;
    font-weight: 400;
    /* Force normal weight */
}

.drop-cap::first-letter {
    font-size: 1.15rem;
    float: none;
    padding: 0;
    margin: 0;
    font-weight: normal;
}

/* Section Headings in AI responses */
.section-heading {
    font-family: var(--headline-font);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 2rem 0 0.6rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    text-transform: none;
}

.section-heading:first-child {
    margin-top: 0;
}

.section-heading-sm {
    font-family: var(--body-font);
    font-size: 1rem;
    font-weight: 700;
    margin: 1.5rem 0 0.4rem 0;
    color: var(--text-color);
}

.bullet-point {
    padding-left: 1rem;
    margin-bottom: 0.3rem;
}

/* Citations Component */
.citations-box {
    margin-top: 2rem;
    column-span: all;
    border-top: 2px dotted var(--border-color);
    padding-top: 1rem;
}

.citations-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.citation-list {
    list-style: none;
    font-size: 0.8rem;
    font-family: sans-serif;
}

.citation-list li {
    margin-bottom: 0.3rem;
}

.citation-list a {
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.citation-list a:hover {
    border-bottom: 1px solid var(--text-color);
}

/* Inline citation links in AI response */
.citation-link {
    color: #555;
    text-decoration: none;
    transition: color 0.2s;
}

.citation-link:hover {
    color: #000;
    text-decoration: underline;
}

/* Highlight the citation when jumped to */
.citation-list li:target,
.citation-list li.citation-highlight {
    background: #fffde7;
    border-left: 3px solid #333;
    padding-left: 0.5rem;
    transition: background 0.3s;
}

/* Input Area */
.input-area {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.chat-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.input-wrapper {
    flex-grow: 1;
    background: transparent;
}

.vintage-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--body-font);
    font-size: 1.25rem;
    color: var(--text-color);
    padding: 0.5rem 0;
    resize: none;
    outline: none;
    transition: border-color 0.3s;
}

.vintage-input:focus {
    border-bottom: 1px solid var(--text-color);
}

.send-btn {
    background-color: var(--text-color);
    color: var(--bg-color);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

.send-btn:hover {
    background-color: #333;
    transform: translateY(-2px);
}

.prompt-limit-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 0.6rem;
    min-height: 1.1em;
}

.prompt-counter {
    font-family: var(--body-font);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    opacity: 0.45;
    transition: color 0.3s, opacity 0.3s;
}

.prompt-counter.warn {
    color: #c9a227;
    opacity: 0.85;
}

.prompt-counter.exhausted {
    color: #a33;
    opacity: 0.9;
    font-weight: 600;
}

.prompt-limit-msg {
    font-family: var(--body-font);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: #a33;
    opacity: 0.9;
}

/* Typewriter Cursor */
.cursor {
    display: inline-block;
    width: 8px;
    height: 1.1em;
    background-color: var(--text-color);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Loader */
.loader-text {
    font-style: italic;
    font-size: 0.9rem;
    color: var(--accent-color);
    margin-top: 1rem;
    column-span: all;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}


/* ── Region Flag Bar ────────────────────────────────────────────── */
.region-flag-bar {
    margin-top: 0.5rem;
}

.region-flag-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 1.25rem;
    border-radius: 6px;
    padding: 0.2rem 0.45rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: border-color 0.2s, background 0.2s;
    color: var(--text-color);
    font-family: var(--body-font);
}

.region-flag-btn:hover {
    border-color: var(--border-color);
    background: rgba(0, 0, 0, 0.04);
}

.region-flag-btn.active {
    border-color: var(--text-color);
    background: rgba(0, 0, 0, 0.06);
}

.active-region-label {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.7;
}

/* ── Region Picker Modal ─────────────────────────────────────────── */
.region-modal-content {
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    text-align: left;
}

.region-section-label {
    font-family: var(--body-font);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    font-weight: 600;
    opacity: 0.45;
    margin: 0 0 0.6rem 0;
}

.region-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

.region-picker-countries {
    grid-template-columns: repeat(4, 1fr);
}

.region-picker-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    padding: 0.65rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    transition: border-color 0.2s, background 0.2s, transform 0.1s;
    color: var(--text-color);
    font-family: var(--body-font);
}

.region-picker-btn:hover {
    border-color: var(--text-color);
    background: rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

.region-picker-btn.selected {
    border-color: var(--text-color);
    background: rgba(0, 0, 0, 0.08);
}

.region-picker-flag {
    font-size: 1.6rem;
    line-height: 1;
}

.region-picker-name {
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    opacity: 0.75;
    text-align: center;
}

/* Responsive Media Query */
@media (max-width: 900px) {
    .content-grid {
        grid-template-columns: 1fr;
        /* Stack sidebar and main content */
        gap: 2rem;
        overflow-y: auto;
    }

    .sidebar {
        display: none;
        /* Hide sidebar completely to favor chat on small screens */
    }

    .brand-title {
        font-size: 3rem;
    }

    .brand-logo {
        height: 48px;
    }

    .masthead {
        margin-bottom: 2rem;
    }
}