/* ===== Theme Variables ===== */
:root {
  --bg-page: #f8f9fa;
  --bg-surface: #fff;
  --bg-surface-hover: #f7f8fa;
  --bg-elevated: #fff;
  --bg-input: #fff;
  --bg-skeleton: #f0f1f3;
  --bg-badge: #f0f1f3;
  --bg-chat-answer: #f0f4ff;
  --border-color: #dee2e6;
  --border-light: #f0f0f0;
  --text-primary: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #737373;
  --text-faint: #767676;
  --accent: #0d6efd;
  --accent-hover: #0a58ca;
  --shimmer: rgba(255,255,255,0.6);
  --shadow-sm: rgba(0,0,0,0.08);
  --shadow-md: rgba(0,0,0,0.1);
  --backdrop: rgba(0,0,0,0.3);
  --stance-pro-gov-bg: #fee2e2;
  --stance-pro-gov-text: #991b1b;
  --stance-anti-gov-bg: #dcfce7;
  --stance-anti-gov-text: #166534;
  --stance-indep-bg: #fef3c7;
  --stance-indep-text: #92400e;
  --bar-track: #f0f1f3;
  --feedback-body-bg: #fff;
  --feedback-prompt: #555;
  --feedback-comment-bg: #fff;
  --feedback-comment-border: #dee2e6;
  --emoji-selected-bg: #eef0fd;
  --success-text: #155724;
}

html.dark {
  --bg-page: #0f0f11;
  --bg-surface: #1a1a1e;
  --bg-surface-hover: #222228;
  --bg-elevated: #222228;
  --bg-input: #2a2a30;
  --bg-skeleton: #2a2a30;
  --bg-badge: #2a2a30;
  --bg-chat-answer: #1e2030;
  --border-color: #2e2e34;
  --border-light: #2a2a30;
  --text-primary: #e8e8ec;
  --text-secondary: #a0a0a8;
  --text-muted: #8e8e96;
  --text-faint: #82828a;
  --accent: #5b9aff;
  --accent-hover: #7db0ff;
  --shimmer: rgba(255,255,255,0.05);
  --shadow-sm: rgba(0,0,0,0.3);
  --shadow-md: rgba(0,0,0,0.4);
  --backdrop: rgba(0,0,0,0.6);
  --stance-pro-gov-bg: #3a1a1a;
  --stance-pro-gov-text: #fca5a5;
  --stance-anti-gov-bg: #1a2e1a;
  --stance-anti-gov-text: #86efac;
  --stance-indep-bg: #2a2418;
  --stance-indep-text: #f5c842;
  --bar-track: #2a2a30;
  --feedback-body-bg: #1a1a1e;
  --feedback-prompt: #a0a0a8;
  --feedback-comment-bg: #2a2a30;
  --feedback-comment-border: #3a3a40;
  --emoji-selected-bg: #2a2a3a;
  --success-text: #4ade80;
}

/* ===== Base ===== */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg-page);
  color: var(--text-primary);
  transition: background 200ms ease, color 200ms ease;
}

/* ===== Bootstrap dark overrides ===== */
html.dark .navbar,
html.dark .chat-bar,
html.dark .main-tabs-bar {
  background: var(--bg-surface) !important;
  border-color: var(--border-color) !important;
}

html.dark .navbar .navbar-brand {
  color: var(--text-primary) !important;
}

html.dark .navbar .nav-link {
  color: var(--text-secondary) !important;
}

html.dark .navbar .nav-link:hover {
  color: var(--text-primary) !important;
}

html.dark .navbar-toggler-icon {
  filter: invert(1) grayscale(1) brightness(2);
}

html.dark .border-bottom {
  border-color: var(--border-color) !important;
}

html.dark .border-top {
  border-color: var(--border-color) !important;
}

html.dark .form-control {
  background-color: var(--bg-input) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

html.dark .form-control::placeholder {
  color: var(--text-muted) !important;
}

html.dark .form-control:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 0.2rem rgba(91,154,255,0.15) !important;
}

html.dark .btn-dark {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}

html.dark .btn-link.text-muted {
  color: var(--text-muted) !important;
}

html.dark .text-muted {
  color: var(--text-muted) !important;
}

html.dark footer {
  background: var(--bg-surface);
  color: var(--text-muted);
}

/* ===== Sticky Site Header =====
   One sticky block holds the flag accent, navbar, optional announcement and
   chat bars, and the main tab row. Sticking the wrapper (rather than each bar
   with its own hard-coded `top` offset) keeps everything aligned as a single
   unit, eliminates the drift/overlap on scroll, and lets the optional bars
   collapse to zero height when hidden — no leftover gap under the navbar. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px var(--shadow-sm);
}

html.dark .site-header {
  background: var(--bg-surface);
  border-color: var(--border-color);
}

/* ===== Ethiopian Flag Stripe ===== */
.eth-flag-stripe {
  height: 3px;
  background: linear-gradient(to right, #009b3a 33.3%, #fcdd09 33.3%, #fcdd09 66.6%, #e31b23 66.6%);
  opacity: 0.6;
}

/* ===== Admin Announcement Bar ===== */
.announcement-bar {
  background: var(--bg-chat-answer);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.announcement-bar[hidden] { display: none; }

.announcement-bar .container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.announcement-text {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

.announcement-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
  border-radius: 0.25rem;
}

.announcement-dismiss:hover { color: var(--text-primary); }

/* ===== Theme Toggle ===== */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  line-height: 1;
  font-size: 1.125rem;
  color: var(--text-secondary);
  border-radius: 0.375rem;
  transition: color 150ms ease, background 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
}

.theme-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-badge);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

html:not(.dark) .theme-toggle .icon-moon { display: block; }
html.dark .theme-toggle .icon-sun { display: block; }

/* Lite mode toggle — pressed state mirrors the theme-toggle hover style
 * so users get a visual confirmation their setting is active. */
#lite-toggle.active {
  color: var(--accent, #4f46e5);
  background: var(--bg-badge);
}

/* ===== AI Chat Bar ===== */
.chat-bar {
  /* Part of the sticky .site-header block — no individual sticky offset.
     Collapses to zero height (display:none) when the admin hides the AI
     chat bar, so it never leaves an empty gap under the navbar. */
  border-top: 1px solid var(--border-light);
}

#chat-input {
  flex: 1;
}

.chat-response {
  padding-bottom: 0.5rem;
}

.chat-answer {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 0.625rem 0.875rem;
  background: var(--bg-chat-answer);
  border-radius: 0.5rem;
  border-left: 3px solid var(--accent);
}

.chat-answer .chat-thinking {
  color: var(--text-muted);
  font-style: italic;
}

.chat-citations {
  margin-top: 0.375rem;
  font-size: 0.875rem;
}

.chat-citations summary {
  min-height: 44px;
  padding: 0.625rem 0;
  cursor: pointer;
}

.chat-sources {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: min(45vh, 18rem);
  overflow-y: auto;
}

.chat-sources a {
  display: block;
  min-height: 44px;
  padding: 0.5rem 0;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.chat-sources time {
  display: block;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ===== Main Tabs ===== */
.main-tabs-bar {
  /* Part of the sticky .site-header block (see .site-header). No top border:
     when the chat/announcement bars are hidden the tabs read as one surface
     with the navbar; when shown, those bars supply the divider above. */
}

/* Keep in-page scroll targets (skip-link, #about, the social pagination jump)
   clear of the sticky header so they don't land hidden beneath it. */
.tab-pane section,
[id^="pane-"],
#news,
#about {
  scroll-margin-top: 112px;
}

.main-tabs {
  border-bottom: none;
  /* Keep all tabs on a single row even on narrow screens — wrapping looked
     broken when the History tab pushed onto its own line. If we ever exceed
     the visible width, the tabs scroll horizontally instead. */
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-tabs::-webkit-scrollbar { display: none; }

.main-tabs .nav-item { flex: 0 0 auto; }

.main-tabs .nav-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.65rem 1.25rem;
  white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease;
}

@media (max-width: 575.98px) {
  /* Tighter padding on phones so 4 tabs (Articles, Social, World, History)
     fit on one row without crowding. Visuals is moved into the navbar
     dropdown at this breakpoint. */
  .main-tabs .nav-link {
    padding: 0.6rem 0.85rem;
    font-size: 0.85rem;
  }
}

.main-tabs .nav-link:hover {
  color: var(--text-primary);
  border-color: var(--border-color);
}

.main-tabs .nav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}

/* ===== Category Chips (kept for potential reuse) ===== */
.chip {
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 150ms ease;
}

.chip:not(.active) {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.chip:not(.active):hover {
  border-color: var(--text-muted);
}

.chip.active {
  background: var(--text-primary);
  color: var(--bg-surface);
  border-color: var(--text-primary);
}

/* ===== Featured Cards ===== */
.featured-card {
  border: 1px solid var(--border-color);
  border-left: 3px solid #f59e0b;
  border-radius: 0.5rem;
  padding: 1rem;
  background: var(--bg-surface);
  cursor: pointer;
  transition: box-shadow 250ms ease;
}

.featured-card:hover {
  box-shadow: 0 2px 8px var(--shadow-sm);
}

.featured-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #f59e0b;
  margin-bottom: 4px;
}

.featured-title {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.featured-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Feed Items ===== */
.feed-item {
  display: flex;
  gap: 10px;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 150ms ease;
}

.feed-item:last-child {
  border-bottom: none;
}

/* Recycled (offscreen-above) cards collapse to a height-preserving
 * placeholder. Border + cursor stay so the layout doesn't jump. */
.feed-item.recycled {
  cursor: default;
  background: transparent;
}

.feed-item:active {
  background: var(--bg-surface-hover);
}

/* Lead thumbnail — fixed box so a slow image can't shift the layout;
   sized for one-hand phone scanning, slightly larger on wider screens.
   Lite mode (data saver) removes it entirely so the bytes are never
   fetched by browsers that defer offscreen lazy images anyway. */
.feed-item-thumb {
  flex-shrink: 0;
  width: 72px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-badge);
  align-self: flex-start;
}

.feed-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (min-width: 576px) {
  .feed-item-thumb { width: 96px; aspect-ratio: 4 / 3; }
}

.lite-mode .feed-item-thumb,
.article-imgs-off .feed-item-thumb {
  display: none;
}

.feed-item-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-badge);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
}

.feed-item-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
}

.feed-item-body {
  flex: 1;
  min-width: 0;
}

.feed-item-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-item-summary {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 4px;
}

.full-article-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.8125rem;
}

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

.feed-item-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.feed-item-source {
  font-weight: 500;
  color: var(--text-secondary);
}

.feed-item-category {
  font-size: 0.6875rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-badge);
  color: var(--text-secondary);
}

.dot {
  opacity: 0.4;
}

/* Tablet+: 2-column card grid */
@media (min-width: 576px) {
  #articles-container,
  #social-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  .feed-item {
    flex-direction: column;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 1rem;
    gap: 0;
    background: var(--bg-surface);
  }
  .feed-item:last-child {
    border: 1px solid var(--border-light);
  }
  .feed-item:hover {
    box-shadow: 0 2px 8px var(--shadow-sm);
  }
  .feed-item:active {
    background: var(--bg-surface);
  }
  .feed-item-avatar {
    margin-bottom: 0.5rem;
  }
  .feed-item-title {
    font-size: 1rem;
    -webkit-line-clamp: 3;
  }
  .feed-item-summary {
    font-size: 0.875rem;
    margin-top: 6px;
  }
  .feed-item-meta {
    margin-top: 0.5rem;
  }
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: var(--bg-skeleton);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--shimmer), transparent);
  animation: shimmer 1.5s infinite;
}

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

.skeleton-title { height: 14px; width: 75%; margin-bottom: 8px; }
.skeleton-meta  { height: 10px; width: 40%; }

.skeleton-row {
  display: flex;
  gap: 10px;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border-light);
  min-width: 0;
}

.skeleton-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

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

.feed-item {
  animation: fadeIn 200ms ease;
}

/* Lead image in the article detail panel. max-height keeps portrait
   images from pushing the body below the fold on phones. */
.panel-image {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
  margin: 0.75rem 0;
  display: block;
}

.lite-mode .panel-image,
.article-imgs-off .panel-image {
  display: none;
}

/* ===== Article Panel ===== */
.article-panel-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  z-index: 1050;
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.article-panel-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.article-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background: var(--bg-surface);
  z-index: 1055;
  transform: translateX(100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.article-panel.open {
  transform: translateX(0);
}

.panel-inner {
  padding: 1rem 1rem 2rem;
  max-width: 640px;
  margin: 0 auto;
}

.panel-close {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  padding: 0.5rem 0;
  min-height: 44px;
}

.panel-close:hover {
  color: var(--accent-hover);
}

.panel-title {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.panel-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.panel-meta .feed-item-source {
  font-weight: 600;
  color: var(--text-secondary);
}

.panel-body {
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--text-secondary);
  word-break: break-word;
}

.panel-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 1.5rem;
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.panel-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

@media (min-width: 576px) {
  .article-panel {
    width: 560px;
    max-width: 80vw;
    border-left: 1px solid var(--border-color);
    box-shadow: 0 4px 16px var(--shadow-md);
  }
}

@media (min-width: 992px) {
  .article-panel {
    width: 640px;
  }
}

/* ===== Political Stance Badges ===== */
.stance-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.stance-badge.pro_government {
  background: var(--stance-pro-gov-bg);
  color: var(--stance-pro-gov-text);
}

.stance-badge.independent {
  background: var(--stance-indep-bg);
  color: var(--stance-indep-text);
}

.stance-badge.lean_pro {
  background: var(--stance-pro-gov-bg);
  color: var(--stance-pro-gov-text);
  opacity: 0.85;
}

.stance-badge.lean_anti {
  background: var(--stance-anti-gov-bg);
  color: var(--stance-anti-gov-text);
  opacity: 0.85;
}

.stance-badge.anti_government {
  background: var(--stance-anti-gov-bg);
  color: var(--stance-anti-gov-text);
}

/* ===== Bias Spectrum ===== */
.bias-spectrum {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.bias-spectrum-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  min-width: 28px;
  text-align: center;
}

.bias-spectrum-label.left {
  color: #16a34a;
}

.bias-spectrum-label.right {
  color: #dc2626;
}

html.dark .bias-spectrum-label.left {
  color: #86efac;
}

html.dark .bias-spectrum-label.right {
  color: #fca5a5;
}

.bias-spectrum-track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  position: relative;
  overflow: visible;
  background: linear-gradient(to right,
    #16a34a 0%,
    #4ade80 20%,
    #d1d5db 40%,
    #d1d5db 60%,
    #f87171 80%,
    #dc2626 100%
  );
}

html.dark .bias-spectrum-track {
  background: linear-gradient(to right,
    #166534 0%,
    #22c55e 20%,
    #4b5563 40%,
    #4b5563 60%,
    #b91c1c 80%,
    #991b1b 100%
  );
}

.bias-spectrum-marker {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2.5px solid var(--text-primary);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px var(--shadow-sm);
  transition: left 0.3s ease;
}

.bias-spectrum-summary {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Compact spectrum for feed items */
.bias-spectrum.compact {
  gap: 4px;
  margin-top: 4px;
}

.bias-spectrum.compact .bias-spectrum-label {
  display: none;
}

.bias-spectrum.compact .bias-spectrum-track {
  height: 5px;
  max-width: 120px;
}

.bias-spectrum.compact .bias-spectrum-marker {
  width: 10px;
  height: 10px;
  border-width: 2px;
}

/* Panel (detail view) spectrum */
.panel-bias-section {
  margin: 16px 0;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.panel-bias-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

/* ===== Visualization Cards ===== */
.vis-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  overflow: hidden;
}

.vis-card-header {
  padding: 0.875rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.vis-card-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.vis-card-subtitle {
  font-size: 0.6875rem;
  color: var(--text-faint);
}

.vis-card-body {
  padding: 1rem;
}

/* Tile Map */
.tilemap-container {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 60px;
}

.tile {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: transform 100ms ease, box-shadow 100ms ease;
  position: relative;
}

.tile:hover {
  transform: scale(1.4);
  z-index: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.tile.pro_government  { background: #dc2626; }
.tile.lean_pro        { background: #f87171; }
.tile.neutral         { background: #d1d5db; }
.tile.lean_anti       { background: #4ade80; }
.tile.anti_government { background: #16a34a; }
.tile.independent     { background: #f59e0b; }

html.dark .tile.pro_government { background: #991b1b; }
html.dark .tile.lean_pro { background: #b91c1c; }
html.dark .tile.neutral { background: #555; }
html.dark .tile.lean_anti { background: #22c55e; }
html.dark .tile.anti_government { background: #166534; }

.tilemap-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-swatch.pro_government  { background: #dc2626; }
.legend-swatch.lean_pro        { background: #f87171; }
.legend-swatch.neutral         { background: #d1d5db; }
.legend-swatch.lean_anti       { background: #4ade80; }
.legend-swatch.anti_government { background: #16a34a; }
.legend-swatch.independent     { background: #f59e0b; }
.legend-swatch.unknown         { background: #d1d5db; }

html.dark .legend-swatch.unknown { background: #555; }
html.dark .legend-swatch.neutral { background: #555; }
html.dark .legend-swatch.pro_government { background: #991b1b; }
html.dark .legend-swatch.lean_pro { background: #b91c1c; }
html.dark .legend-swatch.lean_anti { background: #22c55e; }
html.dark .legend-swatch.anti_government { background: #166534; }

/* Bar Charts */
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.bar-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  flex: 1;
  height: 20px;
  background: var(--bar-track);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 2px;
}

.bar-fill.politics     { background: #dc3545; }
.bar-fill.sport        { background: #198754; }
.bar-fill.culture      { background: #e83e8c; }
.bar-fill.entertainment { background: #6f42c1; }
.bar-fill.news         { background: #6c757d; }
.bar-fill.default      { background: var(--accent); }
.bar-fill.positive     { background: #198754; }
.bar-fill.negative     { background: #dc3545; }
.bar-fill.neutral      { background: #6c757d; }

.bar-count {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 30px;
  flex-shrink: 0;
}

/* Stacked bar — used by sentiment-trend and volume charts. The track
 * holds multiple inline-flex segments whose widths sum to the total. */
.bar-track.stacked {
  display: flex;
}

.bar-track.stacked .bar-fill {
  border-radius: 0;
}

.bar-track.stacked .bar-fill:first-child {
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}

.bar-track.stacked .bar-fill:last-child {
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
}

/* Empty-day placeholder so the row still renders a baseline. */
.bar-track.stacked.empty {
  background: var(--bar-track);
}

/* Volume chart fills — distinct from sentiment colors. */
.bar-fill.volume-news    { background: var(--accent, #4f46e5); }
.bar-fill.volume-social  { background: #e879f9; }

/* Tile tooltip */
.tile-tooltip {
  position: fixed;
  background: var(--text-primary);
  color: var(--bg-page);
  font-size: 0.6875rem;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 2000;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Feedback Widget ===== */

#feedback-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: #667eea;
  color: #fff;
  padding: 0.9rem 0.45rem;
  border-radius: 8px 0 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 1040;
  user-select: none;
  box-shadow: -2px 0 8px rgba(0,0,0,0.18);
  transition: background 0.2s, opacity 0.2s;
  opacity: 0.85;
}
#feedback-tab:hover { background: #5a6fd8; opacity: 1; }
#feedback-tab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
#feedback-tab.hidden {
  opacity: 0;
  pointer-events: none;
}

#feedback-panel {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateX(110%) translateY(-50%);
  width: 300px;
  max-width: calc(100vw - 1rem);
  background: var(--feedback-body-bg);
  border-radius: 12px 0 0 12px;
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  z-index: 1041;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
#feedback-panel.open {
  transform: translateX(0) translateY(-50%);
}

.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem 0.75rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.feedback-title { font-size: 0.9rem; font-weight: 700; }
#feedback-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#feedback-close:hover { background: rgba(255,255,255,0.35); }

.feedback-body { padding: 1rem; }
.feedback-prompt {
  font-size: 0.85rem;
  color: var(--feedback-prompt);
  margin-bottom: 0.85rem;
  text-align: center;
}

.feedback-emojis {
  display: flex;
  justify-content: space-around;
  margin-bottom: 0.9rem;
}
.emoji-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 50%;
  font-size: 1.75rem;
  padding: 0.2rem;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-btn:hover { transform: scale(1.15); }
.emoji-btn.selected {
  border-color: #667eea;
  background: var(--emoji-selected-bg);
  transform: scale(1.2);
}

#feedback-comment {
  width: 100%;
  border: 1px solid var(--feedback-comment-border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  min-height: 65px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
  background: var(--feedback-comment-bg);
  color: var(--text-primary);
}
#feedback-comment:focus { border-color: #667eea; }

#feedback-submit {
  display: block;
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.6rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
#feedback-submit:disabled { opacity: 0.4; cursor: not-allowed; }
#feedback-submit:not(:disabled):hover { opacity: 0.88; }

.feedback-success {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.9rem;
  color: var(--success-text);
}
.feedback-success .check { font-size: 2.2rem; display: block; margin-bottom: 0.5rem; }

@media (max-width: 380px) {
  #feedback-panel {
    width: 100%;
    max-width: 100%;
    top: auto;
    bottom: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #feedback-panel.open {
    transform: translateY(0);
  }
  #feedback-tab {
    top: auto;
    bottom: 4.5rem;
    transform: none;
    writing-mode: horizontal-tb;
    border-radius: 8px 0 0 8px;
    padding: 0.45rem 0.65rem;
    font-size: 0.72rem;
  }
  #feedback-tab.hidden { opacity: 0; pointer-events: none; }
}

/* ===== Skip Link (Accessibility) ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: 0 0 0.5rem 0.5rem;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: top 200ms ease;
}
.skip-link:focus {
  top: 0;
}

/* ===== Language Toggle ===== */
.lang-label {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
}

/* ===== Amharic Font Support ===== */
html[lang="am"] body {
  font-family: 'Noto Sans Ethiopic', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Share Buttons ===== */
.share-row {
  display: flex;
  gap: 8px;
  margin-top: 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
  text-decoration: none;
}
.share-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--text-muted);
  color: var(--text-primary);
}
.share-btn.whatsapp:hover { color: #25D366; border-color: #25D366; }
.share-btn.telegram:hover { color: #0088cc; border-color: #0088cc; }
.share-btn.twitter:hover { color: #1DA1F2; border-color: #1DA1F2; }
.share-btn.copied { color: var(--accent); border-color: var(--accent); }

/* ===== Bookmark Button ===== */
.bookmark-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 150ms ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bookmark-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}
.bookmark-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== Back to Top ===== */
#back-to-top {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 1030;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 2px 8px var(--shadow-sm);
  transition: all 200ms ease;
}
#back-to-top:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#back-to-top.visible {
  display: flex;
}

/* ===== Panel Actions Row ===== */
.panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  align-items: center;
}

/* ===== Reading Time ===== */
.reading-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== Visually Hidden (sr-only) ===== */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ===== Related Articles (in panel) ===== */
.related-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}
.related-heading {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.related-item {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 150ms ease;
}
.related-item:last-child { border-bottom: none; }
.related-item:hover { background: var(--bg-surface-hover); }
.related-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}
.related-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Keyboard Shortcuts Dialog ===== */
.shortcuts-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.shortcuts-dialog-content {
  background: var(--bg-surface);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  max-width: 420px;
  width: 90%;
  overflow: hidden;
}
.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.shortcuts-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.shortcuts-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 4px;
}
.shortcuts-close:hover {
  color: var(--text-primary);
}
.shortcuts-body {
  padding: 16px 20px 20px;
}
.shortcuts-group {
  margin-bottom: 16px;
}
.shortcuts-group:last-child {
  margin-bottom: 0;
}
.shortcuts-group h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 8px;
  font-weight: 600;
}
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.shortcut-row kbd {
  display: inline-block;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-family: inherit;
  min-width: 28px;
  text-align: center;
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  margin-right: 4px;
}
.shortcut-row span {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ===== Add to Home Screen Banner ===== */
.a2hs-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9990;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.a2hs-banner.show {
  transform: translateY(0);
}
.a2hs-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  max-width: 600px;
  margin: 0 auto;
}
.a2hs-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}
.a2hs-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.a2hs-text strong {
  font-size: 0.95rem;
  color: var(--text-primary);
}
.a2hs-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.a2hs-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.a2hs-install {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.a2hs-install:hover {
  opacity: 0.9;
}
.a2hs-dismiss {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
  line-height: 1;
}
.a2hs-dismiss:hover {
  color: var(--text-primary);
}

/* ===== Push Notification Prompt ===== */
.push-prompt {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 9990;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 4px 16px var(--shadow-md);
  transform: translateX(120%);
  transition: transform 0.3s ease;
  max-width: 340px;
}
.push-prompt.show {
  transform: translateX(0);
}
.push-prompt-content {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}
.push-prompt-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}
.push-prompt-text {
  flex: 1;
}
.push-prompt-text strong {
  font-size: 0.85rem;
  color: var(--text-primary);
}
.push-prompt-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.push-enable {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.push-enable:hover { opacity: 0.9; }
.push-dismiss {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 2px;
  line-height: 1;
}
.push-dismiss:hover { color: var(--text-primary); }

/* ===== Ad slots (in-feed) =====
 * Injected by appendArticleElements() every Nth article when the admin
 * has flipped on Ads. Both sponsored and AdSense share .feed-ad-slot so
 * they line up visually with article cards; .feed-ad-label sits above
 * the body to make ad disclosure unmissable (AdSense ToS requires it
 * and reader trust depends on it). */
.feed-ad-slot {
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}

.feed-ad-slot:last-of-type {
  border-bottom: none;
}

.feed-ad-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

/* Sponsored card — clickable, visually similar to a feed-item but with a
 * subtle tint so readers can tell it apart at a glance. */
.feed-ad-sponsored {
  cursor: pointer;
  background: var(--bg-badge, rgba(0,0,0,0.02));
  border-radius: 4px;
  padding: 0.75rem;
  margin: 0.25rem 0;
}

.feed-ad-sponsored:hover {
  background: var(--bg-surface-hover);
}

.feed-ad-sponsored .feed-ad-body {
  display: flex;
  gap: 12px;
}

.feed-ad-sponsored .feed-ad-image {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 4px;
  overflow: hidden;
}

.feed-ad-sponsored .feed-ad-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feed-ad-sponsored .feed-ad-text {
  flex: 1;
  min-width: 0;
}

.feed-ad-sponsored .feed-ad-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

.feed-ad-sponsored .feed-ad-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

/* AdSense slot — minimal wrapper; AdSense controls its own inner styling. */
.feed-ad-adsense {
  min-height: 90px;  /* reserves space while AdSense fills the <ins> */
}

.feed-ad-adsense .adsbygoogle {
  background: transparent;
}

/* ===== Infinite-scroll sentinel + end-of-feed footer ===== */
.articles-sentinel {
  height: 1px;
  width: 100%;
  /* When the parent feed becomes a 2-column grid (tablet+), make sure these
     trailing elements span the full row so the sentinel always sits at the
     true bottom of the feed and IntersectionObserver triggers reliably. */
  grid-column: 1 / -1;
}

.feed-footer {
  padding: 1rem 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

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

.feed-footer-loading {
  font-style: italic;
  opacity: 0.8;
}

.feed-footer-end {
  font-weight: 500;
  opacity: 0.7;
}

/* ===== Today strip (Ethiopian calendar / FX / on-this-day) =====
   Mobile-first: a horizontally scroll-snapping card row so all three
   widgets are one thumb-swipe away without eating vertical space; becomes
   a 3-up grid from tablet width. ===== */
.today-strip {
  display: flex;
  align-items: stretch;   /* all cards share the tallest card's height */
  gap: 0.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0.4rem 0 0.6rem;
}

.today-strip::-webkit-scrollbar { display: none; }

.today-card {
  flex: 0 0 78%;
  scroll-snap-align: start;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 0.6rem 0.8rem;
}

@media (min-width: 576px) {
  .today-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: stretch;
    overflow-x: visible;
  }
  .today-card { flex: initial; }
}

.today-card-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.today-card-main {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.today-card-main-sm { font-size: 0.92rem; }

.today-card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.today-card-note {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.today-card-note a { color: inherit; text-decoration: underline; }

.today-card-tappable { cursor: pointer; }

.today-card-tappable:hover,
.today-card-tappable:focus-visible {
  border-color: var(--text-muted);
}

.today-fx-rows { display: flex; flex-direction: column; gap: 2px; }

.today-fx-row {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  font-size: 0.88rem;
}

.today-fx-code {
  font-weight: 600;
  color: var(--text-muted);
  width: 2.6em;
  font-size: 0.75rem;
}

.today-fx-value { font-weight: 700; color: var(--text-primary); }

.today-fx-change { font-size: 0.7rem; color: var(--text-muted); }
.today-fx-change.up { color: #c0392b; }   /* birr weakening — costs more */
.today-fx-change.down { color: #1e8e4e; } /* birr strengthening */

/* ===== Feed controls (search + freshness + sort) — mobile-first: one
   wrapping row. Search, when enabled, takes the full first line; the
   freshness indicator and the Recent/Trending pill share the next line
   (freshness left, pill right). With search off the whole block is a
   single compact row, so the feed starts higher up the screen. ===== */
.feed-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin: 0 0 0.6rem;
}

.feed-search {
  flex: 1 1 100%;   /* own line above the freshness/sort row */
  order: 0;
  min-width: 0;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

@media (min-width: 576px) {
  /* Roomy screens keep everything on a single row. */
  .feed-search { flex: 0 1 340px; }
}

/* ===== Feed Sort Toggle (Recent / Trending) ===== */
.feed-sort-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  order: 2;
  margin-left: auto;   /* right-align, sharing the freshness row */
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 2px;
  background: var(--bg-surface);
}

.feed-sort-toggle .sort-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0.4rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
  transition: background-color 120ms ease, color 120ms ease;
}

.feed-sort-toggle .sort-btn:hover {
  color: var(--text-primary);
}

.feed-sort-toggle .sort-btn.active {
  background: var(--accent, #4f46e5);
  color: #fff;
}

.feed-sort-toggle .sort-btn:focus-visible {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: 2px;
}

/* ===== Freshness Indicator — sits inline in the feed-controls row (left
   of the sort pill); #world-freshness keeps its own standalone spacing. ===== */
.freshness-indicator {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

#freshness-indicator {
  order: 1;
  flex: 1 1 auto;
  min-width: 0;
}

/* On phones the freshness line shares its row with the Recent/Trending pill,
   so drop the secondary "next fetch in Xm" half (its separator lives inside
   the span) to keep both on one line instead of wrapping. */
@media (max-width: 575.98px) {
  #freshness-indicator .freshness-next { display: none; }
}

#world-freshness {
  padding: 0.5rem 0 0.75rem;
}

.freshness-indicator:empty {
  display: none;
}

.freshness-warn {
  color: #b45309;
  font-weight: 600;
}

/* ===== Roomy feed header (compact_feed_header flag OFF) — restore the
   original layout: the Today strip with equal-height cards and its former
   spacing, the freshness line on its own row above, and the search + sort
   toggle sharing the row below it. ===== */
.feed-header-roomy .today-strip {
  align-items: stretch;
  gap: 0.6rem;
  margin: 0.75rem 0;
}

.feed-header-roomy .today-card {
  padding: 0.75rem 0.9rem;
  min-height: 92px;
}

.feed-header-roomy .feed-toolbar {
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.feed-header-roomy .feed-search {
  flex: 1 1 auto;
}

@media (min-width: 576px) {
  .feed-header-roomy .feed-search { max-width: 340px; }
}

.feed-header-roomy #freshness-indicator {
  order: -1;
  flex: 1 1 100%;   /* own row above the search/sort line */
  padding: 0.5rem 0 0.75rem;
}

.feed-header-roomy .feed-sort-toggle {
  order: 1;
  margin-left: 0;   /* sits next to the search box, not pushed right */
}

/* ===== Pagination Controls ===== */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  margin-top: 0.5rem;
}

.pagination-controls .pg-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
  margin-bottom: 0.25rem;
}

.pagination-controls .pg-buttons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 0.4rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pg-btn:hover:not(.pg-active):not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--accent);
}

.pg-btn.pg-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.pg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pg-btn.pg-first,
.pg-btn.pg-last {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
}

.pg-ellipsis {
  padding: 0 0.25rem;
  color: var(--text-muted);
}

@media (min-width: 576px) {
  .pagination-controls {
    grid-column: 1 / -1;
  }
}

/* =====================================================================
   History tab — editorial articles + Ethiopia timeline.
   Eras get an accent color so the same era reads consistently across
   article cards, timeline cards, and era chips.
   ===================================================================== */

:root {
  --era-ancient: #b08856;
  --era-medieval: #7a4f7a;
  --era-early_modern: #2f6f6a;
  --era-modern: #c0392b;
  --era-contemporary: #2962ff;
}
html.dark {
  --era-ancient: #d2a673;
  --era-medieval: #b07cb0;
  --era-early_modern: #5cb0a8;
  --era-modern: #e57368;
  --era-contemporary: #6fa1ff;
}

.history-hero { padding-top: 0.5rem; }
.history-hero-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: clamp(1.6rem, 3.4vw, 2.2rem);
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}
.history-hero-sub {
  color: var(--text-secondary);
  max-width: 720px;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.history-section-head {
  display: flex; align-items: baseline; gap: 0.75rem;
  margin-bottom: 1rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}
.history-section-title {
  font-size: 1.15rem; font-weight: 700; margin: 0;
  color: var(--text-primary);
}
.history-section-sub {
  font-size: 0.85rem; color: var(--text-muted);
}

.history-featured { margin-bottom: 1.25rem; }
.history-articles-list {
  display: grid; grid-template-columns: 1fr; gap: 1rem;
}
@media (min-width: 720px) {
  .history-articles-list { grid-template-columns: 1fr 1fr; }
}

.history-article-card {
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.history-article-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.history-article-card--featured {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(13,110,253,0.08);
}
@media (min-width: 720px) {
  .history-article-card--featured {
    flex-direction: row;
    min-height: 220px;
  }
  .history-article-card--featured .history-article-image,
  .history-article-card--featured .history-article-image img { width: 320px; height: 100%; }
  .history-article-card--featured .history-article-image img { object-fit: cover; }
}

.history-article-image { background: var(--bg-skeleton); }
.history-article-image img {
  width: 100%; height: 200px; object-fit: cover; display: block;
}
html.lite-mode .history-article-image { display: none; }

.history-article-body {
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.5rem;
  flex: 1;
}
.history-article-badge {
  align-self: flex-start;
  background: var(--accent); color: white;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.55rem; border-radius: 999px;
}
.history-article-title {
  font-size: 1.1rem; font-weight: 700; margin: 0;
  color: var(--text-primary); line-height: 1.3;
}
.history-article-card--featured .history-article-title { font-size: 1.3rem; }
.history-article-excerpt {
  font-size: 0.92rem; color: var(--text-secondary); line-height: 1.5;
  margin: 0;
}
.history-article-meta {
  font-size: 0.78rem; color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center;
}
.history-article-readmore {
  align-self: flex-start;
  background: none; border: 1px solid var(--border-color);
  color: var(--accent); border-radius: 999px;
  padding: 0.3rem 0.85rem; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.history-article-readmore:hover {
  background: var(--accent); color: white; border-color: var(--accent);
}

/* Era tag chips — appear on cards + meta + timeline */
.era-tag {
  display: inline-block;
  padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--bg-badge); color: var(--text-secondary);
}
.era-tag.era-ancient       { background: color-mix(in srgb, var(--era-ancient) 18%, transparent); color: var(--era-ancient); }
.era-tag.era-medieval      { background: color-mix(in srgb, var(--era-medieval) 18%, transparent); color: var(--era-medieval); }
.era-tag.era-early_modern  { background: color-mix(in srgb, var(--era-early_modern) 18%, transparent); color: var(--era-early_modern); }
.era-tag.era-modern        { background: color-mix(in srgb, var(--era-modern) 18%, transparent); color: var(--era-modern); }
.era-tag.era-contemporary  { background: color-mix(in srgb, var(--era-contemporary) 18%, transparent); color: var(--era-contemporary); }

/* Era filter chips (above the timeline) */
.timeline-era-filters {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin: 0.75rem 0 1.25rem;
}
.era-chip {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.3rem 0.85rem; border-radius: 999px;
  font-size: 0.82rem; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.era-chip:hover { background: var(--bg-surface-hover); }
.era-chip.active {
  background: var(--text-primary); color: var(--bg-surface);
  border-color: var(--text-primary);
}

/* Timeline */
.history-timeline { margin-top: 0.5rem; }
.timeline-group { margin-bottom: 2rem; }
.timeline-group-title {
  font-size: 0.95rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin: 0 0 0.75rem 0;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--border-color);
}
.timeline-group--ancient      .timeline-group-title { color: var(--era-ancient); }
.timeline-group--medieval     .timeline-group-title { color: var(--era-medieval); }
.timeline-group--early_modern .timeline-group-title { color: var(--era-early_modern); }
.timeline-group--modern       .timeline-group-title { color: var(--era-modern); }
.timeline-group--contemporary .timeline-group-title { color: var(--era-contemporary); }

.timeline-list {
  list-style: none; padding: 0; margin: 0;
  position: relative;
}
.timeline-list::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 14px;
  width: 2px;
  background: var(--border-color);
}
@media (min-width: 760px) {
  .timeline-list::before { left: 50%; transform: translateX(-50%); }
}

.timeline-item {
  position: relative;
  padding: 0 0 1.5rem 42px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker {
  position: absolute;
  top: 6px;
  left: 8px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--text-muted);
  box-shadow: 0 0 0 3px var(--bg-page);
  z-index: 1;
}
.timeline-item[data-era="ancient"]      .timeline-marker { border-color: var(--era-ancient); }
.timeline-item[data-era="medieval"]     .timeline-marker { border-color: var(--era-medieval); }
.timeline-item[data-era="early_modern"] .timeline-marker { border-color: var(--era-early_modern); }
.timeline-item[data-era="modern"]       .timeline-marker { border-color: var(--era-modern); }
.timeline-item[data-era="contemporary"] .timeline-marker { border-color: var(--era-contemporary); }

.timeline-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.timeline-year {
  font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 0.25rem;
}
.timeline-title {
  font-size: 1.02rem; font-weight: 700; margin: 0 0 0.4rem;
  color: var(--text-primary); line-height: 1.3;
}
.timeline-body {
  font-size: 0.9rem; color: var(--text-secondary);
  line-height: 1.55; margin: 0 0 0.5rem;
}
.timeline-image img {
  width: 100%; max-height: 220px; object-fit: cover;
  border-radius: 8px; margin: 0.4rem 0;
}
html.lite-mode .timeline-image { display: none; }
.timeline-sources {
  margin-top: 0.4rem;
  font-size: 0.78rem; color: var(--text-muted);
  border-top: 1px dashed var(--border-color);
  padding-top: 0.5rem;
}
.timeline-sources-label { font-weight: 700; margin-right: 0.3rem; }
.timeline-source {
  display: inline-block; margin-right: 0.4rem;
  background: var(--bg-badge); padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

/* Wide-screen alternating layout — odd items left, even items right.
   Smaller screens keep the single-rail layout above, which reads better
   on a phone. */
@media (min-width: 760px) {
  .timeline-item {
    width: 50%;
    padding: 0 0 1.75rem 0;
  }
  .timeline-item:nth-child(odd) {
    padding-right: 36px;
    text-align: right;
  }
  .timeline-item:nth-child(even) {
    margin-left: 50%;
    padding-left: 36px;
  }
  .timeline-item:nth-child(odd) .timeline-marker {
    left: auto; right: -7px;
  }
  .timeline-item:nth-child(even) .timeline-marker {
    left: -7px;
  }
}

/* History reading panel — slide-in modal for full article text */
.history-panel {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 600; display: none;
  overflow-y: auto;
  padding: 2rem 0;
}
.history-panel.open { display: flex; align-items: flex-start; justify-content: center; }
.history-panel-inner {
  background: var(--bg-surface);
  width: min(720px, 95vw);
  border-radius: 14px;
  padding: 1.75rem 1.75rem 2rem;
  position: relative;
  box-shadow: 0 16px 48px rgba(0,0,0,0.25);
  color: var(--text-primary);
}
.history-panel-close {
  position: absolute; top: 0.5rem; right: 0.75rem;
  background: none; border: none;
  font-size: 1.7rem; line-height: 1; cursor: pointer;
  color: var(--text-muted);
}
.history-panel-image {
  width: 100%; max-height: 320px; object-fit: cover;
  border-radius: 10px; margin-bottom: 1rem;
}
html.lite-mode .history-panel-image { display: none; }
.history-panel-meta {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  font-size: 0.8rem; color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.history-panel-title {
  font-size: 1.45rem; font-weight: 700;
  line-height: 1.25; margin: 0 0 0.85rem;
}
.history-panel-body {
  font-size: 1rem; line-height: 1.7;
  color: var(--text-secondary);
}
body.panel-open { overflow: hidden; }

/* ===== Ethiopia Information Hub =====
   Mobile-first: single-column cards, a sticky-feeling search box, and a
   horizontally scrollable category chip row sized for thumbs. Cards become
   a 2-col grid at >=768px and 3-col at >=1200px. All colors come from the
   theme variables, so dark mode needs no extra rules. */

.hub-controls {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.hub-search {
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

/* Category chips: one swipeable row on phones, wrapping on wide screens. */
.hub-cat-filters {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.25rem;
  /* Let the row bleed to the screen edge on phones for a native feel. */
  margin: 0 -0.75rem;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.hub-cat-filters::-webkit-scrollbar { display: none; }

.hub-chip {
  flex: 0 0 auto;
  min-height: 44px; /* comfortable touch target */
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.hub-chip:hover { background: var(--bg-surface-hover); }
.hub-chip.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--bg-surface);
}

.hub-section { margin-bottom: 1.5rem; }
.hub-section-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
  color: var(--text-primary);
}

.hub-grid {
  display: grid;
  grid-template-columns: 1fr; /* phones: one column */
  gap: 0.65rem;
}

.hub-card {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: 0 1px 3px var(--shadow-sm);
  transition: box-shadow 150ms ease, transform 150ms ease;
}
.hub-card:hover,
.hub-card:focus-visible {
  color: var(--text-primary);
  box-shadow: 0 4px 12px var(--shadow-md);
  transform: translateY(-1px);
}

.hub-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.hub-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.hub-cadence {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-badge);
  color: var(--text-muted);
}
.hub-cadence-live  { background: var(--stance-anti-gov-bg); color: var(--stance-anti-gov-text); }
.hub-cadence-daily { background: var(--bg-chat-answer); color: var(--accent); }

.hub-card-desc {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
}

.hub-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.hub-tag {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-badge);
  color: var(--text-muted);
  font-weight: 500;
}
.hub-tag-official      { background: var(--stance-indep-bg); color: var(--stance-indep-text); }
.hub-tag-international { background: var(--bg-chat-answer); color: var(--accent); }

.hub-domain { color: var(--text-faint); }

.hub-note { margin-top: 0.5rem; }

@media (min-width: 768px) {
  .hub-cat-filters {
    flex-wrap: wrap;
    overflow-x: visible;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }
  .hub-grid { grid-template-columns: repeat(2, 1fr); }
  .hub-search { max-width: 420px; }
}

@media (min-width: 1200px) {
  .hub-grid { grid-template-columns: repeat(3, 1fr); }
}

/* =====================================================================
   Ledger tab — a timeline-based, sourced accounting of administration
   actions. Mobile-first single-rail timeline; every size inside
   .ledger-container is in em so the deliberate A−/A+ control rescales
   the whole ledger through one CSS variable (--ledger-zoom). Colors come
   from theme variables plus three kind accents, so dark mode only needs
   the accent overrides below.
   ===================================================================== */

:root {
  --ledger-positive: #1a9c5d;
  --ledger-negative: #d64545;
  --ledger-mixed: #d69e2e;
}
html.dark {
  --ledger-positive: #34c98a;
  --ledger-negative: #ef7070;
  --ledger-mixed: #e6b84c;
}

.ledger-hero p { max-width: 720px; }

/* Toolbar: chips on one swipeable row (like the Hub), tools beside/below. */
.ledger-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.ledger-kind-filters {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 100%;
}
.ledger-kind-filters::-webkit-scrollbar { display: none; }

.ledger-chip {
  flex: 0 0 auto;
  min-height: 44px; /* comfortable touch target */
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.ledger-chip:hover { background: var(--bg-surface-hover); }
.ledger-chip.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--bg-surface);
}
/* Active kind chips take their kind's accent so the filter state reads
   at a glance. */
.ledger-chip--positive.active { background: var(--ledger-positive); border-color: var(--ledger-positive); color: #fff; }
.ledger-chip--negative.active { background: var(--ledger-negative); border-color: var(--ledger-negative); color: #fff; }
.ledger-chip--mixed.active    { background: var(--ledger-mixed);    border-color: var(--ledger-mixed);    color: #fff; }

.ledger-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.ledger-tool-btn {
  min-height: 44px;
  min-width: 44px; /* big enough that taps are always intentional */
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.ledger-tool-btn:hover:not(:disabled) { background: var(--bg-surface-hover); }
.ledger-tool-btn:disabled { opacity: 0.4; cursor: default; }

.ledger-zoom {
  display: flex;
  gap: 0;
  border-radius: 8px;
  overflow: hidden;
}
.ledger-zoom .ledger-tool-btn { border-radius: 0; }
.ledger-zoom .ledger-tool-btn:first-child { border-radius: 8px 0 0 8px; }
.ledger-zoom .ledger-tool-btn:last-child { border-radius: 0 8px 8px 0; }
.ledger-zoom .ledger-tool-btn + .ledger-tool-btn { border-left: none; }

/* Running tally — the at-a-glance accounting. */
.ledger-tally { margin-bottom: 1.25rem; }
.ledger-tally:empty { margin-bottom: 0; }
.ledger-tally-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.ledger-tally-item strong { font-weight: 700; }
.ledger-tally-item--positive strong { color: var(--ledger-positive); }
.ledger-tally-item--negative strong { color: var(--ledger-negative); }
.ledger-tally-item--mixed strong    { color: var(--ledger-mixed); }
.ledger-tally-bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-badge);
}
.ledger-tally-seg--positive { background: var(--ledger-positive); }
.ledger-tally-seg--negative { background: var(--ledger-negative); }
.ledger-tally-seg--mixed    { background: var(--ledger-mixed); }

/* Timeline — a single left rail on every screen size (a ledger reads top
   to bottom); wide screens just cap the line length for readability.
   font-size is the zoom hook: card styles below are all in em. */
.ledger-container {
  --ledger-zoom: 1;
  font-size: calc(1rem * var(--ledger-zoom));
  max-width: 860px;
}

.ledger-year-group { margin-bottom: 1.75em; }
.ledger-year-title {
  font-size: 1.05em;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  margin: 0 0 0.75em;
  padding-bottom: 0.3em;
  border-bottom: 1px dashed var(--border-color);
}

.ledger-list {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.ledger-list::before {
  content: '';
  position: absolute;
  top: 0.4em; bottom: 0.4em;
  left: 0.5em;
  width: 2px;
  background: var(--border-color);
}

.ledger-item {
  position: relative;
  padding: 0 0 1.1em 2em;
}
.ledger-item:last-child { padding-bottom: 0; }

.ledger-marker {
  position: absolute;
  top: 0.45em;
  left: calc(0.5em - 5px);
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 3px solid var(--text-muted);
  box-shadow: 0 0 0 3px var(--bg-page);
  z-index: 1;
}
.ledger-item[data-kind="positive"] .ledger-marker { border-color: var(--ledger-positive); }
.ledger-item[data-kind="negative"] .ledger-marker { border-color: var(--ledger-negative); }
.ledger-item[data-kind="mixed"]    .ledger-marker { border-color: var(--ledger-mixed); }

.ledger-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 0.8em 1em;
}
.ledger-item[data-kind="positive"] .ledger-card { border-left-color: var(--ledger-positive); }
.ledger-item[data-kind="negative"] .ledger-card { border-left-color: var(--ledger-negative); }
.ledger-item[data-kind="mixed"]    .ledger-card { border-left-color: var(--ledger-mixed); }

.ledger-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45em;
  margin-bottom: 0.35em;
}
.ledger-date {
  font-size: 0.78em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.ledger-kind {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15em 0.65em;
  border-radius: 999px;
  color: #fff;
}
.ledger-kind--positive { background: var(--ledger-positive); }
.ledger-kind--negative { background: var(--ledger-negative); }
.ledger-kind--mixed    { background: var(--ledger-mixed); }
html.dark .ledger-kind { color: #1a1a1a; }

.ledger-cat {
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  background: var(--bg-badge);
  color: var(--text-secondary);
}

.ledger-title {
  font-size: 1em;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 0.35em;
  color: var(--text-primary);
}
.ledger-body {
  font-size: 0.9em;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0 0 0.4em;
}

.ledger-sources {
  margin-top: 0.35em;
  padding-top: 0.45em;
  border-top: 1px dashed var(--border-color);
  font-size: 0.78em;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35em;
}
.ledger-sources-label { font-weight: 700; }
.ledger-source {
  display: inline-block;
  background: var(--bg-badge);
  padding: 0.2em 0.6em;
  border-radius: 999px;
  color: var(--text-secondary);
  text-decoration: none;
}
a.ledger-source:hover,
a.ledger-source:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.ledger-note { margin-top: 1.25rem; max-width: 720px; }

/* ===== Today tab: top stories =====
   The Today tab's lead-story hero card and its section header. The rest of
   the list reuses the standard .feed-item rows, so type, spacing, and
   interactions stay consistent with the Articles feed. */
.today-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem 0 0.5rem;
}

.today-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.today-seeall {
  background: none;
  border: none;
  padding: 0.25rem 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

.today-seeall:hover { text-decoration: underline; }

.today-hero {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: box-shadow 150ms ease;
}

.today-hero:hover { box-shadow: 0 4px 16px var(--shadow-sm); }

/* Fixed box so the lazy image can't shift layout while it loads. */
.today-hero-img {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-skeleton);
}

.today-hero-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.today-hero-body { padding: 0.8rem 0.9rem 0.9rem; }

.today-hero-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0.35rem 0 0.3rem;
  color: var(--text-primary);
}

.today-hero-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* Same bandwidth/preference controls as feed thumbnails. */
.lite-mode .today-hero-img,
.article-imgs-off .today-hero-img { display: none; }
