/* ============================================================
   FutureOracle — Futuristic Dark-Mode Design System
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Deep space backgrounds */
  --bg-void:        #050508;
  --bg-deep:        #0a0a0f;
  --bg-surface:     #12121a;
  --bg-elevated:    #1a1a28;
  --bg-card:        rgba(18, 18, 26, 0.65);
  --bg-card-hover:  rgba(26, 26, 40, 0.8);

  /* Primary accent — electric cyan */
  --cyan:           #00f0ff;
  --cyan-glow:      rgba(0, 240, 255, 0.25);
  --cyan-dim:       rgba(0, 240, 255, 0.08);

  /* Secondary accent — aurora purple */
  --purple:         #8b5cf6;
  --purple-glow:    rgba(139, 92, 246, 0.25);
  --purple-dim:     rgba(139, 92, 246, 0.08);

  /* Tertiary accents */
  --neon-green:     #22c55e;
  --neon-pink:      #f43f8e;
  --neon-orange:    #f59e0b;
  --neon-red:       #ef4444;
  --neon-blue:      #3b82f6;

  /* Text */
  --text-primary:   #f0f0f8;
  --text-secondary: #8888a8;
  --text-muted:     #55556a;
  --text-inverse:   #0a0a0f;

  /* Borders */
  --border-subtle:  rgba(255, 255, 255, 0.06);
  --border-dim:     rgba(255, 255, 255, 0.10);
  --border-glow:    rgba(0, 240, 255, 0.20);

  /* Glassmorphism */
  --glass-blur:     blur(10px);
  --glass-bg:       rgba(18, 18, 26, 0.75);
  --glass-border:   rgba(255, 255, 255, 0.08);

  /* Category colors */
  --cat-technology:  #00f0ff;
  --cat-science:     #8b5cf6;
  --cat-geopolitics: #f43f8e;
  --cat-economy:     #f59e0b;
  --cat-climate:     #22c55e;
  --cat-health:      #ef4444;
  --cat-space:       #3b82f6;
  --cat-culture:     #e879f9;
  --cat-ai:          #06b6d4;

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Radii */
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card:    0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-subtle);
  --shadow-glow:    0 0 30px var(--cyan-glow), 0 0 60px rgba(0, 240, 255, 0.08);
  --shadow-purple:  0 0 30px var(--purple-glow), 0 0 60px rgba(139, 92, 246, 0.08);

  /* Transitions */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-void);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Particle Canvas Background ---------- */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  transform: translateZ(0);
  will-change: transform;
}

/* ---------- App Container ---------- */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  padding: var(--space-md) var(--space-xl);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: var(--shadow-glow);
}

.logo-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.logo-tag {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: var(--radius-full);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: var(--text-inverse);
  box-shadow: 0 0 20px var(--cyan-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px var(--cyan-glow), 0 4px 16px rgba(0, 0, 0, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-dim);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.btn-icon {
  padding: 0.55rem;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
}

.btn .icon {
  font-size: 1rem;
}

.btn-generating {
  pointer-events: none;
  opacity: 0.8;
}

.btn-generating .icon {
  animation: spin 1s linear infinite;
}

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

/* ---------- Search Bar ---------- */
.search-container {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-normal);
}

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

.search-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

/* ---------- Main Layout ---------- */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-xl);
}

/* ---------- Stats Dashboard ---------- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  transition: all var(--transition-normal);
}

.stat-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: var(--space-xs);
  font-weight: 600;
}

/* ---------- Category Filters ---------- */
.filters-section {
  margin-bottom: var(--space-2xl);
}

.filters-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-dim);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  font-family: 'Inter', sans-serif;
}

.filter-pill:hover {
  border-color: var(--border-glow);
  color: var(--text-primary);
}

.filter-pill.active {
  color: var(--text-inverse);
  border-color: transparent;
}

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

/* Category-specific active states */
.filter-pill[data-category="all"].active          { background: linear-gradient(135deg, var(--cyan), var(--purple)); }
.filter-pill[data-category="Technology"].active    { background: var(--cat-technology); }
.filter-pill[data-category="Science"].active       { background: var(--cat-science); }
.filter-pill[data-category="Geopolitics"].active   { background: var(--cat-geopolitics); }
.filter-pill[data-category="Economy"].active       { background: var(--cat-economy); }
.filter-pill[data-category="Climate"].active       { background: var(--cat-climate); }
.filter-pill[data-category="Health"].active        { background: var(--cat-health); }
.filter-pill[data-category="Space"].active         { background: var(--cat-space); }
.filter-pill[data-category="Culture"].active       { background: var(--cat-culture); }
.filter-pill[data-category="AI & Robotics"].active { background: var(--cat-ai); }

/* ---------- Year Navigation ---------- */
.year-nav {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-2xl);
  overflow-x: auto;
  padding-bottom: var(--space-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
}

.year-tab {
  padding: 0.4rem 1.1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.year-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-dim);
}

.year-tab.active {
  background: var(--cyan);
  color: var(--text-inverse);
  border-color: var(--cyan);
  box-shadow: 0 0 16px var(--cyan-glow);
}

/* ---------- Timeline ---------- */
.timeline-section {
  position: relative;
}

.timeline-year-header {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.timeline-year-header .year-num {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.timeline-year-header .year-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-family: 'JetBrains Mono', monospace;
}

.timeline-line {
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--purple), transparent);
  opacity: 0.3;
}

/* ---------- Prediction Cards ---------- */
.predictions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-3xl);
}

.prediction-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-slow);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.5s ease both;
  transform: translateZ(0);
}

.prediction-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  opacity: 0.8;
}

.prediction-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

/* Category top-bar colors */
.prediction-card[data-category="Technology"]::before    { background: var(--cat-technology); }
.prediction-card[data-category="Science"]::before       { background: var(--cat-science); }
.prediction-card[data-category="Geopolitics"]::before   { background: var(--cat-geopolitics); }
.prediction-card[data-category="Economy"]::before       { background: var(--cat-economy); }
.prediction-card[data-category="Climate"]::before       { background: var(--cat-climate); }
.prediction-card[data-category="Health"]::before        { background: var(--cat-health); }
.prediction-card[data-category="Space"]::before         { background: var(--cat-space); }
.prediction-card[data-category="Culture"]::before       { background: var(--cat-culture); }
.prediction-card[data-category="AI & Robotics"]::before { background: var(--cat-ai); }

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

.card-category {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
}

.card-category .cat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.card-year-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--cyan);
  background: var(--cyan-dim);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.card-narrative {
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

/* Confidence meter */
.confidence-bar {
  margin-bottom: var(--space-md);
}

.confidence-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.confidence-track {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  transition: width 1s ease;
  position: relative;
}

.confidence-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
  animation: pulse 2s ease-in-out infinite;
}

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

/* Tags */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: var(--space-md);
}

.tag {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Card click area */
.card-click-area {
  cursor: pointer;
}

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-subtle);
}

.card-engagement {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.engage-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  font-family: 'Inter', sans-serif;
}

.engage-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.engage-btn.active {
  color: var(--text-primary);
}

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

.engage-count {
  font-size: 0.7rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

.card-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.merge-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--purple);
  font-weight: 600;
  margin-left: 0.25rem;
}

.merge-badge .icon {
  font-size: 0.8rem;
}

/* Favorites filter pill */
.filter-pill-fav.active {
  background: linear-gradient(135deg, #f59e0b, #f43f8e) !important;
  color: var(--text-inverse) !important;
  border-color: transparent !important;
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
  opacity: 0.4;
}

.empty-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.empty-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- API Key Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  animation: fadeIn 0.3s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  max-width: 480px;
  width: 100%;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.4s ease;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  line-height: 1.6;
}

.modal-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-normal);
  margin-bottom: var(--space-lg);
}

.modal-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* ---------- Notification Toast ---------- */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  min-width: 300px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: slideInRight 0.4s ease;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.toast.success { border-left: 3px solid var(--neon-green); }
.toast.error   { border-left: 3px solid var(--neon-red); }
.toast.info    { border-left: 3px solid var(--cyan); }

.toast-icon { font-size: 1.2rem; }
.toast-msg {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ---------- Loading Spinner ---------- */
.generating-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
}

.generating-overlay.hidden {
  display: none;
}

.spinner-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--cyan);
  border-right-color: var(--purple);
  animation: spin 1s linear infinite;
}

.generating-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.generating-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Staggered card animation */
.prediction-card:nth-child(1)  { animation-delay: 0.0s; }
.prediction-card:nth-child(2)  { animation-delay: 0.06s; }
.prediction-card:nth-child(3)  { animation-delay: 0.12s; }
.prediction-card:nth-child(4)  { animation-delay: 0.18s; }
.prediction-card:nth-child(5)  { animation-delay: 0.24s; }
.prediction-card:nth-child(6)  { animation-delay: 0.30s; }
.prediction-card:nth-child(7)  { animation-delay: 0.36s; }
.prediction-card:nth-child(8)  { animation-delay: 0.42s; }
.prediction-card:nth-child(9)  { animation-delay: 0.48s; }
.prediction-card:nth-child(10) { animation-delay: 0.54s; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}


/* ---------- Prediction Detail Modal ---------- */
.detail-modal .modal {
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-scroll-inner {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  padding-right: var(--space-xs);
}

.modal-scroll-inner::-webkit-scrollbar {
  width: 4px;
}
.modal-scroll-inner::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
}

.detail-category {
  margin-bottom: var(--space-md);
}

.detail-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: var(--space-md);
}

.detail-narrative {
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

/* Detail Engagement Bar */
.detail-engagement-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) 0;
  margin-bottom: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.detail-engage-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-dim);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  font-family: 'Inter', sans-serif;
}

.detail-engage-btn:hover {
  border-color: var(--border-glow);
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.detail-engage-btn.active {
  border-color: var(--cyan);
  color: var(--text-primary);
  background: var(--cyan-dim);
}

.detail-engage-stat {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.detail-meta-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.detail-meta-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.detail-evolution {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.detail-evolution-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--purple);
}

.evolution-item {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

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

.evolution-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

/* ---------- Comments Section ---------- */
.detail-comments {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.detail-comments-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

/* Comment Form */
.comment-form {
  margin-bottom: var(--space-xl);
  position: relative;
}

.comment-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.comment-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  outline: none;
  transition: all var(--transition-normal);
  resize: vertical;
}

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

.comment-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

.comment-text {
  min-height: 70px;
  margin-bottom: var(--space-sm);
}

.comment-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.comment-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Comments List */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.no-comments {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-lg) 0;
  font-style: italic;
}

.comment-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--transition-normal);
  position: relative;
}

.comment-item:hover {
  border-color: var(--border-dim);
}

.comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-inverse);
  flex-shrink: 0;
}

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

.comment-meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: 0.3rem;
  flex-wrap: wrap;
}

.comment-author {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-primary);
}

.comment-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.comment-content {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-secondary);
  word-wrap: break-word;
}

.comment-delete {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: all var(--transition-fast);
  line-height: 1;
}

.comment-item:hover .comment-delete {
  opacity: 1;
}

.comment-delete:hover {
  color: var(--neon-red);
  background: rgba(239, 68, 68, 0.1);
}

/* ---------- Responsive — Tablet ---------- */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .search-container {
    order: 3;
    max-width: 100%;
    flex-basis: 100%;
  }

  .header-actions {
    gap: 0.25rem;
  }

  .btn-primary .btn-text-desktop {
    display: none;
  }

  .main-content {
    padding: var(--space-md);
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .stat-card {
    padding: var(--space-md);
  }

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

  .predictions-grid {
    grid-template-columns: 1fr;
  }

  .timeline-year-header {
    font-size: 1.4rem;
  }

  .filter-pills {
    gap: 0.35rem;
  }

  .filter-pill {
    padding: 0.35rem 0.7rem;
    font-size: 0.72rem;
  }

  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
  }

  .toast {
    min-width: auto;
  }

  /* Modal mobile */
  .modal-overlay {
    padding: var(--space-sm);
    align-items: flex-end;
  }

  .modal {
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--space-lg);
  }

  .detail-modal .modal {
    max-width: 100%;
    max-height: 90vh;
  }

  .detail-title {
    font-size: 1.3rem;
  }

  .detail-engagement-bar {
    gap: 0.4rem;
  }

  .detail-engage-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.78rem;
  }

  .detail-engage-stat {
    margin-left: 0;
    width: 100%;
    margin-top: 0.25rem;
  }

  .comment-form-row {
    grid-template-columns: 1fr;
  }

  .comment-form-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .comment-hint {
    text-align: center;
  }

  .comment-avatar {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
  }

  .year-nav {
    gap: 0.2rem;
  }

  .year-tab {
    padding: 0.35rem 0.8rem;
    font-size: 0.75rem;
  }
}

/* ---------- Responsive — Small Phone ---------- */
@media (max-width: 480px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }

  .stat-card {
    padding: var(--space-sm) var(--space-md);
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .logo-text {
    font-size: 1.1rem;
  }

  .logo-tag {
    display: none;
  }

  .header {
    padding: var(--space-sm) var(--space-md);
  }

  .header-actions .btn-primary {
    padding: 0.45rem 0.8rem;
    font-size: 0.75rem;
  }

  .header-actions .btn-ghost.btn-icon {
    padding: 0.4rem;
    font-size: 0.85rem;
  }

  .main-content {
    padding: var(--space-sm);
  }

  .prediction-card {
    padding: var(--space-md);
  }

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

  .card-narrative {
    font-size: 0.8rem;
    -webkit-line-clamp: 3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .card-footer {
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .card-engagement {
    order: 2;
    width: 100%;
    justify-content: flex-start;
  }

  .card-date {
    order: 1;
  }

  .modal {
    padding: var(--space-md);
  }

  .detail-title {
    font-size: 1.15rem;
  }

  .detail-narrative {
    font-size: 0.85rem;
  }

  .detail-meta {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }

  .modal-actions {
    flex-direction: column;
    gap: var(--space-sm);
  }

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

  .comment-item {
    padding: var(--space-sm);
    gap: var(--space-sm);
  }

  .generating-text {
    font-size: 0.95rem;
  }

  .empty-icon {
    font-size: 3rem;
  }

  .empty-title {
    font-size: 1.2rem;
  }

  .empty-desc {
    font-size: 0.82rem;
  }
}

/* ---------- Responsive — Very Small Screens ---------- */
@media (max-width: 360px) {
  .stats-bar {
    grid-template-columns: 1fr 1fr;
  }

  .filter-pill {
    padding: 0.3rem 0.5rem;
    font-size: 0.68rem;
  }

  .year-tab {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }

  .header-inner {
    gap: 0.35rem;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
}
