:root {
  --header-h: 64px;
  --radius: 14px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --bg: #f8fafc;
  --bg-alt: #f1f5f9;
  --surface: #ffffff;
  --header-bg: rgba(248, 250, 252, 0.92);
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #475569;
  --subtle: #64748b;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --chip-bg: #f1f5f9;
  --chip-text: #334155;
  --accent-border: rgba(29, 78, 216, 0.35);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 16px 32px -16px rgba(15, 23, 42, 0.2);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-alt: #131c31;
  --surface: #1a2338;
  --header-bg: rgba(15, 23, 42, 0.92);
  --border: #26324a;
  --border-strong: #3a4766;
  --text: #e2e8f0;
  --muted: #a8b3c7;
  --subtle: #8391a9;
  --accent: #7aa2f7;
  --accent-hover: #9bb8fa;
  --chip-bg: #232e46;
  --chip-text: #cbd5e1;
  --accent-border: rgba(122, 162, 247, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 20px 40px -18px rgba(0, 0, 0, 0.6);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

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

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

.prose a:hover,
.card li a:hover,
.facts a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}

.skip-link:focus {
  top: 1rem;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 100%;
}

.brand {
  color: var(--text);
  font-weight: 700;
}

.brand:hover {
  color: var(--text);
}

.nav-links {
  display: flex;
  gap: 0.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--chip-bg);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.nav-actions {
  display: flex;
  gap: 0.5rem;
}

:root:not([data-theme="dark"]) .icon-sun,
[data-theme="dark"] .icon-moon {
  display: none;
}

.menu-toggle {
  display: none;
}

@media (max-width: 1000px) {
  .menu-toggle {
    display: grid;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    padding: 0.75rem 1.5rem 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

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

  .nav-links a {
    padding: 0.7rem 0.9rem;
    font-size: 1rem;
  }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.2;
}

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

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: #fff;
}

[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-primary:hover {
  color: #0f172a;
}

.btn-icon {
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1.05rem;
}

.btn-sm {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
}

/* ---------- Hero ---------- */
.hero {
  padding: 5rem 0 4rem;
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 3rem;
}

.hero-photo {
  margin: 0;
  width: 220px;
  aspect-ratio: 1;
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.hero h1 {
  font-size: clamp(2.3rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero-role {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 500;
}

.hero-role strong {
  color: var(--text);
}

.hero-lead {
  max-width: 38rem;
  margin: 1rem 0 1.75rem;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

@media (max-width: 760px) {
  .hero {
    padding-top: 3rem;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    text-align: center;
  }

  .hero-photo {
    width: 150px;
    margin: 0 auto;
  }

  .hero-lead {
    margin-inline: auto;
  }

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

/* ---------- Sections ---------- */
.section {
  padding: 4.5rem 0;
  scroll-margin-top: var(--header-h);
}

.section.alt {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-head {
  margin-bottom: 2rem;
}

.section-head h2 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 750;
}

.section-head p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.subhead {
  margin: 3rem 0 1.25rem;
  font-size: 1.25rem;
}

/* ---------- Cards ---------- */
.card {
  position: relative;
  padding: 1.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card {
  transition: translate 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.card:not(.no-hover):hover {
  translate: 0 -4px;
  border-color: var(--accent-border);
  box-shadow: var(--shadow-lg);
}

.card ul:not([class]) {
  margin: 0 0 1.25rem;
  padding-left: 1.15rem;
  color: var(--muted);
}

.card ul:not([class]):last-child {
  margin-bottom: 0;
}

.card li {
  margin: 0.35rem 0;
}

.card li b {
  color: var(--text);
  font-weight: 600;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag {
  padding: 0.18rem 0.6rem;
  border-radius: 6px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.5;
}

.logo {
  display: block;
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.logo.wide {
  padding: 4px;
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  align-items: start;
  gap: 3rem;
}

.prose p {
  margin: 0 0 1.1rem;
  color: var(--text);
}

.prose p:first-child {
  font-size: 1.1rem;
}

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

.focus-card h3 {
  margin-bottom: 1.25rem;
  color: var(--subtle);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.focus-list {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card .focus-list li {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 0;
  font-weight: 500;
}

.focus-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--chip-bg);
  color: var(--accent);
}

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

/* ---------- Timeline (experience / education) ---------- */
.timeline {
  position: relative;
  display: grid;
  gap: 1.25rem;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 42px;
  bottom: 42px;
  left: 41px;
  width: 2px;
  background: var(--border);
}

.tl-item {
  position: relative;
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: start;
  gap: 1.5rem;
}

.tl-item > .card {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tl-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  margin-bottom: 1rem;
}

.tl-head h3 {
  font-size: 1.2rem;
}

.org {
  margin-top: 0.15rem;
  color: var(--accent);
  font-weight: 600;
}

.meta {
  color: var(--subtle);
  font-size: 0.875rem;
  text-align: right;
}

.meta time {
  display: block;
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.badge-current {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.55rem;
  border-radius: 6px;
  background: #dcfce7;
  color: #166534;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  vertical-align: middle;
}

[data-theme="dark"] .badge-current {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.project-line {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.project-line b {
  color: var(--text);
}

/* Key facts (education) */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 3rem;
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.facts .wide {
  flex-basis: 100%;
}

.facts dt {
  color: var(--subtle);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.facts dd {
  margin: 0.15rem 0 0;
  font-weight: 500;
}

.distinction {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.5rem;
  border-radius: 6px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

[data-theme="dark"] .distinction {
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
}

@media (max-width: 640px) {
  .timeline::before {
    left: 25px;
  }

  .tl-item {
    grid-template-columns: 52px 1fr;
    gap: 0.9rem;
  }

  .tl-item .logo {
    width: 52px;
    height: 52px;
    padding: 6px;
    border-radius: 11px;
  }

  .card {
    padding: 1.25rem;
  }

  .meta {
    text-align: left;
  }

  .meta time {
    display: inline;
  }

  .meta time::after {
    content: " · ";
    color: var(--subtle);
  }
}

/* ---------- Projects ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.project {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.project-media {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.project-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 1.4rem;
}

.project-body h3 {
  margin-bottom: 0.6rem;
  font-size: 1.15rem;
}

.project-body h3 a {
  color: var(--text);
}

.project-body h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.project:hover h3 a {
  color: var(--accent);
}

.project-body p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.project-body .tags {
  margin-top: auto;
}

.project-cta {
  margin-top: 1.1rem;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.project-more {
  align-items: center;
  justify-content: center;
  min-height: 220px;
  border-style: dashed;
  text-align: center;
}

.project-more .fa-github {
  margin-bottom: 0.75rem;
  color: var(--text);
  font-size: 2.5rem;
}

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

/* ---------- Certifications ---------- */
.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.9rem;
}

.cert {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1.1rem;
  color: var(--text);
}

.cert:hover {
  color: var(--text);
}

.cert-icon {
  display: block;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.cert-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cert-text {
  flex: 1;
  min-width: 0;
}

.cert-title {
  display: block;
  font-size: 0.93rem;
  font-weight: 600;
  line-height: 1.35;
}

.cert-meta {
  color: var(--subtle);
  font-size: 0.8rem;
}

.cert-arrow {
  color: var(--subtle);
  font-size: 0.8rem;
}

.cert:hover .cert-arrow {
  color: var(--accent);
}

/* ---------- Publications ---------- */
.pub-list {
  display: grid;
  gap: 1.25rem;
}

.pub {
  display: grid;
  grid-template-columns: 210px 1fr;
  align-items: start;
  gap: 1.75rem;
}

.pub-logo {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.pub-logo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pub-logo.padded img {
  inset: 1.5rem;
  width: calc(100% - 3rem);
  height: calc(100% - 3rem);
}

.pub-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.55rem;
  border-radius: 6px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  vertical-align: middle;
}

.pub h3 {
  margin-bottom: 0.4rem;
  font-size: 1.2rem;
}

.pub-authors {
  margin: 0;
  color: var(--muted);
}

.pub-authors strong {
  color: var(--text);
}

.pub-venue {
  margin: 0.25rem 0 0;
  color: var(--subtle);
  font-size: 0.92rem;
  font-style: italic;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

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

  .pub-logo {
    max-width: 220px;
  }
}

/* ---------- Skills ---------- */
.skills {
  padding-block: 0.4rem;
}

.skill-row {
  display: grid;
  grid-template-columns: 260px 1fr;
  align-items: center;
  gap: 1.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
}

.skill-row:last-child {
  border-bottom: 0;
}

.skill-row h3 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
}

.skill-row h3 i {
  width: 1.25rem;
  color: var(--accent);
  text-align: center;
}

@media (max-width: 640px) {
  .skill-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card .chips li {
  margin: 0;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-alt);
  font-size: 0.88rem;
}

/* ---------- Contact ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  color: var(--text);
}

.contact-item:hover {
  color: var(--text);
}

.contact-item i {
  width: 1.5rem;
  color: var(--subtle);
  font-size: 1.35rem;
  text-align: center;
}

.contact-item:hover i {
  color: var(--accent);
}

.contact-label {
  display: block;
  color: var(--subtle);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.contact-value {
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 1.75rem 0 2.25rem;
  border-top: 1px solid var(--border);
  color: var(--subtle);
  font-size: 0.875rem;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer a {
  color: var(--subtle);
}

.site-footer a:hover {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
