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

/* Reserve a stable scrollbar gutter so the layout never jumps horizontally
   when content height crosses the viewport. The fallback for older browsers
   forces the vertical scrollbar to always be present. */
html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

:root {
    --primary-color: #000000;
    --primary-hover: #333333;
    --accent-color: #000000;
    --secondary-color: #000000;
    --background: #ffffff;
    --background-secondary: #f5f5f5;
    --card-background: #ffffff;
    --text-primary: #000000;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.10);
    --transition: all 0.2s ease;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 16px;
    letter-spacing: 0;
    font-weight: 400;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent any descendant (popups near the right edge, long filter chips,
       wide tables) from making the page grow wider than the viewport. */
    overflow-x: clip;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
}

/* Header Styles */
.header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 0;
    /* Reserve room on the right for the absolutely-pinned actions
       (toggle + refresh) so they never overlap brand/stats content. */
    padding-right: 96px;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: nowrap;
    min-width: 0;
    position: relative;
}

.header-content {
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: nowrap;
    /* Now contains the progress strip too, so absorb the slack and let the
       strip's `flex: 1 1 auto` grow inside this wrapper. */
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
}

/* Same styling as .wp-post-btn on article cards */
.header-wp-add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.4rem;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    line-height: 1;
    opacity: 1;
}
.header-wp-add-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}
.header-wp-add-btn .wp-icon {
    font-size: 1.2rem;
    margin-top: -1px;
}

/* The view toggle + refresh are wrapped in .header-actions so they stay
   clustered as a single unit at the right edge of the header. */
.header-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    /* Pinned to the top-right corner of the header on every viewport
       so the toggle + refresh icons stay flush right regardless of
       what's happening with brand / stats / progress in the rest of
       the row. */
    position: absolute;
    top: 12px;
    right: 0;
    margin-left: 0;
}

.view-toggle {
    display: inline-flex;
    background: var(--background-secondary);
    border-radius: 8px;
    padding: 2px;
    gap: 0;
    flex-shrink: 0;
}

.view-toggle-opt {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 28px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.view-toggle-opt.active {
    background: var(--card-background);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.view-toggle-opt:not(.active):hover {
    color: var(--text-primary);
}

.view-card-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1.8px solid currentColor;
    border-radius: 3px;
}

.header-refresh-btn {
    background: transparent;
    border: none;
    color: var(--primary-color);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    /* Sits adjacent to .view-toggle on the right edge — no auto-margin so
       the two stay clustered together rather than splitting the slack. */
}

.header-refresh-btn:hover {
    background: var(--background-secondary);
    transform: rotate(180deg);
}

.header-refresh-btn .refresh-icon {
    display: block;
}

.title {
    font-size: 21px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.011em;
}

/* Legacy hook kept for loading-spinner favicons */
.apple-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.apple-icon svg,
.apple-icon img {
    width: 100%;
    height: 100%;
}

/* Quantinuum horizontal wordmark in the header. PNG is 1702×316 (~5.4:1),
   so lock the height and let width follow the aspect ratio. */
.brand-mark {
    display: inline-flex;
    align-items: center;
    height: 28px;
    flex-shrink: 0;
}

.brand-mark img {
    height: 100%;
    width: auto;
    display: block;
}

/* News Monitor suffix — smaller + bolder so it reads clearly as a label
   rather than competing with the wordmark for size. */
.brand-suffix {
    font-family: inherit;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1;
    letter-spacing: 0.16em;
    margin-left: 12px;
    margin-right: -0.16em;
}

@media (max-width: 600px) {
    .brand-mark { height: 22px; }
    .brand-suffix {
        font-size: 11px;
        margin-left: 8px;
        letter-spacing: 0.14em;
    }
}

.subtitle {
    display: none; /* Hidden for cleaner Apple look */
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 14px;
    /* Separated-uppercase label treatment so the stats read as small
       labels rather than body copy. */
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    font-weight: 500;
}

.header-stat {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.header-stat span {
    font-weight: 700;
    font-size: 12px;
    color: var(--text-primary);
    display: inline-block;
    min-width: 2ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}

.header-stat-divider {
    color: var(--border-color);
    font-weight: 300;
    letter-spacing: 0;
}

.header-stats {
    transition: opacity 0.3s ease;
}

.header-loading-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
}

.header-loading-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    border-top-color: var(--text-secondary);
    animation: headerSpin 0.8s linear infinite;
    flex-shrink: 0;
}

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

.header-loading-favicon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    object-fit: contain;
    flex-shrink: 0;
}

.header-loading-progress {
    font-variant-numeric: tabular-nums;
    color: var(--text-tertiary, #999);
    font-size: 12px;
}

/* WordPress env toggle (Production / Staging) */
.wp-env-toggle {
    display: flex;
    gap: 0;
    background: var(--background-secondary);
    border-radius: 8px;
    padding: 2px;
    margin-left: auto;
    margin-right: 8px;
}
.wp-env-btn {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.wp-env-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.06);
}
.wp-env-btn.active {
    background: var(--card-background);
    color: var(--primary-color);
    box-shadow: var(--shadow);
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    background: var(--background-secondary);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 20px;
    gap: 10px;
    transition: var(--transition);
    border: 1px solid transparent;
}

.search-bar:focus-within {
    background: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.1);
}

/* Search bar inside header */
.header-search {
    max-width: 250px;
    margin: 0;
    background: var(--background-secondary);
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    flex-shrink: 0;
}

.header-search:focus-within {
    background: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.1);
}

.header-search .search-icon {
    opacity: 0.5;
    font-size: 1rem;
}

.header-search .search-input {
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
}

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

.header-search .clear-search-btn {
    color: var(--text-secondary);
    background: transparent;
    width: 20px;
    height: 20px;
    font-size: 0.8rem;
}

.header-search .clear-search-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.search-icon {
    font-size: 1.1rem;
    opacity: 0.5;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}

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

.clear-search-btn {
    background: var(--border-color);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-secondary);
}

.clear-search-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
    overflow: visible;
}

/* Time Filter Bar - same styling as Topics (content-pattern-tag) */
.time-filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0;
    margin-bottom: 0;
}

.time-group-wrapper {
    position: relative;
    display: inline-flex;
}

.time-group-btn {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
    color: #000 !important;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.time-group-btn:hover {
    background: var(--background-secondary);
}

.time-group-btn.active {
    background: var(--text-primary);
    color: #fff !important;
    border-color: var(--text-primary);
}

.time-group-popup {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 100;
    background: var(--card-background, #fff);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 120px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.time-group-wrapper.open .time-group-popup {
    display: flex;
}

.time-group-wrapper.open .supertopic-chevron {
    transform: rotate(180deg);
}

.time-btn {
    padding: 5px 12px;
    background: var(--background-secondary);
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

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

.time-btn.active {
    background: var(--text-secondary);
    color: white;
}

.time-count {
    color: var(--text-secondary);
    opacity: 0.5;
    font-weight: 400;
    font-size: 12px;
}

.time-btn.active .time-count {
    color: inherit;
    opacity: 0.6;
}

/* Filters row: time-filter buttons, incremental search, source dropdown */
.filters-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 4px;
    overflow: visible;
}

/* Incremental-search input — always-open pill that visually matches the
   supertopic bubbles (same height, same border treatment, B/W only).
   Pushed to the right end of the filters row via margin-left: auto. */
.search-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    padding: 0 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    transition: border-color 0.15s ease, background 0.15s ease;
    /* Grow to fill remaining space in the filters-row. */
    flex: 1 1 auto;
    min-width: 140px;
    margin-left: auto;
}

/* Narrower viewports — let the search shrink and stop forcing it to the
   right end (margin-left: auto would leave it hanging off on its own row
   when filters wrap). Below 480 px it spans the full row width. */
@media (max-width: 768px) {
    .search-wrap {
        flex: 1 1 auto;
        min-width: 120px;
        margin-left: 0;
        /* Defensive: prevent any parent flex axis ambiguity from letting
           the bubble grow vertically. Height stays at its base 28px. */
        height: 28px;
        align-self: center;
    }
}
@media (max-width: 480px) {
    .search-wrap {
        flex-basis: 100%;
        min-width: 0;
    }
}

.search-wrap:hover {
    background: var(--background-secondary);
}

.search-wrap:focus-within {
    border-color: var(--text-primary);
    background: var(--card-background);
}

.search-wrap .search-icon {
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    font-weight: 600;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0;
    min-width: 0;
}

.search-input::-webkit-search-cancel-button { display: none; }

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 1;
    font-weight: 400;
}

.clear-search-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.clear-search-btn:hover {
    background: var(--text-primary);
    color: var(--card-background);
}

/* Source dropdown (All Sources) - hidden */
#sourceIconsBar {
    display: none !important;
}

.source-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--background);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    min-width: 130px;
}

.source-dropdown-trigger:hover {
    border-color: var(--primary-color);
    background: var(--background-secondary);
}

.source-dropdown-trigger-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.source-dropdown-trigger-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.source-dropdown-trigger-label {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-dropdown-arrow {
    font-size: 10px;
    opacity: 0.6;
    flex-shrink: 0;
}

.source-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    z-index: 1000;
    display: none;
    flex-direction: column;
    padding: 6px;
}

.source-dropdown-menu.open {
    display: flex;
}

.source-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
    width: 100%;
}

.source-dropdown-item:hover {
    background: var(--background-secondary);
}

.source-dropdown-item.active {
    background: rgba(0, 102, 204, 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

.source-dropdown-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
}

.source-dropdown-item-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.source-dropdown-item-fallback {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Content patterns bar (supertopic rows) */
.content-patterns-bar {
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 0;
    background: transparent;
    margin-bottom: 4px;
}

.content-patterns-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.content-patterns-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
    align-items: center;
    justify-content: flex-start;
}

.pattern-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    opacity: 0.6;
    padding: 5px 2px 5px 8px;
    white-space: nowrap;
    align-self: center;
}

.content-pattern-tag {
    padding: 5px 12px;
    background: var(--background-secondary);
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-align: left;
    /* Each keyword/topic stays on a single line; if its text is wider than
       the popup can fit, clamp with an ellipsis instead of overflowing
       beyond the menu boundary. */
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Inside the supertopic popup the cap is the popup's interior width. */
.supertopic-popup .content-pattern-tag {
    max-width: 100%;
}

.content-pattern-tag:hover {
    background: var(--border-color);
}

.content-pattern-tag.active {
    background: var(--text-primary);
    color: white;
}

/* Count is clickable on supertopic buttons (alongside the chevron and the
   keyboard-shortcut number). Cursor + hover affordance follow accordingly. */
.pattern-count {
    color: var(--text-secondary);
    opacity: 0.5;
    font-weight: 400;
    cursor: pointer;
    padding: 0 3px;
    border-radius: 3px;
}

.pattern-count:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

.content-pattern-tag.active .pattern-count {
    color: inherit;
    opacity: 0.6;
}

/* Supertopic controls row (All Topics, Everything Quantinuum, Everything, +) */
.supertopic-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
}

/* Supertopic wrapper with disclosure popup */
.supertopic-wrapper {
    position: relative;
    display: inline-flex;
}

.supertopic-popup {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 100;
    background: var(--card-background, #fff);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 180px;
    /* Never wider than the viewport (with a 16px breathing margin) so the
       popup can't push the page horizontally on small screens. */
    max-width: min(360px, calc(100vw - 32px));
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    justify-content: flex-start;
    text-align: left;
}

.supertopic-wrapper.open .supertopic-popup {
    display: flex;
}

.supertopic-wrapper.open .supertopic-chevron {
    transform: rotate(180deg);
}

.supertopic-chevron {
    font-size: 18px;
    opacity: 0.8;
    margin-left: 6px;
    display: inline-block;
    line-height: 1;
    transition: transform 0.2s ease;
    cursor: pointer;
    padding: 0 4px;
    vertical-align: -2px;
}
.supertopic-chevron:hover { opacity: 1; }

.supertopic-btn {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
    color: #000 !important;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.supertopic-btn:hover {
    background: var(--background-secondary);
    color: #000 !important;
}

.supertopic-btn.active {
    background: var(--text-primary);
    color: #fff !important;
    border-color: var(--text-primary);
}

/* Circled-glyph shortcut affordance. Clicking it pops the menu (alongside
   the chevron). Sized to read crisply alongside the bubble label. */
.supertopic-key {
    font-size: 13px;
    line-height: 1;
    opacity: 0.7;
    margin-right: 4px;
    font-weight: 400;
    cursor: pointer;
    padding: 0 1px;
    border-radius: 3px;
    font-variant-numeric: tabular-nums;
    /* The circled glyphs render slightly heavier than digits; nudge the
       baseline so they sit centered with the rest of the text. */
    vertical-align: -1px;
}

.supertopic-key:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

.supertopic-btn.active .supertopic-key {
    opacity: 0.9;
}

.content-pattern-tag.content-pattern-add {
    min-width: 28px;
    padding: 5px 10px;
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1;
}

.content-pattern-tag.content-pattern-add:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.content-pattern-add-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.content-pattern-input {
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    font-size: 12px;
    font-family: inherit;
    width: 140px;
    outline: none;
}

.content-pattern-input:focus {
    border-color: var(--primary-color);
}

.content-pattern-tag.content-pattern-add-confirm {
    padding: 5px 10px;
}

/* Topics Bar */
.topics-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    background: transparent;
    margin-bottom: 20px;
}

.topics-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.topics-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.topic-tag {
    padding: 5px 12px;
    background: var(--background-secondary);
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.topic-tag:hover {
    background: var(--border-color);
}

.topic-tag.active {
    background: var(--text-secondary);
    color: white;
}

.topic-count {
    font-size: 11px;
    opacity: 0.6;
    margin-left: 3px;
}

.filters {
    display: none; /* Hidden, using new visual filters */
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-container label {
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.source-filter {
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    background: var(--card-background);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    min-width: 180px;
}

.source-filter:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Loading State */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--background);
}

.loading-spinner-wrap {
    position: relative;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    animation: ringRotate 1s linear infinite;
}

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

.loading-favicon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
    position: relative;
    z-index: 1;
    animation: faviconSwap 0.3s ease;
}

@keyframes faviconSwap {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
}

.loading-source-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    min-height: 20px;
}

.loading-progress {
    font-size: 12px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Error State */
.error {
    text-align: center;
    padding: 40px 20px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.error-message {
    color: #ff3b30;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.retry-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.retry-btn:hover {
    background: #0051d5;
}

/* News Grid */
.news-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 40px;
    width: 100%;
}

@media (max-width: 1400px) {
    .news-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1000px) {
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* News List / Table View */
.news-list {
    margin-bottom: 40px;
    width: 100%;
}

.news-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    /* Fixed layout makes column widths the same on every row regardless of
       content length, so the table doesn't reflow as data loads. */
    table-layout: fixed;
}

/* Explicit per-column widths. .nt-title gets the remaining space (`auto`). */
.news-table col.nt-num     { width: 36px; }
.news-table col.nt-date    { width: 60px; }
.news-table col.nt-source  { width: 160px; }
.news-table col.nt-title   { width: auto; }
.news-table col.nt-topics  { width: 200px; }
.news-table col.nt-actions { width: 44px; }

.news-table thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.news-table-row {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.1s;
}

.news-table-row:hover {
    background: var(--background-secondary);
}

.news-table-row td {
    padding: 8px 12px;
    vertical-align: top;
    /* Truncate overflowing content with an ellipsis instead of letting it
       push the column wider. .nt-title overrides this to allow wrapping. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.news-table-row td.nt-title {
    white-space: normal;
    text-overflow: clip;
}

.nt-num {
    color: rgba(0, 0, 0, 0.18);
    font-size: 11px;
    font-weight: 400;
    width: 28px;
    text-align: right;
    padding-right: 4px;
    font-variant-numeric: tabular-nums;
}

.nt-date {
    white-space: nowrap;
    color: var(--text-secondary);
    width: 50px;
    font-weight: 400;
    font-size: 12px;
}

.nt-source {
    white-space: nowrap;
    width: 140px;
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 13px;
}

td.nt-source {
    display: table-cell;
}

.nt-favicon {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 4px;
}

.nt-title {
    font-weight: 400;
}

.nt-title a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 400;
}

/* Matched keywords inside card / list titles are rendered as <strong>.
   We use demi-bold (600), not full bold, so highlighted phrases stand out
   without dominating the headline. */
.nt-title a strong,
.news-title strong {
    font-weight: 600;
}

.nt-title a:hover {
    text-decoration: underline;
}

.nt-alt-links {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.nt-alt-link {
    opacity: 0.6;
    transition: opacity 0.15s;
}

.nt-alt-link:hover {
    opacity: 1;
}

.nt-topics {
    color: var(--text-secondary);
    font-size: 12px;
    max-width: 200px;
}

/* Matches .card-topic-link so list-view and box-view chips look identical. */
.nt-topic-link {
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 3px 9px;
    border-radius: 10px;
    background: var(--background-secondary);
    transition: background 0.15s, color 0.15s;
    display: inline-block;
    white-space: nowrap;
}

.nt-topic-link:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.nt-actions {
    width: 40px;
    text-align: center;
    white-space: nowrap;
}

.nt-wp-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
    opacity: 0;
}

.news-table-row:hover .nt-wp-btn,
.news-table-row.focused .nt-wp-btn {
    opacity: 1;
}

.nt-wp-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.15);
}

.nt-wp-btn .wp-icon {
    font-size: 0.85rem;
    margin-top: -1px;
}

.news-table-row.focused {
    background: rgba(0, 102, 204, 0.08);
    outline: none;
}

.news-table-row.focused td:first-child {
    box-shadow: inset 3px 0 0 var(--primary-color);
}

/* News Card */
.news-card {
    background: var(--card-background);
    border-radius: 18px;
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.news-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.news-card:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-color), 0 8px 30px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.news-card.keyboard-focus {
    box-shadow: 0 0 0 3px var(--primary-color), 0 8px 30px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.card-counter {
    position: absolute;
    top: 6px;
    left: 8px;
    z-index: 2;
    color: rgba(0, 0, 0, 0.18);
    font-size: 11px;
    font-weight: 500;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

.news-date-top {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 2;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 6px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.news-card-clickable {
    cursor: pointer;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.alt-sources-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 8px;
}

.alt-source-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.alt-source-link:hover {
    opacity: 1;
    text-decoration: underline;
}

.alt-source-icon {
    width: 14px;
    height: 14px;
    border-radius: 2px;
}

.news-image {
    display: none; /* Hidden for now */
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--background-secondary);
}

.news-image-placeholder {
    display: none; /* Hidden for now */
    width: 100%;
    height: 180px;
    background: var(--background-secondary);
    /* display: flex; */
    align-items: center;
    justify-content: center;
}

.news-image-placeholder .apple-logo {
    font-size: 3.5rem;
    color: var(--border-color);
}

.news-image-placeholder .source-initial {
    font-size: 4rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.news-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.news-source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    width: fit-content;
    color: var(--text-secondary);
}

.source-favicon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
}

.news-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.news-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
    flex: 1;
    line-height: 1.5;
}

/* Matched-keyword chips sit at the bottom of the card content, after the
   title and description. Light-gray pills so they read as quiet metadata
   rather than dominant call-outs. */
.card-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    /* No top margin here — the parent .card-bottom row handles spacing. */
}

/* Bottom row of each card: keyword chips on the left, date right-flush. */
.card-bottom {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
    padding-top: 12px;
    flex-wrap: wrap;
}
.card-bottom .card-topics {
    flex: 1 1 auto;
    min-width: 0;
}
.card-bottom .news-date {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}
/* Empty placeholder so the date still right-flushes when there are no chips. */
.card-topics-spacer { flex: 1 1 auto; }

.card-topic-link {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 3px 9px;
    border-radius: 10px;
    background: var(--background-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.card-topic-link:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.news-meta {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.news-date {
    font-weight: 500;
}

.news-author {
    font-style: italic;
}

.read-more {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}

.read-more:hover {
    gap: 10px;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    padding: 20px;
    background: transparent;
    color: var(--text-secondary);
    margin-top: auto;
    font-size: 12px;
    border-top: 1px solid var(--border-color);
}

.footer-brand {
    display: inline-flex;
    align-items: center;
    /* Same lockup as the page header so the bottom mirrors the top. */
}

.footer-credit {
    margin: 0;
}

.footer a {
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
}
.footer a:hover {
    border-bottom-color: var(--text-primary);
}

.footer-sep {
    margin: 0 8px;
    color: var(--border-color);
}

.footer-contact {
    margin-top: 8px;
}

.footer-contact:empty {
    display: none;
}

.footer-contact-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-contact-link:hover {
    color: var(--primary-color);
}

.footer-contact-icon {
    flex-shrink: 0;
    vertical-align: middle;
    filter: grayscale(1);
}

.footer-contact-sep {
    margin: 0 6px;
    opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .header-search {
        order: 3;
        flex: 1 1 100%;
        max-width: none;
        margin: 10px 0 0 0;
    }
    
    .title {
        font-size: 1.3rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .controls {
        gap: 12px;
    }
    
    .time-filter-bar {
        gap: 6px;
    }

    .time-btn {
        padding: 7px 14px;
        font-size: 0.95rem;
    }
    /* Bump the filter-pill labels (time-group buttons + matched-keyword
       chips) up from the 12px desktop size so they're easier to read
       and tap on a phone. */
    .time-group-btn,
    .content-pattern-tag,
    .pattern-group-label {
        font-size: 14px;
    }
    
    .filters-row {
        /* Keep row direction so each child's flex-basis controls width,
           not height. Wrapping (already enabled) lets items spill to new
           rows when needed — going `column` here makes flex-basis size
           the search bubble vertically (e.g. 178 × 200 px). */
        flex-direction: row;
        align-items: center;
    }
    
    .source-dropdown-trigger {
        min-width: 120px;
    }
    
    .topics-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .filters {
        flex-direction: column;
        width: 100%;
    }
    
    .filter-container {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    
    .source-filter {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 10px 15px;
        margin-bottom: 15px;
    }
    
    .title {
        font-size: 1.1rem;
    }
}

/* WordPress Post Button - Circle with Plus */
.wp-post-btn {
    position: absolute;
    bottom: 14px;
    right: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.4rem;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
    line-height: 1;
    opacity: 1;
}

.wp-post-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.wp-post-btn .wp-icon {
    font-size: 1.2rem;
    margin-top: -1px;
}

/* WordPress Modal */
.wp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.wp-modal-content {
    background: var(--card-background);
    border-radius: 20px;
    width: 100%;
    max-width: 95vw;
    max-height: 92vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.wp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #21759b, #0073aa);
    border-radius: 20px 20px 0 0;
    gap: 16px;
}

.wp-modal-header-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.wp-modal-header-url-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.95rem;
    outline: none;
}
.wp-modal-header-url-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}
.wp-modal-header-url-input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
}

.wp-modal-source {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    font-weight: 500;
}

.wp-modal-source-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    flex-shrink: 0;
}

.wp-modal-source-fallback {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.wp-modal-article-link {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.wp-modal-article-link:hover {
    text-decoration: underline;
}

.wp-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.wp-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.wp-modal-body {
    display: flex;
    gap: 0;
    flex: 1;
    min-height: 0;
}

.wp-modal-form {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.wp-form-group {
    margin-bottom: 12px;
}

.wp-form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.wp-input,
.wp-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.875rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--card-background);
    color: var(--text-primary);
}

.wp-input:focus,
.wp-textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.wp-textarea {
    resize: vertical;
    min-height: 80px;
}

.wp-quip-input {
    background: #fffef5;
    border-color: #e8d88e;
}
.wp-quip-input:focus {
    border-color: #c9a227;
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.1);
}

.wp-NB-textarea {
    min-height: 220px;
    background: #fffef5;
    border-color: #e8d88e;
}

.wp-NB-textarea:focus {
    border-color: #c9a227;
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.1);
}

.wp-image-preview {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 12px;
    margin-top: 12px;
    border: 2px solid var(--border-color);
}

.wp-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 28px;
    border-top: 1px solid var(--border-color);
    background: var(--background);
    border-radius: 0 0 20px 20px;
}

.wp-btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.wp-btn-cancel {
    background: var(--border-color);
    color: var(--text-primary);
}

.wp-btn-cancel:hover {
    background: #c2c2c7;
}

.wp-btn-post {
    background: linear-gradient(135deg, #21759b, #0073aa);
    color: white;
    min-width: 180px;
}

.wp-btn-post:hover {
    background: linear-gradient(135deg, #1a5f7a, #005a87);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.wp-btn-post:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Toast Notification */
.wp-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 16px 28px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    z-index: 1001;
    animation: toastSlideUp 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.wp-toast.success {
    background: linear-gradient(135deg, #34c759, #28a745);
}

.wp-toast.error {
    background: linear-gradient(135deg, #ff3b30, #dc3545);
}

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

.wp-toast-link {
    color: white;
    text-decoration: underline;
    font-weight: 700;
    margin-left: 10px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    transition: background 0.2s ease;
}

.wp-toast-link:hover {
    background: rgba(255, 255, 255, 0.35);
    text-decoration: none;
}

/* Responsive adjustments for modal */
@media (max-width: 768px) {
    .wp-modal-content {
        max-height: 95vh;
        max-width: 100%;
        border-radius: 16px;
    }
    
    .wp-modal-header {
        padding: 18px 20px;
        border-radius: 16px 16px 0 0;
    }
    
    .wp-modal-body {
        flex-direction: column;
    }
    
    .wp-modal-form {
        flex: none;
    }
}

@media (max-width: 600px) {
    .wp-modal-footer {
        flex-direction: column;
        padding: 16px 20px;
        border-radius: 0 0 16px 16px;
    }
    
    .wp-btn {
        width: 100%;
        text-align: center;
    }
}

/* ===== Email-share modal additions ===== */
.wp-summary-link {
    display: inline-block;
    color: var(--primary-color);
    word-break: break-all;
    font-size: 0.85rem;
    text-decoration: none;
    padding: 8px 10px;
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    line-height: 1.4;
}
.wp-summary-link:hover {
    color: var(--primary-hover);
    background: #efeaf6;
}

/* ===== Activity histogram (between filters and articles) =====
   Sits flush with the page background — no panel chrome — so it reads as
   inline content rather than a separate widget. */
.activity-histogram {
    margin: 0 0 14px 0;
    padding: 8px 0 4px;
    background: var(--background);
}

/* Big plain-language summary of the active filters — sits between the
   activity histogram and the article grid. Empty (and visually absent)
   until JS fills it in. */
.search-context-title {
    margin: 4px 0 18px;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}
.search-context-title:empty { display: none; }
.search-context-title .search-context-sep {
    color: var(--text-secondary);
    font-weight: 400;
    margin: 0 0.4em;
    opacity: 0.7;
}
.search-context-title .search-context-time {
    color: var(--text-secondary);
    font-weight: 500;
}
@media (max-width: 600px) {
    .search-context-title { font-size: 1.25rem; margin: 2px 0 14px; }
}

.activity-histogram-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.activity-histogram-title {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
}

.activity-histogram-stats {
    font-variant-numeric: tabular-nums;
}

.activity-histogram-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 28px;
    padding-bottom: 2px;
}

.activity-bar {
    flex: 1 1 0;
    min-width: 4px;
    height: 100%;
    display: flex;
    align-items: flex-end;
    cursor: default;
}

.activity-bar-fill {
    width: 100%;
    background: var(--text-primary);
    border-radius: 2px 2px 0 0;
    min-height: 1px;
    box-sizing: border-box;
    transition: opacity 0.15s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Inverted (white) digits so the count reads against the dark fill. */
.activity-bar-count {
    font-size: 9px;
    line-height: 1;
    color: var(--card-background);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    /* Hidden by default; JS adds .has-room when the bar can fit the digits. */
    display: none;
}

.activity-bar-fill.has-room .activity-bar-count {
    display: inline;
}

.activity-bar:hover .activity-bar-fill {
    opacity: 0.85;
    transform: scaleY(1.05);
    transform-origin: bottom;
}

.activity-bar.empty .activity-bar-fill {
    background: var(--border-color);
    opacity: 0.5;
}

.activity-histogram-axis {
    position: relative;
    height: 12px;
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.activity-axis-label {
    position: absolute;
    top: 0;
    /* Shift each label horizontally based on its position so first sits
       flush-left, middle ticks center on their X, last flush-right.
       --pos is the percent (0–100) injected from JS. */
    transform: translateX(calc(var(--pos, 0) * -1%));
    white-space: nowrap;
    pointer-events: none;
}

@media (max-width: 600px) {
    .activity-histogram-bars { height: 22px; }
    .activity-histogram-stats { display: none; }
}

/* ===== NE-corner direct-article link =====
   Each card and list row gets a small ↗ glyph in the NE corner that opens
   the original article. The rest of the card / row routes the user to the
   share / summary page instead. */
.news-card { position: relative; }

/* Action-button row, bottom-right of each card. Hidden by default,
   revealed on hover / focus-within. Holds: email, text, copy, ↗. */
.card-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.news-card:hover .card-actions,
.news-card:focus-within .card-actions {
    opacity: 1;
}
/* On touch devices (no hover), keep the row visible so users can reach
   the share actions. */
@media (hover: none) {
    .card-actions { opacity: 1; }
}

.card-action {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.card-action svg {
    width: 14px;
    height: 14px;
}
.card-action:hover {
    background: var(--text-primary);
    color: var(--card-background);
    transform: translateY(-1px);
}
.article-jump-btn { font-weight: 600; }

.nt-jump-link {
    display: inline-flex;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.news-table-row:hover .nt-jump-link,
.news-table-row.focused .nt-jump-link {
    opacity: 1;
}

.nt-jump-link:hover {
    background: var(--text-primary);
    color: var(--card-background);
}

/* ===== ?dump view =====
   Replaces the news grid with a JSON dump of the current scan so it can
   be fed back to Claude Code to refresh the filter dictionaries. */
.dump-view {
    display: block;
    max-width: 100%;
}

.dump-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.dump-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: 0.01em;
}

.dump-meta {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.dump-copy-btn {
    padding: 8px 16px;
    background: var(--text-primary);
    color: var(--card-background);
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.dump-copy-btn:hover { background: var(--primary-hover); }

.dump-json {
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px 18px;
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre;
    max-height: 80vh;
    overflow-y: auto;
}

body.dump-mode .filters-row,
body.dump-mode .activity-histogram,
body.dump-mode .content-patterns-bar {
    display: none !important;
}

/* ===== Header scan progress =====
   Sits between the loading-status block and the layout toggle. Visible
   only during a scan; the fill grows 0 → 100% as feeds complete and the
   right-aligned label shows "<done>/<total>". */
.header-progress {
    /* The strip shows in two states — `active` during a scan, and `done`
       afterwards (keeps the spinner+text visible as "Up to date"). */
    display: none;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 80px;
    margin-left: 16px;
    margin-right: 16px;
    flex-wrap: nowrap;
    white-space: nowrap;
    /* Match the header-stats label treatment. */
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

.header-progress.active,
.header-progress.done {
    display: flex;
}

/* In the `done` state we hide the live progress track + label so the
   strip reads as a static "✓ Up to date" line rather than an idle bar. */
.header-progress.done .header-progress-track,
.header-progress.done .header-progress-label,
.header-progress.done .header-progress-spinner {
    display: none;
}

.header-progress-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    border-top-color: var(--text-secondary);
    animation: headerSpin 0.8s linear infinite;
    flex-shrink: 0;
}

.header-progress-favicon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    object-fit: contain;
    flex-shrink: 0;
}

.header-progress-text {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-progress-track {
    flex: 1;
    height: 8px;
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.header-progress-fill {
    height: 100%;
    background: var(--text-primary);
    width: 0;
    transition: width 0.25s ease;
}

.header-progress-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
    /* Numbers stay tabular without the wide tracking the rest of the
       strip has — overrides the parent letter-spacing. */
    letter-spacing: 0;
    flex-shrink: 0;
}

/* Force every Google-served source favicon to render in grayscale so
   bright publication brand colors don't fight the B/W palette. The
   filter targets the four favicon classes used across cards, lists,
   alt-source pills, and the loading-status strip. */
.source-favicon,
.nt-favicon,
.alt-source-icon,
.header-loading-favicon,
.loading-favicon {
    filter: grayscale(100%) contrast(1.1);
    -webkit-filter: grayscale(100%) contrast(1.1);
}

/* Sortable list-view headers — small visual lift so they read as buttons */
.news-table thead th[data-sort] {
    user-select: none;
}
.news-table thead th[data-sort]:hover {
    background: var(--background-secondary);
}

/* On mobile the fixed-layout news-table can't fit its column widths,
   so each row gets restructured as a stacked card: title on top, then a
   single meta line with source · date below. Topics + actions columns
   are hidden — topics still surface as filter chips above the list, and
   tapping anywhere in the row opens the original article. */
@media (max-width: 600px) {
    .news-table { display: block; table-layout: auto; font-size: 14px; }
    .news-table thead { display: none; }
    .news-table colgroup { display: none; }
    .news-table tbody { display: block; }
    .news-table-row {
        display: grid;
        grid-template-columns: auto auto 1fr;
        grid-template-areas:
            "title  title   title"
            "num    date    source";
        column-gap: 8px;
        row-gap: 2px;
        padding: 12px 4px;
        border-bottom: 1px solid var(--border-color);
    }
    .news-table-row td {
        display: block;
        padding: 0;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        width: auto;
    }
    .news-table-row td.nt-title {
        grid-area: title;
        font-size: 15px;
        line-height: 1.3;
    }
    .news-table-row td.nt-num {
        grid-area: num;
        font-size: 11px;
        color: rgba(0, 0, 0, 0.3);
        text-align: left;
        padding-right: 0;
    }
    .news-table-row td.nt-date {
        grid-area: date;
        font-size: 12px;
        color: var(--text-secondary);
        white-space: nowrap;
    }
    .news-table-row td.nt-source {
        grid-area: source;
        font-size: 12px;
        color: var(--text-secondary);
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .news-table-row td.nt-topics,
    .news-table-row td.nt-actions { display: none; }
}

/* On narrow viewports the progress strip drops to its own row beneath
   the brand. (Header-actions are already pinned top-right via the base
   .header-actions rule, so they stay put as the rest wraps.) */
@media (max-width: 768px) {
    .header {
        flex-wrap: wrap;
        row-gap: 8px;
    }
    .header-content { order: 1; }
    .header-progress {
        order: 3;
        flex-basis: 100%;
        max-width: 100%;
        min-width: 0;
        margin-left: 0;
        margin-right: 0;
    }
}
