:root {
  /* Light mode — Teal Scientific */
  --text-light: #1A1A1A;
  --text-dark: #E7E9EC;
  --bg-light: #F7F7F2;
  --bg-dark: #0B0F14;
  --accent-light: #2C5F8D;
  --accent-dark: #8DBCE3;
  --accent-hover: #3E78A3; /* hover in light mode */
  --secondary-light: #6B7280;
  --secondary-dark: #9CA3AF;
  --border-light: #E5E7EB;
  --border-dark: #22262B;
  --sidebar-width: 280px;   /* single source of truth */
  --sidebar-gap: 80px;      /* space between sidebar and content */
  
  /* Main color tokens (light mode defaults) */
  --bg: #F7F7F2;
  --text: #1A1A1A;
  --muted: #6B7280;
  --accent: #2C5F8D;
  --card-bg: #FFFFFF;
  --border: #E5E7EB;
}

/* Dark mode token overrides */
body.dark {
  --text-light: #E7E9EC;
  --text-dark: #1A1A1A;
  --bg-light: #0B0F14;
  --bg-dark: #F7F7F2;
  --accent-light: #8DBCE3;
  --accent-dark: #2C5F8D;
  --accent-hover: #A5CCEA; /* hover in dark mode */
  --secondary-light: #9CA3AF;
  --secondary-dark: #6B7280;
  --border-light: #22262B;
  --border-dark: #E5E7EB;
  
  /* Main color tokens (dark mode) */
  --bg: #0B0F14;
  --text: #E7E9EC;
  --muted: #9CA3AF;
  --accent: #8DBCE3;
  --card-bg: #121417;
  --border: #22262B;
}

/* Pleasant alternate color themes */
/* Palette variants */
/* Palette variants (apply base surfaces only in light mode) */
body:not(.dark).theme-teal {
  --bg: #F7F7F2;
  --bg-light: #F7F7F2;
  --card-bg: #FFFFFF;
  --border: #E5E7EB;
  --border-light: #E5E7EB;
  --accent: #2C5F8D;
  --accent-hover: #3E78A3;
}

body:not(.dark).theme-grey {
  --bg: #F2F3F5;
  --bg-light: #F2F3F5;
  --card-bg: #FFFFFF;
  --border: #E5E7EB;
  --border-light: #E5E7EB;
  --accent: #4B5563;      /* Slate accent for light */
  --accent-hover: #64748B;
}

/* Grey palette accents for dark mode */
body.dark.theme-grey {
  --accent: #9AA4B2;
  --accent-hover: #B4BDCA;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-weight: 400;
}

/* Enhanced typography for better readability */
p { line-height: 1.8; letter-spacing: 0.3px; }
h1, h2, h3, h4, h5, h6 { letter-spacing: -0.5px; line-height: 1.3; font-weight: 600; }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 2.5rem 4rem;
}

.site-header {
  background: var(--card-bg);
  color: var(--text);
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.site-header h1 {
  margin: 0;
}

nav {
  margin-top: 0.5rem;
}

nav a {
  color: var(--accent);
  text-decoration: none;
  margin-right: 0.75rem;
}

nav a:hover {
  color: var(--accent-hover);
}

main {
  padding: 0;
}

.muted { color: var(--muted); }

footer {
  background: transparent;
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem 3rem;
  border-top: 1px solid var(--border);
}

/* Footer layout + icons (shared) */
.footer-content {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-social {
  display: flex;
  gap: 0.75rem;
}

.footer-social a {
  color: var(--text);
  opacity: 0.8;
  text-decoration: none;
  font-size: 1.1rem;
}

.footer-social a:hover { opacity: 1; }

.back-to-top {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.back-to-top:hover { text-decoration: underline; }

/* Shared sidebar styles for all pages */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  padding: 2rem 1.25rem;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 1rem;
  overflow-y: auto;             /* ensure bottom icons are reachable */
  overscroll-behavior: contain; /* avoid rubber-banding */
  padding-bottom: 1rem;         /* tighter bottom padding as requested */
  z-index: 100;                 /* keep above page content */
  box-sizing: border-box;       /* include padding in height */
}

.sidebar .profile-image {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  margin-bottom: 0.5rem;
  align-self: center; /* center photo in the sidebar */
}

.sidebar .name { font-size: 1.4rem; font-weight: 700; }
.sidebar .role { color: var(--secondary-light); font-size: 0.95rem; margin-top: -0.25rem; }
/* Center name and role under the photo */
.sidebar .name,
.sidebar .role {
  align-self: center;
  text-align: center;
}
body.dark .sidebar .role { color: var(--secondary-dark); }
.sidebar .role a {
  color: var(--accent-light);
  text-decoration: none;
}
body.dark .sidebar .role a { color: var(--accent-dark); }
.sidebar .role a:hover {
  color: var(--accent-hover);
  text-decoration: none;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; margin-top: 0.75rem; }
.sidebar-nav a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 600;
  display: block;
}
body.dark .sidebar-nav a { color: var(--accent-dark); }
.sidebar-nav a:hover {
  color: var(--accent-hover);
  text-decoration: none;
  opacity: 1; /* override any generic dimming */
}

.sidebar .social-links {
  margin-top: auto; /* push to bottom */
  position: sticky; /* keep visible when scrolling */
  bottom: 0;
  display: flex;
  justify-content: space-evenly; /* evenly spread */
  gap: 0.5rem;
  padding: 0.75rem 0 calc(1rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
  width: 100%;
}
.sidebar .social-links a {
  color: var(--text);
  opacity: 0.8;
  font-size: 1.4rem;
}
.sidebar .social-links a:hover { opacity: 1; }

/* Hide old headers globally */
.site-header, .header { display: none; }

/* Content shift when sidebar present */
@media (min-width: 769px) {
  .with-sidebar { margin-left: calc(var(--sidebar-width) + var(--sidebar-gap)); }
  /* Balance right whitespace to match sidebar gap on the left */
  .container.with-sidebar { padding-right: calc(2.5rem + var(--sidebar-gap)); }
}

/* Mobile: sidebar becomes horizontal header at top */
@media (max-width: 768px) {
  .sidebar { 
    position: relative;
    height: auto; 
    width: 100%; 
    border-right: none; 
    border-bottom: 1px solid var(--border);
    padding: 1rem 1rem; 
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "image nav social";
    align-items: center;
    gap: 1rem;
    box-sizing: border-box;
  }
  
  .sidebar .profile-image {
    grid-area: image;
    width: 50px;
    height: 50px;
    margin: 0;
    border-width: 2px;
  }
  
  .sidebar .name,
  .sidebar .role {
    display: none; /* Hide name/role on mobile to save space */
  }
  
  .sidebar-nav {
    grid-area: nav;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    justify-content: center;
    align-items: center;
  }
  
  .sidebar-nav a {
    font-size: 0.9rem;
    white-space: nowrap;
  }
  
  .sidebar .social-links {
    grid-area: social;
    position: static;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    width: auto;
    justify-content: flex-end;
  }
  
  .sidebar .social-links a {
    font-size: 1.1rem;
  }
  
  /* Adjust container padding for mobile */
  .container {
    padding: 1.5rem 1rem 3rem;
  }
}

/* Generic card style for lists and sections */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.year-section { margin-top: 1rem; }
.year-section h3 { margin: 0.5rem 0 0.75rem; }

/* Publication card styling */
.publication-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.publication-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.dark .publication-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.publication-card h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
  line-height: 1.5;
}

.publication-card p {
  font-size: 0.9rem;
  margin: 0.3rem 0;
  color: var(--muted);
}

.publication-card p i {
  color: var(--accent);
  font-weight: 500;
}

.publication-card a {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.publication-card a:hover {
  text-decoration: underline;
}

.publication-year-header {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
}

.badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  text-transform: uppercase;
}

/* Research card styling */
.research-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: all 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.research-card:hover {
  border-left-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

body.dark .research-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.research-card h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.75rem;
  line-height: 1.5;
}

.research-card p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}

/* Theme toggle button (shared) */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  z-index: 1000;
  padding: 0.5rem;
}
.theme-toggle:hover { opacity: 0.8; }

/* Dark mode toggle next to theme palette */
.mode-toggle {
  position: fixed;
  top: 1rem;
  right: 4.25rem; /* sits left of the palette button */
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  z-index: 1000;
  padding: 0.5rem;
}
.mode-toggle:hover { opacity: 0.8; }

/* Utility classes to mimic desired layout styles */
.text-5xl { font-size: 2.5rem; line-height: 1.2; }
.text-3xl { font-size: 1.75rem; line-height: 1.3; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-10 { margin-bottom: 2.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.mx-6 { margin-left: 1.5rem; margin-right: 1.5rem; }
.text-justify { text-align: justify; }
.grid { display: grid; }
.gap-4 { gap: 1rem; }
.columns-2 { column-count: 2; }
.list-disc { list-style: disc; padding-left: 1.5rem; }

.section { margin-bottom: 2.5rem; }
.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* Timeline styles inspired by TimeLineElement component */
.timeline,
.time-line-container {
  position: relative;
  display: grid;
  gap: var(--tl-gap, 1rem);
  margin-bottom: 2rem;
  padding-left: var(--tl-pad, 2.5rem); /* space for the timeline line and dots */
}

.timeline .card,
.time-line-container .card,
.time-line-container .timeline-item {
  position: relative;
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.timeline .card::before,
.time-line-container .card::before,
.time-line-container .timeline-item::before {
  content: "";
  position: absolute;
  left: -1.63rem; /* aligns with border-left */
  top: 1rem;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
}

.timeline .card p,
.time-line-container .card p {
  margin: 0.35rem 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Prettier timeline heading styles */
.timeline .card h3,
.time-line-container .card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

/* Timeline with accent left border */
.timeline,
.time-line-container {
  position: relative;
  display: grid;
  gap: var(--tl-gap, 1rem);
  margin-bottom: 2rem;
  padding-left: var(--tl-pad, 2.5rem); /* space for timeline line and dots */
}

/* Draw vertical connectors per item so the line stops at last dot */
.timeline .card::after,
.time-line-container .card::after,
.time-line-container .timeline-item::after {
  content: "";
  position: absolute;
  left: calc(-1 * var(--tl-pad, 2.5rem) - 1.5px); /* center of line under dot */
  top: calc(1.5rem + 11px); /* start at this dot's visual center (includes 3px border) */
  width: 3px;
  height: calc(100% + var(--tl-gap, 1rem) + 1px); /* extend through card and the grid gap */
  background: var(--accent);
}

.timeline .card:last-child::after,
.time-line-container .card:last-child::after,
.time-line-container .timeline-item:last-child::after { display: none; }

/* Nudge the very first connector up slightly so it visibly touches the first dot */
.timeline .card:first-child::after,
.time-line-container .card:first-child::after,
.time-line-container .timeline-item:first-child::after {
  top: calc(1.5rem + 10px);
}

/* Ensure dots render above the connector line */
.timeline .card::before,
.time-line-container .card::before,
.time-line-container .timeline-item::before { z-index: 1; }
.timeline .card::after,
.time-line-container .card::after,
.time-line-container .timeline-item::after { z-index: 0; }

.timeline .card,
.time-line-container .card,
.time-line-container .timeline-item {
  position: relative;
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-left: 0;
}

.timeline .card::before,
.time-line-container .card::before,
.time-line-container .timeline-item::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--tl-pad, 2.5rem) - 11px); /* center the full circle (content + border) on the line */
  top: 1.5rem;
  width: 16px;
  height: 16px;
  background: var(--card-bg);
  border: 3px solid var(--accent);
  border-radius: 50%;
}

@media (max-width: 640px) {
  .container { padding: 1.5rem 1rem 3rem; }
  .text-5xl { font-size: 2rem; }
  .text-3xl { font-size: 1.25rem; }
}

/* General link styling (content) */
a { color: var(--accent); text-decoration: none; transition: color 0.2s ease, opacity 0.2s ease; }
a:hover { color: var(--accent-hover); }

/* Bio section (Home) */
.bio { margin-bottom: 4rem; }
.bio h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}
.bio p { margin-bottom: 1rem; text-align: justify; }
.contact-callout {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: rgba(44, 95, 141, 0.03);
  border-left: 2px solid var(--accent-light);
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.6;
}
body.dark .contact-callout {
  background: rgba(107, 163, 212, 0.04);
  border-left-color: var(--accent-dark);
}
.contact-callout a { font-weight: 500; }

/* News section (Home) */
.news-section { margin-bottom: 4rem; }
.news-section h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}
.news-container {
  height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  scroll-behavior: smooth;
}
.news-list { list-style: none; animation: scrollNews 40s linear infinite; }
.news-container:hover .news-list { animation-play-state: paused; }
.news-container::-webkit-scrollbar { width: 6px; }
.news-container::-webkit-scrollbar-track { background: var(--bg-light); }
body.dark .news-container::-webkit-scrollbar-track { background: var(--bg-dark); }
.news-container::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
body.dark .news-container::-webkit-scrollbar-thumb { background: var(--border-dark); }
.news-container::-webkit-scrollbar-thumb:hover { background: var(--secondary-light); }
body.dark .news-container::-webkit-scrollbar-thumb:hover { background: var(--secondary-dark); }
@keyframes scrollNews { 0% { transform: translateY(0);} 100% { transform: translateY(-50%);} }
.news-item { padding: 0.75rem 0; border-bottom: 1px solid var(--border-light); font-size: 0.95rem; display: flex; gap: 1rem; }
@media (max-width: 640px) { .news-item { flex-direction: column; gap: 0.25rem; } }
body.dark .news-item { border-bottom-color: var(--border-dark); }
.news-item:last-child { border-bottom: none; }
.news-date { color: var(--secondary-light); font-weight: 500; flex-shrink: 0; min-width: 110px; }
body.dark .news-date { color: var(--secondary-dark); }
.news-content { flex: 1; }
