* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  overflow: hidden;
  height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: #111;
  border-bottom: 1px solid #222;
  z-index: 1000;
  gap: 12px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-left h1 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.header-left .subtitle {
  font-size: 11px;
  color: #666;
  display: block;
}

.menu-btn {
  display: none;
  background: none;
  border: 1px solid #333;
  border-radius: 4px;
  color: #888;
  font-size: 18px;
  padding: 4px 8px;
  cursor: pointer;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.search-box {
  display: flex;
  gap: 0;
}

.search-box input {
  background: #1a1a1a;
  border: 1px solid #333;
  border-right: none;
  border-radius: 6px 0 0 6px;
  padding: 7px 14px;
  color: #fff;
  font-size: 13px;
  width: 220px;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: #4a9eff;
}

.search-box button {
  background: #4a9eff;
  border: none;
  border-radius: 0 6px 6px 0;
  padding: 7px 16px;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.search-box button:hover {
  background: #3a8eef;
}

/* Time filter */
.time-filter {
  display: flex;
  gap: 4px;
}

.filter-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 5px 12px;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: #4a9eff;
  color: #ccc;
}

.filter-btn.active {
  background: #4a9eff22;
  border-color: #4a9eff;
  color: #4a9eff;
}

/* Icon buttons (filter, sidebar, heatmap) */
.icon-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 5px 10px;
  color: #888;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  border-color: #4a9eff;
  color: #4a9eff;
}

.icon-btn.active {
  background: #4a9eff22;
  border-color: #4a9eff;
  color: #4a9eff;
}

.refresh-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 5px 10px;
  color: #888;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.refresh-btn:hover {
  border-color: #4a9eff;
  color: #4a9eff;
}

.lang-btn {
  background: #4a9eff;
  border: none;
  border-radius: 4px;
  padding: 5px 12px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  letter-spacing: 0.5px;
}

.lang-btn:hover {
  background: #3a8eef;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #999;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.blinking-dot {
  background: #ff4444;
  animation: blink 1.2s ease-in-out infinite;
  box-shadow: 0 0 6px #ff4444;
}

.old-dot {
  background: #4a9eff;
  opacity: 0.7;
}

.stats {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

.stats #newsCount {
  color: #4a9eff;
  font-weight: 700;
}

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 20px;
  background: #0d0d0d;
  border-bottom: 1px solid #1a1a1a;
  font-size: 11px;
  color: #555;
  z-index: 999;
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-bar.refreshing {
  animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { background: #0d0d0d; }
  50% { background: #141420; }
}

/* News Ticker */
.ticker-bar {
  height: 32px;
  overflow: hidden;
  background: #0a0a0a;
  border-bottom: 1px solid #1a1a1a;
  flex-shrink: 0;
  position: relative;
  z-index: 997;
}

.ticker-track {
  display: flex;
  align-items: center;
  white-space: nowrap;
  height: 32px;
  animation: tickerScroll var(--ticker-duration, 15s) linear infinite;
}

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

.ticker-label {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  font-size: 10px;
  font-weight: 700;
  color: #ff4444;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 32px;
  background: #1a0a0a;
  border-right: 1px solid #2a1a1a;
  white-space: nowrap;
  flex-shrink: 0;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  padding: 0 20px;
  font-size: 12px;
  color: #bbb;
  cursor: pointer;
  line-height: 32px;
  transition: color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  gap: 6px;
}

.ticker-item:hover {
  color: #4a9eff;
}

.ticker-item.ticker-placeholder {
  color: #555;
  cursor: default;
  font-style: italic;
}

.ticker-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.ticker-dot-today {
  background: #ff4444;
  box-shadow: 0 0 4px rgba(255, 68, 68, 0.6);
  animation: blink 1.2s ease-in-out infinite;
}

.ticker-dot-older {
  background: #4a9eff;
  opacity: 0.6;
}

.ticker-source {
  color: #4a9eff;
  font-weight: 600;
  font-size: 11px;
}

.ticker-item::after {
  content: "|";
  margin-left: 20px;
  color: #222;
  font-weight: 300;
}

@keyframes tickerScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@keyframes tickerScrollRTL {
  from { transform: translateX(0); }
  to { transform: translateX(50%); }
}

/* Error banner */
.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: #3b1010;
  border-bottom: 1px solid #5a2020;
  color: #ff6b6b;
  font-size: 13px;
  z-index: 999;
  flex-shrink: 0;
}

.error-banner.hidden {
  display: none;
}

.error-banner button {
  background: none;
  border: none;
  color: #ff6b6b;
  font-size: 18px;
  cursor: pointer;
}

/* Filter panel */
.filter-panel {
  background: #111;
  border-bottom: 1px solid #222;
  padding: 12px 20px;
  z-index: 998;
  flex-shrink: 0;
  transition: max-height 0.3s ease;
}

.filter-panel.hidden {
  display: none;
}

.filter-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #aaa;
}

.filter-panel-header button {
  background: none;
  border: none;
  color: #666;
  font-size: 20px;
  cursor: pointer;
}

.filter-panel-header button:hover {
  color: #fff;
}

/* Category pills */
.filter-categories {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.cat-pill {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 20px;
  padding: 4px 14px;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.cat-pill:hover {
  border-color: #4a9eff;
  color: #ccc;
}

.cat-pill.active {
  background: #4a9eff;
  border-color: #4a9eff;
  color: #fff;
}

.cat-pill[data-cat="conflict"].active { background: #ff4444; border-color: #ff4444; }
.cat-pill[data-cat="osint"].active { background: #b07aff; border-color: #b07aff; }
.cat-pill[data-cat="politics"].active { background: #4a9eff; border-color: #4a9eff; }
.cat-pill[data-cat="economy"].active { background: #ffcc00; border-color: #ffcc00; color: #111; }
.cat-pill[data-cat="tech"].active { background: #4aefaa; border-color: #4aefaa; color: #111; }
.cat-pill[data-cat="health"].active { background: #ff6baa; border-color: #ff6baa; }
.cat-pill[data-cat="environment"].active { background: #44cc88; border-color: #44cc88; color: #111; }
.cat-pill[data-cat="crime"].active { background: #ff8844; border-color: #ff8844; }
.cat-pill[data-cat="general"].active { background: #888; border-color: #888; }

/* Source checkboxes */
.filter-sources {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 4px;
}

.filter-sources::-webkit-scrollbar {
  width: 4px;
}

.filter-sources::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

.source-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #999;
  transition: background 0.15s;
}

.source-checkbox:hover {
  background: #1a1a1a;
  color: #ccc;
}

.source-checkbox input {
  accent-color: #4a9eff;
  cursor: pointer;
}

.cat-badge {
  margin-left: auto;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.cat-conflict { background: #3a1a1a; color: #ff6b6b; }
.cat-osint { background: #2a1a3a; color: #b07aff; }
.cat-politics { background: #1a2a3a; color: #4a9eff; }
.cat-economy { background: #3a3a1a; color: #ffcc00; }
.cat-tech { background: #1a3a2a; color: #4aefaa; }
.cat-health { background: #3a1a2a; color: #ff6baa; }
.cat-environment { background: #1a3a2a; color: #44cc88; }
.cat-crime { background: #3a2a1a; color: #ff8844; }
.cat-general { background: #2a2a2a; color: #888; }

/* Map */
#map {
  flex: 1;
  z-index: 1;
}

/* Custom Leaflet tile - dark mode */
.leaflet-container {
  background: #0a0a0a;
}

/* Marker styles */
.news-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  transition: transform 0.2s;
}

.news-marker:hover {
  transform: scale(1.5);
  z-index: 10000 !important;
}

.news-marker.today {
  background: #ff4444;
  box-shadow: 0 0 10px rgba(255, 68, 68, 0.6);
  animation: blink 1.2s ease-in-out infinite;
}

.news-marker.older {
  background: #4a9eff;
  opacity: 0.7;
  box-shadow: 0 0 6px rgba(74, 158, 255, 0.3);
}

@keyframes blink {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.8);
  }
  50% {
    opacity: 0.3;
    box-shadow: 0 0 4px rgba(255, 68, 68, 0.2);
  }
}

/* Marker cluster overrides */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(74, 158, 255, 0.2) !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: rgba(74, 158, 255, 0.6) !important;
  color: #fff !important;
  font-weight: 700;
  font-size: 12px;
}

/* Has-today clusters get red tint */
.cluster-has-today {
  background: rgba(255, 68, 68, 0.2) !important;
  animation: blink-cluster 1.5s ease-in-out infinite;
}

.cluster-has-today div {
  background: rgba(255, 68, 68, 0.6) !important;
}

@keyframes blink-cluster {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Popup */
.leaflet-popup-content-wrapper {
  background: #1a1a1a;
  color: #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
}

.leaflet-popup-tip {
  background: #1a1a1a;
}

.leaflet-popup-close-button {
  color: #666 !important;
}

.popup-content {
  max-width: 300px;
  padding: 4px;
}

.popup-content h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
  color: #fff;
}

.popup-content .popup-meta {
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.popup-content .popup-meta .today-badge {
  background: #ff4444;
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  animation: blink 1.2s ease-in-out infinite;
}

.popup-content .popup-source {
  font-size: 11px;
  color: #4a9eff;
}

.popup-content a {
  color: #4a9eff;
  text-decoration: none;
  font-size: 12px;
  display: inline-block;
  margin-top: 4px;
}

.popup-content .popup-desc {
  font-size: 12px;
  color: #aaa;
  line-height: 1.4;
  margin-bottom: 6px;
}

.popup-content .popup-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}

.popup-content .popup-location {
  font-size: 11px;
  color: #999;
}

.popup-content .popup-location::before {
  content: "\1F4CD ";
}

.popup-content a:hover {
  text-decoration: underline;
}

.popup-content .popup-image {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 8px;
}

/* Sidebar */
.sidebar {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 380px;
  background: #111;
  border-left: 1px solid #222;
  z-index: 2000;
  overflow-y: auto;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.sidebar.hidden {
  transform: translateX(100%);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #ccc;
}

#closeSidebar {
  background: none;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
}

#closeSidebar:hover {
  color: #fff;
}

.sidebar-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar-cards::-webkit-scrollbar {
  width: 4px;
}

.sidebar-cards::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

.sidebar-empty {
  text-align: center;
  padding: 40px 20px;
  color: #555;
  font-size: 14px;
}

/* News cards in sidebar */
.news-card {
  background: #1a1a1a;
  border: 1px solid #252525;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.news-card:hover {
  border-color: #4a9eff;
  background: #1e1e2e;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.card-source {
  font-size: 11px;
  color: #4a9eff;
  font-weight: 600;
}

.card-badge {
  background: #ff4444;
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  animation: blink 1.2s ease-in-out infinite;
}

.card-time {
  font-size: 11px;
  color: #555;
  margin-left: auto;
}

.card-title {
  font-size: 13px;
  color: #ddd;
  line-height: 1.35;
  font-weight: 500;
}

.card-location {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
}

.card-location::before {
  content: "\1F4CD ";
}

/* Loading */
.loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.9);
  z-index: 9999;
  transition: opacity 0.3s;
}

.loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #333;
  border-top: 3px solid #4a9eff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 14px;
}

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

.loading p {
  color: #888;
  font-size: 14px;
}

/* Feature 1: Story Grouping — marker badge + popup sources */
.marker-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #4a9eff;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  pointer-events: none;
  z-index: 10;
}

.popup-sources-section {
  border-top: 1px solid #333;
  margin-top: 8px;
  padding-top: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.popup-sources-header {
  font-size: 11px;
  color: #888;
  margin-bottom: 4px;
  font-weight: 600;
}

.popup-source-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  margin: 2px 0;
  background: #222;
  border-radius: 4px;
  color: #4a9eff !important;
  font-size: 11px;
  text-decoration: none !important;
  transition: background 0.15s;
}

.popup-source-link:hover {
  background: #2a2a3a;
}

.popup-source-link-name {
  font-weight: 600;
}

.popup-source-link-time {
  color: #666;
  font-size: 10px;
}

.card-source-count {
  font-size: 10px;
  color: #888;
  background: #222;
  padding: 1px 6px;
  border-radius: 3px;
}

/* Feature 2: Breaking News Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}

.toast {
  background: #1a1a1a;
  border: 1px solid #333;
  border-left: 3px solid #4a9eff;
  border-radius: 8px;
  padding: 10px 12px;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.toast-alert {
  border-left-color: #ff4444;
}

.toast-info {
  border-left-color: #4a9eff;
}

.toast-visible {
  transform: translateX(0);
  opacity: 1;
}

.toast-dismissed {
  transform: translateX(120%);
  opacity: 0;
}

.toast-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.toast-breaking {
  font-size: 10px;
  font-weight: 700;
  color: #ff4444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toast-cat-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 600;
}

.toast-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
}

.toast-dismiss:hover {
  color: #fff;
}

.toast-title {
  font-size: 13px;
  color: #ddd;
  line-height: 1.3;
  font-weight: 500;
}

.toast-location {
  font-size: 11px;
  color: #666;
  margin-top: 3px;
}

.toast-location::before {
  content: "\1F4CD ";
}

/* Feature 3: Timeline Playback */
.timeline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: #111;
  border-top: 1px solid #222;
  z-index: 998;
  flex-shrink: 0;
}

.timeline.hidden {
  display: none;
}

.timeline-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 4px 10px;
  color: #888;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.timeline-btn:hover {
  border-color: #4a9eff;
  color: #4a9eff;
}

.timeline-speed-btn {
  font-size: 11px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}

.timeline-scrubber {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-scrubber input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
}

.timeline-scrubber input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #4a9eff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(74, 158, 255, 0.5);
}

.timeline-scrubber input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #4a9eff;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 6px rgba(74, 158, 255, 0.5);
}

.timeline-date-label {
  font-size: 10px;
  color: #666;
  white-space: nowrap;
}

.timeline-current-label {
  font-size: 11px;
  color: #4a9eff;
  font-weight: 600;
  white-space: nowrap;
  min-width: 100px;
  text-align: center;
}

/* Feature 4: Statistics Dashboard */
.stats-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #111;
  border-top: 1px solid #222;
  max-height: 280px;
  z-index: 1500;
  overflow: hidden;
}

.stats-panel.hidden {
  display: none;
}

.stats-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid #222;
}

.stats-panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: #ccc;
}

.stats-panel-header button {
  background: none;
  border: none;
  color: #666;
  font-size: 20px;
  cursor: pointer;
}

.stats-panel-header button:hover {
  color: #fff;
}

.stats-charts {
  display: flex;
  padding: 10px 16px;
  gap: 16px;
}

.chart-container {
  flex: 1;
  text-align: center;
}

.chart-container h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  margin-bottom: 6px;
  font-weight: 600;
}

.chart-container canvas {
  display: block;
  margin: 0 auto;
}

/* RTL / Arabic mode */
body.rtl {
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Cairo", sans-serif;
  overflow-x: hidden;
}

html[dir="rtl"] {
  overflow-x: hidden;
}

body.rtl #header {
  flex-direction: row-reverse;
}

body.rtl .header-left {
  text-align: right;
  flex-direction: row-reverse;
}

body.rtl .header-right {
  flex-direction: row-reverse;
}

body.rtl .header-center {
  flex-direction: row-reverse;
}

body.rtl .search-box {
  flex-direction: row-reverse;
}

body.rtl .search-box input {
  border-radius: 0 6px 6px 0;
  border-right: 1px solid #333;
  border-left: none;
  text-align: right;
  direction: rtl;
}

body.rtl .search-box button {
  border-radius: 6px 0 0 6px;
}

body.rtl .legend {
  flex-direction: row-reverse;
}

body.rtl .time-filter {
  flex-direction: row-reverse;
}

body.rtl .filter-categories {
  flex-direction: row-reverse;
}

body.rtl .popup-content.popup-rtl {
  direction: rtl;
  text-align: right;
}

body.rtl .popup-content.popup-rtl .popup-meta {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

body.rtl .popup-content.popup-rtl .popup-footer {
  flex-direction: row-reverse;
}

body.rtl .sidebar {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid #222;
}

body.rtl .sidebar.hidden {
  transform: translateX(-100%);
}

body.rtl .sidebar-header {
  flex-direction: row-reverse;
}

body.rtl .card-top {
  flex-direction: row-reverse;
}

body.rtl .card-time {
  margin-left: 0;
  margin-right: auto;
}

body.rtl .card-title {
  text-align: right;
  direction: rtl;
}

body.rtl .status-bar {
  flex-direction: row-reverse;
}

/* RTL: Story Grouping */
body.rtl .marker-badge {
  right: auto;
  left: -8px;
}

body.rtl .popup-source-link {
  flex-direction: row-reverse;
}

body.rtl .card-source-count {
  margin-left: 0;
}

/* RTL: Toasts */
body.rtl .toast-container {
  right: auto;
  left: 20px;
}

body.rtl .toast {
  transform: translateX(-120%);
  border-left: 1px solid #333;
  border-right: 3px solid #4a9eff;
}

body.rtl .toast-alert {
  border-right-color: #ff4444;
}

body.rtl .toast-info {
  border-right-color: #4a9eff;
}

body.rtl .toast-visible {
  transform: translateX(0);
}

body.rtl .toast-dismissed {
  transform: translateX(-120%);
}

body.rtl .toast-header {
  flex-direction: row-reverse;
}

body.rtl .toast-dismiss {
  margin-left: 0;
  margin-right: auto;
}

body.rtl .toast-title {
  text-align: right;
  direction: rtl;
}

/* RTL: Timeline */
body.rtl .timeline {
  flex-direction: row-reverse;
}

body.rtl .timeline-scrubber {
  flex-direction: row-reverse;
  direction: rtl;
}

/* RTL: Stats */
body.rtl .stats-panel-header {
  flex-direction: row-reverse;
}

body.rtl .stats-charts {
  flex-direction: row-reverse;
}

body.rtl .ticker-track {
  animation-name: tickerScrollRTL;
}

body.rtl .ticker-label {
  border-right: none;
  border-left: 1px solid #2a1a1a;
}

body.rtl .ticker-item {
  direction: rtl;
}

body.rtl .ticker-item::after {
  margin-left: 0;
  margin-right: 20px;
}

body.rtl .filter-panel-header {
  flex-direction: row-reverse;
}

body.rtl .source-checkbox {
  flex-direction: row-reverse;
}

body.rtl .cat-badge {
  margin-left: 0;
  margin-right: auto;
}


/* ---- Video embedding styles ---- */
.video-container {
  position: relative;
  width: 100%;
  margin-bottom: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
}

.popup-video-iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 4px;
}

.popup-video {
  width: 100%;
  max-height: 180px;
  display: block;
  border-radius: 4px;
}

.video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 0, 0, 0.85);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.video-play-overlay:hover {
  transform: translate(-50%, -50%) scale(1.1);
  background: rgba(255, 0, 0, 1);
}

.video-badge {
  background: #cc0000;
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.card-video-badge {
  background: #cc0000;
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
}

.marker-video-badge {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: #cc0000;
  color: #fff;
  font-size: 7px;
  width: 12px;
  height: 12px;
  line-height: 12px;
  text-align: center;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
}

.twitter-embed {
  margin: 8px 0;
  min-height: 100px;
  border-radius: 4px;
  overflow: hidden;
}

/* Video page type - opens video in new tab */
.video-page-link {
  text-decoration: none;
  color: #fff;
}
.video-page-noimg {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  padding: 16px;
  text-align: center;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-page-btn {
  display: inline-block;
  background: rgba(255, 0, 0, 0.85);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
}
.video-page-btn:hover {
  background: rgba(255, 0, 0, 1);
  transform: scale(1.05);
}

.twitter-embed iframe {
  border-radius: 4px !important;
}

body.rtl .video-badge {
  order: -1;
}

body.rtl .card-video-badge {
  order: -1;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  #header {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }

  .menu-btn {
    display: block;
  }

  .header-left .subtitle {
    display: none;
  }

  .header-left h1 {
    font-size: 18px;
  }

  .header-center {
    order: 3;
    flex: 0 0 100%;
    justify-content: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .search-box {
    width: 100%;
  }

  .search-box input {
    flex: 1;
    width: auto;
  }

  .time-filter {
    width: 100%;
    justify-content: center;
  }

  .header-right {
    gap: 8px;
  }

  /* Hide these in mobile by default, show when menu open */
  .legend,
  .stats {
    display: none;
  }

  #header.menu-open .legend,
  #header.menu-open .stats {
    display: flex;
  }

  .popup-video-iframe {
    max-height: 160px;
  }

  .popup-video {
    max-height: 140px;
  }

  .video-play-overlay {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .sidebar {
    width: 100%;
  }

  .ticker-bar {
    height: 28px;
  }

  .ticker-track {
    height: 28px;
  }

  .ticker-item {
    font-size: 11px;
    padding: 0 14px;
    line-height: 28px;
  }

  .ticker-label {
    font-size: 9px;
    padding: 0 10px;
    line-height: 28px;
  }

  .ticker-item::after {
    margin-left: 14px;
  }

  .filter-panel {
    padding: 10px 12px;
  }

  .filter-sources {
    grid-template-columns: 1fr;
  }

  .status-bar {
    padding: 4px 12px;
    font-size: 10px;
  }

  /* Mobile: Toasts */
  .toast-container {
    right: 10px;
    left: 10px;
    max-width: none;
    bottom: 10px;
  }

  body.rtl .toast-container {
    right: 10px;
    left: 10px;
  }

  /* Mobile: Timeline */
  .timeline {
    padding: 4px 10px;
    gap: 4px;
  }

  .timeline-date-label {
    display: none;
  }

  .timeline-current-label {
    font-size: 10px;
    min-width: 70px;
  }

  /* Mobile: Stats */
  .stats-panel {
    max-height: 50vh;
    overflow-y: auto;
  }

  .stats-charts {
    flex-direction: column;
    align-items: center;
  }

  .chart-container {
    width: 100%;
    max-width: 280px;
  }
}

@media (max-width: 480px) {
  .icon-btn {
    padding: 4px 8px;
    font-size: 12px;
  }

  .refresh-btn {
    padding: 4px 8px;
    font-size: 14px;
  }

  .lang-btn {
    padding: 4px 10px;
    font-size: 11px;
  }

  .filter-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
}

/* ===== Mobile + RTL (Arabic) overrides ===== */
@media (max-width: 768px) {
  /* Don't use row-reverse on #header wrapper — it breaks flex-wrap on mobile.
     Instead, swap header-left / header-right with order and reverse their contents. */
  body.rtl #header {
    flex-direction: row;
    flex-wrap: wrap;
  }

  body.rtl .header-left {
    order: 2;
    flex-direction: row-reverse;
    margin-left: 0;
  }

  body.rtl .header-right {
    order: 1;
    flex-direction: row-reverse;
    gap: 6px;
  }

  body.rtl .header-center {
    order: 3;
    flex-direction: column !important;
    flex: 0 0 100%;
    gap: 8px;
  }

  body.rtl .search-box {
    flex-direction: row-reverse;
    width: 100%;
  }

  body.rtl .search-box input {
    flex: 1;
    width: auto;
    text-align: right;
    direction: rtl;
  }

  body.rtl .search-box button {
    border-radius: 6px 0 0 6px;
  }

  body.rtl .time-filter {
    flex-direction: row-reverse;
    width: 100%;
    justify-content: center;
  }

  body.rtl .filter-btn {
    padding: 5px 10px;
    font-size: 12px;
  }

  body.rtl .status-bar {
    flex-direction: row-reverse;
    font-size: 10px;
    text-align: right;
  }

  body.rtl .sidebar {
    right: 0;
    left: auto;
    width: 100%;
    border-left: 1px solid #222;
    border-right: none;
  }

  body.rtl .sidebar.hidden {
    transform: translateX(100%);
  }

  body.rtl .ticker-label {
    font-size: 9px;
  }

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

@media (max-width: 480px) {
  body.rtl .filter-btn {
    padding: 4px 8px;
    font-size: 11px;
  }

  body.rtl .icon-btn {
    padding: 4px 6px;
    font-size: 11px;
  }

  body.rtl .lang-btn {
    padding: 4px 8px;
    font-size: 10px;
  }
}


/* ===== Category Chips (floating on map) ===== */
.map-category-bar {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(17, 17, 17, 0.85);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  border: 1px solid #333;
  overflow-x: auto;
  max-width: 90vw;
  scrollbar-width: none;
}

.map-category-bar::-webkit-scrollbar {
  display: none;
}

.map-cat-chip {
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 14px;
  padding: 4px 12px;
  color: #999;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.map-cat-chip:hover {
  border-color: #4a9eff;
  color: #ccc;
}

.map-cat-chip.active {
  background: #4a9eff22;
  border-color: #4a9eff;
  color: #4a9eff;
}

body.rtl .map-category-bar {
  flex-direction: row-reverse;
}

/* ===== Mobile toast improvements ===== */
@media (max-width: 768px) {
  .toast {
    padding: 8px 12px;
    font-size: 12px;
    max-width: 280px;
  }

  .toast-title {
    font-size: 12px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .toast-location {
    font-size: 10px;
  }

  .toast-breaking {
    font-size: 9px;
  }

  .map-category-bar {
    bottom: 36px;
    padding: 4px 8px;
    gap: 4px;
  }

  .map-cat-chip {
    padding: 3px 8px;
    font-size: 10px;
  }
}
