/* =========================================
   Ström — Design System & Styles
   ========================================= */

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

:root {
    --bg-primary: #0b0b0f;
    --bg-secondary: #111117;
    --bg-card: #17171f;
    --bg-card-hover: #1d1d28;
    --bg-surface: #131319;
    --bg-input: #17171f;

    --text-primary: #ececf1;
    --text-secondary: #a0a0b4;
    --text-muted: #5e5e72;
    --text-link: #b09dff;
    --text-link-hover: #d0c5ff;

    --border-default: #252536;
    --border-subtle: #1e1e2c;
    --border-focus: #7c6bcc;

    --accent-primary: #9b7dff;
    --accent-primary-hover: #8466e8;
    --accent-green: #2dd4a0;
    --accent-green-dim: rgba(45, 212, 160, 0.06);
    --accent-green-glow: rgba(45, 212, 160, 0.12);
    --accent-amber: #f5b731;
    --accent-amber-dim: rgba(245, 183, 49, 0.08);
    --accent-red: #f06868;

    --score-high: #2dd4a0;
    --score-mid: #f5b731;
    --score-low: #8a8a9e;

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.02);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.03);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

    --transition-fast: 120ms ease;
    --transition-normal: 200ms ease;
    --transition-smooth: 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body::before {
    content: '';
    display: block;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-green), var(--accent-amber));
    flex-shrink: 0;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-card);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-xs);
    color: var(--accent-primary);
}

/* --- Layout --- */
.container {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2rem;
}

main.container {
    flex: 1;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

/* --- Header --- */
.site-header {
    border-bottom: 1px solid var(--border-default);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    background: rgba(11, 11, 15, 0.82);
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 48px;
}

.site-header nav { margin-left: auto; }

.logo {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary) !important;
    letter-spacing: -0.03em;
    transition: color var(--transition-fast);
}

.logo:hover {
    color: var(--accent-primary) !important;
}

nav {
    display: flex;
    gap: 0.15rem;
}

.nav-link {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

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

.nav-link.active {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Logout is a POST, so it's a <button> styled to match the nav links. */
.logout-form {
    display: inline-flex;
}

.nav-button {
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
}

/* --- Footer --- */
.site-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 1rem 0;
    text-align: center;
    margin-top: auto;
}

.site-footer p {
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.footer-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-link);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--border-default);
    text-underline-offset: 2px;
    transition: color var(--transition-fast);
}

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

/* ===========================================
   FEED VIEW — single dense stream
   =========================================== */
.feed-view {
    max-width: 820px;
    margin: 0 auto;
}

.feed-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1px;
    animation: fadeIn 0.25s ease-out both;
}

/* Shared meta bits (used by feed-row and the search header). */
.meta-sep {
    margin: 0 0.25rem;
    opacity: 0.35;
}

.meta-source {
    font-weight: 500;
    color: var(--text-muted);
}

/* --- Base compact row (the default look) --- */
.feed-row {
    display: grid;
    grid-template-columns: 2.4rem 1fr auto auto;
    align-items: baseline;
    gap: 0.7rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-xs);
    border-left: 2px solid transparent;
    transition: background var(--transition-fast), border-left-color var(--transition-fast);
    min-width: 0;
    position: relative;
}

.feed-row:hover {
    background: var(--bg-card);
    border-left-color: var(--accent-primary);
}

.feed-score,
.feed-score-spacer {
    grid-column: 1;
    font-size: 0.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 0.2em 0.4em;
    border-radius: var(--radius-xs);
    text-align: center;
    line-height: 1;
    letter-spacing: -0.02em;
    cursor: help;
    align-self: center;
}

.feed-status {
    grid-column: 1;
    font-size: 0.85rem;
    line-height: 1;
    text-align: center;
    align-self: center;
    color: var(--text-muted);
}

.feed-score-spacer {
    /* Reserves the score column on unscored rows so titles line up. */
    visibility: hidden;
    cursor: default;
}

.feed-score.high    { color: var(--score-high); background: rgba(45, 212, 160, 0.12); }
.feed-score.neutral { color: var(--score-mid);  background: rgba(245, 183, 49, 0.10); }
.feed-score.low     { color: var(--score-low);  background: rgba(138, 138, 158, 0.10); }
.feed-score.unscored { color: var(--text-muted); background: var(--bg-card); }

.feed-link {
    grid-column: 2;
    font-size: 0.88rem;
    font-weight: 450;
    color: var(--text-secondary);
    line-height: 1.4;
    transition: color var(--transition-fast);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

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

.feed-meta {
    grid-column: 3;
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 22ch;
    justify-self: end;
}

@media (max-width: 720px) {
    .feed-meta { max-width: 10ch; }
    .feed-row { grid-template-columns: 2.1rem 1fr auto auto; gap: 0.5rem; }
}

/* --- Recommended row variant — same compact shape, just visually nudged so
   the "we picked this for you" cue lands without the row getting taller.
   Reason text lives in the score chip's title tooltip. --- */
.feed-row-rec {
    border-left-color: rgba(45, 212, 160, 0.3);
}

.feed-row-rec:hover {
    background: var(--accent-green-dim);
    border-left-color: var(--accent-green);
}

.feed-row-rec .feed-link {
    color: var(--text-primary);
    font-weight: 500;
}

.feed-row-rec .feed-link:hover {
    color: var(--accent-green);
}

/* --- Divider between recommended block and the rest of the stream --- */
.feed-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 0.5rem 0;
    list-style: none;
}

/* --- Label count chip still used by section labels elsewhere --- */
.label-count {
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-muted);
    opacity: 0.4;
    letter-spacing: 0;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 5rem 1.5rem;
    grid-column: 1 / -1;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1.25rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.empty-state h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.empty-state p {
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto 1.5rem;
    font-size: 0.9rem;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: 1rem;
}

.page-indicator {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ===========================================
   BUTTONS
   =========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: var(--text-primary);
    background: var(--bg-card);
}

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

.btn-primary {
    background: var(--accent-primary);
    color: #0b0b0f;
    border-color: var(--accent-primary);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    border-color: var(--accent-primary-hover);
    color: #0b0b0f;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-default);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: rgba(155, 125, 255, 0.05);
}

.btn-outline.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.35rem 0.8rem;
}

/* ===========================================
   SETTINGS VIEW
   =========================================== */
.settings-view h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    letter-spacing: -0.03em;
}

.settings-section {
    margin-bottom: 2.5rem;
}

.settings-section h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

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

.section-header h2 {
    margin-bottom: 0;
}

/* --- Tables --- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table th {
    text-align: left;
    padding: 0.7rem 1rem;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-secondary);
}

.data-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

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

.data-table tr:hover td {
    background: var(--bg-card-hover);
}

.data-table .center {
    text-align: center;
}

.feed-title-cell {
    font-weight: 500;
    color: var(--text-primary) !important;
    white-space: nowrap;
}

.feed-url-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-url-cell a {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.feed-url-cell a:hover {
    color: var(--text-link);
}

/* --- Toggle Button --- */
.inline-form {
    display: inline;
}

.toggle-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.toggle-btn.active {
    background: rgba(45, 212, 160, 0.1);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    transition: border-color var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--border-focus);
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

.stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.threshold-form {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.threshold-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.5rem;
}

.threshold-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.threshold-end {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.threshold-slider {
    flex: 1;
    accent-color: var(--accent-primary);
    height: 6px;
}

/* --- Login --- */
.login-view {
    max-width: 360px;
    margin: 3rem auto;
}

.login-view h1 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-input {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast);
}

.login-input:focus {
    border-color: var(--border-focus);
}

.login-error {
    color: var(--accent-red);
    font-size: 0.85rem;
    margin: 0;
}

/* --- Add Feed Form --- */
.add-feed-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.feed-url-input {
    flex: 2;
    min-width: 200px;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast);
}

.feed-url-input:focus {
    border-color: var(--border-focus);
}

.feed-title-input {
    flex: 1;
    min-width: 140px;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast);
}

.feed-title-input:focus {
    border-color: var(--border-focus);
}

/* --- AI Config Form --- */
.ai-config-form {
    margin-bottom: 0;
}

.ai-config-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ai-select {
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.ai-select:focus {
    border-color: var(--border-focus);
}

.ai-key-input {
    flex: 1;
    min-width: 180px;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast);
}

.ai-key-input:focus {
    border-color: var(--border-focus);
}

.ai-model-input {
    flex: 1;
    min-width: 160px;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast);
}

.ai-model-input:focus {
    border-color: var(--border-focus);
}

/* --- Utilities --- */
.muted {
    color: var(--text-muted);
    font-style: italic;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .container {
        padding: 0 1rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.65rem;
    }

    .feed-url-cell {
        max-width: 120px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Tag Cloud --- */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
    align-items: center;
    line-height: 1.3;
}

.tag-bubble {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.tag-bubble:hover {
    background: rgba(155, 125, 255, 0.12);
    border-color: var(--accent-primary);
    color: var(--text-link-hover);
}

.tag-bubble.tag-pref {
    background: rgba(45, 212, 160, 0.08);
    border-color: rgba(45, 212, 160, 0.2);
}

.tag-bubble.tag-pref:hover {
    background: rgba(45, 212, 160, 0.16);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.tag-count {
    font-style: normal;
    font-weight: 400;
    opacity: 0.5;
    font-size: 0.85em;
}

/* ===========================================
   ANIMATIONS
   =========================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Subtle staggered fade-in for the first handful of rows — anything beyond
   that is below the fold on load, so the animation budget doesn't matter. */
.feed-row:nth-child(1) { animation: fadeIn 0.22s ease-out both; }
.feed-row:nth-child(2) { animation: fadeIn 0.22s 25ms ease-out both; }
.feed-row:nth-child(3) { animation: fadeIn 0.22s 50ms ease-out both; }
.feed-row:nth-child(4) { animation: fadeIn 0.22s 75ms ease-out both; }
.feed-row:nth-child(5) { animation: fadeIn 0.22s 100ms ease-out both; }

/* ===========================================
   SEARCH BAR (in header)
   =========================================== */
.search-form {
    flex: 1;
    max-width: 360px;
    margin: 0 1rem;
}

.search-form input[type="search"] {
    width: 100%;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast);
}

.search-form input[type="search"]:focus {
    border-color: var(--border-focus);
}

@media (max-width: 640px) {
    .search-form {
        display: none;
    }
}

/* ===========================================
   FILTER TABS
   =========================================== */
.filter-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.4rem;
}

.filter-tab {
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.filter-tab:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.filter-tab.active {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: inset 0 -2px 0 var(--accent-primary);
}

/* ===========================================
   FLASH MESSAGES
   =========================================== */
.flash {
    padding: 0.55rem 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    animation: slideDown 0.22s ease-out both;
}

.flash-info    { background: rgba(155, 125, 255, 0.08); color: var(--text-link); }
.flash-success { background: rgba(45, 212, 160, 0.08);  color: var(--accent-green); }
.flash-error   { background: rgba(240, 104, 104, 0.08); color: var(--accent-red); }

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

/* ===========================================
   ARTICLE ROW ACTIONS (save / read / hide)
   =========================================== */
.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
    margin-left: auto;
    flex-shrink: 0;
}

.article-row:hover .row-actions,
.article-row:focus-within .row-actions,
.article-row.is-liked .row-actions {
    opacity: 1;
}

.row-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
    font-family: inherit;
    filter: grayscale(1) opacity(0.55);
}

.row-btn:hover {
    background: var(--bg-card-hover);
    filter: grayscale(0) opacity(1);
}

.vote-btn.is-active {
    filter: grayscale(0) opacity(1);
}

.vote-btn.is-active.is-like {
    background: rgba(45, 212, 160, 0.12);
}

.vote-btn.is-active.is-dislike {
    background: rgba(240, 104, 104, 0.12);
}

.compact-item .row-actions { grid-column: auto; }

.article-row.is-read .feed-link {
    color: var(--text-muted);
    font-weight: 400;
}

.article-row.is-liked {
    background: rgba(45, 212, 160, 0.04);
    border-left-color: var(--accent-green);
}

.article-row:focus {
    outline: none;
    background: var(--bg-card-hover);
    border-left-color: var(--accent-primary);
}

.article-row:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: -2px;
}

/* Row-action button column. Hidden by default, revealed on row hover/focus. */
.row-actions {
    grid-column: 4;
    justify-self: end;
    align-self: center;
}

/* ===========================================
   KEYBOARD SHORTCUTS MODAL
   =========================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease-out;
}

/* The `hidden` HTML attribute applies `display: none`, but our explicit
   `display: flex` above wins on specificity. Restore the expected behavior. */
.modal[hidden] {
    display: none;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.65rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-xs);
    font-family: inherit;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 1.5rem 2rem;
    min-width: 320px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.shortcuts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.shortcuts dt { font-family: var(--font-mono); }

kbd {
    display: inline-block;
    padding: 0.05rem 0.35rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.78em;
    color: var(--text-primary);
}

/* ===========================================
   SETTINGS — additions
   =========================================== */
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.settings-header h1 { margin-bottom: 0; }

.section-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.opml-import-form { display: inline; }

.opml-label {
    cursor: pointer;
    margin: 0;
    position: relative;
}

.opml-label input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.muted-inline {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.row-warn td { background: rgba(245, 183, 49, 0.04); }

.status-ok {
    color: var(--accent-green);
    font-size: 0.78rem;
}

.status-error {
    color: var(--accent-amber);
    font-size: 0.78rem;
    cursor: help;
}

.retention-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.retention-input {
    width: 80px;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
}

.retention-input:focus { border-color: var(--border-focus); }

.retention-suffix {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===========================================
   SEARCH HEADER
   =========================================== */
.search-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.search-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}


/* ===========================================
   LEARNED PROFILE PANEL (Settings)
   =========================================== */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 1rem 1.15rem;
    text-align: center;
}

.profile-card-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.profile-card-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.profile-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 720px) {
    .profile-cols { grid-template-columns: 1fr; gap: 1rem; }
    .profile-grid { grid-template-columns: 1fr; }
}

.profile-subhead {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.55rem;
}

.affinity-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.affinity-list li {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    font-size: 0.82rem;
}

.affinity-tag {
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.affinity-meta {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.affinity-weight {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 3rem;
    text-align: right;
}

.affinity-weight.pos { color: var(--accent-green); }
.affinity-weight.neg { color: var(--accent-amber); }

/* ===========================================
   STATS PAGE
   =========================================== */
.stats-grid-wide {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* Key/value detail list used for AI status summary. */
.kv-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    font-size: 0.85rem;
}

.kv-grid dt {
    color: var(--text-muted);
    font-weight: 500;
}

.kv-grid dd {
    color: var(--text-primary);
}

/* Numeric column alignment in stats tables. */
.data-table th.num,
.data-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Compact list of recent liked / disliked articles. Shares the score-chip
   styling with the home feed so the same visual vocabulary applies. */
.signal-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.signal-row {
    display: grid;
    grid-template-columns: 2.4rem 1fr auto;
    align-items: baseline;
    gap: 0.7rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-xs);
    transition: background var(--transition-fast);
    min-width: 0;
}

.signal-row:hover {
    background: var(--bg-card);
}

.signal-link {
    font-size: 0.86rem;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

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

.signal-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 22ch;
    justify-self: end;
}

@media (max-width: 720px) {
    .signal-meta { max-width: 10ch; }
    .kv-grid { grid-template-columns: 1fr; gap: 0.15rem 0; }
    .kv-grid dt { margin-top: 0.6rem; }
}
