/* ── PWA mobile-specific overrides ── */

/* Safe area insets for notch phones */
.page-shell {
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

/* Touch targets: minimum 44px */
.tabs a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button,
input[type="checkbox"] {
  min-height: 44px;
  min-width: 44px;
}

.scrap-star {
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

/* ── Feed header: compact toolbar ── */
.feed-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.feed-info {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.feed-sep-dot {
  margin: 0 3px;
  color: var(--line);
}

.filter-toggle-btn {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 4px 10px;
  min-height: 32px;
  min-width: auto;
}

/* ── Collapsible filter panel ── */
.feed-filter-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.feed-filter-panel.open {
  max-height: none;
  padding: 8px 0;
}

.feed-filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.feed-filter-form label {
  display: flex !important;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.feed-filter-form input {
  min-width: 50px !important;
  width: 65px;
  padding: 3px 6px;
  font-size: 0.8rem;
}

/* ── Auto-sync spinner ── */
.auto-sync-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* ── Compact post cards ── */
.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.post-card {
  position: relative;
  overflow: hidden;
  padding: 6px 4px;
  border-bottom: 1px solid #f0f3f8;
}

.post-card:active {
  background: #f6f9ff;
}

/* Recommendation bar background */
.post-card.has-rec::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: var(--rec-pct, 0%);
  background: linear-gradient(90deg, rgba(220,38,38,0.13), rgba(220,38,38,0.04));
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}

.post-card.rec-high::before {
  background: linear-gradient(90deg, rgba(220,38,38,0.22), rgba(220,38,38,0.06));
}

.post-title-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.post-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-title:visited {
  color: #94a3b8;
}

.post-title:hover {
  color: var(--brand);
}

.post-card.feed-post-card { padding: 3px 4px; }
.feed-title-row { gap: 6px; }
.feed-heading { display: flex; align-items: baseline; gap: 4px; flex: 1; min-width: 0; }
.feed-heading .post-title { flex: 0 1 auto; }
.feed-row-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; margin-left: 3px; }
.feed-post-card .post-meta { gap: 4px; margin-top: 0; }
.feed-post-card .post-sep { display: none; }
.feed-post-card .post-time { display: inline; font-size: 10px; flex-shrink: 0; }
.feed-post-card .post-tag { flex-shrink: 1; min-width: 0; }
.feed-post-card .post-author { min-width: 0; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.feed-post-card .feed-read-label:empty { display: none; }
.feed-row-actions .feed-preview-button, .feed-row-actions .scrap-star { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; min-width: 24px; min-height: 24px; padding: 0; line-height: 1; }
.feed-row-actions .scrap-star[aria-disabled="true"] { opacity: .5; cursor: wait; }
.feed-action-status { position: fixed; z-index: 1300; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); max-width: min(420px, calc(100vw - 40px)); padding: 9px 14px; border: 1px solid #ccd9ef; border-radius: 8px; background: #f5f8ff; color: #36578c; box-shadow: 0 3px 14px #1e3a5f1a; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; pointer-events: none; }
.feed-action-status:empty { display: none; }
.feed-action-status.is-error { color: #994b4b; border-color: #efcaca; background: #fff4f4; }
.feed-workspace .feed-header button, .feed-view-controls button { min-width: 0; min-height: 28px; padding: 4px 8px; font-size: 12px; }
.feed-workspace .feed-header #manual-sync { min-height: 34px; }
.feed-apply-updates { color: #2457c7; background: #edf3ff; white-space: nowrap; }
.feed-view-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 5px 0; }
.feed-view-controls label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #586e8c; }
.feed-view-controls select { min-width: 0; max-width: 190px; padding: 4px 6px; font-size: 12px; }
.feed-view-controls input[type="checkbox"] { min-width: 15px; min-height: 15px; width: 15px; height: 15px; }
.feed-view-controls input[type="search"] { min-width: 0; width: 200px; min-height: 28px; padding: 4px 8px; font-size: 12px; border: 1px solid #cbd5e1; border-radius: 6px; }
.feed-mode-buttons { display: inline-flex; gap: 0; }
.feed-mode-buttons button[aria-pressed="true"] { color: #2457c7; background: #eaf1ff; border-color: #b6caf2; }
.feed-column-controls { display: inline-flex; gap: 3px; }
.feed-column-controls[hidden] { display: none; }
.feed-live-status { height: 22px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: #72839b; }
.feed-live-status.is-error { color: #a24949; }
.feed-read-label { color: #7088a3; white-space: nowrap; }
.is-feed-read .post-title { color: #8997a9; }
.feed-dialog { width: min(500px, calc(100vw - 30px)); max-height: 85dvh; overflow: auto; border: 1px solid #cfdcf0; border-radius: 12px; padding: 20px; color: #405572; }
.feed-dialog::backdrop { background: #24395844; }
.feed-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.feed-dialog h2 { margin: 0; font-size: 18px; }
.feed-dialog header button { border: 0; background: transparent; font-size: 23px; }
.feed-dialog form { margin-top: 18px; }
.feed-dialog label { display: grid; gap: 7px; }
.feed-dialog input { min-width: 0; width: 100%; }
.feed-dialog p { font-size: 12px; line-height: 1.7; }
.feed-dialog footer { display: flex; justify-content: flex-end; gap: 8px; }
.feed-dialog-error { color: #994b4b; }
.post-list.feed-linear { --feed-row-height: 54px; display: block; column-width: auto; column-count: auto; column-gap: normal; height: calc(100dvh - 310px); overflow-x: hidden; overflow-y: auto; padding: 0; scrollbar-gutter: stable; overflow-anchor: none; }
.feed-linear .feed-post-card { height: var(--feed-row-height); box-sizing: border-box; padding: 3px 6px; }
.feed-linear .post-title { -webkit-line-clamp: 1; }
.feed-linear .feed-heading { max-width: 1100px; }
.feed-linear .post-meta { gap: 3px; }
@media (max-width: 768px) {
  .feed-view-controls { gap: 5px; }
  .feed-view-controls button, .feed-workspace .feed-header button { font-size: 11px; }
  .feed-view-controls select { max-width: 145px; }
  .feed-column-controls { display: none; }
  .post-list.feed-linear { --feed-row-height: 72px; }
  .feed-linear .post-title { -webkit-line-clamp: 2; }
  .feed-linear .post-time, .feed-linear .post-comments { display: inline; }
}
@media (pointer: coarse) {
  .feed-view-controls button, .feed-workspace .feed-header button { min-height: 36px; }
  .post-list.feed-linear { --feed-row-height: 84px; }
}
@media (max-width: 768px) {
  .feed-action-status { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (pointer: coarse) {
  .feed-row-actions .feed-preview-button, .feed-row-actions .scrap-star { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
}

.post-meta {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.post-sep {
  margin: 0 3px;
  color: #d1d5db;
}

.post-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-rec {
  color: #dc2626;
  font-weight: 700;
  white-space: nowrap;
}

.post-comments {
  white-space: nowrap;
}

.post-time {
  white-space: nowrap;
  color: #94a3b8;
}

.post-author {
  display: none;
  white-space: nowrap;
  color: #64748b;
}

/* ── Mobile: bottom tab bar + compact layout ── */
@media (max-width: 768px) {
  /* Bottom-fixed tab bar for thumb reachability */
  .tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--panel);
    border-top: 1px solid var(--line);
    margin: 0;
    padding: 4px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
    gap: 2px;
  }

  .tabs a {
    flex: 1;
    text-align: center;
    font-size: 0.72rem;
    padding: 8px 2px;
    border-radius: 8px;
  }

  /* Reserve space for the fixed bottom tab bar */
  .page-shell {
    padding-bottom: max(72px, calc(56px + env(safe-area-inset-bottom)));
  }

  /* Compact content area */
  .content {
    padding: 6px;
  }

  /* Post card: tighter on mobile */
  .post-card {
    padding: 5px 2px;
  }

  .post-title {
    font-size: 13px;
    -webkit-line-clamp: 1;
  }

  .post-time,
  .post-comments {
    display: none;
  }

  .post-tag {
    max-width: 50px;
    font-size: 9px;
  }

  .post-meta {
    font-size: 11px;
  }

  .scrap-star {
    min-width: 36px;
    min-height: 36px;
    font-size: 1rem;
  }

  /* Feed filter / gallery form: vertical layout */
  .feed-filter-form {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .feed-filter-form label {
    flex-direction: row;
    justify-content: space-between;
  }

  .feed-filter-form input {
    width: 80px !important;
    min-width: 80px !important;
  }

  .form-grid {
    flex-direction: column;
  }

  .form-grid label {
    width: 100%;
  }

  .form-grid input,
  .form-grid select {
    min-width: 100%;
  }

  .form-grid button[type="submit"] {
    width: 100%;
  }

  /* Gallery card: stack vertically */
  .card.row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .inline-controls {
    justify-content: flex-end;
  }

  /* Hide subtitle on mobile */
  .subtitle {
    display: none;
  }

  .topbar {
    padding: 6px 12px;
  }

  .topbar h1 {
    font-size: 0.95rem;
  }
}

/* ── Tablet+: column-flow board (read top→bottom, then next column right) ── */
@media (min-width: 769px) {
  .post-list {
    display: block;
    column-width: 340px;
    column-gap: 16px;
    column-fill: auto;
    /* height is set via JS to fill viewport — fallback below if JS hasn't run yet */
    height: calc(100dvh - 220px);
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-gutter: stable;
  }
  .post-card {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    display: block;
    padding: 8px 6px;
    border-bottom: 1px solid #f0f3f8;
  }
  .post-title {
    font-size: 14px;
    -webkit-line-clamp: 2;
  }
  .post-tag {
    max-width: 80px;
  }
}

/* ── Wide desktop: author visible ── */
@media (min-width: 1400px) {
  .post-author {
    display: inline;
  }
}

/* ── Gallery search UI ── */
.gallery-search-section {
  margin-bottom: 12px;
}

.gallery-search-section label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.gallery-search-section input {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-sizing: border-box;
}

.gallery-search-results {
  max-height: 240px;
  overflow-y: auto;
  border-radius: 6px;
}

.gallery-search-results:not(:empty) {
  margin-top: 4px;
  border: 1px solid var(--line);
}

.gallery-search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  min-height: 44px;
  cursor: pointer;
  border-bottom: 1px solid #f0f3f8;
  box-sizing: border-box;
}

.gallery-search-result:last-child {
  border-bottom: none;
}

.gallery-search-result:hover,
.gallery-search-result:active {
  background: #f6f9ff;
}

.search-result-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-id {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.search-result-type {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #e2e8f0;
  color: #475569;
  white-space: nowrap;
}

.gallery-add-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.gallery-add-divider::before,
.gallery-add-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.search-loading,
.search-empty {
  padding: 12px 10px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.search-error {
  padding: 12px 10px;
  font-size: 13px;
  color: #dc2626;
  text-align: center;
}

/* ── Dark mode: recommendation bar ── */
@media (prefers-color-scheme: dark) {
  .post-card.has-rec::before {
    background: linear-gradient(90deg, rgba(248,113,113,0.15), rgba(248,113,113,0.04));
  }
  .post-card.rec-high::before {
    background: linear-gradient(90deg, rgba(248,113,113,0.28), rgba(248,113,113,0.08));
  }
}

/* ── Device sync block (Settings tab) ── */
.device-sync-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: #fafbfd;
}

.device-sync-block h3 {
  margin: 0 0 4px 0;
  font-size: 1rem;
}

.device-sync-block label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 8px 0 4px;
}

.device-sync-block input {
  width: 100%;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  box-sizing: border-box;
}

.device-sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 6px;
}

.device-sync-actions button {
  min-height: 32px;
  min-width: auto;
  padding: 4px 10px;
  font-size: 0.8rem;
}

.device-sync-block p.meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 4px 0;
}

@media (prefers-color-scheme: dark) {
  .device-sync-block {
    background: rgba(255,255,255,0.03);
  }
}

/* ── Advanced sync-key section (collapsed under the account block) ── */
.device-sync-advanced {
  margin-bottom: 16px;
}

.device-sync-advanced summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 4px 0;
  user-select: none;
}

.device-sync-advanced .device-sync-block {
  margin-top: 8px;
  margin-bottom: 0;
}

/* ── Pull-to-refresh prevention ── */
html {
  overscroll-behavior-y: contain;
}

/* ── Smooth scrolling ── */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ── Disable text selection on UI chrome (not on content) ── */
.tabs,
button,
.topbar {
  -webkit-user-select: none;
  user-select: none;
}
/* Shared DC/Arca subscription controls. */
.feed-add-source { white-space: nowrap; text-decoration: none; }
.feed-filter-hint { font-size: 12px; color: #637188; line-height: 1.5; margin: 8px 0 12px; }
.feed-filter-form input[type="checkbox"] { width: 16px !important; min-width: 16px !important; min-height: 16px; height: 16px; padding: 0; flex-shrink: 0; }
.feed-filter-form select { min-width: 0; max-width: 100%; }
/* Gallery/channel chips: tap applies immediately. */
.feed-gallery-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0 2px; }
.feed-chip-row { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; flex: 1 1 auto; }
.feed-workspace .feed-chip { display: inline-flex; align-items: center; gap: 5px; min-width: 0; min-height: 30px; padding: 3px 10px; border: 1px solid #cfd9ea; border-radius: 999px; background: #fff; color: #405572; font-size: 12px; white-space: nowrap; cursor: pointer; }
.feed-chip:hover { border-color: #9fb6e4; }
.feed-chip-name { max-width: 14em; overflow: hidden; text-overflow: ellipsis; }
.feed-chip-count { min-width: 1.6em; padding: 0 5px; border-radius: 999px; background: #eef2f8; color: #6a7b94; font-size: 11px; line-height: 17px; text-align: center; }
.feed-chip-source { padding: 0 4px; border-radius: 4px; background: #fff1e4; color: #a35a17; font-size: 10px; line-height: 15px; }
.feed-chip.is-empty { color: #96a3b6; }
.feed-chip.is-empty .feed-chip-count { background: transparent; }
.feed-workspace .feed-chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: #fff; }
.feed-chip[aria-pressed="true"] .feed-chip-count { background: #ffffff33; color: #fff; }
.feed-chip[aria-pressed="true"] .feed-chip-source { background: #ffffff2e; color: #fff; }
.feed-workspace .feed-chip-all { font-weight: 600; }
.feed-chip-summary { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; white-space: nowrap; }
.feed-workspace .feed-chip-summary button { min-height: 24px; min-width: 0; padding: 2px 9px; border: 0; border-radius: 999px; background: #fff; color: var(--brand); font-size: 12px; }
.feed-scope-badge { padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 600; white-space: nowrap; }
.feed-workspace .filter-toggle-btn.is-active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.feed-workspace .feed-chip-more { min-height: 26px; min-width: 0; margin-left: auto; padding: 2px 10px; border: 0; border-radius: 999px; background: #eef2f8; color: #4a5f7d; font-size: 12px; white-space: nowrap; }
.feed-chip-more[hidden] { display: none; }
.feed-workspace .feed-chip-edit { margin-left: 0; }
.feed-workspace .feed-chip-more[hidden] + .feed-chip-edit { margin-left: auto; }
/* Chip order editor */
.feed-gallery-chips.is-editing { padding: 8px 10px; border: 1px dashed #9fb6e4; border-radius: 10px; background: #f7f9fe; }
.feed-chip-edit-hint, .feed-chip-edit-status { flex-basis: 100%; margin: 0; font-size: 12px; color: #586e8c; }
.feed-chip-edit-status { color: var(--brand); }
.is-editing .feed-chip-row { max-height: none !important; }
.feed-workspace .is-editing .feed-chip { cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; border-style: dashed; }
.feed-workspace .is-editing .feed-chip.is-dragging { cursor: grabbing; opacity: .75; border-style: solid; border-color: var(--brand); box-shadow: 0 4px 12px #2251d133; }
.feed-chip-grip { color: #9aa8bc; font-size: 11px; }
.feed-chip-edit-actions { display: flex; flex-basis: 100%; flex-wrap: wrap; align-items: center; gap: 6px; }
.feed-workspace .feed-chip-edit-actions button { min-width: 0; min-height: 30px; padding: 4px 12px; font-size: 12px; }
.feed-workspace .feed-chip-edit-actions #feed-chip-cancel { margin-left: auto; }
/* Phones: chips wrap so every source is visible at once; long lists fold to two rows. */
@media (max-width: 768px) {
  .feed-gallery-chips { --chip-h: 30px; gap: 6px; }
  .feed-chip-row { flex: 1 1 100%; gap: 5px; max-height: calc(var(--chip-h) * 2 + 5px); overflow: hidden; }
  .feed-gallery-chips.is-expanded .feed-chip-row { max-height: none; }
  .feed-workspace .feed-chip { min-height: var(--chip-h); padding: 2px 9px; }
  .feed-chip-name { max-width: 9em; }
}
@media (pointer: coarse) {
  .feed-gallery-chips { --chip-h: 36px; }
  .feed-workspace .feed-chip { min-height: var(--chip-h); }
}
.feed-filter-form { flex-wrap: wrap; }
.feed-preview-button { flex: 0 0 auto; border: 0; background: transparent; color: #71829e; font-size: 14px; padding: 1px 4px; cursor: pointer; }
.feed-preview-button:hover, .feed-preview-button:focus-visible { color: #2251d1; background: #edf2ff; }
/* Heat and gallery-pick badges */
.feed-badge { display: inline-flex; align-items: center; margin-left: 3px; padding: 0 4px; border-radius: 4px; font-size: 10px; line-height: 15px; font-weight: 700; white-space: nowrap; }
.feed-badge-best { background: #fff1e4; color: #b4580e; }
.feed-badge-hot { padding: 0 1px; background: transparent; font-size: 11px; }
/* Missed highlights since the last visit */
.feed-digest { margin: 6px 0 8px; padding: 8px 10px; border: 1px solid #f3d4b5; border-radius: 10px; background: #fffaf3; }
.feed-digest header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feed-digest header strong { font-size: 13px; color: #8a4510; }
.feed-digest header .meta { font-size: 12px; color: #8b7a66; margin-right: auto; }
.feed-workspace .feed-digest header button { min-width: 0; min-height: 26px; padding: 2px 10px; font-size: 12px; }
.feed-digest ol { margin: 6px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 2px 14px; }
.feed-digest.is-collapsed ol { display: none; }
.digest-row { display: flex; align-items: center; gap: 4px; min-width: 0; padding: 3px 0; font-size: 13px; }
.digest-row .post-tag { flex: 0 0 auto; max-width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.digest-row a { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); text-decoration: none; }
.digest-row a:hover { text-decoration: underline; }
.digest-row.is-feed-read a { color: #8997a9; }
.digest-meta { flex: 0 0 auto; font-size: 11px; color: #8a97aa; }
/* A saved post brought back into the feed */
.feed-resurface { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; padding: 8px 10px; border: 1px dashed #b6caf2; border-radius: 10px; background: #f5f8ff; font-size: 13px; }
.feed-resurface-label { color: #4a5f7d; font-size: 12px; white-space: nowrap; }
.feed-resurface-title { flex: 1 1 240px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; text-decoration: none; }
.feed-resurface-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.feed-workspace .feed-resurface-actions button, .feed-resurface-actions a { min-width: 0; min-height: 28px; padding: 3px 10px; font-size: 12px; }
.feed-resurface-actions a.primary { display: inline-flex; align-items: center; border-radius: 8px; background: var(--brand); color: #fff; text-decoration: none; }
/* Scrap tab */
.scrap-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.scrap-tabs button { min-width: 0; min-height: 32px; padding: 4px 12px; font-size: 13px; border-radius: 999px; }
.scrap-tabs button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: #fff; }
.scrap-tab-count { margin-left: 3px; font-size: 11px; opacity: .8; }
.scrap-review { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; padding: 8px 10px; border-radius: 10px; background: #fff6e8; color: #8a4510; font-size: 13px; }
.scrap-review button { min-height: 28px; min-width: 0; padding: 3px 12px; font-size: 12px; margin-left: auto; }
.scrap-saved-at { color: #8a97aa; white-space: nowrap; }
.scrap-actions { display: inline-flex; gap: 4px; margin-left: auto; }
.scrap-actions button { min-width: 0; min-height: 26px; padding: 2px 8px; font-size: 11px; }
.scrap-review-list { margin: 10px 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.scrap-review-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.scrap-review-list li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrap-review-list li small { grid-column: 1; color: var(--muted); font-size: 11px; }
.scrap-review-list li span { grid-column: 2; grid-row: 1 / span 2; display: inline-flex; gap: 4px; }
.scrap-review-list button { min-width: 0; min-height: 28px; padding: 2px 10px; font-size: 12px; }
/* Unread scrap count on the tab */
.tabs a { position: relative; }
.tab-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: #e5484d; color: #fff; font-size: 10px; font-weight: 700; line-height: 1; vertical-align: 1px; }
@media (max-width: 768px) {
  .tab-badge { position: absolute; top: 3px; right: 6px; margin: 0; min-width: 15px; height: 15px; font-size: 9px; padding: 0 4px; }
  .feed-resurface-title { flex-basis: 100%; }
  .digest-meta { display: none; }
}
/* Compact app bar: title and tabs share one row */
.page-shell { padding-top: 8px; }
.topbar { align-items: center; gap: 14px; padding: 4px 6px 4px 14px; flex-wrap: wrap; }
.topbar h1 { font-size: 0.95rem; }
.topbar .tabs { margin-top: 0; }
.content { margin-top: 8px; padding: 8px 12px; }
@media (min-width: 769px) {
  .topbar .tabs a { min-height: 32px; padding: 3px 12px; }
}
@media (max-width: 768px) {
  .page-shell { padding-top: 6px; }
  .topbar { padding: 0; border: 0; background: transparent; }
  .topbar h1 { display: none; }
  .content { margin-top: 0; }
}
/* Feed toolbar: one wrapped row on wide screens */
.feed-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.feed-toolbar-main, .feed-toolbar-more { display: contents; }
.feed-toolbar-more > * { order: 1; }
.feed-toolbar .feed-live-status { order: 2; flex: 1 1 120px; min-width: 0; height: auto; line-height: 1.4; }
.feed-toolbar #filter-toggle { order: 0; margin-left: 0; }
.feed-toolbar .feed-more-toggle { display: none; }
.feed-workspace .feed-toolbar #manual-sync { min-height: 30px; padding: 4px 12px; }
.feed-toolbar .feed-source-status .meta { margin: 0; font-size: 11px; color: #8a97aa; white-space: nowrap; }
.feed-toolbar .feed-add-source { font-size: 12px; white-space: nowrap; }
@media (max-width: 768px) {
  .feed-toolbar { display: block; }
  .feed-toolbar-main { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
  .feed-toolbar-main > * { order: 5; }
  .feed-toolbar-main #manual-sync { order: 1; }
  .feed-toolbar-main #feed-apply-updates { order: 2; }
  .feed-toolbar-main .feed-mode-buttons { order: 3; }
  .feed-toolbar #filter-toggle { order: 4; margin-left: auto; }
  .feed-toolbar .feed-more-toggle { display: inline-flex; order: 4; min-width: 36px; justify-content: center; font-weight: 700; }
  .feed-toolbar .feed-more-toggle[aria-expanded="true"] { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
  .feed-toolbar-main #feed-title-query { order: 10; flex: 1 1 150px; width: auto; }
  .feed-toolbar-main #feed-mark-through { order: 11; }
  .feed-toolbar .feed-live-status { order: 20; flex-basis: 100%; }
  .feed-toolbar .feed-live-status:empty { display: none; }
  .feed-toolbar-more { display: none; margin-top: 6px; padding: 6px; border-radius: 8px; background: #f6f8fc; flex-wrap: wrap; align-items: center; gap: 5px; }
  .feed-toolbar.is-more-open .feed-toolbar-more { display: flex; }
}
.digest-more { display: none; }
@media (max-width: 768px) {
  .feed-toolbar .feed-info { display: none; }
  .feed-toolbar-main { gap: 4px; }
  .feed-workspace .feed-toolbar-main button { padding: 4px 7px; }
  .feed-workspace .feed-toolbar #manual-sync { padding: 4px 9px; }
  /* Phones show the top five highlights; the rest on request. */
  .feed-digest:not(.is-expanded) .digest-row:nth-child(n+6) { display: none; }
  .feed-digest:not(.is-expanded):not(.is-collapsed) .digest-more { display: block; margin: 4px auto 0; min-height: 28px; padding: 2px 12px; font-size: 12px; border-radius: 999px; }
  .feed-digest header .meta { flex-basis: auto; }
}
@media (max-width: 768px) {
  .feed-digest header { flex-wrap: nowrap; gap: 6px; }
  .feed-digest header .meta { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .feed-workspace .feed-digest header button { padding: 2px 8px; white-space: nowrap; }
}
.feed-digest header strong { white-space: nowrap; }
