/* ============================================
   IRNEWS — Enterprise News Platform
   Design: Reuters/BBC/ISW editorial aesthetic
   ============================================ */

/* --- 1. Design Tokens --- */
:root {
  /* Background */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f0f1f3;
  --bg-nav: #0d1117;
  --bg-nav-hover: #161b22;
  --bg-banner: #b91c1c;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #9ca3af;
  --text-inverse: #f9fafb;
  --text-link: #1d4ed8;

  /* Brand & Status */
  --brand-red: #dc2626;
  --brand-dark: #0d1117;
  --navy: #1e3a5f;

  --status-alive: #059669;
  --status-alive-bg: #ecfdf5;
  --status-alive-border: #a7f3d0;
  --status-killed: #dc2626;
  --status-killed-bg: #fef2f2;
  --status-killed-border: #fecaca;
  --status-uncertain: #d97706;
  --status-uncertain-bg: #fffbeb;
  --status-uncertain-border: #fde68a;
  --status-disputed: #2563eb;
  --status-disputed-bg: #eff6ff;
  --status-disputed-border: #bfdbfe;
  --status-unverified: #6b7280;
  --status-unverified-bg: #f3f4f6;
  --status-unverified-border: #d1d5db;

  /* Borders */
  --border-light: #e5e7eb;
  --border-medium: #d1d5db;
  --border-dark: #9ca3af;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-fa: 'Vazirmatn', 'Tahoma', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);

  /* Layout */
  --max-width: 1280px;
  --nav-height: 52px;
}


/* --- 2. Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* Tabular numbers for data */
.tabular { font-variant-numeric: tabular-nums; }


/* --- 3. Typography --- */
h1 { font-size: 2rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.025em; color: var(--text-primary); }
h2 { font-size: 1.375rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.015em; color: var(--text-primary); }
h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.35; color: var(--text-primary); }
h4 { font-size: 0.9375rem; font-weight: 600; line-height: 1.4; color: var(--text-primary); }

.subhead {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 640px;
}

.label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.fa-text { display: none; }
.en-text { display: inline; }
[data-lang="fa"] .fa-text { display: inline; }
[data-lang="fa"] .en-text { display: none; }
[data-lang="fa"] .fa-block { display: block !important; }
[data-lang="fa"] .en-block { display: none !important; }
.fa-block { display: none; }
.en-block { display: block; }

[data-lang="fa"] body,
[dir="rtl"] body {
  font-family: var(--font-fa);
}


/* --- 4. Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.page-content {
  padding: var(--space-8) 0 var(--space-12);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-5); }


/* --- 5. Breaking Banner --- */
.breaking-banner {
  background: var(--bg-banner);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-6);
  overflow: hidden;
  font-size: 0.8125rem;
}

.breaking-label {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(0,0,0,0.25);
  padding: 2px 8px;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}

.breaking-scroll { overflow: hidden; flex: 1; direction: ltr; }

.breaking-text {
  font-weight: 500;
  white-space: nowrap;
  display: inline-block;
  animation: scroll-text 240s linear infinite;
}

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

/* Farsi ticker: enters from left, exits right (Persian TV convention) */
[data-lang="fa"] .breaking-text { animation: scroll-text-fa 240s linear infinite; }
@keyframes scroll-text-fa {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.breaking-banner:hover .breaking-text { animation-play-state: paused; }

/* --- 6. Navigation --- */
.site-nav {
  background: var(--bg-nav);
  height: var(--nav-height);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-inverse);
}

.nav-brand:hover { text-decoration: none; }

.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--brand-red);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  font-family: var(--font-sans);
  color: white;
}

.brand-name {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-family: var(--font-sans);
  line-height: 1;
  color: var(--text-inverse);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
}

.nav-links a {
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  height: var(--nav-height);
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-links a:hover {
  color: rgba(255,255,255,0.95);
  text-decoration: none;
}

.nav-links a.active {
  color: #ffffff;
  border-bottom-color: var(--brand-red);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.nav-updated {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.4);
}

.lang-toggle {
  display: flex;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.lang-btn {
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  background: transparent;
  border: none;
  transition: all 0.15s;
}

.lang-btn:hover { color: rgba(255,255,255,0.8); }
.lang-btn.active { background: var(--brand-red); color: white; }

/* Hamburger Button (mobile only) */
.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
}

.nav-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: rgba(255,255,255,0.8);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.nav-hamburger.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-hamburger.active span:nth-child(2) { opacity: 0; }
.nav-hamburger.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Mobile menu overlay */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--nav-height);
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

.nav-overlay.open { display: block; }


/* --- 7. Page Header --- */
.page-header {
  padding: var(--space-10) 0 var(--space-8);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: var(--space-8);
}

.page-header h1 { margin-bottom: var(--space-2); }
.page-header .subhead { margin-top: var(--space-2); }

.page-header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 2px;
}

.badge-live {
  background: var(--status-killed-bg);
  color: var(--status-killed);
  border: 1px solid var(--status-killed-border);
}

.badge-live .pulse {
  width: 6px;
  height: 6px;
  background: var(--status-killed);
  border-radius: 50%;
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}


/* --- 8. Stat Cards --- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--bg-primary);
  padding: var(--space-5) var(--space-6);
}

.stat-card .label { margin-bottom: var(--space-1); }

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-value.red { color: var(--status-killed); }
.stat-value.green { color: var(--status-alive); }
.stat-value.amber { color: var(--status-uncertain); }
.stat-value.blue { color: var(--status-disputed); }
.stat-value.navy { color: var(--navy); }

.stat-note {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}


/* --- 9. Sections --- */
.section {
  margin-bottom: var(--space-10);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--text-primary);
  margin-bottom: var(--space-5);
}

.section-head h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.section-head h2::before {
  content: '';
  width: 3px;
  height: 18px;
  background: var(--brand-red);
  border-radius: 1px;
  flex-shrink: 0;
}

.section-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}


/* --- 10. Status Badges --- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-badge.alive { background: var(--status-alive-bg); color: var(--status-alive); border: 1px solid var(--status-alive-border); }
.status-badge.alive::before { background: var(--status-alive); }
.status-badge.killed { background: var(--status-killed-bg); color: var(--status-killed); border: 1px solid var(--status-killed-border); }
.status-badge.killed::before { background: var(--status-killed); }
.status-badge.uncertain { background: var(--status-uncertain-bg); color: var(--status-uncertain); border: 1px solid var(--status-uncertain-border); }
.status-badge.uncertain::before { background: var(--status-uncertain); }
.status-badge.disputed { background: var(--status-disputed-bg); color: var(--status-disputed); border: 1px solid var(--status-disputed-border); }
.status-badge.disputed::before { background: var(--status-disputed); }
.status-badge.unverified { background: var(--status-unverified-bg); color: var(--status-unverified); border: 1px solid var(--status-unverified-border); }
.status-badge.unverified::before { background: var(--status-unverified); }


/* --- 11. Filter Bar --- */
.filter-bar {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--text-inverse);
}


/* --- 12. Officials Table --- */
.officials-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.officials-table thead {
  position: sticky;
  top: var(--nav-height);
  z-index: 10;
}

.officials-table th {
  background: var(--bg-secondary);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--border-light);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.officials-table th:hover { color: var(--text-primary); }

.officials-table th .sort-arrow {
  margin-left: 4px;
  font-size: 0.625rem;
  opacity: 0.4;
}

.officials-table th.sorted .sort-arrow { opacity: 1; color: var(--brand-red); }

.officials-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.officials-table tbody tr {
  transition: background 0.1s;
}

.officials-table tbody tr:hover {
  background: var(--bg-secondary);
}

.officials-table tbody tr.killed-row {
  color: var(--text-tertiary);
}

.officials-table tbody tr.killed-row .name-cell .name-en {
  text-decoration: line-through;
  text-decoration-color: var(--status-killed);
  text-decoration-thickness: 1px;
}

.name-cell {
  min-width: 180px;
}

.name-cell .name-en {
  font-weight: 600;
  color: var(--text-primary);
}

.name-cell .name-fa {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  font-family: var(--font-fa);
  margin-top: 1px;
}

.role-cell {
  color: var(--text-secondary);
  max-width: 280px;
}

.date-cell {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.tier-cell {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.conf-dots {
  display: flex;
  gap: 2px;
}

.conf-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-light);
}

.conf-dot.filled { background: var(--text-secondary); }
.conf-dot.filled.high { background: var(--status-alive); }
.conf-dot.filled.low { background: var(--status-uncertain); }


/* --- 13. Officials Cards (alternative view) --- */
.officials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.official-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.official-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.official-card.status-alive { border-left: 3px solid var(--status-alive); }
.official-card.status-killed { border-left: 3px solid var(--status-killed); }
.official-card.status-uncertain { border-left: 3px solid var(--status-uncertain); }
.official-card.status-disputed { border-left: 3px solid var(--status-disputed); }

.official-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.card-header-text { flex: 1; min-width: 0; }

.official-card .card-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.official-card .card-name-fa {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  font-family: var(--font-fa);
  line-height: 1.3;
}

.official-card .card-role {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: var(--space-3);
}

.official-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.official-card.is-killed {
  opacity: 0.7;
}

.official-card.is-killed .card-name {
  text-decoration: line-through;
  text-decoration-color: var(--status-killed);
}


/* --- 14. Category Groups --- */
.category-group {
  margin-bottom: var(--space-8);
}

.category-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: var(--space-4);
}


/* --- 15. View Toggle --- */
.view-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-toggle button {
  padding: 5px 10px;
  background: var(--bg-primary);
  border: none;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: all 0.15s;
}

.view-toggle button:hover { color: var(--text-primary); }
.view-toggle button.active { background: var(--bg-secondary); color: var(--text-primary); font-weight: 600; }

.search-input {
  padding: 6px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-primary);
  width: 220px;
  transition: border-color 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-red);
}

.search-input::placeholder { color: var(--text-tertiary); }


/* --- 16. Charts --- */
.chart-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.chart-card h3 { margin-bottom: 2px; }

.chart-subtitle {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chart-subtitle::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chart-accent, var(--status-killed));
  opacity: 0.6;
  flex-shrink: 0;
}

.chart-wrap {
  position: relative;
  height: 280px;
}


/* --- 17. Collapse Index --- */
.collapse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

.collapse-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.collapse-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

.collapse-card .label { margin-bottom: var(--space-3); }

.progress-bar {
  background: var(--border-light);
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
  margin-bottom: var(--space-2);
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-fill.red { background: linear-gradient(90deg, var(--status-killed), #ef4444); }
.progress-fill.amber { background: linear-gradient(90deg, var(--status-uncertain), #f59e0b); }
.progress-fill.blue { background: linear-gradient(90deg, var(--status-disputed), #3b82f6); }
.progress-fill.green { background: linear-gradient(90deg, var(--status-alive), #10b981); }

.collapse-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.collapse-note {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.4;
}


/* --- 18. Timeline --- */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border-light);
}

.timeline-item {
  position: relative;
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -23px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}

.timeline-item.type-killed::before { background: var(--status-killed); }
.timeline-item.type-event::before { background: var(--status-uncertain); }
.timeline-item.type-collapse::before { background: var(--brand-red); }

.timeline-date {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.timeline-title {
  font-weight: 700;
  margin-bottom: 2px;
}

.timeline-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.timeline-tag {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: var(--space-2);
}


/* --- 19. Proxy Cards --- */
.proxy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}

.proxy-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.proxy-card h4 { margin-bottom: var(--space-2); }

.proxy-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.proxy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.proxy-note {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: var(--space-2);
}


/* --- 20. Tier Methodology --- */
.methodology-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.tier-item {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.tier-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.tier-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

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

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


/* --- 21. Command Chain --- */
.chain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.chain-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.chain-card h4 { margin-bottom: var(--space-3); }

.chain-entry {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: 0.8125rem;
}

.chain-entry + .chain-entry {
  border-top: 1px solid var(--border-light);
}

.chain-arrow {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}


/* --- 22. Footer --- */
.site-footer {
  background: var(--bg-nav);
  color: rgba(255,255,255,0.5);
  padding: var(--space-10) 0;
  margin-top: var(--space-12);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-8);
}

.footer-brand {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text-inverse);
  margin-bottom: var(--space-2);
}

.footer-desc {
  font-size: 0.8125rem;
  line-height: 1.5;
  max-width: 400px;
}

.footer-links {
  display: flex;
  gap: var(--space-6);
  list-style: none;
}

.footer-links a {
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover { color: rgba(255,255,255,0.8); text-decoration: none; }

.footer-disclaimer {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.3);
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid rgba(255,255,255,0.08);
  line-height: 1.6;
}


/* --- 23. RTL Overrides --- */
[dir="rtl"] .section-head h2::before { order: 1; }
[dir="rtl"] .official-card { border-left: none; }
[dir="rtl"] .official-card.status-alive { border-right: 3px solid var(--status-alive); }
[dir="rtl"] .official-card.status-killed { border-right: 3px solid var(--status-killed); }
[dir="rtl"] .official-card.status-uncertain { border-right: 3px solid var(--status-uncertain); }
[dir="rtl"] .official-card.status-disputed { border-right: 3px solid var(--status-disputed); }
[dir="rtl"] .timeline { padding-left: 0; padding-right: 24px; }
[dir="rtl"] .timeline::before { left: auto; right: 5px; }
[dir="rtl"] .timeline-item::before { left: auto; right: -23px; }
[dir="rtl"] .officials-table th { text-align: right; }


/* --- 24. Responsive --- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  /* #5: Force 2x2 grid for 4 collapse cards — avoids 3+1 orphan */
  .collapse-grid { grid-template-columns: repeat(2, 1fr); }
  /* Table scroll for tablets too */
  .officials-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 768px) {
  :root { --nav-height: 48px; }

  .container { padding: 0 var(--space-4); }
  .page-header { padding: var(--space-6) 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .officials-grid { grid-template-columns: 1fr; }
  .nav-updated { display: none !important; }
  .footer-inner { flex-direction: column; }
  .footer-links { flex-direction: column; gap: var(--space-3); }

  .officials-table-wrap { overflow-x: auto; }
  .officials-table { min-width: 700px; }
  /* Disable sticky thead on mobile: overflow-x:auto forces overflow-y:auto per spec,
     making the wrapper a scroll container — sticky top:48px then covers the first row */
  .officials-table thead { position: static; }

  .page-header h1 { font-size: 1.5rem; }

  /* Hamburger visible on mobile */
  .nav-hamburger { display: flex; }

  /* Mobile nav: hidden by default, dropdown when open */
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-nav);
    border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    padding: var(--space-2) 0;
    z-index: 100;
  }

  .nav-links.open { display: flex; }

  .nav-links li { width: 100%; }

  .nav-links a {
    height: auto;
    padding: var(--space-3) var(--space-6);
    border-bottom: none;
    font-size: 0.9375rem;
  }

  .nav-links a.active {
    background: rgba(255,255,255,0.06);
    border-bottom: none;
    border-left: 3px solid var(--brand-red);
  }

  [dir="rtl"] .nav-links a.active {
    border-left: none;
    border-right: 3px solid var(--brand-red);
  }

  /* Keep site-nav relative for absolute dropdown positioning */
  .site-nav { position: sticky; }
  .site-nav .container { position: relative; }
}

@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .collapse-grid { grid-template-columns: 1fr; }
  .search-input { width: 100%; }

  /* #3: Breaking banner — tighter on small screens */
  .breaking-banner { padding: var(--space-1) var(--space-3); font-size: 0.75rem; }
  .breaking-label { font-size: 0.5625rem; padding: 2px 6px; }

  /* #4: Stat cards — reduce large values to fit */
  .stat-value { font-size: 1.375rem; }
  .stat-note { font-size: 0.6875rem; }

  /* #5: Collapse index values */
  .collapse-value { font-size: 1.375rem; }

  /* #7: Charts — set minimum usable height */
  .chart-wrap { height: 220px; }

  /* Proxy cards single column */
  .proxy-grid { grid-template-columns: 1fr; }

  /* Tier methodology cards single column */
  .tier-grid { grid-template-columns: 1fr; }

  /* Latest developments — tighter on mobile */
  .dev-feed { padding-left: var(--space-3); margin-left: 0; }
  [dir="rtl"] .dev-feed { padding-right: var(--space-3); margin-right: 0; }
  .dev-title { font-size: 0.8125rem; }
}


/* --- 25. Latest Developments Feed --- */
.dev-feed {
  border-left: 2px solid var(--border-light);
  padding-left: var(--space-5);
  margin-left: var(--space-1);
}

[dir="rtl"] .dev-feed {
  border-left: none;
  border-right: 2px solid var(--border-light);
  padding-left: 0;
  padding-right: var(--space-5);
  margin-left: 0;
  margin-right: var(--space-1);
}

.dev-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
}

.dev-item + .dev-item {
  border-top: 1px solid var(--bg-tertiary);
}

.dev-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  position: relative;
}

.dev-item:first-child .dev-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: inherit;
  animation: dev-pulse 2s ease-in-out infinite;
}

@keyframes dev-pulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.8); opacity: 0; }
}

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

.dev-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.45;
}

.dev-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: 2px;
}

.dev-date {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.dev-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-link);
  text-decoration: none;
  white-space: nowrap;
}

.dev-link:hover { text-decoration: underline; }


/* --- 26. Print --- */
@media print {
  .site-nav, .breaking-banner, .lang-toggle, .filter-bar, .view-controls { display: none !important; }
  body { font-size: 12px; color: #000; }
  .page-content { padding: 0; }
  .official-card, .chart-card, .proxy-card { break-inside: avoid; }
  .site-footer { display: none; }
}


/* --- 26b. Utility --- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.hidden { display: none !important; }


/* --- 27. Official Avatars --- */
.official-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.official-avatar.large {
  width: 56px;
  height: 56px;
}

.official-avatar .avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: #fff;
  user-select: none;
}

.official-avatar.large .avatar-initials { font-size: 0.9375rem; }

.official-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.official-avatar.status-alive .avatar-initials    { background: var(--status-alive); }
.official-avatar.status-killed .avatar-initials   { background: var(--status-killed); }
.official-avatar.status-uncertain .avatar-initials { background: var(--status-uncertain); }
.official-avatar.status-disputed .avatar-initials  { background: var(--status-disputed); }

.name-with-avatar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}


/* --- 28. Effectiveness Chart --- */
.effectiveness-chart-wrap {
  position: relative;
  height: 380px;
  direction: ltr;
}

.effectiveness-legend {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

.legend-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend-line-swatch {
  width: 28px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
  position: relative;
}

.legend-line-swatch::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: inherit;
}


/* --- 29. Control Index Chart --- */
.control-chart-wrap {
  position: relative;
  height: 420px;
  margin: 8px 8px 0 0;
}

.control-chart-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-light);
}

.control-index-callout {
  flex-shrink: 0;
}

.control-index-number {
  font-size: 3rem;
  font-weight: 900;
  color: var(--brand-red);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  text-shadow: 0 1px 2px rgba(220,38,38,0.1);
}

.control-index-sublabel {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.control-index-change {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.control-chart-formula {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  max-width: 520px;
  line-height: 1.55;
  text-align: right;
}

.formula-line { margin-bottom: 2px; }

[dir="rtl"] .control-chart-formula { text-align: left; }


/* --- 30. News Feed --- */
.news-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.thread-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.thread-card:hover {
  border-color: var(--border-medium, #d1d5db);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.thread-card.pinned {
  border-left: 3px solid var(--brand-red);
}

[dir="rtl"] .thread-card.pinned {
  border-left: 1px solid var(--border-light);
  border-right: 3px solid var(--brand-red);
}

.thread-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.thread-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.thread-status-badge {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.thread-category-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.verdict-badge {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.pinned-badge {
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-red);
  background: rgba(220,38,38,0.06);
  border: 1px solid rgba(220,38,38,0.2);
  padding: 1px 6px;
  border-radius: 3px;
}

.thread-time {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Thread body: text + thumbnail side by side */
.thread-body {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  margin-bottom: var(--space-3);
}
.thread-text {
  flex: 1;
  min-width: 0;
}
[dir="rtl"] .thread-body {
  flex-direction: row-reverse;
}

/* Branded thumbnail — hidden until images finalised */
.thread-thumb {
  display: none;
}

.thread-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  line-height: 1.4;
}

.thread-preview {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-4);
}

.thread-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.toggle-icon {
  font-size: 0.5rem;
}

.empty-state {
  text-align: center;
  padding: var(--space-12) 0;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}


/* --- 31. News Thread Entries (micro-timeline) --- */
.thread-entries {
  margin: var(--space-5) 0 var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

.thread-entry {
  display: flex;
  gap: var(--space-4);
  position: relative;
}

.entry-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 20px;
  padding-top: 4px;
}

.entry-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--bg-primary);
}

.entry-line {
  width: 2px;
  flex: 1;
  background: var(--border-light);
  margin-top: 4px;
}

.entry-content {
  flex: 1;
  padding-bottom: var(--space-5);
  min-width: 0;
}

.thread-entry.last .entry-content {
  padding-bottom: 0;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.entry-type-badge {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.entry-time {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.reported-time {
  font-size: 0.625rem;
  color: var(--text-tertiary);
  opacity: 0.7;
  margin-inline-start: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.entry-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  line-height: 1.4;
}

.entry-body {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: var(--space-3);
}

.entry-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* Sources kept in data layer only — no frontend display */


/* --- 32. Confidence Meter --- */
.confidence-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.confidence-bar {
  display: flex;
  gap: 2px;
}

.confidence-seg {
  width: 16px;
  height: 6px;
  border-radius: 1px;
  background: var(--border-light);
}

.confidence-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}


/* Section 33 reserved */


/* --- 34. News Responsive --- */
@media (max-width: 768px) {
  .thread-card {
    padding: var(--space-4);
  }

  .thread-title {
    font-size: 1rem;
  }

  .thread-header {
    flex-direction: column;
    gap: var(--space-2);
  }

  .thread-thumb {
    width: 100px;
    height: 100px;
  }

  .entry-footer {
    flex-direction: column;
    gap: var(--space-3);
  }

  .source-tier-legend {
    gap: var(--space-3);
  }
}

@media (max-width: 480px) {
  .thread-badges {
    gap: 4px;
  }

  .entry-content {
    padding-bottom: var(--space-4);
  }

}

/* --- 35. Wall of Elimination --- */
.wall-section {
  background: var(--bg-nav);
  padding: var(--space-10) 0;
  margin: var(--space-8) 0;
}
.wall-section .section-head h2 {
  color: var(--text-inverse);
}
.wall-section .wall-subtitle {
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}
.wall-count {
  color: var(--status-killed);
  font-size: 0.875rem;
  font-weight: 600;
}
.wall-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-6);
}
.wall-cell {
  background: #161b22;
  border-radius: 6px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.wall-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.15);
}
.wall-photo-wrap {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #21262d;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wall-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.wall-photo-wrap .avatar-initials {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
}
.wall-photo-wrap::before,
.wall-photo-wrap::after {
  content: '';
  position: absolute;
  top: 5%;
  left: 50%;
  width: 8%;
  height: 90%;
  background: var(--status-killed);
  opacity: 0.75;
  border-radius: 3px;
  z-index: 2;
  pointer-events: none;
}
.wall-photo-wrap::before { transform: translateX(-50%) rotate(45deg); }
.wall-photo-wrap::after { transform: translateX(-50%) rotate(-45deg); }
.wall-info {
  padding: var(--space-2) var(--space-3);
}
.wall-name {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-inverse);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wall-role {
  font-size: 0.5625rem;
  color: var(--text-tertiary);
  line-height: 1.3;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .wall-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .wall-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  .wall-grid { grid-template-columns: repeat(2, 1fr); }
  .wall-info { padding: var(--space-1) var(--space-2); }
  .wall-name { font-size: 0.625rem; }
}

/* --- 36. People's Target List --- */
.target-section {
  margin-top: var(--space-8);
}
/* Info button + popover */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--text-tertiary);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 0.6875rem;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 8px;
  transition: all 0.15s;
  line-height: 1;
  font-family: var(--font-sans);
}
[dir="rtl"] .info-btn { margin-left: 0; margin-right: 8px; }
.info-btn:hover { background: var(--brand-red); color: white; border-color: var(--brand-red); }
/* Info modal overlay */
.info-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modal-fade-in 0.2s ease-out;
}
.info-modal-overlay.hidden { display: none; }
@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.info-modal {
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
  padding: var(--space-8) var(--space-6);
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--text-secondary);
  animation: modal-slide-in 0.25s ease-out;
}
@keyframes modal-slide-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.info-modal h3 { font-size: 1.125rem; color: var(--text-primary); margin-bottom: var(--space-3); }
.info-modal strong { color: var(--text-primary); }
.info-modal p { margin: 8px 0; }
.info-modal-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-secondary);
  border-radius: 50%;
  font-size: 1.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
[dir="rtl"] .info-modal-close { right: auto; left: var(--space-3); }
.info-modal-close:hover { background: var(--brand-red); color: white; }

.target-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: var(--space-6);
}
.target-card {
  background: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 20px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, background 0.2s;
}
.target-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  background: linear-gradient(180deg, #ffffff 0%, #eef0f3 100%);
}
.target-rank {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--brand-red);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  letter-spacing: 0.02em;
  z-index: 2;
}
.target-rank[data-rank="grey"] { background: #9ca3af; }
[dir="rtl"] .target-rank { left: auto; right: 6px; }
.target-rank[data-rank="1"] { background: #b8860b; }
/* WANTED stamp on #1 ranked card */
.target-card[data-rank-card="1"]::before {
  content: 'WANTED';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-25deg);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(220, 38, 38, 0.10);
  pointer-events: none;
  z-index: 0;
  white-space: nowrap;
}
[dir="rtl"] .target-card[data-rank-card="1"]::before {
  content: 'WANTED';  /* Keep English — it's a stamp/brand mark */
  transform: translate(-50%, -50%) rotate(25deg);
}
.target-rank[data-rank="2"] { background: #6b7280; }
.target-rank[data-rank="3"] { background: #92400e; }
.target-photo-wrap {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 8px;
  border: 2px solid var(--border-light);
  transition: border-color 0.2s;
}
.target-card:hover .target-photo-wrap {
  border-color: var(--brand-red);
}
.target-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.target-photo-wrap .avatar-initials {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-tertiary);
}
.target-info {
  margin-bottom: 4px;
  width: 100%;
}
.target-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
}
.target-role {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  margin-top: 1px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
  min-height: 2em;
}
.target-info .status-badge {
  margin-top: 4px;
  display: inline-block;
  font-size: 0.5625rem;
  padding: 1px 5px;
}
.vote-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
  width: 100%;
  justify-content: center;
}
.vote-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.6875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}
.vote-up:hover {
  color: var(--status-alive);
  border-color: var(--status-alive);
  background: var(--status-alive-bg);
  box-shadow: 0 0 0 3px var(--status-alive-bg);
}
.vote-down:hover {
  color: var(--status-killed);
  border-color: var(--status-killed);
  background: var(--status-killed-bg);
  box-shadow: 0 0 0 3px var(--status-killed-bg);
}
.vote-btn:active {
  transform: scale(0.85);
}
.vote-btn.cooling {
  pointer-events: none;
  opacity: 0.3;
  transition: opacity 0.8s ease;
}
.vote-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
/* Disable ALL vote buttons while any vote is processing */
.voting-active .vote-btn {
  pointer-events: none;
  opacity: 0.4;
}
/* On-card toast label */
.card-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
  pointer-events: none;
}
.card-toast.visible { opacity: 1; transform: translate(-50%, -50%); }
.card-toast.up { background: var(--status-alive); color: white; }
.card-toast.down { background: var(--status-killed); color: white; }
.vote-count {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: center;
  transition: color 0.3s;
  direction: ltr;
}
.vote-count.positive { color: var(--status-alive); }
.vote-count.negative { color: var(--status-killed); }

/* "You voted" indicator on buttons */
.vote-btn.voted {
  border-color: currentColor;
  background: currentColor;
  color: white;
}
.vote-up.voted { background: var(--status-alive); border-color: var(--status-alive); color: white; }
.vote-down.voted { background: var(--status-killed); border-color: var(--status-killed); color: white; }

/* Focus-visible for keyboard navigation */
.vote-btn:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: 2px;
}

/* Up/down breakdown tooltip on hover */
.vote-count { position: relative; cursor: default; }
.vote-count[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background: var(--text-primary);
  color: var(--bg-primary);
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 5;
}
.vote-count[data-tip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Photo fade-in */
.target-photo-wrap img {
  animation: photo-fadein 0.3s ease-out;
}
@keyframes photo-fadein {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Vote processing state — subtle border only, no pulse animation */
.target-card.voting {
  border-color: var(--brand-red);
}

/* Vote success flash — direction-aware (green for up, red for down) */
.target-card.vote-success-up {
  animation: card-success-up 0.6s ease-out;
}
@keyframes card-success-up {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.4); }
  40% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0.15); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}
.target-card.vote-success-down {
  animation: card-success-down 0.6s ease-out;
}
@keyframes card-success-down {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  40% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.15); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Vote count pop animation on change */
.vote-count.pop {
  animation: count-pop 0.3s ease-out;
}
@keyframes count-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* Toast notifications */
.vote-toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: var(--space-2) var(--space-5);
  border-radius: 24px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
}
.vote-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.vote-toast.success { background: var(--status-alive); }
.vote-toast.error { background: var(--status-killed); }

/* Loading skeleton for target grid */
.target-skeleton {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.target-skeleton .skel-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.target-skeleton .skel-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.target-skeleton .skel-line.w60 { width: 60%; }
.target-skeleton .skel-line.w40 { width: 40%; }

@media (max-width: 1200px) {
  .target-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .target-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .target-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .target-card { padding: 10px 8px 8px; }
  .target-photo-wrap { width: 44px; height: 44px; }
  .target-name { font-size: 0.75rem; }
  .target-role { font-size: 0.625rem; }
}
@media (max-width: 400px) {
  .target-grid { grid-template-columns: repeat(2, 1fr); }
  .target-photo-wrap { width: 40px; height: 40px; }
  .target-photo-wrap .avatar-initials { font-size: 0.75rem; }
  .vote-count[data-tip]::after { display: none; }
  .vote-btn { width: 28px; height: 28px; font-size: 0.6875rem; }
  .target-card[data-rank-card="1"]::before { font-size: 1.25rem; }
}
@media (max-width: 320px) {
  .target-grid { grid-template-columns: 1fr; gap: 6px; }
  .target-card { padding: 12px 8px 10px; }
  .target-photo-wrap { width: 56px; height: 56px; }
  .target-photo-wrap .avatar-initials { font-size: 1rem; }
  .target-name { font-size: 0.875rem; -webkit-line-clamp: 2; }
  .target-role { font-size: 0.75rem; }
  .vote-btn { width: 32px; height: 32px; font-size: 0.75rem; }
  .vote-count { font-size: 1rem; }
  .target-card[data-rank-card="1"]::before { font-size: 1.5rem; }
}
/* Touch devices: suppress hover tooltips and vote button hover glow */
@media (hover: none) {
  .vote-count[data-tip]::after { display: none !important; }
  .vote-up:hover { color: var(--text-secondary); border-color: var(--border-light); background: var(--bg-secondary); box-shadow: none; }
  .vote-down:hover { color: var(--text-secondary); border-color: var(--border-light); background: var(--bg-secondary); box-shadow: none; }
}

/* --- 37. Vote Analytics Dashboard --- */
.analytics-section {
  margin-top: var(--space-8);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-light);
}
.analytics-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-6);
}
.analytics-stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: var(--space-4);
  text-align: center;
}
.analytics-stat .label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}
.analytics-stat .value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-top: var(--space-1);
}
.analytics-stat .detail {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}
.analytics-charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-6);
}
.analytics-chart-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: var(--space-5);
}
.analytics-chart-card h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: var(--space-4);
}
.trending-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.trending-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}
.trending-item:hover { background: var(--bg-secondary); margin: 0 calc(-1 * var(--space-3)); padding-left: var(--space-3); padding-right: var(--space-3); border-radius: 6px; }
.trending-item:last-child { border-bottom: none; }
.trending-rank {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-tertiary);
  width: 20px;
}
.trending-empty, .analytics-empty {
  color: var(--text-tertiary);
  font-size: 0.8125rem;
  text-align: center;
  padding: var(--space-6);
}
.trending-name {
  flex: 1;
  font-size: 0.8125rem;
  font-weight: 500;
}
.trending-delta {
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.trending-delta.positive { color: var(--status-alive); }
.trending-delta.negative { color: var(--status-killed); }
.engagement-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.engagement-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: var(--space-4);
  text-align: center;
}
.engagement-card .eng-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--navy);
}
.engagement-card .eng-label {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}
.analytics-skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 8px;
  min-height: 120px;
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 1024px) {
  .analytics-summary { grid-template-columns: repeat(3, 1fr); }
  .analytics-charts { grid-template-columns: 1fr; }
  .engagement-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  .analytics-summary { grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
  .analytics-stat { padding: var(--space-3); }
  .analytics-stat .value { font-size: 1.25rem; }
  .engagement-row { grid-template-columns: 1fr; gap: var(--space-2); }
  .engagement-card { padding: var(--space-3); }
  .engagement-card .eng-value { font-size: 1.375rem; }
}

/* --- 38. Photo Grid View --- */
.grid-section {
  background: var(--bg-nav);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-top: var(--space-4);
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-2);
}
.photo-grid-cell {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #161b22;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: default;
}
.photo-grid-cell:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.05);
  z-index: 2;
}
.photo-grid-photo {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #21262d;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-grid-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.photo-grid-cell:hover .photo-grid-photo img {
  transform: scale(1.08);
}
.photo-grid-photo .avatar-initials {
  font-size: 1.25rem;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.05em;
}
/* Status ring indicators */
.photo-grid-cell.status-alive .photo-grid-photo {
  box-shadow: inset 0 0 0 2px var(--status-alive);
}
.photo-grid-cell.status-alive::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--status-alive);
  animation: alive-pulse 2s ease-in-out infinite;
}
@keyframes alive-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; box-shadow: 0 0 8px var(--status-alive); }
}
.photo-grid-cell.status-killed .photo-grid-photo {
  box-shadow: inset 0 0 0 2px var(--status-killed);
}
.photo-grid-cell.status-uncertain .photo-grid-photo {
  box-shadow: inset 0 0 0 2px var(--status-uncertain);
}
.photo-grid-cell.status-disputed .photo-grid-photo {
  box-shadow: inset 0 0 0 2px var(--status-disputed);
}
/* Red X overlay for killed */
.photo-grid-cell.status-killed .photo-grid-photo::before,
.photo-grid-cell.status-killed .photo-grid-photo::after {
  content: '';
  position: absolute;
  top: 5%; left: 50%;
  width: 8%; height: 90%;
  background: var(--status-killed);
  opacity: 0.75;
  border-radius: 3px;
  z-index: 2;
  pointer-events: none;
}
.photo-grid-cell.status-killed .photo-grid-photo::before { transform: translateX(-50%) rotate(45deg); }
.photo-grid-cell.status-killed .photo-grid-photo::after { transform: translateX(-50%) rotate(-45deg); }

.photo-grid-info {
  padding: var(--space-1) var(--space-2);
  background: #161b22;
}
.photo-grid-name {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-inverse);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.photo-grid-role {
  font-size: 0.5rem;
  color: var(--text-tertiary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Grid tooltip */
.photo-grid-cell .grid-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(0,0,0,0.92);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.6875rem;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 10;
}
.photo-grid-cell:hover .grid-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
.grid-tooltip .gt-name { font-weight: 600; }
.grid-tooltip .gt-role { color: #9ca3af; }
.grid-tooltip .gt-status { margin-top: 2px; font-weight: 600; }
.grid-tooltip .gt-status.killed { color: var(--status-killed); }
.grid-tooltip .gt-status.alive { color: var(--status-alive); }
.grid-tooltip .gt-status.uncertain { color: var(--status-uncertain); }
.grid-tooltip .gt-status.disputed { color: var(--status-disputed); }

/* Shimmer skeleton for grid while loading */
.photo-grid-skeleton {
  aspect-ratio: 1;
  border-radius: 6px;
  background: linear-gradient(90deg, #21262d 25%, #30363d 50%, #21262d 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* View transition */
#tableView, #cardsView, #gridView {
  animation: view-fade-in 0.2s ease;
}
@keyframes view-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1024px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
@media (max-width: 768px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}
@media (max-width: 480px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .photo-grid-info { padding: 2px var(--space-1); }
  .photo-grid-name { font-size: 0.5625rem; }
  .photo-grid-role { font-size: 0.4375rem; }
}

/* --- 39. Image Generator Modal --- */
.generate-btn {
  padding: 6px 16px;
  background: var(--brand-red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.generate-btn:hover {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(220,38,38,0.3);
}
.generate-btn:active { transform: translateY(0); }

.img-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.img-modal-overlay.visible { opacity: 1; }
.img-modal-overlay.hidden { display: none !important; }

.img-modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4), 0 0 0 1px rgba(0,0,0,0.05);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}
.img-modal-overlay.visible .img-modal {
  transform: translateY(0);
}
.img-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-light);
}
.img-modal-header h3 { font-size: 1rem; font-weight: 700; margin: 0; }
.img-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.img-modal-close:hover { color: var(--text-primary); background: var(--bg-secondary); }

.img-modal-body {
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.img-modal-field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-1);
}
.img-modal-field select,
.img-modal-field input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: border-color 0.15s;
}
.img-modal-field select:focus,
.img-modal-field input:focus {
  outline: none;
  border-color: var(--brand-red);
}
.img-modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.img-custom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-1);
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  background: var(--bg-secondary);
}
.img-custom-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  padding: 2px 0;
  cursor: pointer;
}
.img-custom-item input[type="checkbox"] { flex-shrink: 0; accent-color: var(--brand-red); }

.img-preview-wrap {
  background: #111827;
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
  position: relative;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-preview-wrap canvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.img-preview-wrap .preview-placeholder {
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}

.img-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-light);
}
.img-btn-download {
  padding: 8px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--brand-red);
  color: #fff;
}
.img-btn-download:hover { background: #b91c1c; }
.img-btn-download:disabled {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  cursor: not-allowed;
}
.img-btn-download.success {
  background: var(--status-alive);
}

@media (max-width: 768px) {
  .img-modal { max-width: 100%; }
  .img-modal-body { padding: var(--space-4); }
  .img-modal-row { grid-template-columns: 1fr; }
}
