:root {
  --cost-blue: #003366;
  --cost-light-blue: #1976D2;
  --cost-orange: #FF6B35;
  --cost-gold: #F7C331;
  --bg-color: #fff;
  --text-color: #333;
  --card-bg: #fff;
}
body.dark-mode {
  --bg-color: #1a1a2e;
  --text-color: #e0e0e0;
  --card-bg: #16213e;
}
/* Compact spacing */
.book-page { padding: 1rem; background: var(--bg-color); color: var(--text-color); }
.markdown { line-height: 1.5; }
.markdown p { margin: 0.5rem 0; }
.markdown h1 { margin: 0.5rem 0; font-size: 1.8rem; }
.markdown h2 { margin: 0.8rem 0 0.5rem; font-size: 1.4rem; color: var(--cost-blue); }
.markdown h3 { margin: 0.3rem 0; font-size: 1.1rem; }
/* Hero gradient with animated bg */
.hero-gradient {
  background: linear-gradient(-45deg, #003366, #1976D2, #FF6B35, #F7C331);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: white;
  padding: 2.5rem 2rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.hero-gradient h1 { color: white; margin: 0; font-size: 2rem; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); }
.hero-gradient p { opacity: 0.95; margin: 0.5rem 0; }
/* Dark mode toggle */
#dark-toggle {
  position: fixed;
  top: 10px;
  right: 60px;
  z-index: 1000;
  background: var(--cost-blue);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
}
#dark-toggle:hover { background: var(--cost-orange); }
/* Stats bar with animated counters */
.stats-bar {
  display: flex;
  justify-content: space-around;
  background: var(--cost-blue);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
}
.stat-item { text-align: center; }
.stat-num { font-size: 2rem; font-weight: bold; color: var(--cost-gold); }
.stat-label { font-size: 0.8rem; opacity: 0.9; }
/* Section cards with FA icons */
.section-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 1rem 0;
}
.section-card {
  background: var(--card-bg);
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  padding: 1.2rem;
  text-align: center;
  transition: all 0.3s ease;
  text-decoration: none;
  color: var(--cost-blue);
}
.section-card:hover {
  border-color: var(--cost-orange);
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(255,107,53,0.25);
}
.section-card i { font-size: 2rem; color: var(--cost-orange); margin-bottom: 0.5rem; display: block; }
.section-card h3 { margin: 0.3rem 0; font-size: 1rem; color: var(--cost-blue); }
.section-card p { margin: 0; font-size: 0.8rem; color: #666; }
/* Working groups */
.wg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0.5rem 0;
}
.wg-card {
  background: linear-gradient(135deg, var(--cost-blue) 0%, var(--cost-light-blue) 100%);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  border-left: 4px solid var(--cost-orange);
  transition: transform 0.2s;
}
.wg-card:hover { transform: scale(1.02); }
.wg-card h4 { margin: 0 0 0.3rem 0; font-size: 0.95rem; }
.wg-card p { margin: 0; font-size: 0.8rem; opacity: 0.9; }
/* Links */
a { color: var(--cost-blue); transition: color 0.2s; }
a:hover { color: var(--cost-orange); }
/* Quick links */
.quick-links { margin: 1rem 0; }
.quick-links a {
  display: inline-block;
  background: var(--cost-blue);
  color: white;
  padding: 0.5rem 1rem;
  margin: 0.2rem;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.quick-links a:hover { background: var(--cost-orange); transform: translateY(-2px); }
.quick-links a i { margin-right: 5px; }
/* Back to top button */
#back-to-top {
  display: none;
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 999;
  background: var(--cost-orange);
  color: white;
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  transition: all 0.3s;
}
#back-to-top:hover { background: var(--cost-blue); transform: scale(1.1); }
/* Fade-in animation */
.fade-in { opacity: 0; transform: translateY(20px); transition: all 0.6s ease; }
.fade-in.visible { opacity: 1; transform: translateY(0); }
/* Publication cards */
.pub-card {
  background: var(--card-bg);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 0;
  transition: all 0.2s;
}
.pub-card:hover { border-color: var(--cost-orange); box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.pub-card h4 { margin: 0 0 0.3rem; color: var(--cost-blue); font-size: 0.95rem; }
.pub-card p { margin: 0; font-size: 0.8rem; color: #666; }
.pub-card .badge { background: var(--cost-orange); color: white; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; }
/* Team cards */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; }
.team-card {
  background: var(--card-bg);
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  transition: all 0.2s;
}
.team-card:hover { transform: translateY(-3px); box-shadow: 0 5px 20px rgba(0,0,0,0.1); }
.team-card .avatar {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--cost-blue), var(--cost-orange));
  border-radius: 50%;
  margin: 0 auto 0.5rem;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.5rem; font-weight: bold;
}
.team-card h4 { margin: 0.3rem 0; font-size: 0.9rem; color: var(--cost-blue); }
.team-card p { margin: 0; font-size: 0.75rem; color: #666; }
/* Timeline */
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 3px; background: linear-gradient(var(--cost-blue), var(--cost-orange)); }
.timeline-item { position: relative; margin: 1rem 0; padding: 1rem; background: var(--card-bg); border-radius: 8px; border-left: 3px solid var(--cost-gold); }
.timeline-item::before { content: ''; position: absolute; left: -25px; top: 1.2rem; width: 12px; height: 12px; background: var(--cost-orange); border-radius: 50%; }
.timeline-item h4 { margin: 0 0 0.3rem; color: var(--cost-blue); font-size: 0.9rem; }
.timeline-item .year { color: var(--cost-orange); font-weight: bold; font-size: 0.85rem; }
.timeline-item p { margin: 0.3rem 0 0; font-size: 0.8rem; color: #666; }
/* Responsive */
@media (max-width: 768px) {
  .section-cards { grid-template-columns: repeat(2, 1fr); }
  .wg-grid { grid-template-columns: 1fr; }
  .stats-bar { flex-wrap: wrap; gap: 10px; }
  #dark-toggle { right: 10px; top: auto; bottom: 80px; }
}
@media (max-width: 480px) { .section-cards { grid-template-columns: 1fr; } }

/* ======================
   CHART CONTAINERS
   ====================== */
.chart-container {
  position: relative;
  width: 100%;
  height: 400px;
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.chart-container canvas {
  max-width: 100%;
}

/* ======================
   WORD CLOUD
   ====================== */
#topics-wordcloud {
  width: 100%;
  height: 400px;
  margin: 1.5rem 0;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  overflow: hidden;
}
#topics-wordcloud svg {
  display: block;
  margin: 0 auto;
}

/* ======================
   MEMBER DIRECTORY
   ====================== */
.member-search-container {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
#member-search {
  flex: 1;
  min-width: 200px;
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}
#member-search:focus {
  outline: none;
  border-color: var(--cost-orange);
}
#country-filter {
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  background: var(--card-bg);
  cursor: pointer;
}
#country-filter:focus {
  outline: none;
  border-color: var(--cost-orange);
}
#clear-search {
  padding: 0.75rem 1.5rem;
  background: var(--cost-blue);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
}
#clear-search:hover {
  background: var(--cost-orange);
}
#results-count {
  color: #666;
  font-size: 0.9rem;
  margin-left: auto;
}

/* Member Grid */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.member-card {
  background: var(--card-bg);
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 1.25rem;
  transition: all 0.3s ease;
}
.member-card:hover {
  border-color: var(--cost-orange);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}
.member-card .member-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--cost-blue);
  margin-bottom: 0.5rem;
}
.member-card .member-name a {
  color: inherit;
  text-decoration: none;
}
.member-card .member-name a:hover {
  color: var(--cost-orange);
}
.member-card .member-institution {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.25rem;
}
.member-card .member-country {
  font-size: 0.85rem;
  color: var(--cost-orange);
  font-weight: 500;
}
.member-card .member-expertise {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.5rem;
  line-height: 1.4;
}

/* ======================
   MEMBER PROFILE PAGE
   ====================== */
.profile-header {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--cost-blue) 0%, var(--cost-light-blue) 100%);
  border-radius: 12px;
  color: white;
}
.profile-avatar {
  width: 100px;
  height: 100px;
  background: var(--cost-orange);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}
.profile-info h1 {
  margin: 0 0 0.5rem;
  color: white;
  font-size: 1.8rem;
}
.profile-info .institution {
  font-size: 1.1rem;
  opacity: 0.9;
}
.profile-info .country {
  font-size: 1rem;
  opacity: 0.8;
  margin-top: 0.25rem;
}
.profile-section {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--card-bg);
  border-radius: 10px;
  border-left: 4px solid var(--cost-orange);
}
.profile-section h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  color: var(--cost-blue);
}
.profile-section p {
  margin: 0;
  line-height: 1.6;
  color: var(--text-color);
}

/* ======================
   GRANTS PAGE
   ====================== */
.grant-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}
.grant-card {
  background: var(--card-bg);
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s ease;
}
.grant-card:hover {
  border-color: var(--cost-orange);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
.grant-card h3 {
  margin: 0 0 0.5rem;
  color: var(--cost-blue);
}
.grant-card .grant-full-name {
  font-size: 0.9rem;
  color: var(--cost-orange);
  margin-bottom: 0.75rem;
}
.grant-card p {
  font-size: 0.9rem;
  color: #666;
  line-height: 1.5;
}

/* ======================
   VMG PROJECTS
   ====================== */
.vmg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}
.vmg-card {
  background: var(--card-bg);
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 1.5rem;
  border-top: 4px solid var(--cost-orange);
  transition: all 0.3s ease;
}
.vmg-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
.vmg-card h3 {
  margin: 0 0 0.5rem;
  color: var(--cost-blue);
  font-size: 1.1rem;
}
.vmg-card .grantee {
  font-size: 0.9rem;
  color: var(--cost-orange);
  margin-bottom: 0.5rem;
}
.vmg-card p {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.5;
}

/* ======================
   CONFERENCE SERIES
   ====================== */
.conference-timeline {
  position: relative;
  padding-left: 40px;
  margin: 2rem 0;
}
.conference-timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--cost-blue), var(--cost-orange));
  border-radius: 2px;
}
.conference-item {
  position: relative;
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
}
.conference-item:hover {
  transform: translateX(5px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.12);
}
.conference-item::before {
  content: '';
  position: absolute;
  left: -33px;
  top: 1.5rem;
  width: 16px;
  height: 16px;
  background: var(--cost-orange);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.conference-item .year-badge {
  display: inline-block;
  background: var(--cost-blue);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.conference-item h3 {
  margin: 0.5rem 0;
  color: var(--cost-blue);
  font-size: 1.1rem;
}
.conference-item .location {
  font-size: 0.9rem;
  color: #666;
}
.conference-item .location i {
  color: var(--cost-orange);
  margin-right: 0.5rem;
}

/* ======================
   IMPACT METRICS
   ====================== */
.impact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.impact-card {
  background: linear-gradient(135deg, var(--cost-blue) 0%, var(--cost-light-blue) 100%);
  color: white;
  padding: 1.5rem;
  border-radius: 12px;
  text-align: center;
}
.impact-card .impact-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--cost-gold);
}
.impact-card .impact-label {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-top: 0.25rem;
}

/* ======================
   RESEARCH TOPICS PAGE
   ====================== */
.topics-intro {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--card-bg);
  border-radius: 10px;
  border-left: 4px solid var(--cost-blue);
}
.topic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}
.topic-pill {
  display: inline-block;
  background: var(--cost-blue);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  transition: all 0.3s ease;
}
.topic-pill:hover {
  background: var(--cost-orange);
  transform: scale(1.05);
}

/* ======================
   RESPONSIVE ADJUSTMENTS
   ====================== */
@media (max-width: 768px) {
  .member-search-container {
    flex-direction: column;
    align-items: stretch;
  }
  #member-search, #country-filter {
    width: 100%;
  }
  #results-count {
    margin-left: 0;
    text-align: center;
  }
  .profile-header {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }
  .chart-container {
    height: 300px;
  }
  #topics-wordcloud {
    height: 300px;
  }
}
