/* ===== ClaudeNews — bespoke dark editorial theme ===== */

:root,
[data-bs-theme="dark"] {
    /* Electric-blue accent + gradient */
    --accent: #4d8dff;
    --accent-hover: #76a6ff;
    --accent-rgb: 77, 141, 255;
    --accent-2: #7b6bff;
    --grad: linear-gradient(135deg, #4d8dff 0%, #7b6bff 100%);
    --grad-soft: linear-gradient(135deg, rgba(77, 141, 255, 0.16), rgba(123, 107, 255, 0.16));

    /* Surfaces */
    --bg: #0a0b0e;
    --bg-2: #0d0f13;
    --surface: #14161c;
    --surface-2: #181b22;
    --surface-top: rgba(255, 255, 255, 0.05);
    --border: #23262f;
    --border-strong: #2e323d;

    /* Text */
    --text: #eceef3;
    --text-soft: #c7ccd6;
    --text-muted: #868c99;

    /* Type */
    --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --font-sans: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "Geist Mono", "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, monospace;

    /* Radii + shadow */
    --r-sm: 10px;
    --r: 16px;
    --r-lg: 22px;
    --shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.85);
    --shadow-glow: 0 14px 40px -16px rgba(var(--accent-rgb), 0.45);

    /* Map onto Bootstrap */
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-emphasis-color: var(--text);
    --bs-secondary-color: var(--text-muted);
    --bs-tertiary-color: var(--text-muted);
    --bs-border-color: var(--border);
    --bs-primary: var(--accent);
    --bs-primary-rgb: var(--accent-rgb);
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: var(--accent-rgb);
    --bs-link-hover-color: var(--accent-hover);
    --bs-font-sans-serif: var(--font-sans);
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-feature-settings: "ss01", "cv01";
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.011em;
    position: relative;
}

/* Ambient accent glow behind the page */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background:
        radial-gradient(900px 480px at 50% -8%, rgba(var(--accent-rgb), 0.16), transparent 70%),
        radial-gradient(700px 420px at 100% 0%, rgba(123, 107, 255, 0.10), transparent 70%),
        linear-gradient(180deg, var(--bg-2), var(--bg) 460px);
}

main { flex: 1; }

h1, h2, h3, h4, h5, h6 { color: var(--text); }

/* Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 3px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover { background: #3a3f4c; }

::selection { background: rgba(var(--accent-rgb), 0.32); color: #fff; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===== Eyebrow / kicker label ===== */
.kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
}

.kicker-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.18);
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ===== Buttons ===== */
.btn { border-radius: var(--r-sm); font-weight: 600; transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease; }
.btn:active { transform: translateY(1px); }

.btn-primary {
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-border-color: transparent;
    --bs-btn-color: #06122b;
    --bs-btn-hover-color: #06122b;
    --bs-btn-active-color: #06122b;
    background-image: var(--grad);
    border: none;
    box-shadow: 0 8px 24px -10px rgba(var(--accent-rgb), 0.7);
}
.btn-primary:hover {
    background-image: var(--grad);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-outline-primary {
    --bs-btn-color: var(--accent);
    --bs-btn-border-color: rgba(var(--accent-rgb), 0.45);
    --bs-btn-bg: rgba(var(--accent-rgb), 0.04);
    --bs-btn-hover-bg: rgba(var(--accent-rgb), 0.14);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-hover-color: var(--accent-hover);
    --bs-btn-active-bg: rgba(var(--accent-rgb), 0.18);
    --bs-btn-active-border-color: var(--accent);
    --bs-btn-active-color: var(--accent-hover);
    backdrop-filter: blur(6px);
}

.btn-lg { border-radius: 12px; padding-inline: 1.6rem; }

/* ===== Top navigation ===== */
.site-nav {
    background-color: rgba(10, 11, 14, 0.72);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.navbar-brand {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.brand-accent {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.site-nav .nav-link {
    position: relative;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.92rem;
    padding: 0.35rem 0.95rem;
    border-radius: 999px;
    transition: color 0.14s ease, background-color 0.14s ease;
}

.site-nav .nav-link:hover,
.site-nav .nav-link:focus { color: var(--text); }

.site-nav .nav-link.active {
    color: var(--text);
    background: var(--grad-soft);
}

/* ===== Page header ===== */
.page-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.2rem, 5vw, 3.1rem);
    line-height: 1.03;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 1.02rem;
    max-width: 60ch;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.14s ease, gap 0.14s ease;
}

.back-link:hover { color: var(--accent); gap: 0.6rem; }

/* ===== Feed ===== */
.feed-header {
    max-width: 760px;
    margin: 0 auto 2rem;
}

.feed {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* A class-level display rule outranks the [hidden] attribute, so be explicit: the search code
   toggles `hidden` to swap between the feed and its search results. */
.feed[hidden] {
    display: none;
}

/* Admin-only headline search box. Sits between the header and the feed. */
.feed-search {
    position: relative;
    max-width: 760px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
}

.feed-search-icon {
    position: absolute;
    left: 0.95rem;
    color: var(--text-muted);
    pointer-events: none;
}

.feed-search-input {
    width: 100%;
    background-color: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 0.7rem 0.95rem 0.7rem 2.6rem;
}

.feed-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(var(--accent-rgb), 0.22);
}

.feed-search-status {
    position: absolute;
    right: 0.95rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    pointer-events: none;
}

[data-theme="eink"] .feed-search-input {
    border: 2px solid #000;
    border-radius: 0;
}

[data-theme="eink"] .feed-search-input:focus {
    box-shadow: none;
    border-color: #000;
}

/* "Unread only" feed filter. Sits between the header (or admin search) and the feed, aligned right. */
.feed-controls {
    max-width: 760px;
    margin: 0 auto 1.25rem;
    display: flex;
    justify-content: flex-end;
}

.unread-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.unread-toggle input {
    cursor: pointer;
    accent-color: var(--accent);
    margin: 0;
}

/* When active, read cards drop out of the feed. They keep their `.is-read` class either way, so
   clearing the toggle brings them straight back without a reload. */
.feed.unread-only .feed-item.is-read {
    display: none;
}

[data-theme="eink"] .unread-toggle input {
    accent-color: #000;
}

.feed-item {
    position: relative;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 1.35rem 1.5rem 1.2rem;
    overflow: hidden;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

/* Accent rail that lights up on hover */
.feed-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--grad);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.feed-item:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.feed-item:hover::before { opacity: 1; }

.feed-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
    /* Reserve room for the floating bookmark button (top-right) so the
       trailing "Read" badge never slides under it and gets clipped. */
    padding-right: 2.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.7rem;
}

.feed-meta .dot { opacity: 0.4; }
.feed-meta .source { color: var(--text-soft); }
/* "+N" hint for the other outlets a story drew on, kept quieter than the primary source. */
.feed-meta .source-more { color: var(--text-muted); opacity: 0.75; }

.feed-title {
    font-family: var(--font-display);
    font-size: 1.42rem;
    font-weight: 600;
    line-height: 1.18;
    letter-spacing: -0.015em;
    margin: 0 0 0.55rem;
}

.feed-title a {
    color: var(--text);
    text-decoration: none;
    background-image: linear-gradient(var(--accent), var(--accent));
    background-size: 0% 1.5px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: color 0.16s ease, background-size 0.25s ease;
}

.feed-item:hover .feed-title a {
    color: var(--accent-hover);
    background-size: 100% 1.5px;
}

.feed-snippet {
    color: var(--text-muted);
    font-size: 0.97rem;
    line-height: 1.6;
    margin: 0 0 1rem;
}

.feed-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.85rem;
}

.read-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.read-link:hover { color: var(--accent-hover); }

.source-out {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}
.source-out:hover { color: var(--text); }

.feed-sentinel {
    max-width: 760px;
    margin: 1.75rem auto 0;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hidden while a headline search is active (see .feed[hidden] above). */
.feed-sentinel[hidden] {
    display: none;
}

.feed-sentinel .feed-end-text {
    display: none;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.feed-sentinel.is-done .feed-spinner { display: none; }
.feed-sentinel.is-done .feed-end-text { display: inline; }

/* ===== "Done for the day" divider between today's batch and the older pile ===== */
/* Reuses the page-header treatment (kicker / title / subtitle), scaled down a touch so it reads
   as a mid-feed section break rather than a second hero. */
.feed-divider {
    margin: 0.5rem 0;
    padding-top: 1.8rem;
    border-top: 1px dashed var(--border-strong);
}

.feed-divider .kicker {
    margin-bottom: 0.6rem;
}

.feed-divider-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.85rem;
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 0 0 0.4rem;
}

/* ===== Topic tag ===== */
.topic-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-hover);
    background: var(--grad-soft);
    border: 1px solid rgba(var(--accent-rgb), 0.22);
    border-radius: 999px;
    padding: 0.26rem 0.7rem;
}

.topic-tag::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
}

/* ===== Empty / loading ===== */
.empty-state {
    max-width: 560px;
    margin: 2.5rem auto;
    padding: 3.25rem 1.75rem;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
}

.text-accent { color: var(--accent) !important; }
.spinner-border.text-primary { color: var(--accent) !important; }

/* ===== Article reading layout ===== */
.article-body {
    max-width: 680px;
    margin: 0 auto;
    font-size: 1.14rem;
    line-height: 1.82;
    color: var(--text-soft);
}

.article-headline {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.1rem, 5.2vw, 3.2rem);
    line-height: 1.05;
    letter-spacing: -0.022em;
    color: var(--text);
}

.article-body > section:first-of-type > p:first-child::first-letter {
    float: left;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 3.4em;
    line-height: 0.74;
    padding: 0.06em 0.12em 0 0;
    color: var(--accent);
}

.article-body p { margin-bottom: 1.35rem; }

.key-points {
    background: var(--grad-soft);
    border: 1px solid rgba(var(--accent-rgb), 0.22);
    border-radius: var(--r);
    padding: 1.5rem 1.7rem;
}

.key-points h4 {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-hover);
}

.key-points ul { padding-left: 1.1rem; }
.key-points li {
    margin-bottom: 0.6rem;
    line-height: 1.6;
    color: var(--text);
}
.key-points li::marker { color: var(--accent); }

/* Claude's own skeptical take — amber, to set it apart from the blue Key Takeaways. */
.scrutiny-section {
    --scrutiny: #f59e3c;
    --scrutiny-rgb: 245, 158, 60;
    background: linear-gradient(135deg, rgba(var(--scrutiny-rgb), 0.13), rgba(var(--scrutiny-rgb), 0.05));
    border: 1px solid rgba(var(--scrutiny-rgb), 0.30);
    border-left: 3px solid var(--scrutiny);
    border-radius: var(--r);
    padding: 1.5rem 1.7rem;
    line-height: 1.7;
}

.scrutiny-section h4 {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--scrutiny);
}

.scrutiny-section p { color: var(--text-soft); }
.scrutiny-section p:last-child { margin-bottom: 0 !important; }

/* "Holds up to scrutiny" score badge next to the heading. */
.scrutiny-score {
    --score: 148, 163, 184;
    display: inline-flex;
    align-items: baseline;
    gap: 0.05em;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.28em 0.6em;
    border-radius: 999px;
    color: rgb(var(--score));
    background: rgba(var(--score), 0.14);
    border: 1px solid rgba(var(--score), 0.40);
}
.scrutiny-score .scrutiny-score-max {
    font-size: 0.7em;
    font-weight: 600;
    opacity: 0.7;
}
.scrutiny-score.score-good { --score: 52, 199, 123; }   /* green  — holds up well */
.scrutiny-score.score-mid  { --score: 245, 158, 60; }   /* amber  — some concerns */
.scrutiny-score.score-bad  { --score: 240, 90, 90; }    /* red    — significant concerns */

.discussion-section {
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 1.5rem 1.7rem;
    line-height: 1.7;
}

.discussion-section h4,
.notes-section h4,
.perspectives-section h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.discussion-section p { color: var(--text-muted); }

/* Every outlet Claude drew on, with a short note on its angle and where it stands vs. the others. */
.perspectives-intro { display: block; }
.perspectives-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.perspective-item {
    padding-left: 0.9rem;
    border-left: 2px solid var(--border);
    line-height: 1.5;
    word-break: break-word;
}
.perspective-source .source-link { font-weight: 600; }
.perspective-note {
    margin-top: 0.2rem;
    color: var(--text-muted);
    line-height: 1.55;
}

/* Related YouTube videos Claude surfaced and we validated via oEmbed. */
.videos-intro { display: block; }
.videos-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.video-link {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 0.6rem;
    border: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}
.video-link:hover { background-color: var(--surface-2); }
.video-thumb {
    position: relative;
    flex: 0 0 auto;
    width: 128px;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface);
}
.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.video-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.35);
}
.video-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}
.video-title { font-weight: 600; line-height: 1.3; }
.video-channel { font-size: 0.85em; color: var(--text-muted); }
.video-note {
    margin-top: 0.15rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ===== Article toolbar ===== */
.article-toolbar {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    padding: 1rem 0 1.4rem;
    margin-bottom: 1.6rem;
    border-bottom: 1px solid var(--border);
}

.article-audio {
    display: block;
    width: 100%;
    max-width: 460px;
    height: 40px;
    margin: -0.6rem 0 1.6rem;
}

.card-meta {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

/* Quiet end-of-article support line. No rule of its own — it sits inside the existing
   end-matter block (under the Read divider, beside the "Generated" line) so the page bottom
   isn't crowded with stacked borders. Muted, centred: reads as a footer note, not an insert. */
.support-note {
    margin-top: 1.75rem;
    text-align: center;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
}
.support-note a {
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.14s ease;
}
.support-note a:hover { color: var(--accent); }
/* The Ko-fi trigger link; opens the support modal (or falls back to its href with JS off). */
.support-cta { margin-top: 0.9rem; }

/* Ko-fi support modal: a compact, themed shell around Ko-fi's embedded donation panel. The
   iframe keeps Ko-fi's own light panel background; only the surrounding chrome is themed. */
.kofi-modal-dialog { max-width: 420px; }
.kofi-modal-content {
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--surface);
}
.kofi-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0.5rem 0.75rem 1.1rem;
    border-bottom: 1px solid var(--border);
}
.kofi-modal-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    margin: 0;
}
.kofi-modal-close {
    flex: none;
    width: 2.4rem;
    height: 2.4rem;
    background: none;
    border: none;
    font-size: 1.7rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.14s ease;
}
.kofi-modal-close:hover { color: var(--text); }
.kofi-modal-frame {
    display: block;
    width: 100%;
    height: 70vh;
    min-height: 480px;
    max-height: 680px;
    border: none;
    background: #f9f9f9;
}

.source-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.14s ease;
}
.source-link:hover { color: var(--accent); }

#copyBtn.copied {
    background-image: var(--grad);
    border: none;
    color: #06122b;
    box-shadow: var(--shadow-glow);
}

/* ===== Notes ===== */
.notes-section {
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 1.4rem 1.6rem 1.5rem;
}

.notes-input {
    background-color: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    resize: vertical;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.65;
    padding: 0.9rem 1.05rem;
}

.notes-input:focus {
    background-color: var(--bg);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(var(--accent-rgb), 0.22);
}

.notes-input::placeholder { color: var(--text-muted); opacity: 0.65; }

.notes-status {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color 0.2s ease;
}
.notes-status.saved { color: var(--accent); }

.notes-count {
    margin-top: 0.4rem;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.notes-count.at-limit { color: var(--danger, #c0392b); font-weight: 600; }

/* ===== Refresh / fetch page ===== */
.refresh-wrap { max-width: 560px; margin: 0 auto; }

.refresh-panel {
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.8rem;
    margin-top: 1.6rem;
    box-shadow: var(--shadow);
}

.trigger-input {
    background-color: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 0.7rem 0.95rem;
}

.trigger-input:focus {
    background-color: var(--bg);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(var(--accent-rgb), 0.22);
}

.form-label {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.trigger-error { color: #ff8a93; font-size: 0.88rem; margin-top: 0.8rem; }

.progress-head { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 1rem; }

.progress-state {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
}

.refresh-progress {
    height: 9px;
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.refresh-progress .progress-bar {
    background-image: var(--grad);
    box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.55);
    transition: width 0.4s ease;
}

.progress-msg {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0.95rem 0 0;
    min-height: 1.2rem;
}

.progress-done { display: flex; gap: 0.65rem; margin-top: 1.2rem; }

/* ===== Time travel ===== */
.timetravel {
    max-width: 760px;
    margin: 0 auto 2.25rem;
}

.timetravel-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.timetravel-toggle svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.timetravel-panel { margin-top: 1rem; }

.timetravel-row {
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
}
.timetravel-field {
    flex: 1 1 180px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.trigger-input[type="date"] {
    color-scheme: dark;
}

/* ===== Timeline (central spine, alternating markers) ===== */
.timeline {
    --tl-half-gap: 1.3rem;
    position: relative;
    max-width: 760px;
    margin: 0 auto;
    padding: 0.5rem 0 1.5rem;
}

/* The colourful spine running down the centre */
.timeline::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: linear-gradient(180deg, #ff8a3d, #4d8dff 22%, #ff5d6c 44%, #2dd4bf 62%, #f472b6 80%, #a78bfa);
    opacity: 0.9;
}

.tl-group { position: relative; }

.tl-row {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: calc(var(--tl-half-gap) * 2);
    align-items: center;
    min-height: 3.6rem;
}

/* Node on the spine */
.tl-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--c, var(--accent));
    border: 3px solid var(--bg);
    box-shadow: 0 0 0 2px var(--c, var(--accent)), 0 0 16px -2px var(--c, var(--accent));
    z-index: 2;
    transition: transform 0.16s ease;
}

.tl-marker {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    max-width: 100%;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.5rem 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.16s ease, transform 0.14s ease, box-shadow 0.16s ease;
}
.tl-marker:hover { border-color: var(--c, var(--border-strong)); transform: translateY(-1px); box-shadow: var(--shadow); }
.tl-group.is-open .tl-marker { border-color: var(--c); }
.tl-group.is-open .tl-dot { transform: translate(-50%, -50%) scale(1.3); }

.tl-group[data-side="left"] .tl-marker { grid-column: 1; justify-self: end; }
.tl-group[data-side="right"] .tl-marker { grid-column: 2; justify-self: start; }

/* Tick connecting the marker to the spine */
.tl-marker::after {
    content: "";
    position: absolute;
    top: 50%;
    width: var(--tl-half-gap);
    height: 2px;
    background: var(--c, var(--border-strong));
    transform: translateY(-50%);
    z-index: 0;
}
.tl-group[data-side="left"] .tl-marker::after { right: calc(var(--tl-half-gap) * -1); }
.tl-group[data-side="right"] .tl-marker::after { left: calc(var(--tl-half-gap) * -1); }

.tl-date { display: flex; flex-direction: column; line-height: 1.05; text-align: left; }
.tl-date-main {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text);
}
.tl-date-year {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-top: 2px;
}

.tl-count {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: #06122b;
    background: var(--c, var(--accent));
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    white-space: nowrap;
}
.tl-count-n { font-weight: 700; }

.tl-chev {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: var(--text-muted);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.18s ease;
}
.tl-group.is-open .tl-chev { transform: rotate(180deg); }

/* Expanded article list */
.tl-articles {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-width: 620px;
    margin: 0.3rem auto 1.6rem;
    padding-left: 1rem;
    border-left: 2px solid var(--c, var(--border));
    animation: tlOpen 0.22s ease both;
}

@keyframes tlOpen {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.tl-article {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    text-decoration: none;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    transition: border-color 0.15s ease, transform 0.12s ease;
}
.tl-article:hover { border-color: var(--c, var(--border-strong)); transform: translateX(2px); }
.tl-article-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.25;
    color: var(--text);
}
.tl-article-meta {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.tl-article-dot { opacity: 0.4; }

/* Read timeline items keep full strength — the "Read" badge alone marks them. */
.tl-article.is-read .read-badge { display: inline-block; vertical-align: middle; }

@media (max-width: 480px) {
    .timeline { --tl-half-gap: 0.7rem; }
    .tl-marker { gap: 0.4rem; padding: 0.4rem 0.55rem; }
    .tl-date-main { font-size: 0.92rem; }
    .tl-count { font-size: 0.66rem; padding: 0.16rem 0.42rem; }
    .tl-count-word { display: none; }
    .tl-chev { width: 14px; height: 14px; }
    .tl-articles { padding-left: 0.75rem; }
}

/* ===== Footer ===== */
.site-footer {
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    letter-spacing: 0.05em;
}

.footer-links {
    margin-top: 0.5rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--text);
    text-decoration: underline;
}

.footer-sep {
    margin: 0 0.5rem;
    opacity: 0.6;
}

/* ===== Legal documents (Privacy, Terms) ===== */
.legal-doc {
    max-width: 46rem;
    margin: 0 auto;
}

.legal-doc h2 {
    margin-top: 1.75rem;
}

.legal-updated {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
}

.legal-callout {
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}

.legal-callout h2 {
    margin-top: 0;
}

/* ===== Alerts ===== */
.alert-danger {
    --bs-alert-bg: rgba(220, 53, 69, 0.12);
    --bs-alert-border-color: rgba(220, 53, 69, 0.35);
    --bs-alert-color: #ff8a93;
    border-radius: var(--r-sm);
}

/* ===== Top nav layout ===== */
.top-nav {
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
}

.nav-account {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.75rem;
}

.nav-user {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
    color: var(--text-muted, #9aa0a6);
}

/* ===== Bookmark toggle ===== */
.bookmark-btn {
    cursor: pointer;
    transition: color 0.15s ease, transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.bookmark-btn svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linejoin: round;
}
.bookmark-btn.is-bookmarked svg { fill: currentColor; }
.bookmark-btn:active { transform: scale(0.88); }

/* Floating icon button on feed cards */
.feed-item .bookmark-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 11px;
}
.feed-item .bookmark-btn:hover {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.12);
    border-color: rgba(var(--accent-rgb), 0.4);
}
.feed-item .bookmark-btn.is-bookmarked {
    color: var(--accent);
    border-color: rgba(var(--accent-rgb), 0.5);
    background: var(--grad-soft);
}

/* Article "Save" CTA (a real button) */
.bookmark-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}
.bookmark-cta.is-bookmarked {
    color: #06122b;
    background-image: var(--grad);
    border: none;
    box-shadow: 0 8px 24px -12px rgba(var(--accent-rgb), 0.7);
}

/* ===== Read state ===== */
/* The "Read" pill in a feed card's meta row — only shown once the card is read. */
.read-badge {
    display: none;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    border: 1px solid rgba(var(--accent-rgb), 0.5);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
}
.feed-item.is-read .read-badge { display: inline-block; }

/* Read cards in the home feed recede but stay browsable — independent of bookmark
   state. Bookmarks are exempt: a saved story shows at full strength even once read,
   marked only by its "Read" badge. */
.feed-item.is-read { opacity: 0.62; }
.feed-item.is-read:hover { opacity: 1; }
body[data-feed="bookmarks"] .feed-item.is-read { opacity: 1; }

/* Article "Mark as read" CTA. */
.read-toggle-row { border-top: 1px solid var(--border); padding-top: 1.6rem; }
.read-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}
.read-btn .read-check {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.read-btn.is-read {
    color: #06122b;
    background-image: var(--grad);
    border: none;
    box-shadow: 0 8px 24px -12px rgba(var(--accent-rgb), 0.7);
}

/* ===== Settings ===== */
.settings-section { margin-top: 2.4rem; }
.settings-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.45rem;
    letter-spacing: -0.01em;
    margin-bottom: 0.3rem;
}
.settings-help {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    margin-bottom: 0;
    max-width: 52ch;
}

/* Settings lock / unlock gate */
.settings-lock { margin-top: 1.4rem; }
.settings-unlocked-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.settings-unlocked-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
}

/* ===== Mobile floating action bar ===== */
.fab { display: none; }

.fab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.5rem 0.8rem;
    border-radius: 999px;
    transition: color 0.16s ease, background 0.16s ease;
}
.fab-item svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.fab-item:not(.active):hover { color: var(--text); }
.fab-item.active {
    color: #06122b;
    background-image: var(--grad);
}

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

@media (max-width: 767.98px) {
    .top-nav { display: none; }

    /* Sign in/out lives in the Account tab on mobile, not the top bar. */
    .nav-account { display: none; }

    body { padding-bottom: 5.5rem; }

    .fab {
        display: flex;
        align-items: center;
        justify-content: space-around;
        gap: 0.2rem;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        padding: 0.5rem 0.5rem calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
        background: rgba(18, 20, 26, 0.72);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-top: 1px solid var(--border-strong);
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -8px 32px -12px rgba(0, 0, 0, 0.75);
        /* No fill-mode: a "both"/"forwards" entrance would keep applying its final
           transform: translateY(0) after it ends, which outranks .fab--hidden in the
           cascade and silently defeats the scroll-to-hide. */
        animation: fabIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
        transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    /* !important so the hide also wins over the fabIn entrance animation if the user
       scrolls within its first 0.45s. */
    .fab--hidden {
        transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px))) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fab { transition: none; }
}

/* ===== Sign-in prompt (floating action bar) ===== */
/* Shown by site.js when an anonymous user attempts a sign-in-gated action
   (bookmark, mark-as-read, notes). Slides up from the bottom, offers a
   one-tap Google sign-in, and auto-dismisses after a few seconds — the
   draining bar at its foot signals "no pressure". */
.signin-prompt {
    position: fixed;
    left: 50%;
    bottom: 1.75rem;
    z-index: 1080;
    width: min(440px, calc(100vw - 1.5rem));
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(18px);
    transition: opacity 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
                transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
                visibility 0s linear 0.28s;
}
.signin-prompt.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
                transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.signin-prompt__inner {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.85rem 0.95rem;
}
.signin-prompt__msg {
    flex: 1 1 auto;
    font-size: 0.86rem;
    line-height: 1.3;
    color: var(--text);
}

/* Google's own button colours — kept across themes for brand recognisability. */
.signin-prompt__btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: #ffffff;
    color: #1f1f1f;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: var(--r-sm);
    transition: box-shadow 0.16s ease, transform 0.06s ease;
}
.signin-prompt__btn:hover { box-shadow: 0 2px 12px -3px rgba(0, 0, 0, 0.45); }
.signin-prompt__btn:active { transform: translateY(1px); }
.signin-prompt__g { flex: 0 0 auto; display: block; }

.signin-prompt__close {
    flex: 0 0 auto;
    width: 1.7rem;
    height: 1.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 999px;
    transition: color 0.16s ease, background 0.16s ease;
}
.signin-prompt__close:hover { color: var(--text); background: var(--surface-top); }

/* Draining countdown bar — replayed from full each time the prompt is shown. */
.signin-prompt__timer {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--accent);
    opacity: 0.45;
    transform: scaleX(0);
    transform-origin: left center;
}
.signin-prompt__timer.is-running {
    animation: signinCountdown 7s linear forwards;
}
.signin-prompt__timer.is-paused {
    animation-play-state: paused;
}
@keyframes signinCountdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 767.98px) {
    /* Sit clear of the mobile floating nav bar. */
    .signin-prompt { bottom: 6rem; }
}

@media (prefers-reduced-motion: reduce) {
    .signin-prompt { transition: opacity 0.2s ease, visibility 0s; transform: translateX(-50%); }
    .signin-prompt.is-visible { transform: translateX(-50%); }
    .signin-prompt__timer.is-running { animation: none; transform: scaleX(0); }
}

/* ===== Read-along narration (TTS) ===== */
/* Word highlighting + tap-to-seek on the headline and body. */
.tts-word {
    cursor: pointer;
    border-radius: 4px;
    /* Reserve the active state's padding on every word — cancelled by the matching negative
       margin — so highlighting a word doesn't widen its box and reflow the rest of the line. */
    padding: 0 1px;
    margin: 0 -1px;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.tts-word:hover { background-color: rgba(77, 141, 255, 0.14); }
.tts-word--active {
    background-image: var(--grad);
    color: #06122b;
    box-shadow: 0 0 0 2px rgba(77, 141, 255, 0.18);
}

/* Bottom-nav play button (read-along control). */
.fab-play {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    background-image: var(--grad);
    color: #06122b;
    box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.7);
    cursor: pointer;
    position: relative;
    margin-top: -20px; /* lift it above the bar for a docked-FAB feel */
    transition: transform 0.15s ease, filter 0.15s ease;
}
.fab-play:hover { filter: brightness(1.06); }
.fab-play:active { transform: scale(0.94); }
.fab-play:focus-visible { outline: 3px solid rgba(77, 141, 255, 0.5); outline-offset: 2px; }

.fab-play-glyph {
    position: absolute;
    width: 26px;
    height: 26px;
    fill: #06122b;
    stroke: none;
}
.fab-play-glyph--pause { display: none; }
.fab-play[data-state="playing"] .fab-play-glyph--play { display: none; }
.fab-play[data-state="playing"] .fab-play-glyph--pause { display: block; }
.fab-play[data-state="loading"] .fab-play-glyph { display: none; }

.fab-play-spinner { display: none; }
.fab-play[data-state="loading"] .fab-play-spinner {
    display: block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(6, 18, 43, 0.3);
    border-top-color: #06122b;
    border-radius: 50%;
    animation: ttsSpin 0.7s linear infinite;
}
@keyframes ttsSpin { to { transform: rotate(360deg); } }

.fab-play--error { animation: ttsShake 0.4s ease; }
@keyframes ttsShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Floating read-along control (desktop). The inline toolbar "Listen" button scrolls out of
   view as narration auto-scrolls to follow the spoken word, leaving no way to pause. This FAB
   reuses all the .fab-play machinery (glyph swap, spinner, eink overrides) and just pins itself
   to the bottom-right while narration is in use. Hidden on mobile, where the docked bar button
   stays pinned via ".tts-active .fab". */
.tts-fab-float {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1040;
    margin-top: 0; /* cancel the docked-fab lift inherited from .fab-play */
    display: none; /* shown only while narration is active — see below */
}
.tts-active .tts-fab-float { display: inline-flex; }
@media (max-width: 767.98px) {
    .tts-fab-float { display: none !important; }
}

/* Keep the bar pinned while narration is active, even when scrolling. */
.tts-active .fab { transform: none !important; }

/* Mobile: nav items share one evenly-spaced group; the play button docks at the far right. */
@media (max-width: 767.98px) {
    .fab-group {
        display: flex;
        flex: 1;
        align-items: center;
        justify-content: space-around;
        gap: 0.2rem;
    }
}

/* Desktop has no bottom bar. The read-along control lives inline in the article toolbar
   (".tts-play-inline"), so there's nothing to float at the bottom. */
@media (min-width: 768px) {
    .fab--reader { display: none; }
}

/* Inline "Listen" button in the article toolbar (desktop only). Shares state (data-state) with
   the docked mobile button; glyphs swap purely in CSS. */
.tts-play-inline { display: none; align-items: center; gap: 0.4rem; }
@media (min-width: 768px) {
    .article-toolbar .tts-play-inline { display: inline-flex; }
}
.tts-play-inline .tts-glyph { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.tts-play-inline .tts-glyph--pause { display: none; }
.tts-play-inline[data-state="playing"] .tts-glyph--play { display: none; }
.tts-play-inline[data-state="playing"] .tts-glyph--pause { display: inline; }
.tts-play-inline[data-state="loading"] .tts-glyph { display: none; }
.tts-play-inline .tts-spinner { display: none; }
.tts-play-inline[data-state="loading"] .tts-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: ttsSpin 0.7s linear infinite;
    vertical-align: -2px;
}

@media (prefers-reduced-motion: reduce) {
    .fab-play, .tts-word { transition: none; }
    .fab-play[data-state="loading"] .fab-play-spinner { animation-duration: 1.4s; }
}

/* =====================================================================
   THEMES
   The block above (:root / [data-bs-theme="dark"]) is the "Classic" theme.
   Signed-in users can switch via the Account page; the chosen theme is set
   as data-theme on <html> (default "eink"). Each theme below mostly re-maps
   the CSS variables; a few decorative rules (glows, gradients, colored
   accents) are neutralized so the look stays coherent.
   ===================================================================== */

/* ---------------------------------------------------------------------
   THEME · White / E-Ink  (data-theme="eink") — the default
   Pure black on paper white, heavy black borders, hard corners, no glow.
   --------------------------------------------------------------------- */
[data-theme="eink"] {
    --accent: #000000;
    --accent-hover: #000000;
    --accent-rgb: 0, 0, 0;
    --accent-2: #000000;
    --grad: linear-gradient(#000, #000);   /* solid black via a flat gradient */
    --grad-soft: #ffffff;

    --bg: #ffffff;
    --bg-2: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --surface-top: rgba(0, 0, 0, 0.04);
    --border: #000000;
    --border-strong: #000000;

    --text: #000000;
    --text-soft: #000000;
    --text-muted: #444444;

    --font-display: "Newsreader", "Iowan Old Style", Georgia, serif;

    --r-sm: 0px;
    --r: 0px;
    --r-lg: 0px;
    --shadow: none;
    --shadow-glow: none;

    color-scheme: light;
}

/* Kill the ambient accent glow behind the page. */
[data-theme="eink"] body::before { display: none; }

/* No pulsing/glowing kicker dot — a flat black square reads better at 1-bit. */
[data-theme="eink"] .kicker-dot {
    border-radius: 0;
    background: #000;
    box-shadow: none;
    animation: none;
}

/* Solid black brand wordmark (was a gradient fill). */
[data-theme="eink"] .brand-accent {
    background: none;
    -webkit-text-fill-color: #000;
    color: #000;
}

/* Heavier structural borders for the e-ink look. */
[data-theme="eink"] .feed-item,
[data-theme="eink"] .key-points,
[data-theme="eink"] .discussion-section,
[data-theme="eink"] .notes-section,
[data-theme="eink"] .refresh-panel,
[data-theme="eink"] .empty-state,
[data-theme="eink"] .theme-card,
[data-theme="eink"] .scrutiny-section { border-width: 2.5px; }

/* Filled-black primary buttons with white text (base text was dark navy). */
[data-theme="eink"] .btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    box-shadow: none;
    border: 2.5px solid #000;
}
[data-theme="eink"] .btn-primary:hover { box-shadow: none; transform: none; }
[data-theme="eink"] #copyBtn.copied { color: #fff; box-shadow: none; }

/* Outline buttons (Save / Copy for LLM / Listen / Generate / Sign out) read as crisp black
   boxes that fill in on hover — not the faint default-gray of the base theme. */
[data-theme="eink"] .btn-outline-primary {
    --bs-btn-color: #000;
    --bs-btn-border-color: #000;
    --bs-btn-bg: #fff;
    --bs-btn-hover-bg: #000;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-border-color: #000;
    --bs-btn-active-bg: #000;
    --bs-btn-active-color: #fff;
    --bs-btn-active-border-color: #000;
    border-width: 2px;
    font-weight: 600;
    backdrop-filter: none;
}

/* Topic tags: filled black, white text, square — the E-Ink signature. */
[data-theme="eink"] .topic-tag {
    color: #fff;
    background: #000;
    border: 2px solid #000;
    border-radius: 0;
}
[data-theme="eink"] .topic-tag::before { display: none; }

/* Topic toggles in E-Ink: square chips, shown = filled black with an inverted check, hidden = struck outline. */
[data-theme="eink"] .topic-toggle { border-width: 2px; border-radius: 0; }
[data-theme="eink"] .topic-toggle-check { border-radius: 0; border-width: 2px; }
[data-theme="eink"] .topic-toggle.is-active { color: #fff; background: #000; border-color: #000; box-shadow: none; }
[data-theme="eink"] .topic-toggle.is-active .topic-toggle-check { background: #fff; border-color: #fff; color: #000; }

/* Active nav / tabs: filled black with white text. */
[data-theme="eink"] .site-nav .nav-link.active { color: #fff; background: #000; border-radius: 0; }
[data-theme="eink"] .fab-item.active { color: #fff; }

/* Translucent bars become solid paper with a black edge. */
[data-theme="eink"] .site-nav { background-color: rgba(255, 255, 255, 0.9); border-bottom: 2.5px solid #000; }
[data-theme="eink"] .fab { background: rgba(255, 255, 255, 0.92); border-top: 2.5px solid #000; box-shadow: none; }

/* Claude's Scrutiny: drop the amber, go monochrome with a heavy black rule. */
[data-theme="eink"] .scrutiny-section {
    --scrutiny: #000;
    --scrutiny-rgb: 0, 0, 0;
    background: #fff;
    border: 2.5px solid #000;
    border-left: 5px solid #000;
}
[data-theme="eink"] .scrutiny-section h4 { color: #000; }
[data-theme="eink"] .scrutiny-score,
[data-theme="eink"] .scrutiny-score.score-good,
[data-theme="eink"] .scrutiny-score.score-mid,
[data-theme="eink"] .scrutiny-score.score-bad { --score: 0, 0, 0; background: #fff; }

/* Feed bookmark + "Save" CTA active states: filled black. */
[data-theme="eink"] .feed-item .bookmark-btn.is-bookmarked { color: #fff; background: #000; border-color: #000; }
[data-theme="eink"] .bookmark-cta.is-bookmarked { color: #fff; box-shadow: none; }

/* Read state: monochrome — filled-black "Read" CTA + badge, heavier top rule. */
[data-theme="eink"] .read-toggle-row { border-top-width: 2.5px; }
[data-theme="eink"] .read-btn.is-read { color: #fff; background: #000; border: 2px solid #000; box-shadow: none; }
[data-theme="eink"] .read-badge { color: #000; border-color: #000; }

/* Progress bar: solid black, no glow. */
[data-theme="eink"] .refresh-progress .progress-bar { box-shadow: none; }

/* Native date picker should match the light page. */
[data-theme="eink"] .trigger-input[type="date"] { color-scheme: light; }

/* Timeline: force the colored spine/markers to monochrome (the colors are set
   inline per group via --c, so override explicitly). */
[data-theme="eink"] .timeline::before { background: #000; opacity: 1; }
[data-theme="eink"] .tl-dot { background: #000 !important; box-shadow: 0 0 0 2px #000 !important; border-color: #fff; }
[data-theme="eink"] .tl-marker { border-color: #000; }
[data-theme="eink"] .tl-marker::after { background: #000 !important; }
[data-theme="eink"] .tl-count { background: #000 !important; color: #fff; }
[data-theme="eink"] .tl-articles { border-left-color: #000 !important; }

/* Read-along (TTS) controls: monochrome. */
[data-theme="eink"] .tts-word--active { color: #fff; box-shadow: none; }
[data-theme="eink"] .fab-play-glyph { fill: #fff; }
/* White spinner on the black e-ink fab. Must out-specify the base loading rule
   (.fab-play[data-state="loading"] .fab-play-spinner), so match its loading selector
   too — otherwise the dark-navy default wins and the spinner vanishes into the fab. */
[data-theme="eink"] .fab-play[data-state="loading"] .fab-play-spinner {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
}

/* ---------------------------------------------------------------------
   THEME · Dark (data-theme="dark") — a simple, flat dark mode
   One calm accent, flat surfaces, no ambient glow or gradients.
   --------------------------------------------------------------------- */
[data-theme="dark"] {
    --accent: #6b9bff;
    --accent-hover: #93b6ff;
    --accent-rgb: 107, 155, 255;
    --accent-2: #6b9bff;
    --grad: linear-gradient(var(--accent), var(--accent));   /* flat — no two-tone gradient */
    --grad-soft: rgba(107, 155, 255, 0.14);

    --bg: #121316;
    --bg-2: #121316;
    --surface: #1a1c20;
    --surface-2: #1a1c20;
    --surface-top: rgba(255, 255, 255, 0.04);
    --border: #2a2d33;
    --border-strong: #3a3e46;

    --text: #e9eaed;
    --text-soft: #c7cad1;
    --text-muted: #9499a3;

    --shadow: 0 12px 30px -20px rgba(0, 0, 0, 0.8);
    --shadow-glow: none;
}

/* No ambient accent glow — keep it plain. */
[data-theme="dark"] body::before { display: none; }
/* Flat single-color brand wordmark. */
[data-theme="dark"] .brand-accent { color: var(--accent); }

/* =====================================================================
   ACCOUNT PAGE — theme picker
   ===================================================================== */
.account-wrap { max-width: 640px; }
.account-signout { margin: -0.25rem 0 0.5rem; }

.theme-grid { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }

.theme-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    text-align: left;
    padding: 1rem 1.1rem;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.theme-card:hover { border-color: var(--border-strong); }
.theme-card.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.theme-swatch {
    flex: 0 0 auto;
    width: 66px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
}
.theme-swatch .ts-bar { height: 8px; width: 58%; border-radius: 2px; }
.theme-swatch .ts-line { height: 4px; width: 100%; border-radius: 2px; }
.theme-swatch .ts-line--short { width: 68%; }

.theme-swatch--eink { background: #fff; border-color: #000; border-radius: 0; }
.theme-swatch--eink .ts-bar { background: #000; border-radius: 0; }
.theme-swatch--eink .ts-line { background: #000; opacity: 0.5; border-radius: 0; }

.theme-swatch--dark { background: #15171b; }
.theme-swatch--dark .ts-bar { background: #6b9bff; }
.theme-swatch--dark .ts-line { background: #9499a3; opacity: 0.6; }

.theme-swatch--classic { background: #0d0f13; }
.theme-swatch--classic .ts-bar { background: linear-gradient(135deg, #4d8dff, #7b6bff); }
.theme-swatch--classic .ts-line { background: #868c99; opacity: 0.6; }

.theme-card-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 0.2rem; }
.theme-card-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.12rem;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}
.theme-default-tag {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
}
.theme-card-desc { color: var(--text-muted); font-size: 0.88rem; line-height: 1.4; }

.theme-check {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    color: transparent;
}
.theme-check svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.theme-card.is-active .theme-check { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Topic show/hide toggles. A pressed chip ("shown") fills in and shows a check; an un-pressed one
   ("hidden") reads as a muted, struck-through outline. */
.topic-toggles { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.topic-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.topic-toggle:hover { border-color: var(--border-strong); }
.topic-toggle.is-active { color: var(--text); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.topic-toggle-check {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    color: transparent;
}
.topic-toggle-check svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.topic-toggle.is-active .topic-toggle-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.topic-toggle:not(.is-active) .topic-toggle-name { text-decoration: line-through; text-decoration-thickness: 1px; opacity: 0.8; }
