/* ============================================================
   مَرصَد · Modern Editorial Design System v2.0
   ============================================================ */

:root {
  /* === Color Palette: Modern Clean === */
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50:  #f8fafc;

  --accent-900: #7c2d12;
  --accent-700: #c2410c;
  --accent-600: #ea580c;
  --accent-500: #f97316;
  --accent-400: #fb923c;
  --accent-100: #ffedd5;
  --accent-50:  #fff7ed;

  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --gold: #ca8a04;
  --blue: #3b82f6;

  /* === Semantic === */
  --bg: var(--ink-50);
  --bg-elevated: #ffffff;
  --bg-muted: var(--ink-100);
  --border: var(--ink-200);
  --border-strong: var(--ink-300);
  --text: var(--ink-900);
  --text-secondary: var(--ink-600);
  --text-muted: var(--ink-500);
  --accent: var(--accent-600);
  --accent-hover: var(--accent-700);
  --accent-soft: var(--accent-50);

  /* === Typography === */
  --font-display: 'Cairo', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', 'Cairo', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Consolas', monospace;
  --font-serif: 'Amiri', Georgia, serif;

  /* === Spacing & Shape === */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* === Shadows (subtle, modern) === */
  --shadow-xs: 0 1px 2px 0 rgb(15 23 42 / 0.04);
  --shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.07), 0 1px 2px -1px rgb(15 23 42 / 0.05);
  --shadow-md: 0 4px 12px -2px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.04);
  --shadow-lg: 0 12px 24px -6px rgb(15 23 42 / 0.1), 0 4px 8px -4px rgb(15 23 42 / 0.05);
  --shadow-xl: 0 24px 48px -12px rgb(15 23 42 / 0.18);
  --shadow-accent: 0 8px 24px -6px rgb(249 115 22 / 0.25);

  /* === Motion === */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

*::before,
*::after {
  box-sizing: border-box;
}

/* HTML [hidden] must always win over CSS display */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  font-feature-settings: "kern" 1, "liga" 1;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  font-size: 15px;
  /* English numbers inside RTL */
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Force LTR English numerals even in RTL context */
.num,
.stat-num,
.engagement-item strong,
input[type="number"],
.post-time,
time {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  unicode-bidi: plaintext;
}

/* ================================================================
   Grain & background decorations
   ================================================================ */
.grain {
  display: none; /* أزلنا الحبيبات للتصميم الأنظف */
}

.bg-decoration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

#appRoot {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#appRoot .posts-grid {
  flex: 1 0 auto;
  min-height: 50vh;
}

#appRoot .footer-simple {
  margin-top: auto;
}

.circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.08;
  animation: float 20s ease-in-out infinite;
}

.c1 {
  width: 600px;
  height: 600px;
  background: var(--accent);
  top: -250px;
  left: -150px;
}

.c2 {
  width: 500px;
  height: 500px;
  background: var(--blue);
  bottom: -200px;
  right: -150px;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(40px, -30px); }
}

/* ================================================================
   Header
   ================================================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.logo-mark {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 8px;
  background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-accent);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: white;
  display: block;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.dot-1 { animation: blink 2s infinite; }
.dot-2 { animation: blink 2s infinite 0.3s; opacity: 0.65; }
.dot-3 { animation: blink 2s infinite 0.6s; opacity: 0.35; }

@keyframes blink {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--ink-900), var(--ink-700));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.01em;
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  flex-wrap: wrap;
}

.last-update {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 7px 14px;
  background: var(--ink-100);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-weight: 500;
}

.pulse {
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ================================================================
   Buttons
   ================================================================ */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease);
  font-weight: 600;
  letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button:active {
  transform: scale(0.97);
}

.btn-refresh {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-refresh:hover {
  background: var(--ink-100);
  border-color: var(--border-strong);
}

.btn-refresh:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-trigger {
  background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
  color: white;
  box-shadow: var(--shadow-accent);
}

.btn-trigger:hover {
  box-shadow: 0 12px 32px -6px rgb(249 115 22 / 0.4);
  transform: translateY(-1px);
}

/* ================================================================
   Facebook brand button — polished "Open on Facebook" CTA
   ================================================================ */
.btn-facebook {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1.25rem;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  background: linear-gradient(135deg, #1877F2 0%, #0866FF 50%, #0A5BE0 100%);
  color: #ffffff !important;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none !important;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 4px 12px -2px rgba(24, 119, 242, 0.45),
    0 2px 4px -1px rgba(24, 119, 242, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-facebook::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), transparent 55%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.btn-facebook::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.btn-facebook:hover {
  transform: translateY(-2px);
  box-shadow:
    0 10px 24px -4px rgba(24, 119, 242, 0.55),
    0 4px 8px -2px rgba(24, 119, 242, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, #1a85ff 0%, #1571ff 50%, #0d62e5 100%);
}

.btn-facebook:hover::before {
  opacity: 1;
}

.btn-facebook:hover::after {
  left: 140%;
}

.btn-facebook:active {
  transform: translateY(0);
  box-shadow:
    0 2px 6px -1px rgba(24, 119, 242, 0.4),
    inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.btn-facebook:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.95),
    0 0 0 5px #1877F2,
    0 8px 20px -4px rgba(24, 119, 242, 0.5);
}

.btn-facebook .fb-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  fill: #ffffff;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
  transition: transform 0.25s ease;
}

.btn-facebook:hover .fb-icon {
  transform: scale(1.1) rotate(-4deg);
}

.btn-facebook .fb-label {
  white-space: nowrap;
  position: relative;
  z-index: 1;
}

.btn-facebook .fb-arrow {
  font-size: 0.8em;
  opacity: 0.85;
  transition: transform 0.25s ease;
  position: relative;
  z-index: 1;
}

.btn-facebook:hover .fb-arrow {
  transform: translate(2px, -2px);
  opacity: 1;
}

/* RTL support: keep Facebook icon first from the reading direction */
[dir="rtl"] .btn-facebook:hover .fb-arrow {
  transform: translate(-2px, -2px);
}

.btn-facebook:disabled,
.btn-facebook.disabled {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.6;
}

.btn-facebook:disabled:hover {
  transform: none;
}

@media (max-width: 640px) {
  .btn-facebook {
    padding: 0.7rem 1rem;
    font-size: 0.85rem;
  }
  .btn-facebook .fb-icon {
    width: 18px;
    height: 18px;
  }
}

/* ================================================================
   Stats bar
   ================================================================ */
.stats-bar {
  position: relative;
  z-index: 5;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem 0.5rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.625rem;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 1rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  transition: all 0.3s var(--ease);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, var(--accent-50));
  opacity: 0;
  transition: opacity 0.3s;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.stat:hover::before {
  opacity: 1;
}

.stat > * {
  position: relative;
  z-index: 1;
}

.stat-num {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.03em;
  direction: ltr;
  text-align: left;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  font-weight: 600;
  white-space: nowrap;
}

.stat-divider {
  display: none; /* استبدلنا الـ dividers بالـ grid */
}

/* ================================================================
   Controls (filters bar)
   ================================================================ */
.controls {
  position: relative;
  z-index: 5;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.625rem 2rem !important;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem 0.625rem;
  align-items: end;
}

.controls.advanced-row {
  padding-top: 0 !important;
}

@media (max-width: 640px) {
  .controls {
    grid-template-columns: repeat(2, 1fr) !important;
    padding: 0.5rem 0.75rem !important;
  }
  .controls .filter-group.flex-grow {
    grid-column: 1 / -1;
  }
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.filter-group.flex-grow {
  /* handled by grid */
}

.filter-label {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
  padding-right: 4px;
}

.select,
.input {
  padding: 7px 12px !important;
  font-size: 0.85rem !important;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.15s var(--ease);
  width: 100%;
  box-shadow: var(--shadow-xs);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
}

.select:hover,
.input:hover {
  border-color: var(--border-strong);
}

.select:focus,
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-50);
}

.input.narrow {
  width: 100%;
}

/* ================================================================
   Results meta bar
   ================================================================ */
.results-meta {
  position: relative;
  z-index: 5;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.meta-left {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-wrap: wrap;
}

#resultCount {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.sources-used {
  font-size: 0.72rem;
  padding: 4px 10px;
  background: var(--ink-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.btn-export {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  padding: 7px 14px;
  box-shadow: var(--shadow-xs);
}

.btn-export:hover {
  background: var(--ink-900);
  color: white;
  border-color: var(--ink-900);
}

/* ================================================================
   Posts grid
   ================================================================ */
.posts-grid {
  position: relative;
  z-index: 5;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem 4rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.post-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  transition: all 0.3s var(--ease);
  overflow: hidden;
  animation: fadeInUp 0.5s var(--ease) backwards;
  box-shadow: var(--shadow-xs);
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent-500), var(--accent-600));
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.3s var(--ease);
}

.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.post-card:hover::before {
  transform: scaleY(1);
}

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

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border);
}

.post-page {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.post-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.post-image {
  margin: -1.5rem -1.5rem 0;
  overflow: hidden;
  max-height: 200px;
  background: var(--ink-100);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--ease);
}

.post-card:hover .post-image img {
  transform: scale(1.04);
}

.post-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.post-engagement {
  display: flex;
  gap: 0.625rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

.engagement-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums lining-nums;
  padding: 3px 8px;
  background: var(--ink-100);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.engagement-item strong {
  color: var(--text);
  font-weight: 700;
  direction: ltr;
  unicode-bidi: plaintext;
}

.engagement-item.high {
  background: var(--accent-50);
  color: var(--accent-700);
}

.engagement-item.high strong {
  color: var(--accent-700);
}

.engagement-item.no-data {
  font-style: italic;
  opacity: 0.65;
  font-size: 0.72rem;
  background: transparent;
  border: 1px dashed var(--border);
}

.post-link {
  margin-right: auto;
  font-size: 0.76rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  letter-spacing: -0.01em;
}

.post-link:hover {
  background: var(--accent-50);
  color: var(--accent-700);
}

/* ================================================================
   Source badges
   ================================================================ */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.66rem;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-family: var(--font-mono), var(--font-display);
  border: 1px solid;
  white-space: nowrap;
  text-transform: uppercase;
}

.source-badge.premium {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #78350f;
  border-color: #fcd34d;
}

.source-badge.rss {
  background: var(--success-light);
  color: #065f46;
  border-color: #6ee7b7;
}

.source-badge.local {
  background: var(--ink-100);
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

/* ================================================================
   Loading & empty states
   ================================================================ */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--ink-200);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

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

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
}

/* ================================================================
   Footer
   ================================================================ */
.footer {
  position: relative;
  z-index: 5;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 2.5rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.footer p {
  margin: 0.35rem 0;
}

.warning {
  color: var(--accent-600);
  font-size: 0.72rem;
  font-weight: 600;
}

/* ================================================================
   Modal
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 520px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUpModal 0.3s var(--ease);
  border: 1px solid var(--border);
}

@keyframes slideUpModal {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  background: transparent;
  font-size: 1.5rem;
  color: var(--text-muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  line-height: 1;
  border-radius: var(--radius-full);
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--ink-100);
}

.modal h2 {
  font-family: var(--font-display);
  margin-bottom: 1rem;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-instructions {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.modal-instructions h3 {
  font-family: var(--font-display);
  font-size: 0.95rem !important;
  font-weight: 700;
  color: var(--text);
  margin-top: 1.5rem !important;
  margin-bottom: 0.75rem;
}

.modal-instructions code {
  background: var(--ink-100);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85em;
  direction: ltr;
  display: inline-block;
  color: var(--accent-700);
  border: 1px solid var(--border);
}

.modal-instructions ol {
  padding-right: 1.5rem;
  margin: 0.75rem 0;
}

.modal-instructions li {
  margin-bottom: 0.5rem;
}

.modal-instructions a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--accent-50);
  transition: all 0.2s;
}

.modal-instructions a:hover {
  border-color: var(--accent);
}

.modal #ghToken {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  direction: ltr;
  text-align: left;
}

/* ================================================================
   Toast
   ================================================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-900);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  z-index: 2000;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s var(--ease), slideDown 0.3s var(--ease) 2.7s;
  border-right: 3px solid var(--accent);
}

@keyframes slideUp {
  from {
    transform: translate(-50%, 20px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

@keyframes slideDown {
  to {
    transform: translate(-50%, 20px);
    opacity: 0;
  }
}

.toast.success {
  border-right-color: var(--success);
}

.toast.error {
  border-right-color: var(--danger);
}

/* ================================================================
   Responsive breakpoints
   ================================================================ */

@media (max-width: 768px) {
  body { font-size: 14px; }

  .header-inner {
    padding: 0.875rem 1rem;
    gap: 0.75rem;
  }

  .brand-text h1 {
    font-size: 1.5rem;
  }

  .tagline {
    font-size: 0.68rem;
  }

  .last-update {
    font-size: 0.72rem;
    padding: 5px 10px;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    padding: 1rem;
    gap: 0.625rem;
  }

  .stat {
    padding: 0.875rem 1rem;
  }

  .stat-num {
    font-size: 1.5rem;
  }

  /* controls: let auto-fit handle it on mobile */

  .posts-grid {
    padding: 0 1rem 2rem;
    gap: 0.875rem;
  }

  .post-card {
    padding: 1.25rem;
    border-radius: var(--radius);
  }

  .results-meta {
    padding: 0 1rem 1rem;
  }

  .modal {
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .stats-bar {
    grid-template-columns: 1fr 1fr;
  }
}

/* ================================================================
   Accessibility & utility
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

::selection {
  background: var(--accent-100);
  color: var(--accent-900);
}

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Scrollbar styling (chromium) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--ink-100);
}

::-webkit-scrollbar-thumb {
  background: var(--ink-300);
  border-radius: 10px;
  border: 2px solid var(--ink-100);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-400);
}

/* ================================================================
   v2.1: Icon buttons (header)
   ================================================================ */
.btn-icon {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  width: 36px;
  height: 36px;
  justify-content: center;
  transition: all 0.2s var(--ease);
}

.btn-icon:hover {
  background: var(--ink-100);
  color: var(--text);
  border-color: var(--border-strong);
}

/* ================================================================
   v2.1: Controls grid update (add toggle button)
   ================================================================ */

.btn-toggle-advanced {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  padding: 10px 14px;
  height: 40px;
  box-shadow: var(--shadow-xs);
  align-self: flex-end;
  justify-content: center;
  white-space: nowrap;
}

.btn-toggle-advanced:hover {
  background: var(--ink-100);
  border-color: var(--border-strong);
}

.btn-toggle-advanced.active {
  background: var(--accent-50);
  color: var(--accent-700);
  border-color: var(--accent-400);
}

/* ================================================================
   v2.1: Advanced filters panel
   ================================================================ */
.advanced-filters {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  align-items: flex-end;
  background: linear-gradient(180deg, var(--accent-50) 0%, transparent 100%);
  border-top: 1px dashed var(--border);
  animation: slideDownFilter 0.3s var(--ease);
}

@keyframes slideDownFilter {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.filter-checkboxes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 0;
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s var(--ease);
  user-select: none;
}

.checkbox-chip input {
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-chip:has(input:checked) {
  background: var(--accent-50);
  border-color: var(--accent);
  color: var(--accent-700);
}

.checkbox-chip:hover {
  border-color: var(--border-strong);
}

.btn-reset-filters {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  padding: 10px 12px;
  height: 40px;
  box-shadow: var(--shadow-xs);
  justify-content: center;
  white-space: nowrap;
}

.btn-reset-filters:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* Active filters badge */
.active-filters-badge {
  font-size: 0.68rem;
  padding: 3px 10px;
  background: var(--accent-500);
  color: white;
  border-radius: var(--radius-full);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Button variants */
.btn-sm {
  font-size: 0.78rem;
  padding: 7px 12px;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ================================================================
   v2.1: Pages Manager Modal
   ================================================================ */
.pages-manager {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pages-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.pages-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 420px;
  overflow-y: auto;
  padding: 0.25rem;
  margin: 0 -0.25rem;
}

.page-row {
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  transition: all 0.2s var(--ease);
}

.page-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.page-row-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.page-row-head .page-name {
  flex: 1;
  font-weight: 600;
}

.page-row-body {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.page-row-inline {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pages-footer {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.pages-footer button {
  flex: 1;
  justify-content: center;
}

.note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: var(--ink-100);
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--accent);
  line-height: 1.65;
}

.note strong { color: var(--text); }

.note-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Switch toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--ink-300);
  border-radius: var(--radius-full);
  transition: 0.25s var(--ease);
}

.slider::before {
  position: absolute;
  content: '';
  height: 14px;
  width: 14px;
  right: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.25s var(--ease);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
}

.switch input:checked + .slider {
  background: var(--success);
}

.switch input:checked + .slider::before {
  transform: translateX(-16px);
}

.btn-icon-sm {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0;
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  font-size: 1.2rem;
  line-height: 1;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon-sm:hover {
  color: white;
  background: var(--danger);
  border-color: var(--danger);
}

/* ================================================================
   v2.1: Setup Wizard
   ================================================================ */
.setup-wizard {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wizard-intro {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.source-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.625rem;
}

.source-card {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  position: relative;
  transition: all 0.25s var(--ease);
  text-align: center;
}

.source-card:hover {
  border-color: var(--accent-400);
  background: var(--accent-50);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.source-card.active {
  border-color: var(--accent);
  background: var(--accent-50);
  box-shadow: 0 0 0 3px var(--accent-50), var(--shadow-md);
}

.source-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.source-card strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
}

.source-card .price {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.source-card .badge-best,
.source-card .badge-cheap,
.source-card .badge-free,
.source-card .badge-warn {
  position: absolute;
  top: -6px;
  left: -6px;
  font-size: 0.6rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: white;
  box-shadow: var(--shadow-sm);
}

.source-card .badge-best  { background: var(--gold); }
.source-card .badge-cheap { background: var(--success); }
.source-card .badge-free  { background: var(--blue); }
.source-card .badge-warn  { background: var(--danger); }

.setup-steps {
  background: var(--ink-50);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  min-height: 200px;
}

.setup-steps h3 {
  font-family: var(--font-display);
  font-size: 1.05rem !important;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.875rem !important;
  margin-top: 0 !important;
}

.setup-steps:empty::before {
  content: '👆 اختر مصدراً من الأعلى لعرض الخطوات';
  display: block;
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
  font-style: italic;
}

.step-list {
  padding-right: 1.25rem;
  margin: 0;
}

.step-list li {
  margin-bottom: 0.75rem;
  line-height: 1.85;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.step-list li::marker {
  color: var(--accent);
  font-weight: 700;
}

.step-list code {
  background: var(--bg-elevated);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85em;
  direction: ltr;
  display: inline-block;
  color: var(--accent-700);
  border: 1px solid var(--border);
}

.step-list a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--accent-100);
  transition: all 0.2s;
}

.step-list a:hover {
  border-bottom-color: var(--accent);
}

.step-list strong {
  color: var(--text);
}

.setup-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.setup-footer a {
  color: var(--accent);
  font-weight: 600;
}

/* Empty state as flexbox */
.empty {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ================================================================
   v2.1: Responsive overrides
   ================================================================ */
@media (max-width: 1024px) {
  .btn-toggle-advanced {
    grid-column: 1 / -1;
  }
  .advanced-filters {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .controls {
    grid-template-columns: 1fr 1fr;
  }
  .advanced-filters {
    grid-template-columns: repeat(2, 1fr);
    padding: 1rem;
  }
  .page-row-inline {
    grid-template-columns: 1fr;
  }
  .pages-footer {
    flex-direction: column;
  }
  .source-picker {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .advanced-filters {
    grid-template-columns: 1fr;
  }
  .btn-refresh span,
  .btn-trigger span {
    display: none;
  }
  .btn-refresh,
  .btn-trigger {
    padding: 9px 10px;
  }
}

/* ================================================================
   v2.2: Live status banner
   ================================================================ */
.live-status-banner {
  background: linear-gradient(90deg, var(--accent-600), var(--accent-500));
  color: white;
  padding: 10px 2rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 99;
  box-shadow: var(--shadow-md);
  animation: slideDownBanner 0.4s var(--ease);
}

@keyframes slideDownBanner {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

.live-status-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.live-dot {
  width: 10px;
  height: 10px;
  background: white;
  border-radius: 50%;
  animation: livePulse 1s infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.3; transform: scale(1.3); }
}

.live-dot-inline {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  animation: livePulse 1s infinite;
}

.live-status-banner a {
  color: white;
  text-decoration: underline;
  font-weight: 700;
}

/* ================================================================
   v2.2: Advanced row (always visible)
   ================================================================ */
.controls.advanced-row {
  padding-top: 0 !important;
  padding-bottom: 0.875rem !important;
  grid-template-columns: 1fr 1fr 1fr 1fr 1.1fr 1.2fr;
  gap: 0.625rem;
}

.filter-action-buttons {
  display: flex;
  gap: 3px;
  align-items: center;
  height: 40px;
}

.btn-quick-range {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex: 1;
  height: 100%;
  font-family: var(--font-display);
  transition: all 0.15s var(--ease);
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-quick-range:hover {
  background: var(--accent-50);
  border-color: var(--accent-400);
  color: var(--accent-700);
}

.btn-quick-range.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-reset-filters {
  width: 38px;
  padding: 0;
  flex: 0 0 38px;
}

/* ================================================================
   v2.2: New Footer
   ================================================================ */
.footer {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 3rem 2rem 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.footer-features {
  max-width: 1400px;
  margin: 0 auto 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
}

.footer-feature {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 1rem;
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.3s var(--ease);
}

.footer-feature:hover {
  border-color: var(--accent-400);
  background: var(--accent-50);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.feature-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}

.footer-feature > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.footer-feature strong {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.footer-feature span {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.footer-bottom {
  max-width: 1400px;
  margin: 0 auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ================================================================
   v2.2: History modal
   ================================================================ */
.modal-lg {
  max-width: 720px !important;
}

.history-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-section h3 {
  font-family: var(--font-display);
  font-size: 0.95rem !important;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.5rem !important;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}

.run-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding: 0.875rem;
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
}

.run-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.run-row-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  font-size: 0.75rem;
}

.run-status {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.7rem;
}

.run-status.success { background: var(--success-light); color: #065f46; }
.run-status.error   { background: #fee2e2; color: #991b1b; }
.run-status.warn    { background: #fef3c7; color: #78350f; }
.run-status.muted   { background: var(--ink-100); color: var(--text-muted); }

.run-trigger {
  color: var(--text-muted);
  font-weight: 600;
}

.run-time {
  color: var(--text-muted);
  margin-right: auto;
  font-variant-numeric: tabular-nums;
}

.run-row-body {
  font-size: 0.82rem;
  color: var(--text-secondary);
  grid-column: 1 / -1;
  line-height: 1.65;
}

.run-row-body strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.run-row-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.run-link {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.run-link:hover {
  background: var(--accent-50);
}

.history-loading {
  text-align: center;
  padding: 2rem;
}

.history-footer {
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: center;
}

.note-info {
  background: #dbeafe !important;
  border-right-color: var(--blue) !important;
  color: #1e40af;
}

/* ================================================================
   v2.2: Simplified Setup Wizard
   ================================================================ */
.setup-wizard-v2 {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.setup-tabs {
  display: flex;
  gap: 4px;
  background: var(--ink-100);
  padding: 4px;
  border-radius: var(--radius);
}

.setup-tab {
  flex: 1;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.setup-tab.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.setup-tab:hover:not(.active) {
  color: var(--text);
}

.quick-setup-steps {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.quick-step {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: var(--shadow-accent);
}

.step-content {
  flex: 1;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--border);
  min-width: 0;
}

.quick-step:last-child .step-content {
  border-bottom: none;
}

.step-content h3 {
  font-family: var(--font-display);
  font-size: 0.95rem !important;
  font-weight: 700;
  margin: 0 0 0.5rem !important;
  color: var(--text);
}

.step-content p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.625rem;
  line-height: 1.65;
}

.mini-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.mini-list li {
  padding: 5px 0;
  padding-right: 18px;
  position: relative;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.mini-list li::before {
  content: '▸';
  position: absolute;
  right: 0;
  color: var(--accent);
  font-weight: 900;
}

.mini-list code {
  background: var(--ink-100);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82em;
  direction: ltr;
  display: inline-block;
  color: var(--accent-700);
}

.small-note {
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
  margin-top: 0.375rem !important;
}

.small-note a {
  color: var(--accent);
  font-weight: 600;
}

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 0.625rem;
}

.quick-source-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0.75rem 0;
}

.quick-source {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-direction: column;
  transition: all 0.15s;
}

.quick-source:hover {
  border-color: var(--accent-400);
  background: var(--accent-50);
}

.quick-source.selected {
  border-color: var(--accent);
  background: var(--accent-50);
  box-shadow: 0 0 0 3px var(--accent-50);
}

.quick-source span {
  font-size: 1.4rem;
  line-height: 1;
}

.quick-source em {
  font-style: normal;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  direction: ltr;
}

.source-quick-info {
  margin-top: 0.75rem;
  padding: 0.875rem;
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: fadeInUp 0.25s var(--ease);
}

.source-quick-info h4 {
  font-family: var(--font-display);
  font-size: 0.88rem;
  margin: 0 0 0.5rem !important;
  color: var(--text);
  font-weight: 700;
}

.alt-method {
  margin-top: 1.25rem;
  padding: 0.75rem;
  background: var(--ink-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.alt-method summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.alt-method[open] summary {
  margin-bottom: 0.5rem;
  color: var(--text);
}

.alt-method p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0.375rem 0;
}

/* Responsive tweaks v2.2 */
@media (max-width: 768px) {
  .filter-action-buttons {
    flex-wrap: wrap;
    height: auto;
  }
  .btn-quick-range {
    flex: 1 1 30%;
    padding: 8px 4px;
  }
  .footer-features {
    grid-template-columns: repeat(2, 1fr);
  }
  .live-status-banner {
    padding: 8px 1rem;
    font-size: 0.78rem;
  }
  .quick-source-grid {
    grid-template-columns: 1fr;
  }
  .quick-source {
    flex-direction: row;
    justify-content: flex-start;
  }
  .modal-lg {
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .controls.advanced-row {
    grid-template-columns: 1fr;
  }
  .footer-features {
    grid-template-columns: 1fr;
  }
}

/* ================================================================
   v2.3: Clickable post cards
   ================================================================ */
.post-card.clickable {
  cursor: pointer;
}

.post-card.clickable:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.post-detail-hint {
  margin-right: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s;
}

.post-card:hover .post-detail-hint {
  opacity: 1;
}

.engagement-item.has-detail {
  background: var(--accent-50);
  color: var(--accent-700);
  border: 1px solid var(--accent-100);
}

.post-media-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 10px;
  background: var(--ink-100);
  border-radius: var(--radius-full);
  display: inline-block;
  width: fit-content;
}

/* ================================================================
   v2.3: Post Detail Modal
   ================================================================ */
.post-detail {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.detail-page-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.detail-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge-info, .badge-warn-inline {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
}
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-warn-inline { background: #fef3c7; color: #78350f; }

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-section h3 {
  font-family: var(--font-display);
  font-size: 0.95rem !important;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.25rem !important;
  padding-bottom: 0.375rem;
  border-bottom: 1px dashed var(--border);
}

.detail-text {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text-secondary);
  font-family: var(--font-body);
  background: var(--ink-50);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Detail Media */
.detail-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}

.media-item {
  display: block;
  aspect-ratio: 1;
  background: var(--ink-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  transition: transform 0.2s;
}

.media-item:hover {
  transform: scale(1.03);
}

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

.media-item.video {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 8px;
  text-align: center;
}

.media-item.video span:first-child {
  font-size: 1.8rem;
}

.media-item.broken {
  display: none;
}

/* Detail Stats */
.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.detail-stat {
  background: var(--ink-50);
  padding: 0.875rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
}

.detail-stat-num {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.detail-stat-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
}

/* Reactions Breakdown */
.reactions-breakdown {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.reaction-pill {
  background: var(--ink-50);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Comments */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  max-height: 400px;
  overflow-y: auto;
}

.comment-item {
  background: var(--ink-50);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: var(--radius);
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.comment-head strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.85rem;
}

.comment-time {
  color: var(--text-muted);
}

.comment-likes {
  margin-right: auto;
  color: var(--accent);
  font-weight: 700;
}

.comment-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.comment-replies {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Hashtags */
.hashtags-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hashtag {
  background: var(--accent-50);
  color: var(--accent-700);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--accent-100);
}

.hashtag em {
  font-style: normal;
  color: var(--text-muted);
  font-weight: 600;
}

/* External Links */
.external-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.external-links li {
  padding: 6px 10px;
  background: var(--ink-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.external-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  word-break: break-all;
  font-family: var(--font-mono);
  direction: ltr;
}

/* Detail Actions */
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 0.5rem;
}

.detail-actions > * {
  flex: 1;
  justify-content: center;
}

.detail-meta {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.detail-meta summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-secondary);
}

.meta-grid {
  margin-top: 0.625rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 0.78rem;
}

.meta-grid > div {
  padding: 4px 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.meta-grid span {
  color: var(--text-muted);
  font-weight: 600;
}

.meta-grid code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  direction: ltr;
  display: inline-block;
  word-break: break-all;
  color: var(--accent-700);
}

/* ================================================================
   v2.3: Analytics Modal
   ================================================================ */
.analytics-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.analytics-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1.125rem;
  border-radius: var(--radius);
  text-align: center;
  transition: all 0.2s;
}

.analytics-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.analytics-num {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.analytics-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 600;
}

.analytics-section {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.analytics-section h3 {
  font-family: var(--font-display);
  font-size: 0.95rem !important;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.5rem !important;
  padding-bottom: 0.375rem;
  border-bottom: 1px dashed var(--border);
}

.analytics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.analytics-section.half {
  background: var(--ink-50);
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Bar chart */
.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  height: 140px;
  padding: 0.5rem;
  background: var(--ink-50);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  align-items: end;
}

.bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  height: 100%;
  justify-content: flex-end;
  cursor: help;
}

.bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--accent-500), var(--accent-600));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 2px;
  transition: all 0.3s var(--ease);
}

.bar-item:hover .bar-fill {
  background: linear-gradient(180deg, var(--accent-400), var(--accent-500));
}

.bar-num {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.bar-day {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

/* Analytics table */
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.analytics-table th,
.analytics-table td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.analytics-table th {
  background: var(--ink-100);
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 0.78rem;
}

.analytics-table tbody tr:hover {
  background: var(--ink-50);
}

.analytics-table td:not(:first-child) {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Source distribution */
.source-distribution {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dist-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
  align-items: center;
}

.dist-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.dist-bar {
  position: relative;
  height: 24px;
  background: var(--ink-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.dist-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-500), var(--accent-400));
  border-radius: var(--radius-sm);
}

.dist-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* Top posts */
.top-posts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.top-post-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 0.625rem;
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  align-items: center;
}

.top-post-row:hover {
  border-color: var(--accent);
  background: var(--accent-50);
}

.top-rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent);
  width: 32px;
  text-align: center;
}

.top-content {
  min-width: 0;
}

.top-page {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.top-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-reactions {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 0.85rem;
}

/* ================================================================
   v2.3: Settings Modal
   ================================================================ */
.settings-modal {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-tabs {
  display: flex;
  gap: 4px;
  background: var(--ink-100);
  padding: 5px;
  border-radius: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.settings-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
  white-space: nowrap;
}

.settings-tab:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.5);
}

.settings-tab.active {
  background: var(--bg-elevated);
  color: var(--accent-700);
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.08), 0 2px 6px -2px rgb(15 23 42 / 0.06);
}

.settings-pane {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-top: 0.25rem;
}

.settings-pane h3 {
  font-family: var(--font-display);
  font-size: 1rem !important;
  font-weight: 800;
  color: var(--text);
  margin-top: 0.25rem;
  margin: 0.5rem 0 0.375rem !important;
}

.settings-source {
  background: var(--ink-50);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 6px;
  transition: all 0.15s;
}

.settings-source.active {
  border-color: var(--success);
  background: var(--success-light);
}

.settings-source-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.settings-source-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: var(--font-mono);
  direction: ltr;
  text-align: left;
}

.settings-source-meta code {
  font-size: 0.72rem;
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent-700);
}

.status-badge {
  font-size: 0.7rem;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.status-badge.success { background: var(--success-light); color: #065f46; }
.status-badge.muted { background: var(--ink-100); color: var(--text-muted); }

.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.settings-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}

.settings-table td:first-child {
  font-weight: 600;
  color: var(--text-secondary);
  width: 40%;
}

.settings-table td:last-child {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  direction: ltr;
  text-align: right;
}

.settings-table code {
  background: var(--ink-100);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--accent-700);
  font-size: 0.78rem;
}

.settings-footer {
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: center;
}

/* Settings overview & advanced */
.settings-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.overview-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
}

.overview-num {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.overview-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 0.5rem;
}

.quick-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.625rem 0.875rem;
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s;
}

.quick-link:hover {
  background: var(--accent-50);
  border-color: var(--accent-400);
  color: var(--accent-700);
  transform: translateX(-3px);
}

.quick-link span {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.advanced-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.advanced-item {
  background: var(--ink-50);
  border: 1px solid var(--border);
  padding: 0.875rem;
  border-radius: var(--radius);
}

.advanced-item strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 6px;
}

.advanced-item p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 6px 0;
}

.advanced-item code {
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--accent-700);
  direction: ltr;
  display: inline-block;
}

.advanced-item pre {
  background: var(--ink-900);
  color: #e2e8f0;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.78rem;
  margin: 6px 0;
  direction: ltr;
}

.advanced-item pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-family: var(--font-mono);
}

/* Config viewer */
.config-viewer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.875rem;
  background: var(--ink-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: none;
}

.config-viewer-head .filename {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text);
  direction: ltr;
}

.config-viewer {
  background: var(--ink-900);
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  overflow: auto;
  max-height: 460px;
  font-size: 0.78rem;
  line-height: 1.6;
  margin: 0;
  direction: ltr;
  text-align: left;
}

.config-viewer code {
  font-family: var(--font-mono);
  white-space: pre-wrap;
  background: transparent;
  color: inherit;
}

/* Responsive overrides for v2.3 */
@media (max-width: 768px) {
  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .analytics-row {
    grid-template-columns: 1fr;
  }
  .detail-media-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .meta-grid {
    grid-template-columns: 1fr;
  }
  .detail-actions {
    flex-direction: column;
  }
  .bar-chart {
    height: 110px;
  }
  .settings-overview-grid {
    grid-template-columns: 1fr;
  }
  .quick-links {
    grid-template-columns: 1fr;
  }
}

/* ================================================================
   v3.0: Alerts, Progress Bar, Wizard, Test Results, Config Editor
   ================================================================ */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.875rem;
  font-size: 0.88rem;
  line-height: 1.65;
  border: 1px solid;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
}

.alert-warn {
  background: #fef3c7;
  color: #78350f;
  border-color: #fcd34d;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.alert code {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  direction: ltr;
  display: inline-block;
}

/* Trigger Form */
.trigger-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.form-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.btn-lg {
  padding: 12px 20px !important;
  font-size: 0.95rem !important;
}

/* Progress Modal */
.progress-modal {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.progress-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-status {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.progress-bar-outer {
  height: 12px;
  background: var(--ink-100);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-500), var(--accent-400));
  transition: width 0.4s var(--ease);
  min-width: 3px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.progress-meta span:first-child {
  font-weight: 600;
}

.progress-log {
  background: var(--ink-900);
  color: #e2e8f0;
  padding: 0.875rem;
  border-radius: var(--radius);
  height: 280px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.65;
  direction: ltr;
  text-align: left;
}

.log-line {
  padding: 2px 0;
  word-break: break-word;
}

.log-line.log-info { color: #cbd5e1; }
.log-line.log-success { color: #86efac; }
.log-line.log-warn { color: #fde68a; }
.log-line.log-error { color: #fca5a5; }

.progress-footer {
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

/* First-Run Wizard */
.wizard {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wizard-intro-big {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--accent-50), transparent);
  border-radius: var(--radius);
  border: 1px solid var(--accent-100);
}

.wizard-step {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: all 0.25s var(--ease);
  opacity: 0.55;
}

.wizard-step.active {
  border-color: var(--accent);
  opacity: 1;
  box-shadow: var(--shadow-md);
}

.wizard-step.done {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.04);
  opacity: 1;
}

.wizard-step-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.75rem;
}

.wizard-step-head .step-num {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
}

.wizard-step.done .step-num {
  background: var(--success);
}

.wizard-step:not(.active):not(.done) .step-num {
  background: var(--ink-300);
}

.step-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.step-check {
  margin-right: auto;
  color: var(--success);
  font-size: 1.4rem;
  font-weight: 800;
}

.wizard-step-body {
  padding-right: 44px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.wizard-step-body p {
  margin-bottom: 0.75rem;
}

.wizard-ok {
  color: var(--success) !important;
  font-weight: 700;
  font-size: 0.92rem !important;
}

.wizard-sources {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wizard-source {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  text-align: right;
  transition: all 0.15s;
  color: var(--text);
}

.wizard-source:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-50);
  transform: translateX(-3px);
}

.wizard-source:disabled {
  opacity: 0.6;
  cursor: wait;
}

.wizard-source .source-icon {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
}

.wizard-source .source-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wizard-source .source-info strong {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
}

.wizard-source .source-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.wizard-source .source-info em {
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  direction: ltr;
  text-align: right;
}

.wizard-quick-page {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wizard-suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 6px 0;
}

.wizard-suggestions > span {
  margin-left: 4px;
}

.suggest-btn {
  background: var(--ink-50);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.suggest-btn:hover {
  background: var(--accent-50);
  border-color: var(--accent-400);
  color: var(--accent-700);
}

.wizard-footer {
  text-align: center;
  padding-top: 0.5rem;
}

/* Page test result */
.btn-icon-sm.btn-test {
  color: var(--blue);
  border-color: var(--blue);
  font-size: 0.9rem;
}

.btn-icon-sm.btn-test:hover {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.page-test-result {
  margin-top: 8px;
  font-size: 0.82rem;
}

.test-result {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-weight: 600;
}

.test-result.success {
  background: var(--success-light);
  color: #065f46;
  border-color: #6ee7b7;
}

.test-result.error {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.test-result.warn {
  background: #fef3c7;
  color: #78350f;
  border-color: #fcd34d;
}

.test-result details {
  margin-top: 6px;
  font-weight: 500;
}

.test-result .test-sample {
  padding: 4px 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink-200);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0;
  display: inline-block;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

/* Config Editor (Settings) */
.config-editor {
  width: 100%;
  min-height: 460px;
  background: var(--ink-900);
  color: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border-top: none;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
  direction: ltr;
  text-align: left;
  resize: vertical;
  outline: none;
}

.config-editor:focus {
  border-color: var(--accent);
}

.config-viewer-head > div {
  display: flex;
  gap: 6px;
}

/* Empty state (for pages list) */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.empty-state h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text);
  margin: 0 0 0.375rem;
  font-weight: 700;
}

.empty-state p {
  font-size: 0.85rem;
}

/* Clickable history row */
.run-row.clickable {
  cursor: pointer;
}

.run-row.clickable:hover {
  border-color: var(--accent);
  background: var(--accent-50);
}

/* ================================================================
   v4.2: Auth Screen - Modern professional design
   ================================================================ */

#authScreen {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(249, 115, 22, 0.08), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.06), transparent 50%),
    var(--ink-50);
  display: grid;
  place-items: center;
  overflow-y: auto;
  z-index: 9999;
}

#authScreen[hidden] {
  display: none !important;
}

#appRoot[hidden] {
  display: none !important;
}

.auth-page {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  gap: 1.25rem;
}

.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 20px 60px -20px rgb(15 23 42 / 0.15);
  position: relative;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 0 0 100% 100%;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo-mark {
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
  border-radius: 14px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  box-shadow: 0 10px 30px -8px rgb(249 115 22 / 0.4);
  margin-bottom: 0.875rem;
}

.auth-logo-mark span {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  animation: blink 2s infinite;
}

.auth-logo-mark span:nth-child(2) { animation-delay: 0.3s; opacity: 0.7; }
.auth-logo-mark span:nth-child(3) { animation-delay: 0.6s; opacity: 0.4; }

.auth-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
  line-height: 1.2;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.auth-alert {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.55;
  margin-bottom: 1.25rem;
  border: 1px solid;
  align-items: flex-start;
}

.auth-alert svg { flex-shrink: 0; margin-top: 1px; }

.auth-alert.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.auth-alert.info {
  background: linear-gradient(135deg, var(--accent-50), #fff);
  color: var(--accent-900);
  border-color: var(--accent-100);
}

.auth-alert strong { font-weight: 700; }

.auth-alert code {
  background: rgba(0, 0, 0, 0.07);
  padding: 1px 6px;
  border-radius: 4px;
  direction: ltr;
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.88em;
}

.auth-switcher {
  display: flex;
  background: var(--ink-100);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
  margin-bottom: 1.25rem;
}

.auth-switch-btn {
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s;
}

.auth-switch-btn.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

.auth-switch-btn:not(.active):hover { color: var(--text); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.auth-form[hidden] {
  display: none;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.auth-field label .req { color: var(--danger); }

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-field-icon {
  position: absolute;
  right: 12px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.auth-input-wrap input {
  flex: 1;
  width: 100%;
  padding: 10px 38px 10px 14px;
  background: var(--ink-50);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  transition: all 0.15s;
  outline: none;
}

.auth-input-wrap input:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-50);
}

.auth-input-wrap input[type="password"] { padding-left: 38px; }

.pw-toggle {
  position: absolute;
  left: 8px;
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
  border-radius: 6px;
  display: grid;
  place-items: center;
}

.pw-toggle:hover { opacity: 0.9; background: var(--ink-100); }
.pw-toggle.visible { opacity: 1; }

.auth-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 0;
  user-select: none;
}

.auth-checkbox input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.auth-submit {
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
  color: white;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 14px -4px rgb(249 115 22 / 0.4);
  transition: all 0.18s;
  margin-top: 0.25rem;
}

.auth-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px rgb(249 115 22 / 0.5);
}

.auth-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.auth-submit .btn-icon { transition: transform 0.15s; }
.auth-submit:hover:not(:disabled) .btn-icon { transform: translateX(-3px); }

.auth-msg {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.5;
  border: 1px solid;
}

.auth-msg.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.auth-footnote {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin: 0;
  text-align: center;
  opacity: 0.8;
}

@media (max-width: 480px) {
  .auth-card {
    padding: 1.5rem 1.25rem;
    border-radius: 12px;
  }
  .auth-title { font-size: 1.4rem; }
  .auth-logo-mark { width: 46px; height: 46px; }
}


/* ================================================================
   v4.0: User Menu (Header)
   ================================================================ */

.user-menu {
  position: relative;
}

.btn-user {
  background: var(--ink-100);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 8px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.btn-user:hover {
  background: var(--accent-50);
  border-color: var(--accent-400);
}

.user-avatar {
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 1000;
  animation: slideDownBanner 0.15s var(--ease);
}

.user-info {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.user-info strong {
  display: block;
  font-family: var(--font-display);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.25;
}

.user-info #userUsernameLabel {
  font-size: 0.75rem;
  color: var(--text-muted);
  direction: ltr;
  font-family: var(--font-mono);
}

.user-role-chip {
  display: inline-block !important;
  margin-top: 4px;
  font-size: 0.68rem !important;
  padding: 2px 8px;
  background: var(--ink-100);
  border-radius: var(--radius-full);
  color: var(--text-secondary) !important;
  font-weight: 700;
  width: fit-content;
  align-self: flex-start;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  text-align: right;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.dropdown-item[hidden] {
  display: none !important;
}

.dropdown-item:hover {
  background: var(--ink-100);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger:hover {
  background: #fee2e2;
}

.dropdown-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ================================================================
   v4.0: Post Management (Bulk Actions + Checkboxes)
   ================================================================ */

.meta-right {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-meta {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: var(--shadow-xs);
}

.btn-meta:hover {
  border-color: var(--border-strong);
  background: var(--ink-100);
}

.btn-meta.danger {
  color: var(--danger);
  border-color: #fca5a5;
}

.btn-meta.danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-meta input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Post card with checkbox + delete */
.post-checkbox-wrap {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-sm);
  padding: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.post-card:hover .post-checkbox-wrap,
.post-card:has(.post-select:checked) .post-checkbox-wrap {
  opacity: 1;
}

.post-select {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  display: block;
}

.post-card:has(.post-select:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-50);
}

.btn-delete-post {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s;
  z-index: 2;
  display: grid;
  place-items: center;
}

.post-card:hover .btn-delete-post {
  opacity: 1;
}

.btn-delete-post:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* ================================================================
   v4.0: Clear modal
   ================================================================ */

.clear-modal {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.clear-option {
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clear-option.danger {
  background: #fef2f2;
  border-color: #fca5a5;
}

.clear-option h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin: 0;
  color: var(--text);
}

.danger-btn {
  background: var(--danger) !important;
  color: white !important;
  border-color: var(--danger) !important;
}

/* ================================================================
   v4.0: Source Config Cards (Settings)
   ================================================================ */

.settings-intro {
  padding: 0.875rem;
  background: var(--accent-50);
  border: 1px solid var(--accent-100);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 1rem;
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.source-config-card {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s var(--ease);
  overflow: hidden;
  user-select: none;
}

.source-config-card.enabled {
  border-color: var(--success);
}

.source-config-card.disabled {
  opacity: 0.75;
}

.source-config-card.disabled:hover {
  opacity: 1;
}

.source-config-card.expanded {
  box-shadow: var(--shadow-md);
}

/* Drag states */
.source-config-card.dragging {
  opacity: 0.4;
  cursor: grabbing !important;
}

.source-config-card.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-50);
  transform: translateY(-1px);
}

.source-config-card[draggable="true"] {
  cursor: grab;
}

.source-config-card[draggable="true"]:active {
  cursor: grabbing;
}

.source-config-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.source-config-head:hover {
  background: var(--ink-50);
}

.source-drag-handle {
  flex-shrink: 0;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  cursor: grab;
  transition: color 0.15s;
  display: flex;
  align-items: center;
}

.source-drag-handle:hover {
  color: var(--text);
  background: var(--ink-100);
}

.source-drag-handle:active {
  cursor: grabbing;
}

.source-priority-badge {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.source-config-card.disabled .source-priority-badge {
  background: var(--ink-300);
}

.source-config-card.enabled .source-priority-badge {
  background: var(--success);
}

.source-config-info {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
  align-items: center;
}

.source-config-text {
  min-width: 0;
  flex: 1;
}

.source-collapse-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  transition: all 0.15s;
}

.source-collapse-btn:hover {
  background: var(--ink-100);
  color: var(--text);
}

.source-collapse-btn .chev {
  transition: transform 0.2s;
}

.source-config-body {
  padding: 0 16px 14px;
  border-top: 1px dashed var(--border);
  margin-top: 0;
  padding-top: 12px;
}

.source-warn-banner {
  margin: 0 14px 12px;
}

.source-icon-lg {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.source-config-info strong {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text);
  display: block;
  font-weight: 700;
}

.source-price {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  direction: ltr;
}

.source-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.source-config-body {
  margin-top: 1rem;
  padding-top: 0.875rem;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.token-input-row {
  display: flex;
  gap: 6px;
}

.token-input-row .input {
  flex: 1;
}

.source-help-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  margin-top: 4px;
}

.source-help-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.source-help-links a:hover {
  text-decoration: underline;
}

.info-box {
  background: var(--ink-50);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
  border: 1px solid var(--border);
}

.info-box a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

/* ================================================================
   v4.0+4.9: Users list (admin) - full CRUD UI
   ================================================================ */

.users-list h3 {
  font-family: var(--font-display);
  margin-bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.users-header .count-badge {
  background: var(--accent-100);
  color: var(--accent-900);
  font-size: 0.78rem;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.users-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-row {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.user-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.user-row-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-500), var(--accent-700));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 2px 6px -1px rgba(249,115,22,0.35);
}

.user-row-info strong {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 1rem;
  display: block;
}

.user-sub {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.user-sub span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.user-role {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--ink-100);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.user-role.admin {
  background: #fef3c7;
  color: #78350f;
}

.user-role.disabled {
  background: #fee2e2;
  color: #991b1b;
}

.user-role.self {
  background: #dbeafe;
  color: #1e40af;
}

.user-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 0.76rem;
  color: var(--text-muted);
  grid-column: 1;
}

.user-row-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.user-row-actions .btn-refresh {
  padding: 6px 10px;
  font-size: 0.76rem;
}

.btn-danger {
  color: #991b1b !important;
  border-color: #fca5a5 !important;
}

.btn-danger:hover:not(:disabled) {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
}

/* Add-user form */
.user-add-form {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.user-add-form h4 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  color: var(--text);
}

.user-add-form .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.user-add-form .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .user-row {
    grid-template-columns: 1fr;
  }
  .user-row-actions {
    grid-column: 1;
    grid-row: auto;
    justify-content: flex-start;
  }
  .user-row-meta {
    order: 3;
  }
}

/* Account settings */
.account-settings {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.account-settings h3 {
  margin: 0 0 0.75rem !important;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.account-settings .settings-table table {
  width: 100%;
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
}

.account-settings .settings-table td {
  padding: 6px 10px;
}

.account-settings .settings-table td:first-child {
  color: var(--text-muted);
  font-weight: 600;
  width: 40%;
}

.profile-form,
.change-pass-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
}

.profile-form .form-field,
.change-pass-form .form-field {
  gap: 6px;
}

.profile-form label,
.change-pass-form label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.profile-form .input,
.change-pass-form .input {
  background: var(--bg-elevated);
  padding: 10px 14px !important;
  font-size: 0.9rem !important;
  border-radius: 8px;
}

.profile-form .input:disabled {
  background: var(--ink-100);
  color: var(--text-muted);
  cursor: not-allowed;
}

.profile-form .field-help,
.change-pass-form .field-help {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: -2px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 0.5rem;
}

.form-actions .btn-trigger,
.form-actions .btn-refresh {
  padding: 10px 18px;
  font-size: 0.88rem;
}

.auth-msg.success {
  background: #ecfdf5;
  color: #065f46;
  border-color: #6ee7b7;
}

/* ================================================================
   v4.0: Simplified footer
   ================================================================ */

.footer-simple {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2rem;
}

.footer-simple p {
  margin: 0;
  font-weight: 600;
}

/* ================================================================
   v4.1: Responsive tweaks - mobile first improvements
   ================================================================ */

/* Tablet and below - hide icon button labels */
@media (max-width: 900px) {
  .btn-refresh span,
  .btn-trigger span {
    display: none;
  }
  .btn-refresh,
  .btn-trigger {
    padding: 8px 10px;
  }
}

/* Mobile - compact header */
@media (max-width: 768px) {
  .header-inner {
    padding: 0.75rem;
    gap: 0.5rem;
  }
  .brand-text h1 {
    font-size: 1.4rem;
  }
  .brand-text .tagline {
    display: none;  /* يحرر مكان */
  }
  .logo-mark {
    padding: 8px 6px;
  }
  .last-update {
    font-size: 0.7rem;
    padding: 4px 8px;
  }
  .last-update #lastUpdateText {
    display: none;
  }
  .last-update::after {
    content: '';
  }
  .header-actions {
    gap: 4px;
  }
  .btn-icon {
    width: 32px;
    height: 32px;
    padding: 6px;
  }
  .btn-user {
    padding: 3px 6px;
  }
  .user-avatar {
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
  }
  .stats-bar {
    padding: 1rem 0.75rem;
    gap: 0.5rem;
  }
  .stat {
    padding: 0.75rem 0.5rem;
  }
  .stat-num {
    font-size: 1.3rem;
  }
  .stat-label {
    font-size: 0.7rem;
  }
  .controls,
  .controls.advanced-row {
    padding: 0.75rem;
  }
  .results-meta {
    padding: 0 0.75rem 0.75rem;
  }
  .results-meta .meta-right {
    width: 100%;
    justify-content: flex-end;
  }
  .posts-grid {
    padding: 0 0.75rem 2rem;
  }
  .post-card {
    padding: 1rem;
  }
  .modal {
    padding: 1.25rem 1rem;
    border-radius: var(--radius);
    max-width: 100%;
    max-height: 95vh;
  }
  .modal h2 {
    font-size: 1.2rem;
  }
  .auth-container {
    padding: 1.5rem 1.25rem;
    margin: 0.5rem;
  }
  .source-config-head {
    flex-direction: column;
    align-items: stretch;
  }
  .source-config-head .switch {
    align-self: flex-start;
  }
}

/* Very small - keep 2-col filters, 1-col posts */
@media (max-width: 420px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-num {
    font-size: 1.15rem;
  }
  .controls,
  .controls.advanced-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .posts-grid {
    grid-template-columns: 1fr !important;
  }
  .btn-meta {
    padding: 5px 8px;
    font-size: 0.72rem;
  }
  .filter-action-buttons {
    flex-wrap: wrap;
  }
  .btn-quick-range {
    flex: 1 1 45%;
  }
  .user-dropdown {
    right: auto;
    left: 0;
    min-width: 180px;
  }
}

/* ================================================================
   v4.6: Schedules - beautiful card-based form + rows
   ================================================================ */

.schedules-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

#addScheduleBtn {
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 10px;
  justify-content: center;
}

/* Empty state for schedules */
.schedules-wrapper .empty-state {
  padding: 2.5rem 1rem;
  background: var(--ink-50);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.schedules-wrapper .empty-state .empty-icon {
  font-size: 3.5rem;
}

/* Schedule form as card */
.schedule-form {
  background: linear-gradient(135deg, var(--bg-elevated), var(--ink-50));
  border: 1.5px solid var(--accent-100);
  border-radius: 14px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 2px 8px -4px rgb(249 115 22 / 0.15);
  animation: schedFormIn 0.25s var(--ease);
}

@keyframes schedFormIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.schedule-form h4 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 0.25rem;
  color: var(--text);
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}

.schedule-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.schedule-form label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.schedule-form .req {
  color: var(--danger);
}

.schedule-form .input,
.schedule-form .select {
  background: var(--bg-elevated);
  padding: 10px 14px !important;
  font-size: 0.9rem !important;
  border-radius: 8px;
}

/* Pages picker inside schedule form */
.schedule-pages-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.schedule-pages-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.schedule-form .checkbox-chip {
  padding: 8px 14px;
  background: var(--ink-50);
  border: 1px solid var(--border);
  font-size: 0.82rem;
}

.schedule-form .checkbox-chip:has(input:checked) {
  background: var(--accent-50);
  border-color: var(--accent);
  color: var(--accent-700);
}

/* Schedule rows (existing schedules) */
.schedules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.schedule-row {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  transition: all 0.2s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.schedule-row.enabled {
  border-color: var(--success);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.03), var(--bg-elevated));
}

.schedule-row.disabled {
  opacity: 0.7;
}

.schedule-row:hover {
  box-shadow: var(--shadow-md);
}

.schedule-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.schedule-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.schedule-info strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.schedule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.schedule-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.schedule-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.schedule-actions .btn-meta {
  min-width: 36px;
  padding: 8px 10px;
  font-size: 0.92rem;
}

.schedule-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.schedule-stats strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Modal inner padding polish */
.modal {
  padding: 1.75rem;
}

.modal h2 {
  margin-bottom: 1.25rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
  .schedule-form {
    padding: 1rem;
  }
  .schedule-row {
    padding: 0.875rem 1rem;
  }
  .schedule-actions {
    flex-wrap: wrap;
  }
  .modal {
    padding: 1.25rem 1rem;
  }
}
