/* Light mode — WCAG AA compliant contrast ratios */
:root {
    color-scheme: light dark;
    --bg-primary: oklch(98.5% 0.004 75);     /* warm cream tint */
    --bg-secondary: oklch(94% 0.006 75);     /* warm light gray */
    --text-primary: oklch(19% 0.014 250);    /* rich near-black */
    --text-secondary: oklch(43% 0.012 248);
    --text-muted: oklch(49.5% 0.010 245);    /* ≥5:1 on bg-primary */
    --text-on-accent: #fff;                  /* text on filled accent backgrounds */
    --border-color: oklch(86% 0.008 240);
    --link-color: oklch(35% 0.19 242);       /* deep navy — ≥7:1 on bg-primary */
    --accent-color: oklch(41% 0.17 242);     /* rich navy blue */
    --accent-strong: oklch(29% 0.17 242);    /* deep navy — ≥10:1 with white */
    --gift-color: oklch(50% 0.22 158);       /* rich emerald */
    --gift-bg: oklch(96.5% 0.055 158);       /* fresh emerald bg */
    --gift-border: oklch(83% 0.13 158);      /* vivid emerald border */

    /* Border radius scale */
    --radius-sm: 4px;            /* badges */
    --radius-md: 6px;            /* buttons, nav links, sort tabs */
    --radius-lg: 8px;            /* images, card-like items */

    /* Easing curves */
    --ease-out: cubic-bezier(0.25, 1, 0.5, 1);   /* smooth, refined deceleration */
    --ease-out-fast: cubic-bezier(0.16, 1, 0.3, 1); /* snappier for short distances */

    /* Typography */
    --font-display: 'Lora', Georgia, 'Times New Roman', serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* Category hues — one degree per category, shared formula computes badge colors */
    --cat-hue-politics:        15;   /* red           */
    --cat-hue-world:          235;   /* blue          */
    --cat-hue-business:       190;   /* teal          */
    --cat-hue-technology:     218;   /* sky-blue      */
    --cat-hue-science:        293;   /* violet        */
    --cat-hue-health:         152;   /* green         */
    --cat-hue-entertainment:   62;   /* amber         */
    --cat-hue-culture:        340;   /* rose          */
    --cat-hue-food:            50;   /* warm orange   */
    --cat-hue-sports:          28;   /* orange-red    */
    --cat-hue-opinion:        268;   /* indigo        */
    --cat-hue-media:          308;   /* magenta       */
    --cat-hue-legal:           83;   /* gold          */
    --cat-hue-transportation: 210;   /* sky           */
    --cat-hue-travel:         170;   /* turquoise     */
}

/* Dark mode — system preference */
@media (prefers-color-scheme: dark) {
    .feed-refresh-banner {
        box-shadow:
            0 4px 12px rgba(0,0,0,.40),
            0 16px 40px rgba(0,0,0,.55),
            0 0 0 1px color-mix(in oklch, var(--accent-color) 20%, transparent);
    }
    :root {
        --bg-primary: oklch(13% 0.010 240);
        --bg-secondary: oklch(20% 0.010 240);
        --text-primary: oklch(91% 0.005 240);
        --text-secondary: oklch(67% 0.008 242);
        --text-muted: oklch(62% 0.008 242);      /* ≥5.5:1 on bg-primary */
        --border-color: oklch(30% 0.012 240);
        --link-color: oklch(70% 0.16 240);       /* richer bright blue */
        --accent-color: oklch(65% 0.15 240);     /* richer blue */
        --accent-strong: oklch(46% 0.15 240);    /* white text at ≥5:1 */
        --gift-color: oklch(76% 0.23 158);       /* vivid emerald */
        --gift-bg: oklch(21% 0.08 158);          /* deep emerald bg */
        --gift-border: oklch(34% 0.14 158);      /* emerald border */
    }
}

/* Explicit dark override (JS theme toggle) */
[data-theme="dark"] .feed-refresh-banner {
    box-shadow:
        0 4px 12px rgba(0,0,0,.40),
        0 16px 40px rgba(0,0,0,.55),
        0 0 0 1px color-mix(in oklch, var(--accent-color) 20%, transparent);
}

[data-theme="dark"] {
    --bg-primary: oklch(13% 0.010 240);
    --bg-secondary: oklch(20% 0.010 240);
    --text-primary: oklch(91% 0.005 240);
    --text-secondary: oklch(67% 0.008 242);
    --text-muted: oklch(62% 0.008 242);
    --border-color: oklch(30% 0.012 240);
    --link-color: oklch(70% 0.16 240);
    --accent-color: oklch(65% 0.15 240);
    --accent-strong: oklch(46% 0.15 240);
    --gift-color: oklch(76% 0.23 158);
    --gift-bg: oklch(21% 0.08 158);
    --gift-border: oklch(34% 0.14 158);
}

/* Explicit light override (JS theme toggle) */
[data-theme="light"] {
    --bg-primary: oklch(98.5% 0.004 75);
    --bg-secondary: oklch(94% 0.006 75);
    --text-primary: oklch(19% 0.014 250);
    --text-secondary: oklch(43% 0.012 248);
    --text-muted: oklch(49.5% 0.010 245);
    --border-color: oklch(86% 0.008 240);
    --link-color: oklch(35% 0.19 242);
    --accent-color: oklch(41% 0.17 242);
    --accent-strong: oklch(29% 0.17 242);
    --gift-color: oklch(50% 0.22 158);
    --gift-bg: oklch(96.5% 0.055 158);
    --gift-border: oklch(83% 0.13 158);
}

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

/* Global keyboard focus indicator */
:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 2px;
}

/* Focus on accent-colored backgrounds: flip to text-on-accent so the ring is visible */
.page-btn:focus-visible,
.pwa-toast-install:focus-visible {
    outline-color: var(--text-on-accent);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    max-width: 85ch;
    margin: 0 auto;
    padding: 20px;
    padding-top: 73px;
}

/* ── Header ── */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    max-width: 85ch;
    margin: 0 auto;
    padding: 14px 20px;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 100;
}

.site-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    white-space: nowrap;
    transition: color 0.15s var(--ease-out);
}

.site-title:hover {
    color: var(--accent-color);
}

.main-nav {
    display: flex;
    gap: 2px;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 44px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.15s var(--ease-out), color 0.15s var(--ease-out);
}

.main-nav a:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.main-nav a.active,
.main-nav a[aria-current="page"] {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* ── Nav icons ── */
.nav-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Bookmarks: slightly larger to balance the badge counter */
.nav-bookmarks-link .nav-icon {
    width: 20px;
    height: 20px;
}

/* ── Theme toggle ── */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 5px 9px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: background-color 0.15s var(--ease-out), transform 0.1s var(--ease-out);
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
}

.theme-toggle:hover {
    background-color: var(--bg-secondary);
}

.theme-toggle:active {
    transform: scale(0.91);
}

/* ── Sort tabs ── */
.sort-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    padding-top: 10px;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 73px;
    z-index: 50;
    background-color: var(--bg-primary);
    margin-inline: -20px;
    padding-inline: 20px;
}

.sort-tab {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 6px 14px 9px;
    margin-bottom: -2px;
    border-radius: 0;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    transition: color 0.15s var(--ease-out), border-bottom-color 0.15s var(--ease-out), transform 0.1s var(--ease-out);
}

.sort-tab:hover {
    color: var(--text-primary);
}

.sort-tab:active {
    transform: scale(0.96);
}

.sort-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-strong);
}

.sort-tab.active:hover {
    color: var(--text-primary);
    border-bottom-color: var(--accent-strong);
}

/* Disable tabs while a navigation is in-flight */
.sort-tabs.is-navigating .sort-tab {
    pointer-events: none;
    opacity: 0.55;
}
.sort-tabs.is-navigating .sort-tab.active {
    opacity: 1;
}

/* ── Search toggle ── */
.search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 5px 9px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition:
        background-color 0.32s var(--ease-out),
        color            0.15s var(--ease-out),
        border-color     0.32s var(--ease-out),
        transform        0.1s  var(--ease-out);
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
}

.search-toggle:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.search-toggle:active {
    transform: scale(0.91);
}

/* Search toggle when living in the sort-tabs bar */
.sort-tabs .search-toggle {
    margin-left: auto;      /* push to trailing edge */
    margin-bottom: -2px;    /* match sort-tab bottom offset */
    padding: 6px 14px 9px; /* match desktop sort-tab padding */
    border: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    min-width: unset;
    min-height: 44px;
    line-height: 1;         /* collapse line box — removes emoji descender gap */
}

/* Active state: a search query is currently applied */
.search-toggle--active {
    background-color: color-mix(in oklch, var(--accent-color) 10%, var(--bg-secondary));
    border-color: color-mix(in oklch, var(--accent-color) 35%, var(--border-color));
    color: var(--accent-color);
}

/* ── Search panel (collapsible container) ── */
.search-panel {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    overflow: hidden;
    margin-bottom: 0;
    margin-inline: -20px;
    padding-inline: 20px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    transition:
        grid-template-rows  0.32s var(--ease-out),
        opacity             0.25s var(--ease-out),
        margin-bottom       0.32s var(--ease-out),
        background-color    0.32s var(--ease-out);
}

.search-panel--open {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-bottom: 0;
    background-color: color-mix(in oklch, var(--accent-color) 8%, var(--bg-secondary));
}

/* When search is open, collapse the gap so the toggle sits flush against the panel */
.search-panel--open + .sort-tabs {
    padding-top: 0;
}

/* Toggle becomes a tab shape — top edge joins the panel, bottom corners rounded */
.search-panel--open + .sort-tabs .search-toggle {
    background-color: color-mix(in oklch, var(--accent-color) 8%, var(--bg-secondary));
}

/* Grid-trick requirement: inner content must be able to compress to zero height */
.search-panel > .search-form {
    min-height: 0;
    margin-bottom: 0;
    padding-top: 12px;
    padding-bottom: 12px;
}

/* Icon swap animation — quick squeeze-and-release when 🔍 ↔ ✕ */
@keyframes search-icon-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(0.72); }
    100% { transform: scale(1); }
}

/* Form entrance — fires when the panel opens; slides content up from below */
@keyframes search-form-enter {
    from {
        opacity: 0.4;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-panel--open > .search-form {
    animation: search-form-enter 0.35s var(--ease-out) both;
}

@media (prefers-reduced-motion: reduce) {
    .search-panel {
        transition: opacity 0.15s linear;
    }

    .search-panel--open > .search-form {
        animation: none;
    }
}

/* ── Search form ── */
.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 12px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    /* Reset platform search styles */
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}

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

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px color-mix(in oklch, var(--accent-strong) 15%, transparent);
}

/* Remove the webkit search clear button that appears inconsistently */
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
    -webkit-appearance: none;
}

.search-btn {
    flex-shrink: 0;
    height: 36px;
    padding: 0 14px;
    background-color: var(--accent-strong);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s var(--ease-out), transform 0.1s var(--ease-out);
}

.search-btn:hover {
    background-color: color-mix(in srgb, var(--accent-strong) 82%, #000);
}

.search-btn:active {
    transform: scale(0.95);
}

/* ── Active filter bar ── */
.filter-bar[hidden] { display: none; }
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 16px;
    background-color: color-mix(in oklch, var(--accent-color) 8%, var(--bg-secondary));
    border: 1px solid color-mix(in oklch, var(--accent-color) 20%, var(--border-color));
    border-radius: var(--radius-md);
    font-size: 13px;
}

.filter-bar-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-bar-pub { color: var(--accent-color); }

.filter-bar-sep { color: var(--text-muted); }

.filter-bar-cat { color: var(--text-secondary); font-weight: 400; }

.filter-bar-search { color: var(--text-secondary); font-weight: 400; font-style: italic; }

.filter-bar-clear {
    flex-shrink: 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    white-space: nowrap;
    transition: color 0.15s var(--ease-out), background-color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}

.filter-bar-clear:hover {
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    border-color: var(--text-muted);
}

/* ── Article list ── */
.article-list {
    display: flex;
    flex-direction: column;
}

.article-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.article-card:last-child {
    border-bottom: none;
}

@media (hover: hover) {
    .article-card::before {
        content: '';
        position: absolute;
        left: -8px;
        top: 28px;
        bottom: 28px;
        width: 1.5px;
        border-radius: 1px;
        background: var(--gift-color);
        opacity: 0;
        transform: scaleY(0.3);
        transform-origin: center;
        transition: opacity 0.2s var(--ease-out),
                    transform 0.2s var(--ease-out);
    }

    .article-card:hover::before {
        opacity: 1;
        transform: scaleY(1);
    }

    .article-card:hover .article-title {
        color: color-mix(in oklch, var(--text-primary) 55%, var(--link-color));
        text-decoration-color: color-mix(in oklch, var(--link-color) 55%, transparent);
    }

    /* title's own :hover stays vivid — specificity tie breaks by source order */
    .article-card .article-title:hover {
        color: var(--link-color);
        text-decoration-color: var(--link-color);
    }
}

.article-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.article-main {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 14px;
    row-gap: 6px;
    align-items: start;
}

.article-title-wrap {
    min-width: 0;
}

/* Shared chip base */
.pub-badge,
.cat-badge,
.new-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.pub-badge {
    color: var(--accent-color);
    background-color: color-mix(in oklch, var(--accent-color) 10%, transparent);
    border: 1px solid color-mix(in oklch, var(--accent-color) 25%, transparent);
}

.cat-badge {
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.new-badge {
    display: none;
    align-items: center;
    background-color: color-mix(in oklch, var(--accent-color) 15%, transparent);
    color: var(--accent-color);
    border: 1px solid color-mix(in oklch, var(--accent-color) 30%, transparent);
}

@keyframes new-badge-enter {
    from { opacity: 0; transform: scale(0.6); }
    to   { opacity: 1; transform: scale(1); }
}

.article-new .new-badge {
    display: inline-flex;
    animation: new-badge-enter 0.25s var(--ease-out) both;
}

.article-title {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--link-color) 40%, transparent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    line-height: 1.3;
    word-break: break-word;
    transition: color 0.15s var(--ease-out),
                text-decoration-color 0.15s var(--ease-out),
                text-decoration-thickness 0.15s var(--ease-out);
}

.article-title:hover {
    color: var(--link-color);
    text-decoration-color: var(--link-color);
    text-decoration-thickness: 2px;
}

/* Articles with a direct gift URL — green underline signals "unlocked" */
.article-title.gift-link {
    text-decoration-color: color-mix(in srgb, var(--gift-color) 40%, transparent);
    text-decoration-thickness: 1px;
    transition: color 0.2s var(--ease-out),
                text-decoration-color 0.2s var(--ease-out),
                text-decoration-thickness 0.2s var(--ease-out);
}

.article-title.gift-link:hover {
    color: var(--gift-color);
    text-decoration-color: var(--gift-color);
    text-decoration-thickness: 2.5px;
}

.article-title.gift-link:active {
    transform: scale(0.98);
    color: var(--gift-color);
    text-decoration-color: var(--gift-color);
    text-decoration-thickness: 2.5px;
}

.article-description-feed {
    grid-column: 1 / -1;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 600px) {
    .thumbnail {
        grid-column: 2;
        grid-row: 1 / -1;
        align-self: start;
    }

    .article-description-feed {
        grid-column: 1;
        grid-row: 2;
    }
}

.article-title.no-title {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    word-break: break-all;
    text-decoration: none;
}

.article-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.meta-item {
    font-size: 12px;
    color: var(--text-muted);
}

.gift-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 3px 10px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    color: var(--gift-color);
    background-color: var(--gift-bg);
    border: 1px solid var(--gift-border);
    transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), opacity 0.15s var(--ease-out);
    white-space: nowrap;
}

.gift-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
    opacity: 1;
}

.gift-btn:active {
    transform: translateY(1px);
    box-shadow: none;
    opacity: 0.9;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 3px 10px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), color 0.15s var(--ease-out);
    white-space: nowrap;
}

.nav-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
    color: var(--text-primary);
}

.nav-btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

@keyframes gift-pickup {
    0%   { transform: rotate(0deg) scale(1); }
    25%  { transform: rotate(-12deg) scale(1.2); }
    65%  { transform: rotate(8deg) scale(1.1); }
    85%  { transform: rotate(-3deg) scale(1.05); }
    100% { transform: rotate(0deg) scale(1); }
}

.gift-emoji {
    display: inline-block;
}

.gift-btn:hover .gift-emoji,
.more-gift-btn:hover .gift-emoji {
    animation: gift-pickup 0.45s var(--ease-out) both;
}

.more-gift-btn {
    font-size: 12px;
    padding: 3px 10px;
    opacity: 0.85;
    cursor: pointer;
    transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), opacity 0.15s var(--ease-out), background-color 0.15s var(--ease-out);
}

.more-gift-btn[aria-expanded="true"] {
    background-color: color-mix(in oklch, var(--gift-bg) 50%, var(--bg-secondary));
    opacity: 1;
}

.share-btn,
.bookmark-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 44px;
    min-height: 44px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.15s var(--ease-out), background-color 0.15s var(--ease-out), transform 0.1s var(--ease-out);
    flex-shrink: 0;
}

.share-btn:hover,
.bookmark-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.share-btn:active,
.bookmark-btn:active {
    transform: scale(0.92);
}

.share-btn svg,
.bookmark-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.bookmark-btn {
    margin-left: auto;
}

.bookmark-btn.bookmarked {
    color: oklch(55% 0.28 158);
}

.bookmark-btn.bookmarked svg {
    fill: currentColor;
}

/* ── Bookmark animations ────────────────────────────────────────────────── */

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

@keyframes bookmark-release {
    0%   { transform: scale(1); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes bookmark-glow {
    0%   { box-shadow: 0 0 0 0 oklch(55% 0.28 158 / 45%); }
    60%  { box-shadow: 0 0 0 10px oklch(55% 0.28 158 / 0%); }
    100% { box-shadow: 0 0 0 0 oklch(55% 0.28 158 / 0%); }
}

@keyframes bookmark-bg-flash {
    0%   { background-color: transparent; }
    30%  { background-color: oklch(55% 0.28 158 / 15%); }
    100% { background-color: transparent; }
}

@keyframes card-slide-out {
    0%   { opacity: 1; transform: translateX(0); max-height: 200px; margin-bottom: var(--space-sm, 8px); }
    50%  { opacity: 0; transform: translateX(-24px); max-height: 200px; }
    100% { opacity: 0; transform: translateX(-24px); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; }
}

@keyframes badge-pop {
    0%   { transform: scale(0); opacity: 0; }
    70%  { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.bookmark-btn.animating-in svg {
    animation: bookmark-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.bookmark-btn.animating-out svg {
    animation: bookmark-release 0.18s ease-in both;
}

.bookmark-btn.glow-pulse {
    animation: bookmark-glow 0.5s ease-out, bookmark-bg-flash 0.5s ease-out;
}

.article-card.removing {
    animation: card-slide-out 0.35s ease-in forwards;
    pointer-events: none;
}

.bookmark-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: oklch(55% 0.28 158);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}

.bookmark-badge.badge-pop {
    animation: badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.nav-icon-wrap {
    position: relative;
    display: inline-flex;
}

.share-btn {
    background: var(--gift-bg);
    border: 1px solid var(--gift-border);
    color: var(--gift-color);
}

.share-btn:hover {
    background-color: color-mix(in oklch, var(--gift-color) 12%, var(--gift-bg));
    border-color: color-mix(in oklch, var(--gift-color) 60%, var(--gift-border));
    color: var(--gift-color);
}

.card-gift-expand {
    flex-basis: 100%;
    display: flex;
    flex-direction: column;
    margin-top: 6px;
    background-color: color-mix(in oklch, var(--bg-secondary) 72%, var(--gift-bg));
    border: 1px solid color-mix(in oklch, var(--border-color) 55%, var(--gift-border));
    border-radius: 6px;
    overflow: hidden;
    width: 100%;
}

.card-gift-expand[hidden] {
    display: none;
}

.card-gift-url {
    display: block;
    font-size: 13px;
    word-break: break-all;
    color: var(--gift-color);
    text-decoration: none;
    padding: 7px 10px;
    border-bottom: 1px solid color-mix(in oklch, var(--gift-border) 35%, transparent);
    transition: background-color 0.12s var(--ease-out);
    line-height: 1.4;
}

.card-gift-url:last-child {
    border-bottom: none;
}

.card-gift-url:hover {
    background-color: color-mix(in oklch, var(--gift-bg) 65%, transparent);
    text-decoration: underline;
    text-decoration-color: var(--gift-color);
}

.card-gift-url:focus-visible {
    outline: 2px solid var(--gift-color);
    outline-offset: -2px;
    border-radius: 3px;
}

.card-gift-empty {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    padding: 8px 10px;
}

.thumbnail {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-lg);
    object-fit: cover;
    background-color: var(--bg-secondary);
    flex-shrink: 0;
    transition: transform 0.2s var(--ease-out);
}

@media (hover: hover) {
    .article-card:hover .thumbnail {
        transform: scale(1.04);
    }
}

/* ── Article detail ── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 20px;
    padding: 8px 0;
    min-height: 44px;
    transition: color 0.15s var(--ease-out);
}

.back-link:hover {
    color: var(--text-primary);
}

.back-arrow {
    display: inline-block;
    transition: transform 0.15s var(--ease-out);
}

.back-link:hover .back-arrow {
    transform: translateX(-3px);
}

.article-detail-pub {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.article-detail-title {
    font-family: var(--font-display);
    font-size: clamp(26px, 4vw, 36px);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.5px;
    margin-bottom: 16px;
}

.article-detail-title a {
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--link-color) 40%, transparent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color 0.15s var(--ease-out),
                text-decoration-color 0.15s var(--ease-out),
                text-decoration-thickness 0.15s var(--ease-out);
}

.article-detail-title a:hover {
    color: var(--link-color);
    text-decoration-color: var(--link-color);
    text-decoration-thickness: 2px;
}

.article-detail-title a.gift-link {
    text-decoration-color: color-mix(in srgb, var(--gift-color) 40%, transparent);
}

.article-detail-title a.gift-link:hover {
    color: var(--gift-color);
    text-decoration-color: var(--gift-color);
    text-decoration-thickness: 2px;
}

.article-description {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.65;
    margin-bottom: 16px;
}

.article-detail-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-muted);
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 28px;
}

.article-thumbnail-large {
    width: 100%;
    aspect-ratio: 2 / 1;        /* reserves height before image loads — prevents CLS */
    object-fit: cover;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.page-heading {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.section-heading {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Gift URL list */
.gift-urls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 36px;
}

.gift-url-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background-color: var(--bg-secondary);
}

.gift-url-item.active-url {
    border-color: var(--gift-border);
    background-color: var(--gift-bg);
}

.gift-url-link {
    flex: 1;
    font-size: 13px;
    color: var(--gift-color);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 2px;
    word-break: break-all;
    min-width: 0;
    transition: text-decoration-color 0.15s var(--ease-out);
}

.gift-url-item.active-url .gift-url-link {
    color: var(--gift-color);
    font-weight: 600;
}

.gift-url-link:hover {
    text-decoration-color: currentColor;
}

.gift-url-meta {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.retired-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

/* ── Gift links details ── */
.gift-details > summary {
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: var(--text-muted);
    margin-bottom: 12px;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: color 0.15s var(--ease-out);
}

.gift-details > summary:hover {
    color: var(--text-secondary);
}

.gift-details > summary::-webkit-details-marker {
    display: none;
}

.gift-details > summary::before {
    content: '▶';
    font-size: 8px;
    transition: transform 0.2s var(--ease-out);
}

.gift-details[open] > summary::before {
    transform: rotate(90deg);
}

@keyframes gift-open {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Attention ring on the first (primary) active gift URL — fires once on load */
@keyframes gift-ring {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gift-color) 35%, transparent); }
    60%  { box-shadow: 0 0 0 5px color-mix(in srgb, var(--gift-color) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.gift-url-item.active-url:first-child {
    animation: gift-ring 1s var(--ease-out-fast) 0.6s both;
}

.gift-details[open] .gift-urls {
    animation: gift-open 0.35s var(--ease-out) both;
}

/* Shares list */
.shares-list {
    display: flex;
    flex-direction: column;
    margin-bottom: 36px;
}

.share-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.share-item:last-child {
    border-bottom: none;
}

.share-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background-color: var(--bg-secondary);
    margin-top: 1px;
    transition: transform 0.15s var(--ease-out);
}

.share-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-top: 1px;
    transition: transform 0.15s var(--ease-out);
}

.share-item:hover .share-avatar,
.share-item:hover .share-avatar-placeholder {
    transform: scale(1.08);
}

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

.share-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.share-author {
    font-weight: 500;
    color: var(--link-color);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.15s var(--ease-out);
}

.share-author:hover {
    color: var(--link-color);
    text-decoration: underline;
}

.share-author.anonymous {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
}

.share-stats {
    display: flex;
    gap: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    font-size: 12px;
}

.share-time {
    color: var(--link-color);
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 12px;
    text-decoration: none;
    transition: color 0.15s var(--ease-out);
}

.share-time:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

.share-post-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-break: break-word;
}

/* ── Page heading ── */
.page-heading {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 20px;
}

/* ── Sources page ── */
.sources-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.sources-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.0px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
}

.sources-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.sources-table tr:last-child td {
    border-bottom: none;
}

.sources-table tbody tr:hover td {
    background-color: var(--bg-secondary);
}

.source-filter-link {
    color: var(--link-color);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 2px;
    font-weight: 500;
    transition: text-decoration-color 0.15s var(--ease-out);
}

.source-filter-link:hover {
    text-decoration-color: currentColor;
}

.source-count {
    font-variant-numeric: tabular-nums;
}

.source-pub-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* ── Empty / error states ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-inline {
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.empty-state-icon {
    font-size: 36px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}

/* ── Onboarding banner ── */
.onboard-banner[hidden] {
    display: none;
}

.onboard-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin-top: 4px;
    margin-bottom: 0;
    background-color: var(--gift-bg);
    border: 1px solid var(--gift-border);
    border-left: 3px solid var(--gift-color);
    border-radius: var(--radius-lg);
}

.onboard-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.onboard-icon {
    font-size: 14px;
    flex-shrink: 0;
    line-height: 1;
}

.onboard-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
}

.onboard-text strong {
    color: var(--text-primary);
}

/* Inline sample showing the gift-link underline style */
.onboard-gift-sample {
    color: var(--gift-color);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--gift-color) 40%, transparent);
    text-underline-offset: 2px;
}

.onboard-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gift-color);
    font-size: 12px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.15s var(--ease-out), background-color 0.15s var(--ease-out);
}

.onboard-dismiss:hover {
    opacity: 1;
    background-color: color-mix(in srgb, var(--gift-color) 12%, transparent);
}

/* ── PWA install toast (fixed, bottom-right) ── */
.pwa-toast[hidden] {
    display: none;
}

.pwa-toast {
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 312px;
    background-color: var(--bg-primary);
    border: 1px solid color-mix(in srgb, var(--accent-color) 28%, var(--border-color));
    border-top: 3px solid var(--accent-strong);
    border-radius: var(--radius-lg);
    box-shadow:
        0 4px 8px -2px rgba(0, 0, 0, 0.10),
        0 14px 32px -4px rgba(0, 0, 0, 0.18),
        0 0 0 1px color-mix(in srgb, var(--accent-color) 10%, transparent);
    overflow: hidden;
    z-index: 200;
    /* Entry state: hidden below viewport */
    transform: translateY(calc(100% + 32px));
    opacity: 0;
    transition:
        transform 0.42s var(--ease-out),
        opacity   0.3s  var(--ease-out);
}

.pwa-toast--visible {
    transform: translateY(0);
    opacity: 1;
}

/* Exit: slightly faster than entry */
.pwa-toast:not(.pwa-toast--visible) {
    transition:
        transform 0.32s var(--ease-out),
        opacity   0.22s var(--ease-out);
}

.pwa-toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 14px;
}

.pwa-toast-icon {
    font-size: 20px;
    flex-shrink: 0;
    line-height: 1;
}

.pwa-toast-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pwa-toast-body strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.pwa-toast-body span {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.pwa-toast-install {
    background-color: var(--accent-strong);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-md);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    min-height: 44px;
    transition:
        background-color 0.15s var(--ease-out),
        transform        0.1s  var(--ease-out);
}

.pwa-toast-install:hover {
    background-color: color-mix(in srgb, var(--accent-strong) 82%, #000);
}

.pwa-toast-install:active {
    transform: scale(0.95);
}

.pwa-toast-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.55;
    transition:
        opacity          0.15s var(--ease-out),
        background-color 0.15s var(--ease-out);
}

.pwa-toast-dismiss:hover {
    opacity: 1;
    background-color: var(--bg-secondary);
}

/* Progress bar: drains left→right over 8s, paused via JS */
.pwa-toast-track {
    height: 3px;
    background-color: color-mix(in srgb, var(--accent-strong) 12%, var(--bg-secondary));
}

.pwa-toast-bar {
    height: 100%;
    background: linear-gradient(to right, var(--accent-strong), var(--accent-color));
    transform-origin: left center;
    transform: scaleX(1);
    /* transition is set dynamically by JS */
}

/* Mobile: stretch to full width at the bottom */
@media (max-width: 600px) {
    .pwa-toast {
        left: 12px;
        right: 12px;
        bottom: 16px;
        width: auto;
    }
}

/* Dark mode: use secondary bg and stronger shadows for visible elevation */
@media (prefers-color-scheme: dark) {
    .pwa-toast {
        background-color: var(--bg-secondary);
        box-shadow:
            0 4px 12px rgba(0, 0, 0, 0.40),
            0 16px 40px rgba(0, 0, 0, 0.55),
            0 0 0 1px color-mix(in srgb, var(--accent-color) 20%, transparent);
    }
}

[data-theme="dark"] .pwa-toast {
    background-color: var(--bg-secondary);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.40),
        0 16px 40px rgba(0, 0, 0, 0.55),
        0 0 0 1px color-mix(in srgb, var(--accent-color) 20%, transparent);
}

/* Reduced motion: fade only, no slide */
@media (prefers-reduced-motion: reduce) {
    .pwa-toast,
    .pwa-toast:not(.pwa-toast--visible) {
        transform: none;
        transition: opacity 0.15s linear;
    }
}

/* ── SW update banner (fixed, bottom-left) ── */
.sw-update-banner[hidden] {
    display: none;
}

.sw-update-banner {
    position: fixed;
    bottom: 24px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 16px;
    background-color: var(--bg-primary);
    border: 1px solid color-mix(in srgb, var(--accent-color) 28%, var(--border-color));
    border-top: 3px solid var(--accent-strong);
    border-radius: var(--radius-lg);
    box-shadow:
        0 4px 8px -2px rgba(0, 0, 0, 0.10),
        0 14px 32px -4px rgba(0, 0, 0, 0.18);
    z-index: 200;
    max-width: calc(100vw - 40px);
}

.sw-update-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.3;
}

.sw-update-btn {
    background-color: var(--accent-strong);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-md);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    min-height: 36px;
    transition:
        background-color 0.15s var(--ease-out),
        transform        0.1s  var(--ease-out);
}

.sw-update-btn:hover {
    background-color: color-mix(in srgb, var(--accent-strong) 82%, #000);
}

.sw-update-btn:active {
    transform: scale(0.95);
}

.sw-update-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.55;
    transition:
        opacity          0.15s var(--ease-out),
        background-color 0.15s var(--ease-out);
}

.sw-update-dismiss:hover {
    opacity: 1;
    background-color: var(--bg-secondary);
}

@media (max-width: 600px) {
    .sw-update-banner {
        left: 12px;
        right: 12px;
        bottom: 16px;
    }
}

@media (prefers-color-scheme: dark) {
    .sw-update-banner {
        background-color: var(--bg-secondary);
        box-shadow:
            0 4px 12px rgba(0, 0, 0, 0.40),
            0 16px 40px rgba(0, 0, 0, 0.55);
    }
}

[data-theme="dark"] .sw-update-banner {
    background-color: var(--bg-secondary);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.40),
        0 16px 40px rgba(0, 0, 0, 0.55);
}

/* ── Scroll-to-top FAB ── */
#scroll-top-fab {
    position: fixed;
    bottom: 88px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--accent-strong);
    color: var(--text-on-accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 6px 20px rgba(0, 0, 0, 0.12);
}

#scroll-top-fab.scroll-top-fab--visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#scroll-top-fab:hover {
    background-color: color-mix(in srgb, var(--accent-strong) 82%, #000);
    transform: translateY(-2px);
}

#scroll-top-fab:active {
    transform: scale(0.92);
}

#scroll-top-fab:focus-visible {
    outline: 2px solid var(--text-on-accent);
    outline-offset: 2px;
}

@media (max-width: 600px) {
    #scroll-top-fab {
        bottom: 80px;
        right: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #scroll-top-fab,
    #scroll-top-fab.scroll-top-fab--visible {
        transform: none;
        transition: opacity 0.15s linear;
    }
    #scroll-top-fab:hover {
        transform: none;
    }
}

/* ── Feed refresh notification ── */
.feed-refresh-banner {
    position: fixed;
    top: 133px;                        /* header 73px + sort-tabs ~52px + 8px gap */
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;

    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 16px;

    background-color: var(--bg-secondary);
    border: 1px solid color-mix(in oklch, var(--accent-color) 20%, var(--border-color));
    border-top: 3px solid var(--accent-strong);
    border-radius: var(--radius-lg);
    box-shadow:
        0 4px 8px -2px rgba(0,0,0,.10),
        0 14px 32px -4px rgba(0,0,0,.18),
        0 0 0 1px color-mix(in oklch, var(--accent-color) 10%, transparent);

    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    max-width: calc(100vw - 32px);
    animation: feed-banner-drop 0.25s var(--ease-out) both;
}

@keyframes feed-banner-drop {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.feed-refresh-banner[hidden] {
    display: none;
}

.feed-refresh-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.feed-refresh-reload {
    font-weight: 600;
    color: var(--accent-color);
    background: none;
    border: 1px solid var(--accent-color);
    cursor: pointer;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    font-size: 12px;
    font-family: inherit;
    transition: background-color 0.15s var(--ease-out), color 0.15s var(--ease-out);
}

.feed-refresh-reload:hover {
    background-color: var(--accent-color);
    color: var(--text-on-accent);
}

.feed-refresh-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1;
    transition: color 0.15s var(--ease-out), background-color 0.15s var(--ease-out);
}

.feed-refresh-dismiss:hover {
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

@media (prefers-reduced-motion: reduce) {
    .feed-refresh-banner {
        animation: none;
    }
}


.empty-state h2 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.error-page {
    text-align: center;
    padding: 60px 20px;
}

.error-page h1 {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.error-page p {
    font-size: 18px;
    margin-bottom: 24px;
    color: var(--text-secondary);
}

.error-page a {
    color: var(--link-color);
    text-decoration: none;
    font-size: 16px;
    transition: opacity 0.15s var(--ease-out);
}

.error-page a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ── Footer ── */
footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

footer a {
    color: var(--link-color);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--link-color) 35%, transparent);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.15s var(--ease-out);
}

footer a:hover {
    text-decoration-color: var(--link-color);
}

/* ── Mobile ── */
@media (max-width: 600px) {
    body {
        padding: 12px;
        padding-top: 69px;   /* match mobile header height: 12px + 44px + 12px + 1px border */
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    header {
        padding: 12px 16px;
    }

    /* ── Bottom tab bar ── */
    .main-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
        margin: 0;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        justify-content: space-around;
        background-color: var(--bg-primary);
        border-top: 1px solid var(--border-color);
        z-index: 200;
    }

    .main-nav a {
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 52px;
        padding: 6px 4px;
        font-size: 10px;
        border-radius: 0;
    }

    .nav-icon {
        display: block;
        width: 22px;
        height: 22px;
    }

    .nav-bookmarks-link .nav-label {
        display: block;
    }

    .sort-tabs {
        top: 69px;           /* match mobile header height */
        margin-inline: -12px;   /* match mobile body padding (desktop uses -20px) */
        padding-inline: 12px;
    }

    .feed-refresh-banner {
        top: 129px;          /* mobile header 69px + sort-tabs ~52px + 8px gap */
    }

    /* Search panel: match mobile body padding (desktop uses -20px) */
    .search-panel {
        margin-inline: -12px;
        padding-inline: 12px;
    }

    /* Sort tabs: fill width for a cleaner, more intentional mobile layout */
    .sort-tabs .search-toggle {
        padding: 8px 6px 11px;  /* match mobile sort-tab padding */
    }

    /* When search is open, widen the ✕ for a comfortable touch target */
    .search-panel--open + .sort-tabs .search-toggle {
        padding-inline: 20px;
    }

    .sort-tab {
        flex: 1;
        text-align: center;
        justify-content: center;
        padding: 8px 6px 11px;  /* taller touch target */
    }

    /* Article list */
    .thumbnail {
        width: 56px;
        height: 56px;
    }

    .article-main {
        gap: 10px;
    }

    /* Article detail — clamp handles minimum, no override needed */

    .article-detail-meta {
        gap: 10px;
    }

    /* Gift URL items: wrap date/badge below URL on narrow screens */
    .gift-url-item {
        flex-wrap: wrap;
        gap: 4px 10px;
    }

    /* Shares: tighten wrap gap so stats+time don't sprawl */
    .share-header {
        gap: 6px;
    }

    .sources-table th,
    .sources-table td {
        padding: 10px 8px;
    }

    /* Hide "Most Recent" on mobile — not enough room without wrapping */
    .sources-table th:nth-child(3),
    .sources-table td:nth-child(3) {
        display: none;
    }
}

/* ── Very narrow (e.g. 320px) ── */
@media (max-width: 400px) {
    .site-title {
        font-size: 16px;
    }

    .article-title {
        font-size: 18px;
    }

    .article-main {
        gap: 8px;
    }

    .main-nav a {
        font-size: 10px;
    }
}

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.page-btn {
    padding: 6px 14px;
    border-radius: var(--radius-md);
    background-color: var(--accent-strong);
    color: var(--text-on-accent);
    font-size: 13px;
    font-weight: 500;
    min-height: 44px;
    min-width: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s var(--ease-out), transform 0.1s var(--ease-out);
}

.page-btn:hover {
    opacity: 0.85;
}

.page-btn:active {
    transform: scale(0.96);
    opacity: 1;
}

.page-info {
    font-size: 13px;
    color: var(--text-muted);
}

@media print {
    body {
        max-width: none;
        padding: 20px;
        padding-top: 20px;
        color: #000;
        background: #fff;
        font-size: 12pt;
    }

    header {
        position: static;
        border: none;
        background: none;
        padding: 0 0 12px;
    }

    /* Hide interactive / navigation chrome */
    .main-nav,
    .theme-toggle,
    .sort-tabs,
    .filter-bar,
    .gift-btn,
    .more-gift-btn,
    .card-gift-expand,
    .back-link,
    .onboard-banner,
    .feed-refresh-banner,
    #scroll-top-fab,
    .gift-details > summary::before {
        display: none;
    }

    /* Expand external link URLs after link text */
    a[href^="http"]::after,
    a[href^="https"]::after {
        content: " (" attr(href) ")";
        font-size: 0.75em;
        color: #555;
        word-break: break-all;
    }

    /* No URL expansion for internal navigation links */
    a[href^="/"]::after {
        content: none;
    }

    /* Remove decorative backgrounds; save ink */
    .pub-badge,
    .cat-badge,
    .new-badge,
    .retired-badge {
        background: none;
        border: 1px solid #ccc;
    }

    .gift-url-item {
        background: none;
        border: 1px solid #ccc;
    }

    /* Avoid orphaned article cards and share rows */
    .article-card,
    .share-item {
        break-inside: avoid;
    }

    footer {
        border: none;
        margin-top: 20px;
    }
}

/* ── Offline page ──────────────────────────────────────────────────────────── */

.offline-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
    gap: 1rem;
    padding: 2rem;
}

.offline-icon {
    font-size: 4rem;
    line-height: 1;
}

.offline-page h1 {
    font-size: 1.75rem;
    margin: 0;
}

.offline-page p {
    color: var(--text-muted);
    max-width: 28ch;
    margin: 0;
}

.btn-primary {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    background: var(--accent-strong);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
}

.btn-primary:hover {
    opacity: 0.88;
}

/* ── Category badge colors ─────────────────────────────────────────────────── */
/*
 * Parametric hue system — each category binds its hue variable to --_h;
 * the shared formula below computes bg/text/border from it via OKLCH.
 * Retuning a category means changing one number in :root above.
 */

/* Bind each category name to its hue */
.cat-badge[data-cat="politics"]        { --_h: var(--cat-hue-politics); }
.cat-badge[data-cat="world"]           { --_h: var(--cat-hue-world); }
.cat-badge[data-cat="business"]        { --_h: var(--cat-hue-business); }
.cat-badge[data-cat="technology"]      { --_h: var(--cat-hue-technology); }
.cat-badge[data-cat="science"]         { --_h: var(--cat-hue-science); }
.cat-badge[data-cat="health"]          { --_h: var(--cat-hue-health); }
.cat-badge[data-cat="entertainment"]   { --_h: var(--cat-hue-entertainment); }
.cat-badge[data-cat="culture"]         { --_h: var(--cat-hue-culture); }
.cat-badge[data-cat="food"]            { --_h: var(--cat-hue-food); }
.cat-badge[data-cat="sports"]          { --_h: var(--cat-hue-sports); }
.cat-badge[data-cat="opinion"]         { --_h: var(--cat-hue-opinion); }
.cat-badge[data-cat="media"]           { --_h: var(--cat-hue-media); }
.cat-badge[data-cat="legal"]           { --_h: var(--cat-hue-legal); }
.cat-badge[data-cat="transportation"]  { --_h: var(--cat-hue-transportation); }
.cat-badge[data-cat="travel"]          { --_h: var(--cat-hue-travel); }

/* Light mode — shared formula applied to all known categories */
.cat-badge[data-cat] {
    background-color: oklch(93% 0.04 var(--_h));
    color:            oklch(34% 0.16 var(--_h));
    border-color:     oklch(82% 0.09 var(--_h));
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .cat-badge[data-cat] {
        background-color: oklch(22% 0.06 var(--_h));
        color:            oklch(76% 0.14 var(--_h));
        border-color:     oklch(32% 0.08 var(--_h));
    }
}

[data-theme="dark"] .cat-badge[data-cat] {
    background-color: oklch(22% 0.06 var(--_h));
    color:            oklch(76% 0.14 var(--_h));
    border-color:     oklch(32% 0.08 var(--_h));
}

/* ── Cat badge as link ── */
a.cat-badge {
    text-decoration: none;
    cursor: pointer;
}

/* ── Filter bar removable badge ── */
.filter-badge {
    cursor: pointer;
    text-decoration: none;
}

.filter-badge:hover {
    opacity: 0.75;
}

/* ── Hidden-by-preference / hidden-by-chip ── */
[data-hidden-by-pref],
[data-hidden-by-chip] {
    display: none !important;
}

/* ── Prefs filter status line ── */
.prefs-filter-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 4px 0 8px;
    align-items: center;
    gap: 6px;
    margin: 0;
}

/* display:flex must be gated on :not([hidden]) — author styles beat the UA
   [hidden]{display:none} rule, so an unconditional display would override it. */
.prefs-filter-status:not([hidden]) {
    display: flex;
}

.prefs-status-reset {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent-color);
    font-size: 0.8rem;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}

/* ── Prefs toggle ── */
.prefs-toggle {
    position: relative;
    background-color: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 5px 9px;
    cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s var(--ease-out), color 0.15s var(--ease-out),
                border-color 0.15s var(--ease-out), transform 0.1s var(--ease-out);
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
}

.prefs-toggle svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}

.prefs-toggle:hover {
    background-color: color-mix(in oklch, var(--accent-color) 10%, var(--bg-secondary));
    border-color: var(--accent-color);
    color: var(--text-primary);
}

.prefs-toggle:active {
    transform: scale(0.91);
}

/* Active state when hidden categories exist — tinted border signals "configured", not "new" */
.prefs-toggle.prefs-active {
    border-color: var(--accent-color);
    background-color: color-mix(in oklch, var(--accent-color) 12%, var(--bg-secondary));
}

/* ── Prefs scrim ── */
.prefs-scrim {
    position: fixed;
    inset: 0;
    background: oklch(0% 0 0 / 0.4);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.25s var(--ease-out);
}

.prefs-scrim--visible {
    opacity: 1;
}

/* ── Body scroll lock when sheet is open ── */
body.prefs-open {
    overflow: hidden;
}

/* ── Prefs sheet ── */
.prefs-sheet {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 85ch;
    background: var(--bg-secondary);
    border-radius: 14px 14px 0 0;
    border-top: 2px solid var(--accent-color);
    z-index: 200;
    /* No padding here — split between sticky-top and prefs-body */
    transition: transform 0.25s var(--ease-out);
    max-height: 85dvh;
    /* Flex column: header stays fixed, body scrolls independently */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -8px 40px oklch(0% 0 0 / 0.22), 0 -2px 8px oklch(0% 0 0 / 0.10);
}

.prefs-sheet--open {
    transform: translateX(-50%) translateY(0);
}

/* ── Handle + header — never scrolls, sits above the scroll container ── */
.prefs-sticky-top {
    flex-shrink: 0;
    padding: 0 1.25rem;
    background: var(--bg-secondary);
    /* Thin separator so scrolling content passes visibly beneath */
    border-bottom: 1px solid var(--border-color);
}

/* ── Scrollable body — the only element that scrolls ── */
.prefs-body {
    flex: 1 1 auto;
    min-height: 0;           /* allow flex child to shrink below content height */
    overflow-y: auto;
    padding: 0 1.25rem calc(2.5rem + env(safe-area-inset-bottom, 0px));
}

/* ── Sheet handle ── */
.prefs-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--accent-color);
    opacity: 0.35;
    margin: 14px auto 10px;
    cursor: grab;
}

/* ── Sheet header ── */
.prefs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0 12px;
}

.prefs-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.prefs-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: var(--radius-md);
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s var(--ease-out);
}

.prefs-close:hover {
    background-color: var(--bg-primary);
}

/* ── Sheet sections ── */
.prefs-section {
    padding: 14px 0;
    border-top: 1px solid var(--border-color);
}

.prefs-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin: 0 0 12px;
}

/* ── 3-way theme group ── */
.prefs-theme-group {
    display: flex;
    gap: 8px;
}

.prefs-theme-btn {
    flex: 1;
    padding: 7px 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    min-height: 44px;
    cursor: pointer;
    transition: background-color 0.15s var(--ease-out), color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}

.prefs-theme-btn[aria-pressed="true"] {
    background: var(--accent-color);
    color: oklch(98% 0.005 240);
    border-color: var(--accent-color);
}

.prefs-theme-btn:hover:not([aria-pressed="true"]) {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* ── Show all / Hide all controls ── */
.prefs-cat-all-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.prefs-cat-all-btn {
    flex: 1;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    min-height: 36px;
    font-family: inherit;
    transition: background-color 0.15s var(--ease-out), color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}

.prefs-cat-all-btn:hover {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* ── Category group headings ── */
.prefs-cat-group {
    margin-bottom: 14px;
}

.prefs-cat-group:last-child {
    margin-bottom: 0;
}

.prefs-cat-group-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin: 0 0 8px;
}

/* ── Category toggle list ── */
/* auto-fill keeps columns ~140px so cells never stretch to hundreds of pixels on desktop */
.prefs-cat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 4px 8px;
}

.prefs-cat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    min-height: 40px;
}

/* ── CSS pill toggle switch ── */
.prefs-cat-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    border: none;
    padding: 0;
    cursor: pointer;
    background: var(--border-color);
    transition: background 0.2s var(--ease-out);
    flex-shrink: 0;
}

.prefs-cat-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px oklch(0% 0 0 / 0.25);
    transition: transform 0.2s var(--ease-out);
}

.prefs-cat-toggle[aria-checked="true"] {
    background: var(--gift-color);
}

.prefs-cat-toggle[aria-checked="true"]::after {
    transform: translateX(16px);
}

@media (prefers-color-scheme: dark) {
    .prefs-cat-toggle::after { background: oklch(92% 0.005 240); }
}

[data-theme="dark"] .prefs-cat-toggle::after { background: oklch(92% 0.005 240); }

.prefs-cat-item:has(.prefs-cat-toggle[aria-checked="false"]) .cat-badge {
    opacity: 0.4;
    text-decoration: line-through;
    text-decoration-color: currentColor;
}

/* ── Focus rings on accent-colored controls ── */
/* Global ring uses accent-strong — invisible against accent bg. Flip to near-white. */
.prefs-theme-btn[aria-pressed="true"]:focus-visible,
.prefs-cat-toggle[aria-checked="true"]:focus-visible {
    outline-color: oklch(98% 0.005 240);
}

/* ── Cat toggle hover ── */
.prefs-cat-toggle:hover {
    opacity: 0.82;
}

/* ── Filter bar fade-in via @starting-style ── */
.filter-bar {
    transition: opacity 0.18s var(--ease-out);
}
@starting-style {
    .filter-bar:not([hidden]) {
        opacity: 0;
    }
}

/* ── Status line & filter empty state fade-in ── */
#prefs-filter-status {
    transition: opacity 0.15s var(--ease-out);
}
@starting-style {
    #prefs-filter-status:not([hidden]) {
        opacity: 0;
    }
}

#filter-empty-state {
    transition: opacity 0.2s var(--ease-out);
}
@starting-style {
    #filter-empty-state:not([hidden]) {
        opacity: 0;
    }
}

/* ── filter-badge active press feedback ── */
.filter-badge:active {
    opacity: 0.55;
    transform: scale(0.95);
}

/* ── About page ──────────────────────────────────────────────────────────── */

.about-hero {
    padding: 28px 0 36px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
}

@keyframes about-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.about-headline {
    font-family: var(--font-display);
    font-size: clamp(1.55rem, 3.5vw, 2rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.015em;
    color: var(--text-primary);
    max-width: 32ch;
    margin-bottom: 16px;
    animation: about-rise 0.45s cubic-bezier(0.25, 1, 0.5, 1) both;
}

.about-lead {
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text-secondary);
    max-width: 60ch;
    animation: about-rise 0.45s cubic-bezier(0.25, 1, 0.5, 1) 0.08s both;
}

.about-section {
    padding: 32px 0;
    border-bottom: 1px solid var(--border-color);
}

.about-section:last-child {
    border-bottom: none;
    padding-bottom: 20px;
}

/* Section labels — editorial uppercase markers (The Atlantic style) */
.about-section > h2 {
    font-family: var(--font-body);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.about-section > p {
    font-size: 1rem;
    line-height: 1.72;
    color: var(--text-primary);
    max-width: 65ch;
}

.about-section > p + p {
    margin-top: 12px;
}

/* Publications — two-column grid, accent left-border */
.publications-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px 16px;
    margin-top: 16px;
}

.publications-list li {
    font-size: 0.9375rem;
    line-height: 1.45;
    color: var(--text-primary);
    padding: 5px 0 5px 12px;
    border-left: 2px solid var(--accent-color);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: border-color 0.15s var(--ease-out), background-color 0.15s var(--ease-out), padding-left 0.15s var(--ease-out);
}

.publications-list li:hover {
    background-color: var(--bg-secondary);
    border-color: var(--accent-strong);
    padding-left: 14px;
}

/* --accent-color resolves to dark value automatically via :root dark overrides */

/* How it works — numbered steps with Lora accent counters */
.how-it-works {
    list-style: none;
    counter-reset: steps;
    margin-top: 16px;
}

.how-it-works li {
    position: relative;
    padding: 16px 0 16px calc(2.25rem + 16px);
    border-bottom: 1px solid var(--border-color);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-primary);
    counter-increment: steps;
    max-width: 65ch;
}

.how-it-works li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Absolutely positioned so it never participates in block flow
   and is immune to whitespace text node placement bugs */
.how-it-works li::before {
    content: counter(steps);
    font-family: var(--font-display);
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--accent-color);
    line-height: 1;
    letter-spacing: -0.02em;
    position: absolute;
    left: 0;
    top: 16px; /* aligns with top of text content area (= padding-top) */
}

.how-it-works li strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ── Category landing page ───────────────────────────────────────────────── */

/* Hue-derived color tokens — computed once per page from --cat-page-hue.
   Light mode: dark saturated for heading, medium for the accent bar and active tab. */
.category-page {
    --cat-page-hue: 242;                            /* fallback: navy */
    --cat-heading-color: oklch(31% 0.14 var(--cat-page-hue));
    --cat-accent-color:  oklch(50% 0.20 var(--cat-page-hue));
}

/* Dark mode: lift lightness so colors remain readable on dark bg */
@media (prefers-color-scheme: dark) {
    .category-page {
        --cat-heading-color: oklch(72% 0.16 var(--cat-page-hue));
        --cat-accent-color:  oklch(62% 0.18 var(--cat-page-hue));
    }
}
[data-theme="dark"] .category-page {
    --cat-heading-color: oklch(72% 0.16 var(--cat-page-hue));
    --cat-accent-color:  oklch(62% 0.18 var(--cat-page-hue));
}
/* Explicit light override: reset to light values when JS toggles light on a dark-mode system */
[data-theme="light"] .category-page {
    --cat-heading-color: oklch(31% 0.14 var(--cat-page-hue));
    --cat-accent-color:  oklch(50% 0.20 var(--cat-page-hue));
}

/* Thin editorial rule above the heading — The Atlantic section-marker style */
.category-page .page-heading::before {
    content: '';
    display: block;
    width: 28px;
    height: 3px;
    background-color: var(--cat-accent-color);
    margin-bottom: 10px;
    border-radius: 1px;
}

/* Heading tinted to the category hue */
.category-page .page-heading {
    color: var(--cat-heading-color);
    padding-top: 8px;
}

/* Active sort-tab underline tracks the category hue */
.category-page .sort-tab.active {
    border-bottom-color: var(--cat-accent-color);
    color: var(--cat-heading-color);
}

/* When a page-heading is immediately followed by a subheading,
   tighten the gap so they read as a unit (28px→6px between them). */
.page-heading:has(+ .page-subheading) {
    margin-bottom: 6px;
}

.page-subheading {
    font-size: 0.9375rem;
    color: var(--text-muted);
    margin-top: 0;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ── Responsive: collapse cat grid to 1-col on very narrow screens ── */
@media (max-width: 360px) {
    .prefs-cat-list {
        grid-template-columns: 1fr;
    }
}
