* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  scroll-behavior: smooth;
  transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover,
a:focus {
  text-decoration-style: wavy;
  color: var(--link-hover);
}

p a {
  font-weight: 600;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-position: under;
  transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

nav a {
  position: relative;
  font-weight: bold;
  text-decoration: none;
}

nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 2px;
  background: var(--link);
  transition: width .3s ease;
}

#about a[href="#projects"] {
  text-decoration: underline;
  text-underline-position: under;
}

#about a[href="#projects"]:hover,
#about a[href="#projects"]:focus {
  text-decoration-style: wavy;
  color: var(--link-hover);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 1rem 2rem;
  background: var(--card-bg);
  box-shadow: 0 2px 5px rgba(0, 0, 0, .1);
  transition: box-shadow .3s ease, background .3s ease;
}

header h1 {
  font-size: 1.5rem;
  margin: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.brand .logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.logo-light {
  display: block;
}

.logo-dark {
  display: none;
}

html.dark .logo-light {
  display: none;
}

html.dark .logo-dark {
  display: block;
}

nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

nav a {
  font-weight: bold;
  color: var(--text);
  position: relative;
}

nav a:hover::after {
  width: 100%;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: none;
  border: none;
  border-radius: 6px;
  padding: .4rem;
  transition: background .3s;
}

.theme-toggle:hover {
  background: var(--hover);
}

section {
  padding: 4rem 2rem;
  text-align: center;
  opacity: 0;
  transform: translateY(40px);
  transition: all .8s ease-out;
}

section p {
  max-width: 700px;
  margin: 0 auto;
}

section.visible {
  opacity: 1;
  transform: translateY(0);
}

h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2rem;
}

.hero img {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1.5rem;
  transition: transform .4s ease;
}

.hero img:hover {
  transform: scale(1.08);
}

.hero h2 {
  font-size: 2.2rem;
  margin-bottom: .5rem;
}

.hero p {
  font-size: 1.1rem;
  color: var(--subtext);
}

.flip-card {
  width: 200px;
  height: 200px;
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s;
}

.flip-card:hover .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  top: 0;
  left: 0;
}

.flip-card-front img,
.flip-card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.flip-card-back {
  transform: rotateY(180deg);
}

.flip-card-back.logo-light {
  display: block;
}

html.dark .flip-card-back.logo-light {
  display: none;
}

.flip-card-back.logo-dark {
  display: none;
}

html.dark .flip-card-back.logo-dark {
  display: block;
}

.cards {
  display: grid;
  gap: 2rem;
  justify-content: center;
}

section:not(.carousel) .cards {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .1);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}

.card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 24px rgba(0, 0, 0, .15);
}

.card img {
  width: 100%;
  height: 280px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.card h3 {
  margin: .5rem 0;
}

.card p {
  font-size: .95rem;
  margin-bottom: .75rem;
  color: var(--subtext);
}

.labels {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.label {
  padding: .25rem .6rem;
  border-radius: 999px;
  background: var(--hover);
  font-size: .75rem;
  font-weight: 500;
  color: var(--subtext);
  user-select: none;
  pointer-events: none;
  white-space: nowrap;
}

.buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.buttons a.btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.2rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: var(--link);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: transform .3s ease, background .3s, color .3s;
}

.buttons a.btn:hover,
.btn:hover {
  background: var(--link-hover);
  color: #fff;
  transform: translateY(-3px) scale(1.05);
}

.buttons a.btn i {
  vertical-align: middle;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.contact-links a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  background: var(--card-bg);
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .1);
  font-weight: 500;
  color: var(--text);
  transition: transform .3s ease, background .3s;
}

.contact-links a {
  text-decoration: none;
  color: var(--text);
}

.contact-links a:hover,
.contact-links a:focus {
  color: var(--text);
  text-decoration: none;
  transform: scale(1.08);
  background: var(--hover);
}

footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 2rem;
  text-align: center;
  transition: background .3s, color .3s;
}

footer .links {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
}

footer a {
  color: var(--footer-link);
  text-decoration: none;
  font-weight: normal;
  transition: color 0.3s ease;
}

footer a:hover,
footer a:focus {
  color: var(--link);
}

.back-to-top {
  margin: 2rem auto 0;
  display: inline-block;
  background: var(--link);
  color: #fff;
  padding: .8rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  box-shadow: 0 4px 8px rgba(0, 0, 0, .2);
  transition: transform .3s ease, background .3s;
}

.back-to-top:hover {
  background: var(--link-hover);
  transform: scale(1.08);
}

#tagline {
  font-size: 1.1rem;
  color: var(--subtext);
  border-right: 2px solid var(--link);
  white-space: nowrap;
  display: inline-block;
  animation: blink-cursor .7s infinite;
  padding-right: 5px;
}

@keyframes blink-cursor {

  0%,
  50% {
    border-color: var(--link);
  }

  51%,
  100% {
    border-color: transparent;
  }
}

:root {
  --bg: #f8f9fa;
  --text: #333;
  --subtext: #555;
  --link: #007BFF;
  --link-hover: #0056b3;
  --card-bg: #fff;
  --hover: #f1f1f1;
  --footer-bg: #111;
  --footer-text: #bbb;
  --footer-link: #ddd;
}

.dark {
  --bg: #121212;
  --text: #eee;
  --subtext: #aaa;
  --link: #4dabf7;
  --link-hover: #1c7ed6;
  --card-bg: #1e1e1e;
  --hover: #2a2a2a;
  --footer-bg: #000;
  --footer-text: #888;
  --footer-link: #bbb;
}

html.dark #theme-toggle svg {
  stroke: white;
}

section:nth-of-type(odd) {
  background: #ffffff;
}

section:nth-of-type(even) {
  background: #f7fbff;
}

.dark section:nth-of-type(odd) {
  background: #121212;
}

.dark section:nth-of-type(even) {
  background: #181a1d;
}

.dark .split-section>section {
  background: #1e1e1e;
}

.split-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: stretch;
  text-align: left;
}

.split-section>section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .1);
  transition: background .3s;
  display: flex;
  flex-direction: column;
}

.split-section h2 {
  margin-bottom: 1rem;
}

@media (max-width: 992px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
  }

  nav {
    flex-wrap: wrap;
    gap: .8rem;
  }

  .hero h2 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.7rem;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  header {
    padding: 1rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  nav {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  nav a {
    padding: 0.5rem 0;
  }

  .hero img {
    width: 120px;
    height: 120px;
  }

  .hero h2 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  .carousel .cards,
  section:not(.carousel) .cards {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 1rem;
  }

  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .split-section {
    grid-template-columns: 1fr;
  }

  .contact-links {
    flex-direction: column;
    align-items: center;
  }

  #menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    color: var(--text);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #menu-toggle:active {
    transform: scale(0.95);
  }

  nav#nav-links {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--card-bg);
    margin-top: 0;
    padding: 0 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);

    max-height: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    overflow: hidden;
    transition:
      max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.3s ease,
      transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
      padding 0.3s ease,
      margin-top 0.3s ease;
  }

  nav#nav-links.show {
    max-height: 500px;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    padding: 1rem;
    margin-top: 0.5rem;
  }


  footer .links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
  }

  footer p {
    font-size: 0.85rem;
  }
}

.carousel {
  overflow: hidden;
  position: relative;
  width: 100%;
}

.carousel-track {
  display: flex;
  transition: transform .5s ease;
  width: 100%;
  touch-action: pan-y;
  cursor: grab;
}

.carousel-track:active {
  cursor: grabbing;
}

.carousel .cards {
  min-width: 100%;
  grid-template-columns: repeat(3, 1fr);
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: .6rem;
  margin-top: 1rem;
}

.carousel-dots button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  background: #bbb;
  cursor: pointer;
  transition: background .3s;
}

.carousel-dots button.active {
  background: var(--link);
}

.card.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--subtext);
  font-style: italic;
}



.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.image-lightbox.active {
  opacity: 1;
  pointer-events: auto;
}

.image-lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 85%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  background: #111;
}

.image-lightbox-content img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
  object-fit: contain;
}

.image-lightbox-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  gap: 0.5rem;
}

.image-lightbox button {
  background: #222;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s ease;
}

.image-lightbox button:hover {
  background: #333;
}

@media (max-width: 600px) {
  .image-lightbox-content {
    max-width: 95%;
    max-height: 80%;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

#menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background 0.3s ease;
}

#menu-toggle:hover {
  background: var(--hover);
}

#menu-toggle i {
  width: 28px;
  height: 28px;
  stroke: #fff;
  transition: transform 0.3s ease, stroke 0.3s ease;
}

#menu-toggle.open i {
  transform: rotate(90deg);
  stroke: var(--link);
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 1000;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}

.skip-link:focus {
  top: 0;
}

.centered {
  text-align: center;
}

.hero-actions {
  margin: 1.5rem 0;
  text-align: center;
}

.btn-disabled {
  background: #ccc;
  color: #666;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  font-size: 1rem;
  cursor: not-allowed;
}

.icon-lg {
  width: 40px;
  height: 40px;
  margin-bottom: 0.8rem;
}

.list-left {
  text-align: left;
}

.back-to-top-wrapper {
  margin-top: 2rem;
  text-align: center;
}

:focus-visible {
  outline: 3px solid #4f46e5;
  outline-offset: 3px;
}

button {
  font-family: inherit;
}

.lab-card h3 {
  margin-bottom: 1rem;
}

.pub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  padding: 1rem 0;
}

.pub-card {
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pub-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.pub-img-link {
  display: block;
  overflow: hidden;
  height: 180px;
  background: var(--hover);
  position: relative;
}

.pub-img-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--hover) 0%, var(--bg) 100%);
}

.pub-icon {
  width: 64px;
  height: 64px;
  color: var(--link);
  transition: transform 0.4s ease;
}

.pub-card:hover .pub-icon {
  transform: scale(1.1) rotate(5deg);
}

.pub-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.pub-content h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.pub-content h3 a {
  text-decoration: none;
  color: var(--text);
  transition: color 0.2s;
}

.pub-content h3 a:hover {
  color: var(--link);
}

.pub-content p {
  font-size: 0.95rem;
  color: var(--subtext);
  margin-bottom: 1.5rem;
  flex-grow: 1;
}

.pub-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tag {
  background: var(--hover);
  color: var(--subtext);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.pub-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--hover);
  font-size: 0.85rem;
  color: var(--subtext);
}

.pub-source {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pub-source i {
  width: 16px;
  height: 16px;
}

.read-more {
  display: inline-block;
  background: var(--link);
  color: #fff;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.8rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

.read-more:hover {
  background: var(--link-hover);
  transform: scale(1.05);
  color: #fff;
}

@media (max-width: 768px) {
  .pub-grid {
    grid-template-columns: 1fr;
  }
}

.lab-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.lab-tags span {
  background-color: var(--hover);
  color: var(--text);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

.lab-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hover);
  width: 100%;
}

.lab-status {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--link);
}
