/* Feed list: header search, chips, cards, sentinel (index.html) */

.feed-main {
    flex: 1;
    width: 100%;
    max-width: 780px;
    margin: 0 auto;
    padding: 20px 20px 96px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
}

.topbar-search {
    width: 100%;
    max-width: 740px;
    min-width: 0;
    display: flex;
    justify-self: center;
}

/* Scope button (header) — opens the left scope drawer, shows current scope */
.scope-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 10px;
    /* Size to content; the header column (grid 1fr) caps how far it can grow.
       min-width:0 lets the label ellipsis only when the column is truly tight. */
    min-width: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .12s ease, color .12s ease, background-color .12s ease;
}
.scope-btn:hover { border-color: var(--border-strong); color: var(--text); background: var(--bg-subtle); }
.scope-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.scope-btn svg { flex-shrink: 0; }
.scope-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.scope-caret { opacity: 0.7; }

.feed-search {
    width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 6px 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    transition: border-color .15s ease, box-shadow .15s ease;
    min-width: 0;
}
.feed-search:focus-within {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px var(--focus-ring);
    color: var(--text);
}
.feed-search .feed-search-icon { flex-shrink: 0; align-self: center; }
.feed-search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 14px;
}
.feed-search input::-webkit-search-cancel-button,
.feed-search input::-webkit-search-decoration { display: none; -webkit-appearance: none; }

/* Custom clear (×) button for search fields — replaces the off-palette,
   hard-to-hit native type="search" cancel button. Shown only while the field
   has text (toggled via [hidden] in JS). */
.input-clear {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-subtle);
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}
.input-clear:hover { background: var(--bg-subtle); color: var(--text); }
.input-clear:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
.input-clear[hidden] { display: none; }

.feed-filter-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
    flex-shrink: 0;
    position: relative;
}
.feed-filter-btn:hover { background: var(--bg-subtle); color: var(--text); }
.feed-filter-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.feed-filter-btn svg { color: inherit; }
.filter-count {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 14px;
    height: 14px;
    padding: 0 4px;
    border-radius: 7px;
    background: var(--accent);
    color: var(--accent-fg);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 10px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--bg-elevated);
}

.feed-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.feed-chips:empty { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 6px 0 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease;
    white-space: nowrap;
}
.chip:hover { border-color: var(--border-strong); }
/* Period chip cannot be cleared — click opens the drawer instead; no "×" glyph */
.chip-locked { padding-right: 12px; }
.chip-x {
    display: inline-flex;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-subtle);
    font-size: 14px;
    line-height: 1;
    transition: background-color .12s ease, color .12s ease;
}
.chip:hover .chip-x { background: var(--bg-subtle); color: var(--text); }

/* Feed card */

.feed-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    margin: 0;
}

.feed-card {
    /* Containing block for a card-scoped "+N" sheet (see .is-contained below).
       Harmless for the card's other absolute bits — they each sit inside a
       closer positioned box (.feed-card-body / -foot / -media-cell / -badge-edit). */
    position: relative;
    background: var(--bg-elevated);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color .12s ease;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: left;
    width: 100%;
    font: inherit;
    color: inherit;
}

.feed-card-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.feed-card-title {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.35;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
    word-break: break-word;
    transition: color .12s ease;
}
.feed-card-title:hover { color: var(--accent); }
.feed-card-title:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
    border-radius: 4px;
}

/* Subline under the title: source link + date (left), plaques (right) */
.feed-card-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: -2px;
}
.feed-card-marks {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.feed-sub-source {
    display: inline-flex;
    align-items: center;
    color: var(--text-subtle);
    text-decoration: none;
    flex-shrink: 0;
    transition: color .12s ease;
}
.feed-sub-source svg { display: block; }
.feed-sub-source:hover { color: var(--accent); }
.feed-sub-source:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); border-radius: 3px; }
.feed-sub-sep {
    color: var(--text-subtle);
    opacity: 0.5;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 11px;
}
.feed-sub-date {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 11px;
    color: var(--text-subtle);
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.feed-sub-date svg { display: block; flex-shrink: 0; opacity: 0.7; }

/* Photo album (hoisted to the top of the card) */
.feed-card-media {
    display: grid;
    gap: 3px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--border);
}
.feed-card-media[data-count="1"] { grid-template-columns: 1fr; }
.feed-card-media[data-count="2"] { grid-template-columns: 1fr 1fr; }
/* Definite album height (aspect-ratio) so the tall spanning cell and the two
   stacked cells share exact row heights — otherwise the short cells leave gaps. */
.feed-card-media[data-count="3"] {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
    aspect-ratio: 16 / 10;
}
.feed-card-media[data-count="3"] .feed-media-cell:first-child { grid-row: 1 / 3; }
.feed-card-media[data-count="4"] { grid-template-columns: 1fr 1fr; }
.feed-media-cell {
    position: relative;
    margin: 0;
    overflow: hidden;
    background: var(--bg-subtle);
    min-height: 0;
    cursor: zoom-in;
}
.feed-media-cell:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--focus-ring);
}
.feed-media-cell img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.feed-card-media[data-count="1"] .feed-media-cell img { height: auto; max-height: 460px; }
.feed-card-media[data-count="2"] .feed-media-cell,
.feed-card-media[data-count="4"] .feed-media-cell { aspect-ratio: 4 / 3; }
/* count=3 cells fill their grid tracks (album has a definite height) — no per-cell ratio */
/* Every photo failed to load — the album keeps its slot as a quiet placeholder */
.feed-card-media[data-count="0"] {
    grid-template-columns: 1fr;
    background: none;
}
.feed-media-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 150px;
    padding: 24px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 13px;
}
.feed-media-empty svg { display: block; opacity: 0.5; }
.feed-media-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 22px;
    font-weight: 600;
}

/* Body: rich text, clamped with a fade */
.feed-card-body {
    position: relative;
    max-height: 15em;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.feed-card-body.is-clamped::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3.4em;
    background: linear-gradient(to bottom, transparent, var(--bg-elevated));
    pointer-events: none;
}
/* Expanded in place via "Показать полностью" — drop the clamp and the fade */
.feed-card-body.is-expanded { max-height: none; }
.feed-card-body.is-expanded::after { display: none; }
.feed-card-body p { margin: 0; }
.feed-card-body strong { font-weight: 600; color: var(--text); }
.feed-card-body a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}
.feed-card-body h1, .feed-card-body h2, .feed-card-body h3,
.feed-card-body h4, .feed-card-body h5, .feed-card-body h6 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    line-height: 1.3;
}
.feed-card-body ul, .feed-card-body ol {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.feed-card-body blockquote {
    margin: 0;
    padding-left: 12px;
    border-left: 3px solid var(--border-strong);
    color: var(--text-subtle);
}
.feed-card-body pre {
    margin: 0;
    padding: 10px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow-x: auto;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
}
.feed-card-body img { max-width: 100%; border-radius: 6px; }
.feed-card-body hr { border: none; border-top: 1px solid var(--border); margin: 2px 0; }

/* Search / rubric match (<mark class="hl-term"> from blocks.js): a soft
   underline, not a filled highlight. Colour comes from --hl (the rubric's
   colour, set inline per match); full-text query matches have no --hl and fall
   back to the accent. Used in the feed and the article page. */
.hl-term {
    background: none;
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--hl, var(--accent));
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    /* Continuous line — don't let it break around descenders (р/д/у/б) or the
       leg of a capital Р, which looked like a "broken" highlight. */
    text-decoration-skip-ink: none;
}

.feed-card-more {
    align-self: flex-start;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
}
.feed-card-more:hover { text-decoration: underline; }
.feed-card-more:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); border-radius: 4px; }

/* Footer — divider separates the article text from the control strip.
   Chips (rubrics + tags) collapse to one row on the left; entity counters sit
   on the right. position:relative anchors the desktop "+N" popover. */
.feed-card-foot {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 2px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* Source · date, pinned to the bottom-right of the footer */
.feed-card-meta {
    margin-left: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    gap: 8px;
}

/* Single-row chip strip; JS folds the overflow behind a "+N" chip */
.feed-card-chips {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}
.feed-card-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 22px;
    padding: 0 9px;
    background: var(--bg-subtle);
    border-radius: 11px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex: 0 0 auto;
}
/* Only the tag icon is tinted — same restraint as the rubric folder icon */
.feed-card-tag svg { color: #4f8cff; }
html[data-theme="dark"] .feed-card-tag svg { color: #7ea2e8; }
/* City chips — same pill as tags, only a location icon instead of the "#" glyph */
.feed-card-city {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 22px;
    padding: 0 9px;
    background: var(--bg-subtle);
    border-radius: 11px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex: 0 0 auto;
}
.feed-card-city svg { color: #4f8cff; }
html[data-theme="dark"] .feed-card-city svg { color: #7ea2e8; }
/* "+N" overflow chip */
.feed-chips-more {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 10px;
    border: 1px dashed var(--border-strong);
    border-radius: 11px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    flex: 0 0 auto;
}
.feed-chips-more:hover { color: var(--text); }
.feed-chips-more:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }

/* Grouped overlay (shared by popover + bottom sheet) */
.feed-chips-overlay { min-height: 0; }
.feed-chips-group-title {
    margin: 12px 0 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-subtle);
}
.feed-chips-group-title:first-child { margin-top: 0; }
.feed-chips-group { display: flex; flex-wrap: wrap; gap: 6px; }
/* Chips always show inside the overlay even if collapsed in the card */
.feed-chips-group .feed-card-rubric,
.feed-chips-group .feed-card-tag,
.feed-chips-group .feed-card-city { display: inline-flex !important; }
.feed-chips-group .feed-card-rubric { max-width: none; }

/* Desktop: popover anchored under the "+N" chip */
.feed-chips-popover {
    position: absolute;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: min(360px, 90vw);
    max-height: 320px;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-dropdown);
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Mobile: bottom sheet */
.feed-chips-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.feed-chips-backdrop.open { opacity: 1; pointer-events: auto; }
html[data-theme="dark"] .feed-chips-backdrop { background: rgba(0, 0, 0, 0.6); }
.feed-chips-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 61;
    max-width: 640px;
    margin: 0 auto;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
    background: var(--bg-elevated);
    border-radius: 20px 20px 0 0;
    box-shadow: var(--shadow-dropdown);
    transform: translateY(100%);
    transition: transform 0.25s ease;
}
.feed-chips-sheet.open { transform: translateY(0); }
/* Scoped to a host box (the card it belongs to) rather than the viewport: same
   sheet, docked to that card's bottom. The host is the containing block, so
   `fixed` becomes `absolute` and the safe-area padding no longer applies.
   Radii follow the card's own 10px so the sheet can't overhang its corners. */
.feed-chips-backdrop.is-contained {
    position: absolute;
    border-radius: 10px;
    transition: opacity .16s ease;   /* finishes with the sheet's fade */
}
.feed-chips-sheet.is-contained {
    position: absolute;
    max-width: none;
    max-height: 100%;
    padding: 14px;
    border-radius: 12px 12px 10px 10px;
    /* Fades like a dropdown instead of sliding off-screen: the viewport clips a
       fixed sheet on its way out, but a card doesn't, so a slide would just park
       the sheet over the next card and force a second step to hide it. One
       motion, and it's gone where it stands. */
    transform: translateY(6px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform .16s ease, opacity .16s ease, visibility 0s linear .16s;
}
.feed-chips-sheet.is-contained.open {
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform .16s ease, opacity .16s ease;
}
/* No swipe-to-close affordance in a card-sized dropdown. */
.feed-chips-sheet.is-contained .feed-chips-grab { display: none; }
.feed-chips-sheet .feed-chips-overlay {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.feed-chips-grab {
    flex: 0 0 auto;
    width: 36px;
    height: 4px;
    margin: 4px auto 14px;
    border-radius: 2px;
    background: var(--border-strong);
}

/* Importance / sentiment plaques (editable: click to pick a value) */
.feed-badge-edit { position: relative; display: inline-flex; }
.feed-plaque {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 20px;
    padding: 0 8px;
    border: none;
    border-radius: 5px;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
    cursor: pointer;
}
.feed-plaque svg { display: block; flex-shrink: 0; }
.feed-plaque-label { line-height: 1; }
/* Unset plaque is icon-only → tighter, near-square */
.feed-plaque.is-empty { padding: 0 6px; }
.feed-plaque:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
/* While its popup is open — highlight the owning plaque */
.feed-plaque.is-open { box-shadow: 0 0 0 2px var(--focus-ring); }
/* Empty → dashed placeholder plaque with an outline icon */
.feed-plaque.is-empty {
    background: transparent;
    border: 1px dashed var(--border-strong);
    color: var(--text-subtle);
}
.feed-plaque.is-sent-pos { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
.feed-plaque.is-sent-neu { background: var(--bg-subtle); color: var(--text-muted); }
.feed-plaque.is-sent-neg { background: rgba(239, 68, 68, 0.14); color: #ef4444; }
html[data-theme="dark"] .feed-plaque.is-sent-pos { color: #22c55e; }
.feed-plaque.is-imp-4 { background: rgba(239, 68, 68, 0.14); color: #ef4444; }
.feed-plaque.is-imp-3 { background: rgba(217, 119, 6, 0.16); color: #d97706; }
.feed-plaque.is-imp-2 { background: rgba(59, 130, 246, 0.14); color: #3b82f6; }
.feed-plaque.is-imp-1 { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
html[data-theme="dark"] .feed-plaque.is-imp-3 { color: #f59e0b; }
html[data-theme="dark"] .feed-plaque.is-imp-1 { color: #22c55e; }
.feed-badge-menu {
    position: absolute;
    top: calc(100% + 7px);
    left: 0;
    right: auto;
    z-index: 20;
    min-width: 156px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}
/* Caret pointing up to the plaque that opened this popup */
.feed-badge-menu::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 13px;
    right: auto;
    width: 9px;
    height: 9px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    transform: rotate(45deg);
}
.feed-badge-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: none;
    border: none;
    border-radius: 5px;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}
.feed-badge-menu-item:hover { background: var(--bg-subtle); }
.feed-badge-menu-item.is-current { font-weight: 600; }
.feed-badge-menu-item svg { flex-shrink: 0; display: block; }
/* Importance options — text tinted to match the resulting plaque colour */
.feed-badge-menu-item.imp-c-1 { color: #16a34a; }
.feed-badge-menu-item.imp-c-2 { color: #3b82f6; }
.feed-badge-menu-item.imp-c-3 { color: #d97706; }
.feed-badge-menu-item.imp-c-4 { color: #ef4444; }
html[data-theme="dark"] .feed-badge-menu-item.imp-c-1 { color: #22c55e; }
html[data-theme="dark"] .feed-badge-menu-item.imp-c-3 { color: #f59e0b; }
/* Sentiment options — same colour-coding as the resulting plaque */
.feed-badge-menu-item.sent-c-pos { color: #16a34a; }
.feed-badge-menu-item.sent-c-neu { color: var(--text-muted); }
.feed-badge-menu-item.sent-c-neg { color: #ef4444; }
html[data-theme="dark"] .feed-badge-menu-item.sent-c-pos { color: #22c55e; }
.feed-badge-menu-clear {
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    border-radius: 0 0 5px 5px;
    color: var(--text-subtle);
}
.feed-badge-menu-clear svg { opacity: 0.8; }

/* Rubric chip — quiet (must not dominate the footer). Height matches the tag
   chip so both align on the collapsed single row. */
.feed-card-rubric {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 9px;
    border-radius: 11px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 11px;
    max-width: 220px;
    flex: 0 0 auto;
}
.feed-card-rubric svg { flex-shrink: 0; opacity: 0.7; }
.feed-card-rubric-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-card-rubric[hidden] { display: none; }

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.dot-pos { background: #22c55e; }
.dot-neu { background: var(--text-subtle); }
.dot-neg { background: #ef4444; }

.feed-card-bookmark {
    flex-shrink: 0;
    background: transparent;
    border: none;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    cursor: pointer;
    border-radius: 4px;
    transition: color .12s ease, background-color .12s ease;
    padding: 0;
    margin: -3px -4px 0 0;
}
.feed-card-bookmark:hover { background: var(--bg-subtle); color: var(--text); }
.feed-card-bookmark:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
.feed-card-bookmark[aria-pressed="true"] { color: var(--accent); }
.feed-card-bookmark[aria-pressed="true"] svg { fill: currentColor; }

/* Sentinel / empty */

.feed-sentinel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px 0;
    color: var(--text-subtle);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    min-height: 40px;
}
.feed-loader {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--text-muted);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.feed-sentinel.done { display: none; }
.feed-loader-lg { width: 28px; height: 28px; border-width: 3px; }

.feed-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-size: 14px;
}

/* Centered "no projects" prompt */
.feed-blank {
    flex: 1;
    min-height: 55vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--text-subtle);
}
.feed-blank[hidden] { display: none; }
.feed-blank > svg { opacity: 0.55; }
.feed-blank-title { font-size: 17px; font-weight: 600; color: var(--text); }
.feed-blank-text { font-size: 14px; color: var(--text-muted); max-width: 360px; line-height: 1.5; }
.feed-blank .btn-primary {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 190px;
    min-height: 40px;
    text-decoration: none;
}

/* ===== Image lightbox (photo preview) ===== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .18s ease;
    padding: 20px;
    overflow: hidden;   /* clip the top card as it flies off during a swipe */
}
.lightbox[hidden] { display: none; }
.lightbox.open { opacity: 1; }
.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: #000;
}
/* Underneath layer: the neighbour photo revealed while swiping (card stack).
   Hidden until a horizontal drag engages; never intercepts input. */
.lightbox-below {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;   /* JS ramps this up with drag distance */
    /* Match .lightbox's own padding so the mirrored stage has the exact same
       available box — otherwise 94vw resolves against a wider area here than for
       the padded top stage, and the photo shrinks ~5% on release. */
    padding: 20px;
}
.lightbox.is-sliding .lightbox-below { display: flex; }
/* The below layer mirrors the stage exactly (same .lightbox-stage inside), so
   the revealed photo is pixel-identical to the one that lands on top — no jump
   on release. Lift only the top card so its edge reads as a card. */
.lightbox.is-sliding > #lb-stage .lightbox-img {
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.7);
}
.lightbox-stage {
    position: relative;
    z-index: 1;
    margin: 0;
    max-width: min(1100px, 94vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.lightbox-img {
    max-width: 100%;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
/* Reserve room for the bottom filmstrip so a tall photo never sits under it. */
.lightbox.has-thumbs .lightbox-img { max-height: min(82vh, calc(100dvh - 168px)); }
.lightbox-btn {
    position: absolute;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color .15s ease;
    padding: 0;
}
.lightbox-btn:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.45); }
.lightbox-close { top: 16px; right: 16px; width: 40px; height: 40px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); width: 44px; height: 44px; }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-btn[hidden] { display: none; }
.lightbox-counter {
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    color: rgba(255, 255, 255, 0.8);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
    letter-spacing: 0.05em;
}

/* Bottom thumbnail filmstrip — scrolls horizontally when the album is large */
.lightbox-thumbs {
    position: absolute;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 2;
    display: flex;
    gap: 8px;
    max-width: min(94vw, 720px);
    padding: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior: contain;
    scrollbar-width: none;
    scroll-behavior: smooth;
}
.lightbox-thumbs::-webkit-scrollbar { display: none; }
.lightbox-thumbs[hidden] { display: none; }
.lightbox-thumb {
    position: relative;
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.07);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity .15s ease, border-color .15s ease;
}
.lightbox-thumb:hover { opacity: 0.85; }
.lightbox-thumb:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.45); }
.lightbox-thumb.is-active { opacity: 1; border-color: #fff; }
.lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 1;
    transition: opacity .2s ease;
}
/* While loading (or failed) hide the img and show a spinner over the tile. */
.lightbox-thumb.is-loading img,
.lightbox-thumb.is-error img { opacity: 0; }
.lightbox-thumb.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    animation: lbThumbSpin .7s linear infinite;
}
.lightbox-thumb.is-error { opacity: 0.3; }
@keyframes lbThumbSpin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
    .lightbox-nav { width: 38px; height: 38px; }
    .lightbox-prev { left: 8px; }
    .lightbox-next { right: 8px; }
    .lightbox-close { top: 10px; right: 10px; }
    .lightbox-thumb { width: 46px; height: 46px; }
    .lightbox.has-thumbs .lightbox-img { max-height: min(82vh, calc(100dvh - 148px)); }
}

/* Touch devices navigate photos by swiping (see lightbox.js) — the prev/next
   arrows are a pointer/desktop affordance, so hide them where there's no hover
   and a coarse pointer. The close button stays. The overlay owns all gestures
   (paging + drag-to-dismiss), so it opts out of native panning; only the
   thumbnail strip keeps horizontal scrolling. */
@media (hover: none) and (pointer: coarse) {
    .lightbox-nav { display: none; }
    .lightbox { touch-action: none; }
    .lightbox-thumbs { touch-action: pan-x; }
}
