/* ==============================================================================
   Dr. Paper: Journal-Grade Editorial Styles (The Morning Paper Tradition)
   Typography: Newsreader (Editorial Serif) + Inter (Clean Sans)
   ============================================================================== */

:root {
    /* Warm Paper Theme (Light) */
    --bg-page: #fbfaf7;
    --bg-surface: #ffffff;
    --bg-subtle: #f4f1ea;
    --bg-inset: #eeeae0;
    
    --text-ink: #1c1917;
    --text-prose: #292524;
    --text-muted: #57534e;
    --text-faint: #857f77;
    
    --border-light: #e7e4dc;
    --border-subtle: #ded9cd;
    --border-emphasis: #c8c0b0;
    
    --accent-amber: #b45309;
    --accent-amber-bg: rgba(180, 83, 9, 0.07);
    --accent-amber-border: #d97706;
    
    --link-color: #1e3a8a;
    --link-hover: #1d4ed8;
    
    --font-serif: 'Newsreader', Georgia, Cambria, 'Times New Roman', Times, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] {
    /* Obsidian Warm Charcoal Theme (Dark) */
    --bg-page: #131211;
    --bg-surface: #1b1918;
    --bg-subtle: #242220;
    --bg-inset: #2d2a27;
    
    --text-ink: #f5f5f4;
    --text-prose: #d6d3d1;
    --text-muted: #a8a29e;
    --text-faint: #78716c;
    
    --border-light: #2c2926;
    --border-subtle: #383430;
    --border-emphasis: #4d4742;
    
    --accent-amber: #f59e0b;
    --accent-amber-bg: rgba(245, 158, 11, 0.1);
    --accent-amber-border: #f59e0b;
    
    --link-color: #60a5fa;
    --link-hover: #93c5fd;
    
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-ink);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* ==============================================================================
   Masthead
   ============================================================================== */

.masthead {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    padding-top: 1.5rem;
    position: relative;
}

.masthead-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.25rem;
}

.masthead-branding {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.masthead-logo {
    height: 3.2rem;
    width: auto;
    border-radius: var(--radius-sm);
}

.journal-title {
    font-family: var(--font-serif);
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-ink);
    line-height: 1.1;
}

.journal-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.journal-subtitle em {
    font-family: var(--font-serif);
    font-style: italic;
}

.theme-toggle {
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    color: var(--text-ink);
    border-color: var(--border-emphasis);
}

.editorial-bar {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0 0.5rem 0;
    border-top: 1px solid var(--border-light);
}

.queue-bar {
    padding: 0.25rem 0 0.85rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.feed-tabs {
    display: inline-flex;
    background-color: var(--bg-subtle);
    padding: 3px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    gap: 2px;
}

.feed-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.9rem;
    border-radius: calc(var(--radius-md) - 2px);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-sans);
}

.feed-tab:hover {
    color: var(--text-ink);
}

.feed-tab.active {
    background-color: var(--bg-page);
    color: var(--text-ink);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.tab-count {
    font-size: 0.75rem;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    background-color: var(--bg-inset);
    color: var(--text-muted);
    font-weight: 600;
}

.feed-tab.active .tab-count {
    background-color: var(--border-light);
    color: var(--text-ink);
}

.search-box {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: 0.85rem;
}

.search-input {
    width: 100%;
    padding: 0.55rem 0.75rem 0.55rem 2.2rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background-color: var(--bg-page);
    color: var(--text-ink);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-amber);
}

.topic-select {
    padding: 0.55rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background-color: var(--bg-page);
    color: var(--text-ink);
    font-size: 0.85rem;
    cursor: pointer;
}

/* ==============================================================================
   Main Content & Curation Banner
   ============================================================================== */

.main-content {
    flex: 1;
    padding: 2rem 0 4rem 0;
}

.curation-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.85rem 1.25rem;
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-top: 3.5rem;
    margin-bottom: 0;
    font-size: 0.85rem;
}

.banner-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-val {
    font-weight: 700;
    color: var(--text-ink);
}

.stat-lbl {
    color: var(--text-muted);
}

.banner-divider {
    width: 1px;
    height: 1rem;
    background-color: var(--border-subtle);
}

/* ==============================================================================
   Article Dispatch Cards (The Morning Paper Layout)
   ============================================================================== */

.dispatches-flow {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.dispatch-article {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s ease;
}

.dispatch-article:hover {
    border-color: var(--border-emphasis);
}

.article-header {
    margin-bottom: 1.25rem;
}

.article-meta-top {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.article-edition {
    font-weight: 700;
    color: var(--accent-amber);
}

.article-topic {
    color: var(--text-muted);
}

.featured-tag {
    background-color: var(--accent-amber-bg);
    color: var(--accent-amber);
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.article-headline {
    font-family: var(--font-serif);
    font-size: 1.85rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--text-ink);
    margin-bottom: 0.5rem;
}

.article-authors {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--font-serif);
}

/* Curator's Note (Human-in-the-Loop Callout) */
.curator-take {
    background-color: var(--accent-amber-bg);
    border-left: 3px solid var(--accent-amber-border);
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius-sm);
    margin: 1.25rem 0;
}

.curator-badge {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-amber);
    margin-bottom: 0.25rem;
}

.curator-text {
    font-size: 0.95rem;
    color: var(--text-ink);
    line-height: 1.55;
}

/* Lead Thesis Hook */
.thesis-hook {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-style: italic;
    line-height: 1.55;
    color: var(--text-prose);
    padding: 0.9rem 0 1.25rem 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1.25rem;
}

/* Plain-English Gist Box */
.plain-gist-card {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.3rem;
    margin: 1.25rem 0 1.5rem 0;
}

.plain-gist-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-amber);
    margin-bottom: 0.35rem;
}

.plain-gist-content {
    font-size: 0.98rem;
    color: var(--text-prose);
    line-height: 1.7;
    font-family: var(--font-sans);
}

/* Narrative Essay Body */
.essay-body {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.essay-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.section-heading {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-ink);
    margin: 1.35rem 0 0.45rem 0;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.essay-paragraph {
    font-size: 1.02rem;
    color: var(--text-prose);
    line-height: 1.8;
    margin-bottom: 1rem;
}

.essay-quote {
    font-family: var(--font-serif);
    font-style: italic;
    border-left: 3px solid var(--accent-amber);
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Key Takeaways Section */
.takeaways-container {
    margin: 1rem 0 1.25rem 0;
}

.takeaways-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.takeaways-pills {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.takeaways-pills li {
    font-size: 0.9rem;
    color: var(--text-ink);
    background-color: var(--bg-subtle);
    border-left: 2px solid var(--accent-amber);
    padding: 0.5rem 0.85rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    line-height: 1.5;
}

/* Deep Dive Expandable Section */
.deep-dive-wrapper {
    margin: 1.25rem 0;
    border-top: 1px dashed var(--border-light);
    padding-top: 0.85rem;
}

.deep-dive-toggle-btn {
    width: 100%;
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.7rem 1rem;
    color: var(--text-ink);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.deep-dive-toggle-btn:hover {
    border-color: var(--border-emphasis);
    background-color: var(--bg-inset);
}

.deep-dive-toggle-btn i:first-child {
    margin-right: 0.5rem;
    color: var(--accent-amber);
}

.deep-dive-toggle-btn .chevron-icon {
    font-size: 0.8rem;
    transition: transform 0.25s ease;
}

.deep-dive-toggle-btn.expanded .chevron-icon {
    transform: rotate(180deg);
}

.deep-dive-content {
    margin-top: 1.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-light);
    animation: fadeIn 0.25s ease;
}

/* Original Abstract Drawer */
.abstract-drawer {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.toggle-abstract-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
    transition: color 0.2s ease;
}

.toggle-abstract-btn:hover {
    color: var(--text-ink);
}

.toggle-abstract-btn i {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

.toggle-abstract-btn.expanded i {
    transform: rotate(180deg);
}

.abstract-content {
    margin-top: 0.65rem;
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-muted);
    background-color: var(--bg-subtle);
    padding: 0.9rem 1.15rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

/* Article Footer Links */
.article-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.article-links {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.btn-link:hover {
    color: var(--text-ink);
    border-color: var(--border-emphasis);
    background-color: var(--bg-inset);
}

.btn-link.pdf-link {
    color: #b91c1c;
}

[data-theme="dark"] .btn-link.pdf-link {
    color: #f87171;
}

.read-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.5rem;
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}

.card-action-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.card-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: var(--font-sans);
}

.card-action-btn:hover {
    color: var(--text-ink);
    border-color: var(--border-emphasis);
    background-color: var(--bg-inset);
}

.card-action-btn.btn-bookmark.active {
    color: #2563eb;
    background-color: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.3);
}

[data-theme="dark"] .card-action-btn.btn-bookmark.active {
    color: #60a5fa;
    background-color: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.4);
}

.card-action-btn.btn-bookmark.active i {
    font-weight: 900;
}

.card-action-btn.btn-star.active {
    color: #d97706;
    background-color: rgba(217, 119, 6, 0.08);
    border-color: rgba(217, 119, 6, 0.3);
}

[data-theme="dark"] .card-action-btn.btn-star.active {
    color: #fbbf24;
    background-color: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.4);
}

.card-action-btn.btn-star.active i {
    font-weight: 900;
}

.card-action-btn.btn-dismiss:hover {
    color: #15803d;
    background-color: rgba(21, 128, 61, 0.08);
    border-color: rgba(21, 128, 61, 0.3);
}

.card-action-btn.btn-dismiss.is-read {
    color: #15803d;
    background-color: rgba(21, 128, 61, 0.06);
}

[data-theme="dark"] .card-action-btn.btn-dismiss:hover {
    color: #4ade80;
    background-color: rgba(74, 222, 128, 0.1);
}

.dispatch-article {
    transition: transform 0.28s ease, opacity 0.28s ease, margin 0.28s ease, max-height 0.28s ease;
    touch-action: pan-y;
}

.dispatch-article.dismissing {
    opacity: 0;
    transform: translateX(-50px);
    pointer-events: none;
}

/* All Caught Up Empty State */
.all-caught-up {
    text-align: center;
    padding: 3.5rem 1.5rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin: 1.5rem 0;
}

.caught-up-circle {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    background-color: rgba(21, 128, 61, 0.1);
    color: #15803d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
}

[data-theme="dark"] .caught-up-circle {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.all-caught-up h3 {
    font-family: var(--font-serif);
    font-size: 1.55rem;
    color: var(--text-ink);
    margin: 0 0 0.4rem 0;
}

.all-caught-up p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0 0 1.5rem 0;
}

.caught-up-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.btn-outline {
    background: var(--bg-page);
    border: 1px solid var(--border-light);
    color: var(--text-ink);
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-outline:hover {
    border-color: var(--border-emphasis);
    background-color: var(--bg-subtle);
}

.share-icon-btn {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-icon-btn:hover {
    color: var(--text-ink);
    border-color: var(--border-emphasis);
}

/* ==============================================================================
   State Displays & Footer
   ============================================================================== */

.editorial-loading, .editorial-error, .no-dispatches {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}

.editorial-loading i, .editorial-error i, .no-dispatches i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    color: var(--accent-amber);
}

.editorial-error i {
    color: #dc2626;
}

.journal-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-light);
    padding: 2.5rem 0;
    margin-top: auto;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.journal-footer a {
    color: var(--text-ink);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Toast with Undo */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-ink);
    color: var(--bg-page);
    padding: 0.65rem 1rem 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1000;
    animation: toastSlideUp 0.22s ease-out;
}

.toast-undo-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: #38bdf8;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

[data-theme="light"] .toast-undo-btn {
    color: #60a5fa;
    border-color: rgba(0,0,0,0.25);
}

.toast-undo-btn:hover {
    background-color: rgba(255,255,255,0.15);
}

@keyframes toastSlideUp {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
    .masthead-top { padding-bottom: 0.65rem; }
    .editorial-bar { padding: 0.5rem 0; flex-direction: column; gap: 0.5rem; }
    .queue-bar { padding: 0.25rem 0 0.65rem 0; overflow-x: auto; }
    .feed-tabs { width: 100%; display: flex; justify-content: space-between; }
    .feed-tab { flex: 1; justify-content: center; padding: 0.4rem 0.5rem; }
    .main-content { padding: 1rem 0 2.5rem 0; }
    .dispatch-article { padding: 1.35rem 1rem; }
    .article-headline { font-size: 1.35rem; }
    .article-footer { flex-direction: column; align-items: stretch; gap: 0.75rem; }
    .article-links { justify-content: flex-start; }
    .card-action-bar { justify-content: space-between; width: 100%; }
    .card-action-btn { flex: 1; justify-content: center; padding: 0.45rem 0.5rem; }
    .masthead-branding { gap: 0.65rem; }
    .masthead-logo { height: 2.25rem; }
    .journal-title { font-size: 1.5rem; }
    .journal-subtitle { font-size: 0.8rem; }
    .curation-banner { margin-top: 2rem; flex-direction: column; gap: 0.4rem; padding: 0.75rem 1rem; }
    .banner-divider { display: none; }
    .toast { left: 16px; right: 16px; bottom: 16px; justify-content: space-between; }
}