/* =====================================   WHAT'S HAPPENING — Cosmic Prediction Dashboard
   UI Redesign: Sidebar + Grid Dashboard Layout
   Inspired by Omnis design system
   ============================================ */

/* =====================================   DESIGN TOKENS
   ============================================ */
:root {
  /* Backgrounds */
  --bg-primary: #09090b;
  --bg-secondary: #0f0f14;
  --bg-card: #131318;
  --bg-prediction: #0d1117;
  --bg-hover: #1c1c24;
  --bg-muted: #18181d;
  --bg-sidebar: #0c0c10;
  --bg-sidebar-hover: #1a1a22;
  --bg-sidebar-active: #1f1f2a;
  --bg-overlay: rgba(0, 0, 0, 0.7);

  /* Text — WCAG 2.1 AA compliant */
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-sidebar: #a1a1aa;
  --text-sidebar-active: #e4e4e7;

  /* Accent */
  --accent: #6366f1;
  --accent-hover: #5558e6;
  --accent-muted: rgba(99, 102, 241, 0.15);

  /* Borders */
  --border: #1e1e28;
  --border-subtle: #161620;
  --border-hover: #2a2a3a;

  /* Confidence colors */
  --confidence-very-high: #22c55e;
  --confidence-high: #4ade80;
  --confidence-medium: #fbbf24;
  --confidence-low: #f87171;
  --confidence-insufficient: #6b7280;

  /* Probability bar */
  --bar-fill: #3b82f6;
  --bar-bg: #1e293b;

  /* Alert */
  --alert-bg: #1c1917;
  --alert-border: #f59e0b;

  /* Positive/Negative */
  --positive: #4ade80;
  --negative: #f87171;
  --neutral: #94a3b8;

  /* Toggle */
  --toggle-bg: #1e293b;
  --toggle-border: #334155;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
  --spacing-2xl: 32px;
  --spacing-3xl: 48px;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  /* Touch target */
  --touch-target: 44px;

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 60px;
  --header-height: 56px;
  --mobile-nav-height: 64px;

  /* Typography — Perfect Fourth (1.3) scale */
  --type-scale: 1.3;
  --text-xs: 0.64rem;    /* 10.24px */
  --text-sm: 0.833rem;   /* 13.33px */
  --text-base: 1rem;     /* 16px */
  --text-md: 1.3rem;     /* 20.8px */
  --text-lg: 1.69rem;    /* 27.04px */
  --text-xl: 2.197rem;   /* 35.15px */
  --text-2xl: 2.856rem;  /* 45.7px */
  --text-3xl: 3.713rem;  /* 59.4px */

  /* Font families */
  --font-body: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Rubik', 'Barlow', sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', monospace;
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #fafafa;
  --bg-secondary: #f4f4f5;
  --bg-card: #ffffff;
  --bg-prediction: #f8fafc;
  --bg-hover: #e4e4e7;
  --bg-muted: #f4f4f5;
  --bg-sidebar: #ffffff;
  --bg-sidebar-hover: #f4f4f5;
  --bg-sidebar-active: #e4e4e7;
  --bg-overlay: rgba(0, 0, 0, 0.5);

  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-sidebar: #52525b;
  --text-sidebar-active: #18181b;

  --border: #e4e4e7;
  --border-subtle: #f4f4f5;
  --border-hover: #d4d4d8;

  --confidence-very-high: #16a34a;
  --confidence-high: #22c55e;
  --confidence-medium: #d97706;
  --confidence-low: #dc2626;
  --confidence-insufficient: #6b7280;

  --bar-bg: #e2e8f0;
  --alert-bg: #fffbeb;
  --positive: #16a34a;
  --negative: #dc2626;
  --neutral: #64748b;
  --toggle-bg: #e2e8f0;
  --toggle-border: #cbd5e1;
}

/* Tablet+ spacing */
@media (min-width: 640px) {
  :root {
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
  }
}

/* Theme transition */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* =====================================   RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Headings */
h1, h2, h3, h4, h5, h6,
.section-title,
.page-header-title,
.sidebar-brand-name {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 { font-size: var(--text-2xl); line-height: 1.0; font-weight: 700; }
h2 { font-size: var(--text-xl); line-height: 1.1; font-weight: 600; }
h3 { font-size: var(--text-lg); line-height: 1.2; font-weight: 600; }
h4 { font-size: var(--text-md); line-height: 1.3; font-weight: 500; }

/* Mono / data text */
.value, .probability, .percentage, .index-value,
.module-value, code, kbd, pre,
.stat-card-label {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* =====================================   APP LAYOUT — Sidebar + Main
   ============================================ */
#app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* =====================================   SIDEBAR
   ============================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-normal), transform var(--transition-normal);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* Hide sidebar on mobile */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
  display: block;
}

/* Sidebar header / brand */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-lg) var(--spacing-lg);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
}

.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  color: #fff;
  font-weight: 700;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-brand-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-brand-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.collapsed .sidebar-brand-text {
  display: none;
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm) 0;
}

.sidebar-group {
  padding: var(--spacing-xs) var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.sidebar-group-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--spacing-xs) var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.collapsed .sidebar-group-label {
  display: none;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-sm);
  border-radius: var(--radius-md);
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  min-height: 36px;
  position: relative;
}

.sidebar-nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.sidebar-nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.sidebar-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.sidebar-nav-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.collapsed .sidebar-nav-label {
  display: none;
}

.collapsed .sidebar-nav-item {
  justify-content: center;
  padding: var(--spacing-sm) 0;
}

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: var(--spacing-sm) var(--spacing-sm);
}

.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  width: 100%;
  padding: var(--spacing-sm);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.sidebar-toggle-label {
  overflow: hidden;
  white-space: nowrap;
}

.collapsed .sidebar-toggle-label {
  display: none;
}

/* Hide desktop sidebar toggle on mobile */
@media (max-width: 767px) {
  .sidebar-toggle-btn { display: none; }
}

/* =====================================   MAIN CONTENT AREA
   ============================================ */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  transition: margin-left var(--transition-normal);
}

.sidebar.collapsed ~ .main-wrapper {
  margin-left: var(--sidebar-collapsed-width);
}

@media (max-width: 767px) {
  .main-wrapper {
    margin-left: 0;
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  }
}

/* =====================================   TOP HEADER BAR
   ============================================ */
.header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  height: var(--header-height);
  padding: 0 var(--spacing-lg);
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .header {
    padding: 0 var(--spacing-xl);
  }
}

.header-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.2rem;
}

@media (max-width: 767px) {
  .header-mobile-toggle {
    display: flex;
  }
}

.header-title {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-right: auto;
}

@media (min-width: 768px) {
  .header-title {
    display: none; /* Brand is in sidebar on desktop */
  }
}

/* Search trigger in header */
.header-search-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  height: 36px;
  padding: 0 var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.header-search-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.header-search-icon {
  font-size: 0.9rem;
}

.header-search-text {
  display: none;
}

@media (min-width: 640px) {
  .header-search-text {
    display: inline;
  }
}

.header-search-kbd {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  font-size: 0.65rem;
  font-family: inherit;
  color: var(--text-muted);
}

@media (min-width: 768px) {
  .header-search-kbd {
    display: inline-flex;
  }
}

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

.header-link {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  min-height: var(--touch-target);
}

.header-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.header-link-icon { font-size: 1rem; }
.header-link-text { display: none; }
@media (min-width: 480px) { .header-link-text { display: inline; } }

/* Header Share Button */
.header-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  height: 36px;
  padding: 0 var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.header-share-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.header-share-btn .share-icon { width: 16px; height: 16px; flex-shrink: 0; }
.header-share-btn .share-btn-text { display: none; }
@media (min-width: 480px) { .header-share-btn .share-btn-text { display: inline; } }

/* Compare button */
.header-compare-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--spacing-md);
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: all 0.2s;
}

.header-compare-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.compare-btn-text { display: none; }
@media (min-width: 480px) { .compare-btn-text { display: inline; } }

/* Live indicator */
.live-indicator {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--confidence-high);
  animation: pulse 2s infinite;
}

.live-dot.stale { background-color: var(--confidence-medium); animation: none; }
.live-dot.error { background-color: var(--confidence-low); animation: none; }
.live-dot--live { background-color: var(--confidence-high); animation: pulse 2s infinite; }
.live-dot--connecting, .live-dot--reconnecting { background-color: var(--confidence-medium); animation: pulse 0.8s infinite; }
.live-dot--disconnected { background-color: var(--confidence-low); animation: none; }
.live-dot--fallback { background-color: var(--confidence-medium); animation: none; }

/* WebSocket connection states */
.live-dot--live {
  background-color: var(--confidence-high);
  animation: pulse 2s infinite;
}

.live-dot--connecting,
.live-dot--reconnecting {
  background-color: var(--confidence-medium);
  animation: pulse 0.8s infinite;
}

.live-dot--disconnected {
  background-color: var(--confidence-low);
  animation: none;
}

.live-dot--fallback {
  background-color: var(--confidence-medium);
  animation: none;
}

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

/* =====================================   MAIN CONTENT
   ============================================ */
.content-area {
  flex: 1;
  padding: var(--spacing-lg);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 768px) {
  .content-area {
    padding: var(--spacing-xl) var(--spacing-2xl);
  }
}

/* Page header */
.page-header {
  margin-bottom: var(--spacing-xl);
}

.page-header-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--spacing-xs);
}

.page-header-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.page-header-subtitle {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 600px;
  margin-top: 0.25rem;
}

@media (min-width: 640px) {
  .page-header-title {
    font-size: 1.75rem;
  }
  .page-header-subtitle {
    font-size: 1.25rem;
  }
}

/* =====================================   STAT CARDS ROW
   ============================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  transition: border-color var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-hover);
}

.stat-card-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-card-value {
  font-family: var(--font-mono); letter-spacing: 0.05em;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-card-trend {
  font-size: 0.8rem;
}

.stat-card-trend.rising { color: var(--positive); }
.stat-card-trend.falling { color: var(--negative); }
.stat-card-trend.stable { color: var(--neutral); }

/* Indices bar — now stat cards */
.indices-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
}

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

.index-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.index-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.index-trend { font-size: 0.85rem; }
.index-trend.rising { color: var(--positive); }
.index-trend.falling { color: var(--negative); }
.index-trend.stable { color: var(--neutral); }

/* =====================================   SECTION HEADERS
   ============================================ */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.section-icon { font-size: 1.1rem; }

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* =====================================   FILTER BAR
   ============================================ */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

@media (min-width: 640px) {
  .filter-bar {
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
  }
}

.filter-bar-main {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  align-items: center;
}

.filter-search-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
}

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

.filter-search {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-sm) calc(var(--spacing-sm) * 4);
  font-size: 0.9rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: var(--touch-target);
  transition: border-color var(--transition-fast);
}

.filter-search:focus {
  outline: none;
  border-color: var(--accent);
}

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

.filter-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  min-height: var(--touch-target);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.filter-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 9px;
  background: var(--accent);
  color: white;
}

.filter-presets {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  min-height: var(--touch-target);
}

.filter-advanced {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

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

.filter-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.filter-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.filter-categories {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.filter-category-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.filter-category-label:hover { background: var(--bg-hover); }

.filter-category-label:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.filter-category-label input { display: none; }
.category-icon { font-size: 1rem; }

.filter-select {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  min-height: var(--touch-target);
  max-width: 200px;
}

.filter-date-range {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.filter-date {
  padding: var(--spacing-sm);
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: var(--touch-target);
}

.filter-date::-webkit-calendar-picker-indicator { filter: invert(0.7); }
[data-theme="light"] .filter-date::-webkit-calendar-picker-indicator { filter: none; }

.filter-date-separator { color: var(--text-muted); font-size: 0.85rem; }

.filter-actions {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: flex-end;
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--border);
}

.filter-action-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: var(--touch-target);
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.filter-action-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.filter-action-btn-primary:hover { background: var(--accent-hover); }

/* Predictions count */
.predictions-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: normal;
}

/* Filter toast */
.filter-toast {
  position: fixed;
  bottom: var(--spacing-lg);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--positive);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
  color: var(--text-primary);
  z-index: 1200;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.filter-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* No results */
.no-results {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-secondary);
}

.no-results-icon { font-size: 2rem; margin-bottom: var(--spacing-sm); }
.no-results-text { font-size: 0.9rem; }

/* =====================================   PREDICTIONS PANEL
   ============================================ */
.predictions-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

@media (min-width: 640px) {
  .predictions-panel {
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
  }
}

.predictions-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

@media (min-width: 640px) {
  .predictions-list {
    gap: var(--spacing-md);
  }
}

/* Prediction Card */
.prediction {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
}

@media (min-width: 640px) {
  .prediction { padding: var(--spacing-lg); }
}

.prediction:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.prediction:active { background: var(--bg-hover); }

.prediction-summary {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

@media (min-width: 640px) {
  .prediction-summary { gap: var(--spacing-sm); }
}

.prediction-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-xs);
}

@media (min-width: 480px) {
  .prediction-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }
}

.prediction-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

@media (min-width: 640px) { .prediction-name { font-size: 1rem; } }

.prediction-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  font-size: 0.75rem;
}

@media (min-width: 640px) {
  .prediction-stats { gap: var(--spacing-sm); font-size: 0.85rem; flex-wrap: nowrap; }
}

.confidence-interval { color: var(--text-secondary); font-family: var(--font-mono); letter-spacing: 0.05em; }
.sample-size { color: var(--text-muted); font-family: var(--font-mono); letter-spacing: 0.05em; }

.confidence-badge {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confidence-very-high { background: rgba(34, 197, 94, 0.15); color: var(--confidence-very-high); }
.confidence-high { background: rgba(74, 222, 128, 0.15); color: var(--confidence-high); }
.confidence-medium { background: rgba(251, 191, 36, 0.15); color: var(--confidence-medium); }
.confidence-low { background: rgba(248, 113, 113, 0.15); color: var(--confidence-low); }
.confidence-insufficient { background: rgba(107, 114, 128, 0.15); color: var(--confidence-insufficient); }

[data-theme="light"] .confidence-very-high { background: #dcfce7; color: #14532d; }
[data-theme="light"] .confidence-high { background: #d1fae5; color: #166534; }
[data-theme="light"] .confidence-medium { background: #fef3c7; color: #713f12; }
[data-theme="light"] .confidence-low { background: #fee2e2; color: #7f1d1d; }
[data-theme="light"] .confidence-insufficient { background: #e5e7eb; color: #374151; }

/* Probability Bar */
.probability-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

@media (min-width: 640px) { .probability-row { gap: var(--spacing-md); } }

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

@media (min-width: 640px) { .probability-bar { height: 8px; border-radius: 4px; } }

.probability-fill {
  height: 100%;
  background: var(--bar-fill);
  border-radius: 4px;
  transition: width var(--transition-normal);
}

.probability-fill.high { background: linear-gradient(90deg, var(--bar-fill), var(--confidence-medium)); }
.probability-fill.very-high { background: linear-gradient(90deg, var(--confidence-medium), var(--confidence-low)); }

.probability-value {
  font-family: var(--font-mono); letter-spacing: 0.05em;
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 45px;
  text-align: right;
}

/* Prediction Details */
.prediction-details {
  display: none;
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border);
}

.prediction.expanded .prediction-details { display: block; }

.factors-list { display: flex; flex-direction: column; gap: var(--spacing-sm); }

.factor {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 0.85rem;
}

.factor-tree { color: var(--text-muted); font-family: var(--font-mono); letter-spacing: 0.05em; }
.factor-name { flex: 1; color: var(--text-secondary); }

.factor-contribution {
  font-family: var(--font-mono); letter-spacing: 0.05em;
  font-weight: 500;
  min-width: 50px;
  text-align: right;
}

.factor-contribution.positive { color: var(--positive); }
.factor-contribution.negative { color: var(--negative); }
.factor-sample { color: var(--text-muted); font-family: var(--font-mono); letter-spacing: 0.05em; font-size: 0.75rem; }

.factor-bar { width: 80px; height: 4px; background: var(--bar-bg); border-radius: 2px; overflow: hidden; }
.factor-bar-fill { height: 100%; background: var(--bar-fill); transition: width var(--transition-normal); }

.prediction-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-item { display: flex; align-items: center; gap: var(--spacing-xs); }
.meta-label { color: var(--text-muted); }
.meta-value { font-family: var(--font-mono); letter-spacing: 0.05em; color: var(--text-secondary); }

/* =====================================   PATTERN ALERT
   ============================================ */
.pattern-alert {
  background: var(--alert-bg);
  border: 1px solid var(--alert-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.pattern-alert.hidden { display: none; }

.alert-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.alert-icon { font-size: 1.2rem; }

.alert-title {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--alert-border);
  flex: 1;
}

.match-score { font-family: var(--font-mono); letter-spacing: 0.05em; font-weight: 600; color: var(--alert-border); }
.alert-content { font-size: 0.9rem; }
.alert-description { color: var(--text-primary); margin-bottom: var(--spacing-md); }

.matching-dates { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); margin-bottom: var(--spacing-md); }

.matching-date {
  background: var(--bg-card);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono); letter-spacing: 0.05em;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.outcome-rate { color: var(--text-secondary); font-size: 0.9rem; }
.outcome-rate strong { color: var(--text-primary); }

/* =====================================   DATA MODULES GRID
   ============================================ */
.modules-section { margin-bottom: var(--spacing-xl); }

.data-grid {
  display: grid;
  gap: var(--spacing-sm);
  grid-template-columns: 1fr;
}

@media (min-width: 480px) { .data-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .data-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .data-grid { grid-template-columns: repeat(4, 1fr); } }

/* Module Card */
.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  min-height: 100px;
  -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
}

.module-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

@media (min-width: 640px) {
  .module-card:hover { transform: translateY(-2px); }
}

.module-card:active { background: var(--bg-hover); }

.module-card.expanded { grid-column: 1 / -1; }
@media (min-width: 480px) { .module-card.expanded { grid-column: span 2; } }

.module-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.module-icon { font-size: 1.2rem; }

.module-name {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  flex: 1;
}

.module-header .freshness-badge { margin-left: auto; text-transform: capitalize; }

.module-primary {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
}

.module-secondary {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.module-details {
  display: none;
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.module-card.expanded .module-details { display: block; }

.module-detail-row {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-xs) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.module-detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); }
.detail-value { font-family: var(--font-mono); letter-spacing: 0.05em; color: var(--text-primary); }

/* =====================================   SUGGESTIONS FOOTER
   ============================================ */
.suggestions-footer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
}

@media (min-width: 640px) { .suggestions-footer { padding: var(--spacing-xl); } }

.suggestions-content {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.suggestion-group { display: flex; flex-direction: column; gap: var(--spacing-sm); }

.suggestion-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.suggestion-label.favorable { color: var(--positive); }
.suggestion-label.caution { color: var(--negative); }
.suggestion-label.info { color: var(--neutral); }

.suggestion-list { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); }

.suggestion-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.disclaimer {
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

/* =====================================   EMAIL SIGNUP
   ============================================ */
.email-signup-section {
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

@media (min-width: 640px) { .email-signup-section { padding: var(--spacing-xl); } }

.email-signup-content { max-width: 500px; margin: 0 auto; }

.email-signup-header {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.email-signup-icon { font-size: 2rem; line-height: 1; }

.email-signup-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: var(--spacing-xs);
}

@media (min-width: 640px) { .email-signup-title { font-size: 1.5rem; } }

.email-signup-subtitle { font-size: 0.9rem; color: rgba(255, 255, 255, 0.8); }
.email-signup-form { display: flex; flex-direction: column; gap: var(--spacing-md); }

.email-input-group { display: flex; flex-direction: column; gap: var(--spacing-sm); }
@media (min-width: 480px) { .email-input-group { flex-direction: row; } }

.email-input {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  min-height: var(--touch-target);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.email-input::placeholder { color: rgba(255, 255, 255, 0.6); }
.email-input:focus { outline: none; border-color: #fff; background: rgba(255, 255, 255, 0.25); }

.email-submit-btn {
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: 2px solid #fff;
  border-radius: var(--radius-md);
  background: #fff;
  color: #1d4ed8;
  cursor: pointer;
  min-height: var(--touch-target);
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.email-submit-btn:hover { background: transparent; color: #fff; }
.email-submit-btn:active { transform: scale(0.98); }
.email-submit-btn:disabled { opacity: 0.7; cursor: not-allowed; }

.email-preferences { display: flex; flex-wrap: wrap; gap: var(--spacing-sm) var(--spacing-lg); }

.email-pref-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.email-pref-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: #fff; cursor: pointer; }

.email-signup-message {
  font-size: 0.9rem;
  padding: var(--spacing-sm);
  border-radius: var(--radius-sm);
  text-align: center;
}

.email-signup-message.success { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.email-signup-message.error { background: rgba(248, 113, 113, 0.2); color: #fca5a5; }

[data-theme="light"] .email-signup-section {
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
}

/* =====================================   TOAST NOTIFICATIONS
   ============================================ */
.subscription-toast {
  position: fixed;
  bottom: var(--spacing-lg);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
  color: var(--text-primary);
  z-index: 1001;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.subscription-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.subscription-toast.success .toast-icon { color: var(--positive); }
.subscription-toast.error .toast-icon { color: var(--negative); }
.toast-icon { font-size: 1.1rem; }

/* =====================================   ERROR BANNER
   ============================================ */
.error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--confidence-low);
  color: white;
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-md);
  z-index: 1000;
}

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

.error-dismiss {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: var(--spacing-sm);
  line-height: 1;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =====================================   SHARE MODAL
   ============================================ */
.share-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: 1100;
  animation: fadeIn 0.2s ease;
}

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

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

.share-modal-content {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.25s ease;
}

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

.share-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border);
}

.share-modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.share-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  margin: calc(var(--spacing-sm) * -1);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.share-modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.share-modal-body { padding: var(--spacing-lg); }

.share-section { margin-bottom: var(--spacing-xl); }
.share-section:last-child { margin-bottom: 0; }

.share-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

.share-buttons { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); }

.share-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  min-height: var(--touch-target);
}

.share-btn:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.share-btn:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.share-icon { font-size: 1rem; font-weight: 600; }

.share-btn-twitter:hover { border-color: #1DA1F2; }
.share-btn-facebook:hover { border-color: #4267B2; }
.share-btn-whatsapp:hover { border-color: #25D366; }
.share-btn-linkedin:hover { border-color: #0077B5; }
.share-btn-link:hover { border-color: var(--accent); }

.export-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--spacing-sm);
}

.export-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  min-height: 70px;
}

.export-btn:hover { background: var(--bg-hover); border-color: var(--border-hover); transform: translateY(-2px); }
.export-btn:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.export-btn:active { transform: translateY(0); }
.export-icon { font-size: 1.5rem; }
.export-btn small { font-size: 0.7rem; color: var(--text-muted); font-weight: 400; }

/* Share toast */
.share-toast {
  position: fixed;
  bottom: var(--spacing-lg);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
  color: var(--text-primary);
  z-index: 1200;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.share-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.share-toast-success { border-color: var(--positive); }
.share-toast-error { border-color: var(--negative); }

[data-theme="light"] .share-modal { background: rgba(0, 0, 0, 0.5); }
[data-theme="light"] .share-modal-content, [data-theme="light"] .share-toast {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* =====================================   COMMAND PALETTE
   ============================================ */
.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: min(20vh, 150px);
  animation: fadeIn 0.15s ease;
}

.command-palette-overlay.hidden { display: none; }

.command-palette {
  width: 100%;
  max-width: 560px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: slideUp 0.2s ease;
}

.command-palette-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border);
}

.command-palette-search-icon {
  color: var(--text-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.command-palette-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

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

.command-palette-results {
  max-height: 320px;
  overflow-y: auto;
  padding: var(--spacing-sm);
}

.command-palette-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--spacing-sm) var(--spacing-sm);
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.command-palette-item:hover,
.command-palette-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.command-palette-item-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.command-palette-item-label { flex: 1; }

.command-palette-item-shortcut {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: inherit;
}

.command-palette-footer {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.command-palette-footer kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 0.65rem;
  font-family: inherit;
}

/* =====================================   MOBILE BOTTOM NAV
   ============================================ */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 767px) {
  .mobile-bottom-nav { display: block; }
}

.mobile-nav-items {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--mobile-nav-height);
  padding: 0 var(--spacing-xs);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 56px;
  min-height: 48px;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 500;
  transition: color var(--transition-fast), background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.mobile-nav-item:hover { color: var(--text-primary); }

.mobile-nav-item.active {
  color: var(--accent);
  background: var(--accent-muted);
}

.mobile-nav-icon { font-size: 1.25rem; }
.mobile-nav-label { line-height: 1; }

/* Mobile "More" menu */
.mobile-more-menu {
  position: fixed;
  bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + var(--spacing-sm));
  right: var(--spacing-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 101;
  min-width: 180px;
}

.mobile-more-menu.hidden { display: none; }

.mobile-more-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  border: none;
  background: transparent;
  width: 100%;
  font-family: inherit;
}

.mobile-more-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.mobile-more-icon { font-size: 1rem; width: 18px; text-align: center; }

/* =====================================   LOADING SKELETON
   ============================================ */
.skeleton { position: relative; overflow: hidden; }

.skeleton::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-hover) 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.prediction-skeleton {
  height: 100px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

/* Data Freshness */
.freshness-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.freshness-live { background: rgba(34, 197, 94, 0.15); color: var(--confidence-high); }
.freshness-recent { background: rgba(251, 191, 36, 0.15); color: var(--confidence-medium); }
.freshness-stale { background: rgba(248, 113, 113, 0.15); color: var(--confidence-low); }

[data-theme="light"] .freshness-live { background: #dcfce7; color: #166534; }
[data-theme="light"] .freshness-recent { background: #fef3c7; color: #92400e; }
[data-theme="light"] .freshness-stale { background: #fee2e2; color: #991b1b; }

/* =====================================   UTILITY CLASSES
   ============================================ */
.hidden { display: none !important; }
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-neutral { color: var(--neutral); }
.text-muted { color: var(--text-muted); }

/* Factor mobile */
@media (max-width: 479px) {
  .factor { flex-wrap: wrap; }
  .factor-bar { width: 60px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =====================================   ACCESSIBILITY
   ============================================ */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #ffffff;
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  z-index: 10000;
  transition: top var(--transition-fast);
}

.skip-link:focus { top: var(--spacing-sm); outline: 3px solid #ffffff; outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.prediction:focus-visible,
.module-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.2);
}

.prediction:focus:not(:focus-visible),
.module-card:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Prediction change highlight */
.prediction-changed {
  animation: highlightChange 2s ease-out;
}

@keyframes highlightChange {
  0% { background-color: rgba(99, 102, 241, 0.3); box-shadow: 0 0 8px rgba(99, 102, 241, 0.5); }
  100% { background-color: var(--bg-card); box-shadow: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .live-dot { animation: none; }
  .skeleton::after { animation: none; background: var(--bg-card); }
  .prediction-changed { animation: none; background-color: rgba(99, 102, 241, 0.2); }
}

/* Print */
@media print {
  body { background: white; color: black; }
  .sidebar, .mobile-bottom-nav, .command-palette-overlay { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .module-card, .prediction, .predictions-panel, .suggestions-footer {
    background: #f5f5f5; color: black;
  }
}

/* =====================================   PWA INSTALL BANNER
   ============================================ */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #0a0a0f 100%);
  border-top: 1px solid rgba(99, 102, 241, 0.3);
  padding: var(--spacing-md) var(--spacing-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md);
  z-index: 1000;
  transform: translateY(100%);
  transition: transform var(--transition-normal);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.pwa-install-banner.visible { transform: translateY(0); }

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex: 1;
  min-width: 0;
}

.pwa-install-icon { font-size: 2rem; flex-shrink: 0; }

.pwa-install-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pwa-install-text strong { color: var(--text-primary); font-size: 0.95rem; font-weight: 600; }
.pwa-install-text span { color: var(--text-secondary); font-size: 0.8rem; }

.pwa-install-actions { display: flex; gap: var(--spacing-sm); flex-shrink: 0; }

.pwa-install-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.pwa-install-btn:hover { transform: scale(1.05); box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3); }
.pwa-install-btn:active { transform: scale(0.98); }

.pwa-dismiss-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--text-muted);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.pwa-dismiss-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.pwa-update-notification {
  position: fixed;
  top: var(--spacing-lg);
  right: var(--spacing-lg);
  background: var(--bg-card);
  border: 1px solid rgba(34, 197, 94, 0.5);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  z-index: 1001;
  opacity: 0;
  transform: translateY(-20px);
  transition: all var(--transition-normal);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.pwa-update-notification.visible { opacity: 1; transform: translateY(0); }
.pwa-update-notification span { color: var(--text-primary); font-size: 0.9rem; }

.pwa-update-notification button {
  background: var(--positive);
  color: #0a0a0f;
  border: none;
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pwa-update-notification button:hover { transform: scale(1.05); }

.offline-banner {
  background: var(--warning-color, #e2b340);
  color: #000;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 1000;
}

@media (max-width: 480px) {
  .pwa-install-banner {
    flex-direction: column;
    padding: var(--spacing-lg);
    gap: var(--spacing-md);
  }
  .pwa-install-content { width: 100%; }
  .pwa-install-actions { width: 100%; justify-content: stretch; }
  .pwa-install-btn, .pwa-dismiss-btn { flex: 1; text-align: center; }
}

@media (display-mode: standalone) {
  body { padding-bottom: env(safe-area-inset-bottom, 0); }
  .header { padding-top: calc(var(--spacing-md) + env(safe-area-inset-top, 0)); }
  .pwa-install-banner { display: none !important; }
}

/* =====================================   HISTORICAL COMPARISON PANEL
   ============================================ */
.comparison-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 900;
  overflow-y: auto;
  padding: 24px;
  transition: right 0.3s ease;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

.comparison-panel.visible { right: 0; }

.comparison-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.comparison-title { font-size: 1.1rem; color: var(--text-primary); margin: 0; }

.comparison-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.comparison-close:hover { color: var(--text-primary); background: var(--bg-primary); }

.comparison-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.comparison-label { color: var(--text-secondary); font-size: 0.85rem; }

.comparison-date-input {
  padding: 6px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.comparison-load-btn {
  padding: 6px 16px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.comparison-load-btn:hover { background: var(--accent-hover); }

.comparison-loading, .comparison-error {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.comparison-error { color: var(--negative); }

.comparison-date-label {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.comparison-similarity { margin-bottom: 20px; }
.similarity-label { color: var(--text-secondary); font-size: 0.85rem; margin-right: 8px; }
.similarity-value { color: var(--accent); font-weight: 700; font-size: 1.1rem; }

.similarity-bar {
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.similarity-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.comparison-modules { display: flex; flex-direction: column; gap: 12px; }

.comparison-module-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.comparison-module-title { font-size: 0.9rem; color: var(--text-primary); margin: 0 0 8px 0; }

.comparison-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border-subtle);
}

.comparison-row:last-child { border-bottom: none; }
.comparison-key { color: var(--text-secondary); text-transform: capitalize; }

.comparison-val {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comparison-outcomes {
  margin-top: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

@media (max-width: 480px) {
  .comparison-panel { width: 100vw; max-width: 100vw; right: -100vw; }
}

/* =====================================   THEME TOGGLE BUTTON
   ============================================ */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.theme-toggle:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle:active { transform: scale(0.95); }

.theme-toggle-icon { display: inline-block; transition: transform 0.3s ease; }
.theme-toggle:hover .theme-toggle-icon { transform: rotate(15deg); }

/* =====================================   HEADER BUTTONS (generic)
   ============================================ */
.header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.header-btn:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.header-btn:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.header-btn:active { transform: scale(0.95); }

/* Autocomplete dropdown (#152) */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}

.autocomplete-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent);
  color: #fff;
}

.autocomplete-item mark {
  background: transparent;
  color: inherit;
  font-weight: 700;
}

/* Location radius filter (#152) */
.filter-location-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.filter-radius {
  width: 120px;
  padding: 0.4rem 0.6rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.filter-location-status {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* =====================================   INSIGHT HERO — Conclusion-first AI Narrative
   ============================================ */

.insight-hero {
  padding: 2rem 1.5rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #0a0d1a 0%, #1b2d4e 50%, #0f1a30 100%);
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
  min-height: 200px;
}

.insight-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.03) 0%, transparent 60%);
  pointer-events: none;
}

/* Mood badge */
.insight-mood-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: capitalize;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  letter-spacing: 0.03em;
}

/* Narrative */
.insight-narrative {
  position: relative;
  z-index: 1;
}

.insight-narrative p {
  font-size: var(--text-md);
  line-height: 1.75;
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-weight: 400;
  max-width: 68ch;
}

.insight-narrative p:last-child {
  margin-bottom: 0;
}

/* Highlights strip */
.insight-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
  position: relative;
  z-index: 1;
}

.insight-highlight-pill {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.insight-highlight-pill:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.insight-highlight-pill[data-source=""] {
  cursor: default;
}
.insight-highlight-pill[data-source=""]:hover {
  transform: none;
}

/* Guidance card */
.insight-guidance {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
  z-index: 1;
}

.insight-guidance-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.insight-guidance-icon {
  font-size: 1.1rem;
}

.insight-guidance-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.insight-guidance-text {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-primary);
  opacity: 0.9;
}

/* Meta row */
.insight-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.insight-refresh-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  margin-left: auto;
}

.insight-refresh-btn:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text-primary);
}

/* Error state */
.insight-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  gap: 1rem;
}

.insight-error-icon {
  font-size: 2rem;
}

.insight-error-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 40ch;
  line-height: 1.6;
}

/* Skeleton loading */
.insight-loading {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.insight-skeleton-mood {
  width: 100px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}

.insight-skeleton-line {
  height: 16px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
}

.insight-skeleton-pills {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.insight-skeleton-pill {
  width: 120px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}

/* Module highlight flash */
.module-card.highlight-flash {
  animation: flashHighlight 2s ease-out;
}

@keyframes flashHighlight {
  0% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5); }
  100% { box-shadow: none; }
}

/* =====================================   RAW DATA — Collapsible Section
   ============================================ */

.raw-data-section {
  margin-top: 0.5rem;
}

.raw-data-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.raw-data-toggle:hover {
  background: rgba(255,255,255,0.03);
}

.raw-data-toggle-count {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.75rem;
}

.raw-data-toggle-arrow {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.3s;
}

.raw-data-section:not(.collapsed) .raw-data-toggle-arrow {
  transform: rotate(180deg);
}

.raw-data-wrapper {
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  max-height: 5000px;
  opacity: 1;
}

.raw-data-section.collapsed .raw-data-wrapper {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* =====================================   INSIGHT — Light Theme Overrides
   ============================================ */

[data-theme="light"] .insight-hero {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 50%, #f5f7ff 100%) !important;
  border-color: rgba(0,0,0,0.06);
}

[data-theme="light"] .insight-mood-badge {
  background: rgba(0,0,0,0.05);
  color: var(--text-primary);
}

[data-theme="light"] .insight-highlight-pill {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.2);
  color: #4f46e5;
}

[data-theme="light"] .insight-guidance {
  background: rgba(0,0,0,0.02);
  border-color: rgba(0,0,0,0.06);
}

[data-theme="light"] .insight-refresh-btn {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.1);
}

[data-theme="light"] .insight-hero::before {
  background: radial-gradient(ellipse at 30% 20%, rgba(99,102,241,0.04) 0%, transparent 60%);
}

/* =====================================   INSIGHT — Responsive
   ============================================ */

@media (max-width: 767px) {
  .insight-hero {
    padding: 1.25rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
  }

  .insight-narrative p {
    font-size: 1rem;
    line-height: 1.7;
  }

  .insight-meta {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .insight-refresh-btn {
    margin-left: 0;
  }
}

/* =================================   Countdown Timer
   ======================================== */

.update-countdown {
  display: flex;
  align-items: center;
  margin-right: 12px;
}

.countdown-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  white-space: nowrap;
}

.countdown-separator {
  opacity: 0.4;
}

.countdown-next {
  color: var(--accent);
  opacity: 0.85;
}

.countdown-refreshing {
  color: var(--accent);
  animation: pulse-text 1s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@media (max-width: 767px) {
  .update-countdown {
    display: none;
  }
}

/* --- Autocomplete --- */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  margin: 4px 0 0;
  padding: 4px 0;
  list-style: none;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border-primary, #2a2a3e);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-height: 240px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary, #a0a0b8);
  transition: background 0.15s, color 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent-primary, #6c63ff);
  color: var(--text-primary, #fff);
}

.autocomplete-item mark {
  background: transparent;
  color: var(--accent-primary, #6c63ff);
  font-weight: 600;
}

.autocomplete-item:hover mark,
.autocomplete-item.active mark {
  color: inherit;
/* Preferences Panel (#154) */
.preferences-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
}

.preferences-panel.open {
  display: block;
}

.prefs-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.prefs-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-secondary, #1a1a2e);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

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

.prefs-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.prefs-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.prefs-close:hover {
  color: var(--text-primary);
}

.prefs-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.prefs-section {
  margin-bottom: 1.75rem;
}

.prefs-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.prefs-section-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.prefs-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.prefs-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-primary);
  transition: border-color 0.2s, background 0.2s;
}

.prefs-chip.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
}

.prefs-chip-input {
  display: none;
}

.prefs-chip-icon {
  font-size: 0.9rem;
}

.prefs-chip-label {
  font-size: 0.8rem;
}

.prefs-cat-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.prefs-btn-sm {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
}

.prefs-btn-sm:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.prefs-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.prefs-time-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.prefs-time-chip.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
}

.prefs-time-input {
  display: none;
}

.prefs-time-label {
  font-size: 0.85rem;
  color: var(--text-primary);
}

.prefs-time-desc {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.prefs-notifications {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.prefs-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
}

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

.prefs-btn-save {
  flex: 1;
  padding: 0.65rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.prefs-btn-save:hover {
  opacity: 0.9;
}

.prefs-btn-save.saved {
  background: #22c55e;
}

.prefs-btn-reset {
  padding: 0.65rem 1rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.prefs-btn-reset:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.header-prefs-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: color 0.2s, border-color 0.2s;
}

.header-prefs-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

@media (max-width: 480px) {
  .prefs-drawer {
    width: 100vw;
  }
  .prefs-btn-text {
    display: none;
  }
}

/* --- Autocomplete --- */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  margin: 4px 0 0;
  padding: 4px 0;
  list-style: none;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border-primary, #2a2a3e);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-height: 240px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary, #a0a0b8);
  transition: background 0.15s, color 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent-primary, #6c63ff);
  color: var(--text-primary, #fff);
}

.autocomplete-item mark {
  background: transparent;
  color: var(--accent-primary, #6c63ff);
  font-weight: 600;
}

.autocomplete-item:hover mark,
.autocomplete-item.active mark {
  color: inherit;
}
