/* === CSS Custom Properties === */
:root {
    --bg: #f8f9fb;
    --bg-card: #ffffff;
    --bg-hover: #f1f3f8;
    --text: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #8892a4;
    --border: #e2e6ef;
    --border-hover: #c7cdd9;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: rgba(79, 70, 229, 0.08);
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.08);
    --warning: #f59e0b;
    --error: #dc2626;
    --nav-bg: rgba(255, 255, 255, 0.85);
    --nav-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
    --card-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.03);
    --card-shadow-hover: 0 2px 4px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.06);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg: #0c1220;
    --bg-card: #161f31;
    --bg-hover: #1c2840;
    --text: #e4e8f1;
    --text-secondary: #a0aec0;
    --text-muted: #6b7a94;
    --border: #243049;
    --border-hover: #344563;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-soft: rgba(129, 140, 248, 0.1);
    --success-soft: rgba(22, 163, 74, 0.12);
    --nav-bg: rgba(12, 18, 32, 0.88);
    --nav-shadow: 0 1px 2px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.15);
    --card-shadow: 0 1px 2px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.1);
    --card-shadow-hover: 0 2px 4px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.15);
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* === Navbar === */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 56px;
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--nav-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    transition: opacity var(--transition);
}
.logo:hover { opacity: 0.8; color: var(--text); text-decoration: none; }

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: #fff;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
}

.logo-text {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.nav-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.25rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 500;
    padding: 0.38rem 0.75rem;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    position: relative;
}

.nav-links a:hover {
    color: var(--text);
    background: var(--accent-soft);
    text-decoration: none;
}

.nav-links a.active {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

/* Nav right-side elements */
.nav-updated {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.nav-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}
.nav-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border-hover);
    text-decoration: none;
}

/* Sign in button */
.nav-signin-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 1rem;
    background: var(--accent);
    color: #fff !important;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all var(--transition);
    letter-spacing: -0.01em;
}
.nav-signin-btn:hover {
    background: var(--accent-hover);
    color: #fff !important;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* User pill (authenticated) */
.nav-user-pill {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    transition: all var(--transition);
}
.nav-user-pill:hover {
    border-color: var(--border-hover);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.nav-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0;
    flex-shrink: 0;
}

.nav-user-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}
.nav-logout:hover {
    background: var(--bg-hover);
    color: var(--accent);
    text-decoration: none;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
}

.btn-large { padding: 0.7rem 1.75rem; font-size: 0.95rem; }

.btn-icon {
    padding: 0.4rem 0.55rem;
    font-size: 1.05rem;
    line-height: 1;
}

.refresh-icon { font-size: 1rem; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-primary.refreshing .refresh-icon {
    animation: spin 1s linear infinite;
}

/* Theme toggle */
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }

/* === Container === */
.container {
    max-width: 940px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* === Progress Banner === */
.progress-banner {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}

.progress-content {
    max-width: 940px;
    margin: 0 auto;
}

.progress-bar-track {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.5s ease;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.progress-banner:not(.done):not(.error) .progress-bar-fill {
    animation: progress-pulse 2s ease-in-out infinite;
}

.progress-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.progress-banner.done .progress-bar-fill {
    background: var(--success);
}

.progress-banner.error .progress-bar-fill {
    background: var(--error);
}

/* === Digest Header === */
.digest-header {
    margin-bottom: 1.75rem;
}

.digest-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    letter-spacing: -0.02em;
}

.digest-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* === Filter Bar === */
.filter-bar {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-select, .filter-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.84rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-select { min-width: 170px; }
.filter-input { flex: 1; min-width: 200px; }

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* === Category Heading === */
.category-heading {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 2.25rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

/* === Story Card === */
.story-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    margin-bottom: 0.6rem;
    box-shadow: var(--card-shadow);
    transition: all var(--transition);
    position: relative;
}

.story-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-1px);
}

.story-card-accent {
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    width: 3px;
    border-radius: 0 3px 3px 0;
}

.story-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.story-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.3rem; line-height: 1.4; letter-spacing: -0.01em; }
.story-title a { color: var(--text); }
.story-title a:hover { color: var(--accent); text-decoration: none; }

.story-meta {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.source-icon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
    object-fit: contain;
}

.source-icon-lg {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.story-meta .source {
    font-weight: 500;
}

.summary-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === Source Badges (full article vs headline only) === */
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.source-full {
    background: var(--success-soft);
    color: #16a34a;
    border: 1px solid rgba(22, 163, 74, 0.2);
}

[data-theme="dark"] .source-full {
    color: #4ade80;
    border-color: rgba(22, 163, 74, 0.25);
}

.source-headline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* === Category Badges === */
.category-badge {
    display: inline-block;
    padding: 0.12rem 0.55rem;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.category-world { background: #dbeafe; color: #1e40af; }
.category-technology { background: #ede9fe; color: #5b21b6; }
.category-business { background: #dcfce7; color: #166534; }
.category-science { background: #fef9c3; color: #854d0e; }
.category-health { background: #fce7f3; color: #9d174d; }
.category-sports { background: #ffedd5; color: #9a3412; }
.category-entertainment { background: #f3e8ff; color: #7c3aed; }
.category-nation { background: #e0e7ff; color: #3730a3; }

[data-theme="dark"] .category-world { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .category-technology { background: #2e1065; color: #c4b5fd; }
[data-theme="dark"] .category-business { background: #14532d; color: #86efac; }
[data-theme="dark"] .category-science { background: #422006; color: #fde047; }
[data-theme="dark"] .category-health { background: #500724; color: #f9a8d4; }
[data-theme="dark"] .category-sports { background: #431407; color: #fdba74; }
[data-theme="dark"] .category-entertainment { background: #3b0764; color: #d8b4fe; }
[data-theme="dark"] .category-nation { background: #1e1b4b; color: #a5b4fc; }

/* Category accent colors for story card left bar */
.accent-world { background: #3b82f6; }
.accent-technology { background: #7c3aed; }
.accent-business { background: #16a34a; }
.accent-science { background: #eab308; }
.accent-health { background: #ec4899; }
.accent-sports { background: #f97316; }
.accent-entertainment { background: #a855f7; }
.accent-nation { background: #4f46e5; }

/* === Bookmark Button === */
.bookmark-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.15rem;
    color: var(--text-muted);
    padding: 0.2rem;
    transition: all var(--transition);
    border-radius: 4px;
}

.bookmark-btn:hover { transform: scale(1.15); color: var(--warning); }

.bookmark-btn .bookmark-icon-active { display: none; }
.bookmark-btn.active .bookmark-icon { display: none; }
.bookmark-btn.active .bookmark-icon-active { display: inline; color: var(--warning); }

@keyframes bookmark-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.bookmark-btn.just-toggled {
    animation: bookmark-pop 0.3s ease;
}

/* === Story Detail === */
.story-detail { max-width: 720px; margin: 0 auto; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.75rem;
    padding: 0.3rem 0.6rem;
    margin-left: -0.6rem;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}

.back-link:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }

.story-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.story-detail-title {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.story-detail-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.story-detail-meta .source { font-weight: 600; }

.original-link {
    margin-left: auto;
    font-weight: 500;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}

.original-link:hover { background: var(--accent-soft); }

.story-section {
    margin-bottom: 2rem;
}

.story-section h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.story-section p {
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-secondary);
}

.effects-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.75rem;
}

.effects-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.effects-list {
    padding-left: 1.25rem;
}

.effects-list li {
    margin-bottom: 0.6rem;
    line-height: 1.6;
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.effects-list li:last-child { margin-bottom: 0; }

/* === Status Badges === */
.status-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
}

.status-running { background: #dbeafe; color: #1e40af; }
.status-failed { background: #fee2e2; color: #991b1b; }

[data-theme="dark"] .status-running { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .status-failed { background: #450a0a; color: #fca5a5; }

/* === Archive === */
.archive-list { display: flex; flex-direction: column; gap: 0.5rem; }

.archive-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    transition: all var(--transition);
    box-shadow: var(--card-shadow);
}

.archive-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-1px);
    text-decoration: none;
}

.archive-date {
    font-weight: 600;
    font-size: 1rem;
    min-width: 110px;
}

.archive-info { flex: 1; display: flex; align-items: center; gap: 0.75rem; }
.archive-count { color: var(--text-muted); font-size: 0.85rem; }
.archive-duration {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.1rem 0.45rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-variant-numeric: tabular-nums;
}
.digest-duration {
    font-variant-numeric: tabular-nums;
}
.archive-arrow { color: var(--text-muted); font-size: 1.1rem; }

/* === Bookmarks === */
.bookmark-digest-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bookmark-digest-date:first-child { margin-top: 0; }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
}

.empty-state h1 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

/* === Notes & Action Items === */
.notes-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.note-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.note-item:hover {
    border-color: var(--border-hover);
}

.note-item.is-action {
    border-left: 3px solid var(--warning);
}

.note-item.done {
    opacity: 0.5;
}

.note-item.done .note-content {
    text-decoration: line-through;
}

.action-check {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.15rem;
    padding: 0;
    margin-top: 0.05rem;
    line-height: 1;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color var(--transition);
}

.action-check:hover { color: var(--text); }

.action-check .check-done { display: none; }
.done .action-check .check-empty { display: none; }
.done .action-check .check-done { display: inline; color: var(--success); }

.note-body {
    flex: 1;
    min-width: 0;
}

.note-content {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    word-wrap: break-word;
}

.note-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    display: block;
}

.note-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    padding: 0 0.25rem;
    opacity: 0;
    transition: all var(--transition);
    flex-shrink: 0;
}

.note-item:hover .note-delete { opacity: 1; }
.note-delete:hover { color: var(--error); }

.note-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.note-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.5rem 0.75rem;
    font-size: 0.87rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    resize: vertical;
    min-height: 2.5rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.note-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.note-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.action-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    user-select: none;
}

.action-toggle input[type="checkbox"] {
    accent-color: var(--warning);
}

.action-toggle-label {
    font-weight: 500;
}

.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
}

/* Action Items Page */
.actions-page h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.87rem;
    margin-bottom: 2rem;
}

.actions-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.action-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.action-row:hover {
    border-color: var(--border-hover);
    border-left-color: var(--warning);
}

.action-row.done {
    opacity: 0.5;
    border-left-color: var(--success);
}

.action-row.done .action-content {
    text-decoration: line-through;
}

.action-body {
    flex: 1;
    min-width: 0;
}

.action-content {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 0.3rem;
    word-wrap: break-word;
}

.action-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.action-story-link {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.action-story-link:hover { color: var(--accent); }

.action-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.action-row .note-delete { opacity: 0; }
.action-row:hover .note-delete { opacity: 1; }

/* === Narrative Timeline (Story Detail) === */
.narrative-section {
    margin-top: 2.5rem;
}

.narrative-timeline {
    position: relative;
    padding-left: 1.5rem;
    margin-top: 1rem;
}

.narrative-timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 1rem;
    padding-left: 1rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -1.5rem;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    z-index: 1;
}

.timeline-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    transition: all var(--transition);
}

.timeline-content:hover {
    border-color: var(--border-hover);
    box-shadow: var(--card-shadow);
}

.timeline-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.15rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.timeline-title {
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--text);
    display: block;
    margin-bottom: 0.25rem;
    line-height: 1.35;
}

.timeline-title:hover {
    color: var(--accent);
    text-decoration: none;
}

.timeline-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.timeline-source {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.timeline-similarity {
    font-size: 0.68rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.08rem 0.45rem;
    border-radius: 99px;
    font-weight: 500;
    border: 1px solid var(--border);
}

/* ==========================================
   TRENDS PAGE
   ========================================== */

.trends-page h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    letter-spacing: -0.02em;
}

/* Stats bar */
.trends-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.2rem;
    padding: 0.9rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    align-items: center;
    flex-wrap: wrap;
}

.trend-stat {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

.trend-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.trend-stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.trend-stat-escalating .trend-stat-value { color: #dc2626; }
.trend-stat-stable .trend-stat-value { color: #2563eb; }
.trend-stat-de-escalating .trend-stat-value { color: #16a34a; }
.trend-stat-new .trend-stat-value { color: #d97706; }

[data-theme="dark"] .trend-stat-escalating .trend-stat-value { color: #f87171; }
[data-theme="dark"] .trend-stat-stable .trend-stat-value { color: #60a5fa; }
[data-theme="dark"] .trend-stat-de-escalating .trend-stat-value { color: #4ade80; }
[data-theme="dark"] .trend-stat-new .trend-stat-value { color: #fbbf24; }

/* Category mini bar chart */
.trend-stat-catbar {
    display: flex;
    height: 26px;
    border-radius: 4px;
    overflow: hidden;
    flex: 1;
    min-width: 120px;
    max-width: 280px;
    border: 1px solid var(--border);
}

.catbar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    transition: flex 0.3s ease;
}

.catbar-segment span {
    font-size: 0.6rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.category-bg-world { background: #3b82f6; }
.category-bg-technology { background: #8b5cf6; }
.category-bg-business { background: #f59e0b; }
.category-bg-nation { background: #ef4444; }
.category-bg-science { background: #10b981; }
.category-bg-health { background: #ec4899; }
.category-bg-sports { background: #06b6d4; }
.category-bg-entertainment { background: #f97316; }

/* Controls bar */
.trends-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.trend-search {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.82rem;
    font-family: var(--font);
    width: 200px;
    transition: all var(--transition);
}

.trend-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.trend-search::placeholder {
    color: var(--text-muted);
}

.trend-filter-group {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.trend-sort {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.78rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.trend-sort:focus {
    outline: none;
    border-color: var(--accent);
}

.trend-filter-btn {
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.73rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.trend-filter-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.trend-filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Keyboard hint */
.trends-keyboard-hint {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.6;
}

.trends-keyboard-hint kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg);
    font-family: var(--font);
    font-size: 0.65rem;
    margin: 0 0.1rem;
}

/* Thread list */
.threads-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Thread card base */
.thread-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    transition: all var(--transition);
    overflow: hidden;
}

.thread-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--card-shadow-hover);
}

.thread-card.focused {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft), var(--card-shadow-hover);
}

.thread-card.dormant {
    opacity: 0.55;
}

.thread-card-body {
    padding: 1rem 1.15rem;
    display: flex;
    gap: 0.85rem;
}

/* Thread accent bar */
.thread-accent {
    width: 3px;
    flex-shrink: 0;
    border-radius: 3px;
    align-self: stretch;
    transition: width 0.3s ease;
}

/* Featured tier: thicker accent + glow */
.thread-tier-featured .thread-accent {
    width: 4px;
}

.thread-accent-escalating { background: #dc2626; }
.thread-accent-stable { background: #2563eb; }
.thread-accent-de-escalating { background: #16a34a; }
.thread-accent-dormant { background: var(--text-muted); }

.thread-tier-featured .thread-accent-escalating {
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.3);
}

[data-theme="dark"] .thread-accent-escalating { background: #f87171; }
[data-theme="dark"] .thread-accent-stable { background: #60a5fa; }
[data-theme="dark"] .thread-accent-de-escalating { background: #4ade80; }

[data-theme="dark"] .thread-tier-featured .thread-accent-escalating {
    box-shadow: 0 0 8px rgba(248, 113, 113, 0.3);
}

.thread-content {
    flex: 1;
    min-width: 0;
}

.thread-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.thread-badges {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: wrap;
}

.thread-indicators {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.trajectory-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.12rem 0.5rem;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.trajectory-escalating { background: #fee2e2; color: #b91c1c; }
.trajectory-stable { background: #dbeafe; color: #1d4ed8; }
.trajectory-de-escalating { background: #dcfce7; color: #15803d; }
.trajectory-dormant { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

[data-theme="dark"] .trajectory-escalating { background: rgba(220, 38, 38, 0.15); color: #fca5a5; }
[data-theme="dark"] .trajectory-stable { background: rgba(37, 99, 235, 0.15); color: #93c5fd; }
[data-theme="dark"] .trajectory-de-escalating { background: rgba(22, 163, 74, 0.15); color: #86efac; }

/* NEW badge */
.thread-badge-new {
    display: inline-block;
    padding: 0.08rem 0.4rem;
    border-radius: 4px;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

[data-theme="dark"] .thread-badge-new {
    background: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
    border-color: rgba(251, 191, 36, 0.3);
}

/* DEVELOPING badge */
.thread-badge-developing {
    display: inline-block;
    padding: 0.08rem 0.4rem;
    border-radius: 4px;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    animation: pulse-developing 2s ease-in-out infinite;
}

[data-theme="dark"] .thread-badge-developing {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

@keyframes pulse-developing {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

/* Signal strength bars */
.signal-bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 1.5px;
    height: 14px;
}

.signal-bars span {
    width: 3px;
    border-radius: 1px;
    background: var(--text-muted);
    opacity: 0.18;
    transition: opacity 0.3s;
}

.signal-bars span:nth-child(1) { height: 4px; }
.signal-bars span:nth-child(2) { height: 6px; }
.signal-bars span:nth-child(3) { height: 8px; }
.signal-bars span:nth-child(4) { height: 10px; }
.signal-bars span:nth-child(5) { height: 12px; }

.signal-bars span.active { opacity: 1; background: var(--accent); }

.thread-signal-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 1.2em;
    text-align: right;
}

.thread-title {
    font-size: 1.02rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.thread-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.35rem;
}

.thread-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.71rem;
    color: var(--text-muted);
}

/* --- Tier: Standard --- */
.thread-tier-standard .thread-card-body {
    padding: 0.75rem 1.1rem;
}

.thread-tier-standard .thread-summary {
    display: none;
}

.thread-tier-standard .thread-title {
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}

/* --- Tier: Compact --- */
.thread-tier-compact .thread-card-body {
    padding: 0.55rem 1rem;
}

.thread-tier-compact .thread-summary,
.thread-tier-compact .thread-meta {
    display: none;
}

.thread-tier-compact .thread-title {
    font-size: 0.88rem;
    margin-bottom: 0;
}

.thread-tier-compact .thread-header {
    margin-bottom: 0.15rem;
}

.thread-tier-compact .thread-accent {
    width: 2px;
}

/* Expand all override: show everything full */
.threads-list.all-expanded .thread-tier-standard .thread-summary,
.threads-list.all-expanded .thread-tier-compact .thread-summary,
.threads-list.all-expanded .thread-tier-compact .thread-meta {
    display: flex;
}

.threads-list.all-expanded .thread-tier-standard .thread-card-body,
.threads-list.all-expanded .thread-tier-compact .thread-card-body {
    padding: 1rem 1.15rem;
}

.threads-list.all-expanded .thread-tier-standard .thread-title,
.threads-list.all-expanded .thread-tier-compact .thread-title {
    font-size: 1.02rem;
}

/* Expand button */
.thread-expand-btn {
    background: none;
    border: none;
    padding: 0.4rem 1.15rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    font-weight: 500;
    width: 100%;
    text-align: center;
    border-top: 1px solid var(--border);
}

.thread-expand-btn:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

/* Timeline */
.thread-timeline {
    margin: 0;
    border-top: 1px solid var(--border);
    padding: 0.9rem 1.25rem;
    background: var(--bg);
}

.timeline-signal {
    font-size: 0.83rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 0.15rem;
}

.thread-no-signals {
    font-size: 0.83rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.5rem 0;
}

.timeline-loading {
    font-size: 0.83rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.5rem 0;
}

/* View toggle */
.trends-view-toggle {
    text-align: center;
    margin-top: 1rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-text:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

/* Story-thread link on story detail page */
.story-threads {
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.story-thread-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.7rem;
    background: var(--accent-soft);
    border: 1px solid rgba(79, 70, 229, 0.15);
    border-radius: 99px;
    font-size: 0.78rem;
    color: var(--accent);
    text-decoration: none;
    transition: all var(--transition);
}

[data-theme="dark"] .story-thread-link {
    border-color: rgba(129, 140, 248, 0.2);
}

.story-thread-link:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    text-decoration: none;
}

.story-thread-link strong {
    color: inherit;
    font-weight: 600;
}

/* Dormant section */
.dormant-section {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.dormant-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 1rem;
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: var(--font);
    transition: all var(--transition);
}

.dormant-toggle:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.dormant-list {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* === Page fade-in === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    animation: fadeInUp 0.3s ease-out;
}

/* === Progressive Loading === */
.story-card-new {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.story-card-new:not(.story-card-new) {
    opacity: 1;
    transform: translateY(0);
}

.analyzing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    margin-top: 0.75rem;
    background: var(--accent-soft);
    border: 1px dashed var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 0.87rem;
    font-weight: 500;
}

.analyzing-spinner {
    display: inline-block;
    font-size: 1.1rem;
    animation: spin 1.5s linear infinite;
}

/* === Responsive === */
@media (max-width: 640px) {
    .navbar { padding: 0 0.75rem; height: 50px; }
    .nav-left, .nav-right { gap: 0.3rem; }
    .logo-text { display: none; }
    .nav-divider { display: none; }
    .nav-links a { padding: 0.3rem 0.5rem; font-size: 0.78rem; }
    .nav-user-name { display: none; }
    .nav-user-pill { padding: 0.2rem; }
    .nav-updated { display: none; }
    .container { padding: 1.25rem 1rem; }
    .filter-bar { flex-direction: column; }
    .filter-select { min-width: unset; width: 100%; }
    .story-detail-meta { flex-wrap: wrap; }
    .story-detail-title { font-size: 1.35rem; }
    .thread-card-body { padding: 0.75rem 0.9rem; }
    .thread-header { flex-direction: column; align-items: flex-start; gap: 0.35rem; }
    .thread-meta { flex-direction: column; gap: 0.2rem; }
    .trends-stats { flex-wrap: wrap; gap: 0.8rem; }
    .trends-controls { flex-wrap: wrap; gap: 0.4rem; }
    .trend-search { width: 100%; }
    .trend-stat-catbar { max-width: 100%; min-width: 80px; }
    .trends-keyboard-hint { display: none; }
}

/* === Auth Pages === */
.sign-in-prompt {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 1.5rem 0;
}
.sign-in-prompt a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.sign-in-prompt a:hover {
    text-decoration: underline;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 2rem 1rem;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.auth-title {
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 0.25rem;
    color: var(--text);
}
.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin: 0 0 1.5rem;
    font-size: 0.9rem;
}
.auth-form .form-group {
    margin-bottom: 1rem;
}
.auth-form label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}
.auth-form input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--bg);
    color: var(--text);
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.btn-full {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.7rem;
    font-size: 0.95rem;
}
.auth-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.auth-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.auth-footer a:hover {
    text-decoration: underline;
}
.flash {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}
.flash-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.flash-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}
/* (nav-user styles moved to navbar section) */

/* === Settings Page === */
.settings-page { max-width: 600px; }
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.settings-section h2 {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
}
.settings-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0 0 1rem;
}
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.5rem;
}
.category-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-size: 0.85rem;
}
.category-toggle:hover {
    background: var(--bg-hover);
}
.category-toggle input:checked + .category-label {
    font-weight: 600;
    color: var(--accent);
}
.settings-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}
.save-status { font-size: 0.85rem; }
.save-ok { color: var(--success); }
.save-error { color: var(--error); }
