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

:root {
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --text: #1a1a2e;
  --text-secondary: #555;
  --border: #e0e0e0;
  --accent: #0366d6;
  --accent-hover: #0256b9;
  --card-bg: #ffffff;
  --nav-bg: rgba(255,255,255,0.95);
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --radius: 8px;
  --max-width: 900px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-alt: #161b22;
  --text: #c9d1d9;
  --text-secondary: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --card-bg: #161b22;
  --nav-bg: rgba(13,17,23,0.95);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── Navigation ─── */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s;
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.nav-brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 24px;
}

.nav-links a {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

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

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
  margin-left: 12px;
}

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

.theme-toggle .icon-dark {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-light {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-dark {
  display: inline;
}

/* ─── Hero ─── */

.section {
  padding: 80px 0;
}

#about {
  padding-top: 120px;
}

.hero-content {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

.hero-avatar {
  flex-shrink: 0;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--border);
  position: relative;
}

.hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sprite {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background-image: url('../img/proper_sprite_sheet_1024.png');
  background-repeat: no-repeat;
  background-size: 400% 300%;
  image-rendering: auto;
}

.avatar-fallback {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-alt);
}

.avatar-placeholder img {
  display: none;
}

.avatar-placeholder .avatar-fallback {
  display: flex;
}

.hero-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.hero-text h1 {
  font-size: 2rem;
  font-weight: 700;
}

.hero-title {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.contact-icons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.contact-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.contact-icon:hover {
  border-color: var(--accent);
  background: var(--bg-alt);
}

.contact-img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  pointer-events: none;
}

.callout {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--accent);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  text-align: center;
  z-index: 100;
  animation: callout-in 0.15s ease-out;
}

.callout.open {
  display: block;
}

.callout::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--accent);
}

.callout::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--bg);
}

.callout-text {
  cursor: pointer;
  transition: opacity 0.15s;
}

.callout-text:hover {
  opacity: 0.7;
}

.callout-text.copied {
  opacity: 0.5;
}

@keyframes callout-in {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hero-bio {
  color: var(--text-secondary);
  margin-bottom: 20px;
  max-width: 560px;
  text-align: justify;
}

.hero-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ─── Buttons ─── */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

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

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ─── Section Titles ─── */

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

/* ─── Web Systems Grid ─── */

.systems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.system-card {
  position: relative;
  display: block;
  height: 200px;
  border-radius: var(--radius);
  background-size: cover;
  background-position: center;
  overflow: hidden;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.25s, box-shadow 0.25s;
}

.system-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  text-decoration: none;
}

.system-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px;
  background: linear-gradient(transparent 40%, rgba(0,0,0,0.7));
  color: #fff;
  transition: background 0.3s;
}

.system-card:hover .system-card-overlay {
  background: linear-gradient(transparent 20%, rgba(0,0,0,0.85));
}

.system-card-overlay h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.system-card-overlay p {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* ─── Projects ─── */

.projects-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.project-item {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  transition: box-shadow 0.2s;
}

.project-item:hover {
  box-shadow: var(--shadow);
}

.project-item h3 {
  font-size: 1rem;
  margin-bottom: 6px;
}

.project-item p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.project-item a {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ─── News ─── */

.news-list {
  list-style: none;
}

.news-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.news-list li:last-child {
  border-bottom: none;
}

.news-date {
  color: var(--text);
  font-weight: 600;
}

/* ─── Skills ─── */

.skills-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.skills-category h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.skills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--bg-alt);
  transition: border-color 0.2s, background 0.2s;
}

.skill-tag:hover {
  border-color: var(--accent);
  background: transparent;
}

/* ─── Experience ─── */

.experience-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

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

.experience-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.experience-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.experience-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.experience-role {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 500;
  margin: 2px 0 4px;
}

.experience-location {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.experience-details {
  list-style: disc;
  padding-left: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.experience-subsection {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 16px 0 6px;
  padding-top: 4px;
}

.experience-details li {
  margin-bottom: 6px;
}

.experience-details li:last-child {
  margin-bottom: 0;
}

/* ─── Education ─── */

.education-item {
  padding: 16px 0;
}

.education-item h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.education-school {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.education-location,
.education-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ─── Publications ─── */

.pub-list {
  list-style: none;
  counter-reset: pub-counter;
}

.pub-item {
  counter-increment: pub-counter;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

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

.pub-item::before {
  content: counter(pub-counter) ". ";
  font-weight: 600;
  color: var(--text-secondary);
  float: left;
  margin-right: 4px;
}

.pub-authors {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
}

.pub-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

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

.pub-links {
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ─── Modal ─── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg);
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: modal-in 0.25s ease-out;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal::-webkit-scrollbar {
  width: 6px;
}

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

.modal::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.modal::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}

.modal-close:hover {
  background: rgba(0,0,0,0.7);
}

.modal-carousel {
  position: relative;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

.carousel-track {
  display: flex;
  transition: transform 0.35s ease;
  height: 220px;
}

.carousel-slide {
  min-width: 100%;
  height: 220px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  position: relative;
}

.carousel-slide-video {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
}

.carousel-play-btn {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}

.carousel-play-btn:hover {
  background: rgba(0,0,0,0.8);
  transform: scale(1.1);
}

.carousel-expand-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: none;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 5;
  line-height: 1;
}

.carousel-expand-btn:hover {
  background: rgba(0,0,0,0.7);
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 0;
  background: var(--bg);
}

.carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, border-color 0.2s;
}

.carousel-dot.active {
  background: var(--accent);
  border-color: var(--accent);
}

.carousel-dot:hover {
  border-color: var(--accent);
}

.modal-body {
  padding: 24px;
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-description {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
}

.modal-details h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.modal-details .tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.modal-details .tech-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--bg-alt);
}

.modal-details .feature-list {
  list-style: disc;
  padding-left: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modal-details .feature-list li {
  margin-bottom: 4px;
}

.subsystem-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.subsystem-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.subsystem-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.subsystem-card h5 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--accent);
}

.subsystem-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ─── Lightbox ─── */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,0.92);
  align-items: center;
  justify-content: center;
  padding: 40px;
  backdrop-filter: blur(8px);
}

.lightbox.open {
  display: flex;
}

.lightbox-image {
  width: 100%;
  max-width: 900px;
  height: 80vh;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  animation: lightbox-in 0.25s ease-out;
}

.lightbox-video-container {
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
}

@keyframes lightbox-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 10;
  line-height: 1;
}

.lightbox-close:hover {
  opacity: 1;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  font-size: 3rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  padding: 12px 8px;
  z-index: 10;
  line-height: 1;
}

.lightbox-nav:hover {
  opacity: 1;
}

.lightbox-prev {
  left: 12px;
}

.lightbox-next {
  right: 12px;
}

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ─── Certifications ─── */

.cert-item {
  padding: 16px 0;
}

.cert-item h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

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

/* ─── Copy feedback ─── */

.copy-feedback {
  position: fixed;
  pointer-events: none;
  z-index: 5000;
  font-size: 0.8rem;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  padding: 6px 14px;
  border-radius: 20px;
  animation: copy-pop 0.8s ease-out forwards;
}

@keyframes copy-pop {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-24px) scale(0.9); }
}

/* ─── Footer ─── */

.footer {
  text-align: center;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    gap: 12px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-container {
    justify-content: flex-start;
  }

  .nav-brand {
    display: none;
  }

  .theme-toggle {
    margin-left: auto;
  }

  .hero-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .hero-name-row {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .hero-avatar {
    width: 140px;
    height: 140px;
  }

  .hero-bio {
    max-width: 100%;
  }

  .hero-links {
    justify-content: center;
  }

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

  .section {
    padding: 56px 0;
  }

  #about {
    padding-top: 96px;
  }
}
