:root,
[data-theme="dark"],
[data-theme="dark"][data-dark-theme="charcoal"] {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-top: rgba(13, 17, 23, 0.92);
  --card: #161b22;
  --text: #c9d1d9;
  --muted: #8b949e;
  --line: #30363d;
  --accent: #f85149;
  --accent-soft: rgba(248, 81, 73, 0.16);
  --chip: #21262d;
  --chip-text: #c9d1d9;
}

[data-theme="dark"][data-dark-theme="midnight"] {
  color-scheme: dark;
  --bg: #0b0c0f;
  --bg-top: rgba(11, 12, 15, 0.92);
  --card: #14161c;
  --text: #f4f4f5;
  --muted: #8b93a2;
  --line: #232733;
  --accent: #ff3b4e;
  --accent-soft: rgba(255, 59, 78, 0.16);
  --chip: #1b1e27;
  --chip-text: #d5dae3;
}

[data-theme="dark"][data-dark-theme="warm"] {
  color-scheme: dark;
  --bg: #1a1816;
  --bg-top: rgba(26, 24, 22, 0.92);
  --card: #24211e;
  --text: #e2dad0;
  --muted: #9e9488;
  --line: #38342f;
  --accent: #e05338;
  --accent-soft: rgba(224, 83, 56, 0.18);
  --chip: #2c2824;
  --chip-text: #ded5ca;
}

[data-theme="dark"][data-dark-theme="nord"] {
  color-scheme: dark;
  --bg: #242933;
  --bg-top: rgba(36, 41, 51, 0.92);
  --card: #2e3440;
  --text: #eceff4;
  --muted: #9aa5b8;
  --line: #434c5e;
  --accent: #bf616a;
  --accent-soft: rgba(191, 97, 106, 0.18);
  --chip: #3b4252;
  --chip-text: #e5e9f0;
}

[data-theme="dark"][data-dark-theme="solarized"] {
  color-scheme: dark;
  --bg: #00212b;
  --bg-top: rgba(0, 33, 43, 0.92);
  --card: #073642;
  --text: #93a1a1;
  --muted: #657b83;
  --line: #0f4a57;
  --accent: #dc322f;
  --accent-soft: rgba(220, 50, 47, 0.18);
  --chip: #0a3f4d;
  --chip-text: #93a1a1;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f3f5;
  --bg-top: rgba(242, 243, 245, 0.94);
  --card: #fff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #e11d2e;
  --accent-soft: #fff1f2;
  --chip: #fff;
  --chip-text: #374151;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "SF Pro Text", "PingFang SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 8px;
  background: var(--bg-top);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
}
h1 { margin: 0; font-size: 17px; letter-spacing: -0.03em; }
.sub { margin: 1px 0 0; font-size: 11px; color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.5; }
button.active,
.chip.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.filters {
  position: sticky;
  top: 53px;
  z-index: 9;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px 10px;
  background: var(--bg-top);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.52);
  display: grid;
  place-items: end center;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: min(640px, 100%);
  max-height: min(78dvh, 640px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 14px 16px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.sheet-head h2 { margin: 0; font-size: 16px; }
.sheet-copy { margin: 0 0 12px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
}
.sheet-divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0 14px;
}
.sheet-subhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}
.sheet-subhead h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.dark-theme-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}
.dark-theme-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.dark-theme-opt:active {
  transform: scale(0.98);
}
.dark-theme-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.dark-theme-opt-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.dark-theme-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}
.dark-theme-opt-desc {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.2;
}
.sheet-reset-wrap {
  margin-top: 12px;
}
.sheet-reset {
  width: 100%;
  border-radius: 12px;
}
.reset-confirm-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  animation: bannerSlideUp 0.18s ease-out;
}
.reset-confirm-box[hidden] { display: none; }
.reset-confirm-msg {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.92;
}
.reset-confirm-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.reset-confirm-btn {
  flex: 1;
  min-width: 140px;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.reset-cancel-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}
.reset-cancel-btn:hover {
  color: var(--text);
}
.sheet-install-wrap {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.install-instructions {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.sheet-install-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 9px 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.sheet-install-btn:hover {
  filter: brightness(1.08);
}
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--chip-text);
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-transform: capitalize;
  cursor: pointer;
}

main { width: min(640px, 100%); margin: 0 auto; padding: 8px 0 56px; }
#status {
  margin: 8px 14px;
  font-size: 12px;
  color: var(--muted);
}
#status.error {
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.status-retry-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.footer-status {
  margin: 20px 14px 28px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
}

.feed { display: grid; }
.card {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 14px;
  color: inherit;
  text-decoration: none;
}
.card.text-only { grid-template-columns: 1fr; }
.card:focus { outline: none; background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
.card.hero {
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0 0 12px;
}
.card.hero .thumb {
  width: 100%;
  height: 200px;
  border-radius: 0;
  object-fit: cover;
  object-position: center top;
}
.card.hero .body { padding: 12px 14px 0; }
.body { min-width: 0; }
.thumb {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--line);
}
.card h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.32;
  letter-spacing: -0.02em;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.summary {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
}
.badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
}
.badge.secondary {
  background: var(--chip);
  color: var(--chip-text);
  border: 1px solid var(--line);
}
.share {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 11px;
  font-weight: 650;
}
.share:hover { color: var(--accent); }
.story-page { padding: 16px 16px 48px; }
.story-kicker { margin: 0 0 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.story-page h2 { margin: 0 0 12px; font-size: 22px; line-height: 1.3; }
.story-hero { width: 100%; max-height: 280px; object-fit: cover; object-position: center top; border-radius: 12px; margin: 0 0 12px; }
.story-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.story-actions a { text-decoration: none; }
.brand { color: inherit; text-decoration: none; }

#sentinel { height: 1px; }

@media (max-width: 420px) {
  .card:not(.hero) { grid-template-columns: 1fr 84px; padding: 12px; }
  .card:not(.hero) .thumb { width: 84px; height: 64px; }
  .card h2 { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---- Row gestures: swipe like/skip, long-press peek, undo, new-stories pill ---- */
.row {
  position: relative;
  overflow: hidden;
  background: var(--bg);
  --swipe: 0;
}
.row.gone { pointer-events: none; }
.row .card {
  position: relative;
  z-index: 1;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}
.row .card.read h2 { color: var(--muted); }
.row-bg {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  opacity: calc(0.35 + var(--swipe) * 0.65);
}
.row-bg .row-ico { font-size: 24px; transform: scale(calc(0.7 + var(--swipe) * 0.4)); }
.row-bg.like { background: #1f9d55; justify-content: flex-start; }
.row-bg.skip { background: #6b7280; justify-content: flex-end; }
.row[data-dir="like"] .row-bg.like,
.row[data-dir="skip"] .row-bg.skip { display: flex; }
.row.armed .row-bg .row-ico { transform: scale(1.25); }

/* Short swipe right reveals action buttons (Like and Share) */
.row-bg-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 6px;
  height: 100%;
}
.row-action-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease, transform 0.1s ease;
  min-width: 72px;
}
.row-action-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.35);
}
.row-action-btn svg, .row-action-btn .row-ico {
  font-size: 14px;
  line-height: 1;
}
.row.revealed .row-bg.like {
  display: flex !important;
  opacity: 1 !important;
}
.row.liked .card {
  box-shadow: inset 3px 0 0 0 #1f9d55;
}
.card-liked-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #1f9d55;
  background: rgba(31, 157, 85, 0.12);
  border: 1px solid rgba(31, 157, 85, 0.28);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
}

.peek {
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(12px + env(safe-area-inset-top));
  z-index: 40;
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.peek[hidden] { display: none; }
.peek h3 { margin: 0 0 8px; font-size: 15px; line-height: 1.3; }
.peek p { margin: 0 0 10px; font-size: 13px; line-height: 1.45; color: var(--text); opacity: 0.88; max-height: 30vh; overflow: hidden; }
.peek-meta { font-size: 12px; color: var(--muted); }

.snack {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-radius: 999px;
  background: #1c202a;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f4f4f5;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.75);
  pointer-events: auto;
  animation: snackSlideUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.snack[hidden] { display: none; }
@keyframes snackSlideUp {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.snack-btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 59, 78, 0.4);
}
.snack-btn:active {
  transform: scale(0.96);
}

.new-pill {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.new-pill[hidden] { display: none; }

/* ---- Install Banner ("Add to home screen for best experience") ---- */
.install-banner {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 14px;
  right: 14px;
  max-width: 520px;
  margin: 0 auto;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: bannerSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.install-banner[hidden] { display: none; }
@keyframes bannerSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.install-banner-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.install-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.install-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.install-banner-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.install-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.install-banner-btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.install-banner-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
}

@media (max-width: 420px) {
  .install-banner {
    left: 8px;
    right: 8px;
    padding: 8px 10px;
    gap: 8px;
    border-radius: 12px;
  }
  .install-banner-mark {
    width: 32px;
    height: 32px;
    font-size: 17px;
    border-radius: 8px;
  }
  .install-banner-title {
    font-size: 13px;
  }
  .install-banner-sub {
    font-size: 11px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .install-banner-btn {
    font-size: 12px;
    padding: 6px 12px;
  }
  .install-banner-close {
    font-size: 18px;
    padding: 4px;
  }
}

/* ---- Install Guide Modal ---- */
.install-guide-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  margin-top: 12px;
}
.install-guide-body p {
  margin: 0 0 10px;
}
.install-guide-body ol {
  margin: 8px 0 12px 20px;
  padding: 0;
}
.install-guide-body li {
  margin-bottom: 8px;
  line-height: 1.45;
}
.install-guide-body strong {
  color: var(--accent);
}

/* ---- Help & About Sheet Modal ---- */
.help-sheet-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.help-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.help-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.help-section p {
  margin: 0;
  color: var(--text);
  opacity: 0.9;
  line-height: 1.5;
}
.help-list {
  margin: 4px 0 0 18px;
  padding: 0;
}
.help-list li {
  margin-bottom: 6px;
  line-height: 1.45;
}
.help-list strong {
  color: var(--accent);
}
.help-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

/* ---- Welcome Modal Footer ---- */
.welcome-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.welcome-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.welcome-checkbox-label input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}
.welcome-footer .sheet-install-btn {
  margin: 0;
  width: auto;
  min-width: 100px;
  padding: 8px 22px;
}

/* ---- Swipe Gesture Hint Teaser (first 5 opens, 1st card) ---- */
@keyframes swipeTeaseCard {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(136px);
  }
  38% {
    transform: translateX(136px);
  }
  48% {
    transform: translateX(0);
  }
  68% {
    transform: translateX(-136px);
  }
  84% {
    transform: translateX(-136px);
  }
  94% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes swipeTeaseLikeBg {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  38% {
    opacity: 1;
  }
  48% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

@keyframes swipeTeaseSkipBg {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 0;
  }
  60% {
    opacity: 1;
  }
  84% {
    opacity: 1;
  }
  94% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

.card.swipe-teaser {
  animation: swipeTeaseCard 4.4s cubic-bezier(0.25, 1, 0.35, 1) 0s 1 normal forwards;
}

.row.swipe-teaser-active .row-bg.like {
  display: flex !important;
  opacity: 0;
  animation: swipeTeaseLikeBg 4.4s ease-in-out 0s 1 normal forwards;
}

.row.swipe-teaser-active .row-bg.skip {
  display: flex !important;
  opacity: 0;
  animation: swipeTeaseSkipBg 4.4s ease-in-out 0s 1 normal forwards;
}

/* ---- Long-Press Hint Teaser (first 5 opens, 1st normal card) ---- */
.card.longpress-teaser-target {
  position: relative;
  overflow: visible;
  transition: transform 0.25s ease, background 0.25s ease;
}

.card.longpress-teaser-pressing {
  transform: scale(0.985);
  background: color-mix(in srgb, var(--accent) 7%, var(--card)) !important;
}

.card-teaser-touch {
  position: absolute;
  top: 50%;
  left: 36%;
  transform: translate(-50%, -50%);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-teaser-touch::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
  box-shadow: 0 0 14px var(--accent);
  animation: touchDotPulse 1.2s ease-in-out infinite alternate;
}

.card-teaser-touch::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: touchRingExpand 1.6s cubic-bezier(0.2, 0.8, 0.3, 1) infinite;
}

@keyframes touchDotPulse {
  0% {
    transform: scale(0.9);
    opacity: 0.75;
  }
  100% {
    transform: scale(1.15);
    opacity: 1;
  }
}

@keyframes touchRingExpand {
  0% {
    transform: scale(0.5);
    opacity: 0.9;
  }
  75% {
    transform: scale(1.4);
    opacity: 0.35;
  }
  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}




/* =========================================================================
   Staging v2: Option A Multi-Perspective Grouping & Tag Cloud Sidebar
   ========================================================================= */

/* Coverage Pill for Grouped Stories */
.coverage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  width: fit-content;
  max-width: 100%;
  text-decoration: none;
}

.coverage-pill:hover {
  background: rgba(128, 128, 128, 0.16);
  border-color: var(--accent);
}

.coverage-pill-icon {
  font-size: 11px;
  color: var(--accent);
}

.coverage-pill-label {
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.coverage-pill-sources {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.coverage-pill-count {
  font-weight: 700;
  color: var(--text);
  margin-left: 2px;
}

@media (min-width: 768px) {
  .coverage-pill {
    padding: 5px 12px;
    font-size: 12px;
  }
  .coverage-pill-sources {
    max-width: 260px;
  }
}

/* Full Coverage Modal Sheet (Mobile Bottom Drawer & Desktop Dialog) */
.coverage-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  touch-action: pan-y;
}

.coverage-modal.active {
  visibility: visible;
  opacity: 1;
}

.coverage-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  touch-action: none;
}

.coverage-sheet {
  position: relative;
  width: 100%;
  max-width: 680px;
  max-height: 88dvh;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 24px);
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(40px);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.coverage-modal.active .coverage-sheet {
  transform: translateY(0);
}

@media (min-width: 768px) {
  .coverage-modal {
    align-items: center;
    padding: 24px;
  }
  .coverage-sheet {
    max-height: 84vh;
    border-radius: 18px;
    border-bottom: 1px solid var(--line);
    transform: scale(0.96) translateY(20px);
    padding-bottom: 0;
  }
  .coverage-modal.active .coverage-sheet {
    transform: scale(1) translateY(0);
  }
}

/* Markup classes actually used in index.html (sheet head / scrollable body) */
.coverage-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 8px auto 0;
  flex-shrink: 0;
}

.coverage-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.coverage-sheet-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.coverage-tag {
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.coverage-close-btn {
  background: rgba(128, 128, 128, 0.12);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.coverage-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 14px 16px 20px;
}

.coverage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}

.coverage-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.coverage-count {
  font-size: 12px;
  color: var(--muted);
}

.coverage-btn-close {
  background: rgba(128, 128, 128, 0.12);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.coverage-btn-close:hover {
  background: rgba(128, 128, 128, 0.22);
}

.coverage-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  min-height: 0;
  padding: 16px 18px 28px;
  flex: 1;
}

.coverage-topic-header {
  margin-bottom: 18px;
  background: rgba(128, 128, 128, 0.04);
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.coverage-lead-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 6px;
}

.coverage-lead-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.coverage-lead-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 8px;
  color: var(--text);
}

.coverage-lead-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.coverage-lead-hop {
  color: var(--accent);
  font-weight: 600;
}

.coverage-perspectives-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
  padding-left: 2px;
}

.coverage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.coverage-card-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.coverage-card-item:hover {
  border-color: var(--accent);
  background: rgba(128, 128, 128, 0.08);
}

.coverage-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
}

.coverage-item-source {
  font-weight: 700;
  color: var(--accent);
}

.coverage-item-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  color: var(--text);
}

.coverage-footer {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.coverage-btn-secondary {
  background: rgba(128, 128, 128, 0.1);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s ease;
}

.coverage-btn-secondary:hover {
  background: rgba(128, 128, 128, 0.18);
}

/* =========================================================================
   Responsive Desktop Layout & Equal-Sized Tag Cloud Sidebar (min-width: 1024px)
   ========================================================================= */

.layout-container {
  display: block;
  width: 100%;
}

.sidebar {
  display: contents;
}

.sidebar-header {
  display: none;
}

/* Bloomberg Style World News Ticker Tape (Base: Mobile FLIP Mode) */
.ticker-tape {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 8;
  height: 32px;
  background: var(--bg-top);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  font-size: 11.5px;
  user-select: none;
  -webkit-user-select: none;
}

.ticker-lead {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 10px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  height: 100%;
  flex-shrink: 0;
  z-index: 3;
}

.ticker-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e53e3e;
  box-shadow: 0 0 6px #e53e3e;
  animation: tickerPulse 1.8s ease-in-out infinite;
}

@keyframes tickerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.ticker-title {
  display: none !important;
  font-weight: 800;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}

.ticker-viewport {
  flex: 1;
  height: 100%;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.ticker-viewport::before,
.ticker-viewport::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20px;
  z-index: 2;
  pointer-events: none;
}
.ticker-viewport::before {
  left: 0;
  background: linear-gradient(to right, var(--bg-top), transparent);
}
.ticker-viewport::after {
  right: 0;
  background: linear-gradient(to left, var(--bg-top), transparent);
}

/* Rolling Marquee */
.ticker-track.mode-roll {
  display: flex;
  align-items: center;
  width: max-content;
  animation: tickerRoll 55s linear infinite;
}

.ticker-track.mode-roll:hover {
  animation-play-state: paused;
}

@keyframes tickerRoll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  transition: color 0.15s ease;
  cursor: pointer;
}

.ticker-item:hover {
  color: var(--accent);
}

.ticker-item-source {
  font-weight: 700;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(128, 128, 128, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.ticker-item-title {
  font-weight: 500;
  font-size: 11.5px;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticker-item-time {
  font-size: 10.5px;
  color: var(--muted);
  margin-left: 2px;
  flex-shrink: 0;
}

.ticker-sep {
  color: var(--line);
  font-size: 8px;
  margin-left: 6px;
  opacity: 0.8;
}

/* Flipboard Mode */
.ticker-track.mode-flip {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 10px;
  width: 100%;
  min-width: 0;
}

.ticker-flip-slide {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  min-width: 0;
  animation: flipIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ticker-flip-slide:hover {
  color: var(--accent);
}

@keyframes flipIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 640px) {
  .ticker-title {
    display: inline-block !important;
    font-size: 10.5px;
  }

  .ticker-tape {
    height: 36px;
    font-size: 12px;
  }

  .crypto-tape {
    height: 30px;
    font-size: 11.5px;
  }

  .crypto-item {
    gap: 6px;
    padding: 0 14px;
  }

  .crypto-sym {
    font-size: 9.5px;
  }

  .crypto-price {
    font-size: 11.5px;
  }

  .crypto-chg {
    font-size: 10px;
  }

  .ticker-lead {
    gap: 8px;
    padding: 0 14px 0 20px;
  }

  .ticker-pulse {
    width: 7px;
    height: 7px;
  }

  .ticker-viewport::before,
  .ticker-viewport::after {
    width: 28px;
  }

  .ticker-item {
    gap: 7px;
    padding: 0 16px;
  }

  .ticker-item-source {
    font-size: 10.5px;
    padding: 1px 5px;
  }

  .ticker-item-title {
    font-size: 12px;
  }

  .ticker-item-time {
    font-size: 11px;
  }

  .ticker-flip-slide {
    gap: 10px;
  }
}

/* Crypto 30 Ticker Tape (Direct Binance WebSocket Feed) */
.crypto-tape {
  height: 27px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}

.crypto-lead {
  border-right: 1px solid var(--line);
  background: var(--bg-top);
}

.crypto-pulse {
  background: #10b981 !important;
  box-shadow: 0 0 6px #10b981 !important;
  animation: cryptoPulse 1.8s ease-in-out infinite !important;
}

@keyframes cryptoPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

#crypto-track.mode-roll {
  display: flex;
  align-items: center;
  width: max-content;
  animation: cryptoRoll 80s linear infinite;
}

#crypto-track.mode-roll:hover {
  animation-play-state: paused;
}

@keyframes cryptoRoll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.crypto-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.crypto-item:hover {
  opacity: 0.85;
}

.crypto-sym {
  color: #10b981 !important;
  background: rgba(16, 185, 129, 0.1) !important;
  border: 1px solid rgba(16, 185, 129, 0.3) !important;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.crypto-price {
  font-weight: 600;
  font-size: 11px;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.crypto-chg {
  font-weight: 600;
  font-size: 9.5px;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
}

.crypto-up {
  color: #10b981;
}

.crypto-down {
  color: #ef4444;
}

.crypto-neutral {
  color: var(--muted);
}

@media (min-width: 1024px) {
  .topbar {
    padding: 12px 32px;
  }

  #world-ticker {
    position: sticky;
    top: 53px;
    z-index: 10;
  }

  #crypto-ticker {
    position: sticky;
    top: 89px; /* 53px topbar + 36px world ticker */
    z-index: 9;
  }

  .layout-container {
    display: grid;
    grid-template-columns: 280px minmax(0, 680px);
    justify-content: center;
    gap: 36px;
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 20px 60px;
    align-items: start;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 130px;
    max-height: calc(100vh - 148px);
    padding-right: 16px;
    border-right: 1px solid var(--line);
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
    flex-shrink: 0;
  }

  .filters {
    position: static;
    top: auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap; /* Equal-sized Tag Cloud */
    gap: 8px;
    padding: 2px 0 20px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 128, 128, 0.25) transparent;
    max-height: calc(100vh - 140px);
  }

  .filters::-webkit-scrollbar {
    width: 4px;
  }

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

  .filters::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.25);
    border-radius: 4px;
  }

  .filters::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.45);
  }

  .chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 13px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 550;
    line-height: 1.2;
    border: 1px solid var(--line);
    background: var(--chip);
    color: var(--chip-text);
    transition: all 0.15s ease;
    cursor: pointer;
    text-transform: none;
  }

  .chip:hover {
    background: rgba(128, 128, 128, 0.12);
    border-color: var(--accent);
    color: var(--text);
  }

  .chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 650;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  .card.hero .thumb {
    height: 260px;
  }

  main {
    width: 100%;
    max-width: 680px;
    margin: 0;
    padding: 0 0 56px;
  }
}
