/* ============ Tokens ============ */
:root {
  /* Dark theme (default) */
  --bg: #0a0e14;
  --bg-alt: #0d1320;
  --surface: #121927;
  --surface-2: #161f30;
  --border: #212c3f;
  --text: #e7ecf5;
  --text-dim: #98a3b8;
  --text-faint: #6b7688;
  --accent: #38e0d8;
  --accent-2: #7c9dff;
  --accent-soft: rgba(56, 224, 216, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(10, 14, 20, 0.72);
  --header-shadow: rgba(0, 0, 0, 0.4);
  --selection-fg: #05201e;

  --radius: 14px;
  --radius-sm: 8px;
  --container: 1120px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

:root[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-alt: #eef2f8;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --border: #dce3ee;
  --text: #131a25;
  --text-dim: #55606f;
  --text-faint: #8b95a4;
  --accent: #0f9d95;
  --accent-2: #4a6bdd;
  --accent-soft: rgba(15, 157, 149, 0.12);
  --shadow: 0 10px 30px rgba(23, 37, 66, 0.12);
  --header-bg: rgba(255, 255, 255, 0.8);
  --header-shadow: rgba(23, 37, 66, 0.1);
  --selection-fg: #ffffff;
}

html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

/* ============ Reset ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font: inherit; cursor: pointer; }

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

::selection { background: var(--accent); color: var(--selection-fg); }

/* ============ Progress bar ============ */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 1000;
  transition: width 0.1s ease-out;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}
.btn-small { padding: 9px 18px; font-size: 0.85rem; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06110f;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(56, 224, 216, 0.25); }
.btn-outline {
  border-color: var(--border);
  color: var(--text);
  background: transparent;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.btn-ghost { color: var(--text-dim); }
.btn-ghost:hover { color: var(--accent); }

/* ============ Header ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background 0.25s ease, box-shadow 0.2s ease;
}
.site-header.is-scrolled { box-shadow: 0 8px 24px var(--header-shadow); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  gap: 24px;
}
.logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}
.logo-dot { color: var(--accent); }

.nav-desktop ul { display: flex; gap: 32px; }
.nav-link {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-dim);
  position: relative;
  padding: 6px 0;
  transition: color 0.2s ease;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--accent); }
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.header-cta { flex-shrink: 0; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: center;
}
.nav-toggle span {
  width: 18px;
  height: 2px;
  background: var(--text);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-mobile {
  display: none;
  max-height: 0;
  overflow: hidden;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  transition: max-height 0.3s ease;
}
.nav-mobile.open { max-height: 500px; }
.nav-mobile ul { padding: 16px 24px 24px; display: flex; flex-direction: column; gap: 4px; }
.nav-mobile .nav-link { display: block; padding: 12px 4px; font-size: 1rem; }
.nav-mobile li:last-child { margin-top: 12px; }

/* ============ Hero ============ */
.hero { padding: 96px 0 80px; position: relative; }
.hero::before {
  content: "";
  position: absolute;
  top: -10%; right: -10%;
  width: 480px; height: 480px;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  filter: blur(40px);
  z-index: -1;
}
.hero-inner {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 56px;
  align-items: center;
}
.eyebrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  margin-bottom: 18px;
  text-transform: uppercase;
}
.hero-text h1 {
  font-size: clamp(2.2rem, 4.2vw, 3.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 22px;
}
.accent { color: var(--accent); }
.hero-lede {
  color: var(--text-dim);
  font-size: 1.08rem;
  max-width: 540px;
  margin-bottom: 34px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 34px; }
.hero-socials { display: flex; gap: 18px; }
.hero-socials a {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.hero-socials a:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

.hero-photo-wrap { position: relative; justify-self: center; }
.hero-photo-frame {
  width: min(340px, 80vw);
  aspect-ratio: 1 / 1;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, var(--surface-2), var(--bg-alt));
  box-shadow: var(--shadow);
  position: relative;
}
.hero-photo-frame::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 28px;
  box-shadow: inset 0 0 0 1px rgba(56, 224, 216, 0.15);
}
.hero-photo { width: 100%; height: 100%; object-fit: cover; }
.hero-badge {
  position: absolute;
  bottom: -18px; left: -18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.hero-badge-num { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.hero-badge-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* ============ Sections ============ */
.section { padding: 96px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-eyebrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.section-title {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 48px;
  max-width: 640px;
}

/* ============ Key Metrics ============ */
.metrics-section { padding: 64px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.metrics-head { text-align: center; margin-bottom: 40px; }
.metrics-title {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.metrics-underline {
  display: inline-block;
  width: 48px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.metric-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.metric-icon { color: var(--accent); }
.metric-num {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
}
.metric-label { color: var(--text-dim); font-size: 0.88rem; }

/* ============ About ============ */
.about-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  align-items: start;
}
.about-text-wrap { display: flex; flex-direction: column; gap: 16px; }
.about-text { color: var(--text-dim); font-size: 1.05rem; }
.about-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.stat-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.stat-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}
.stat-label { font-size: 0.85rem; color: var(--text-dim); }

/* ============ Timeline ============ */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px; top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(var(--accent), var(--border));
}
.timeline-item { position: relative; padding-bottom: 44px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -32px; top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.timeline-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
}
.timeline-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.timeline-head h3 { font-size: 1.2rem; font-weight: 700; }
.timeline-date { font-family: var(--font-mono); font-size: 0.82rem; color: var(--accent); white-space: nowrap; }
.timeline-company { color: var(--text-dim); font-weight: 500; margin-bottom: 14px; }
.timeline-content ul { display: flex; flex-direction: column; gap: 10px; }
.timeline-content li {
  position: relative;
  padding-left: 20px;
  color: var(--text-dim);
  font-size: 0.95rem;
}
.timeline-content li::before {
  content: "";
  position: absolute;
  left: 0; top: 9px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
}

/* ============ Skills ============ */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.skill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.skill-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.skill-card h3 { font-size: 1.05rem; margin-bottom: 12px; }
.skill-desc { color: var(--text-dim); font-size: 0.92rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
}

/* ============ Projects ============ */
.projects-subhead {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 40px 0 20px;
}
.projects-subhead:first-of-type { margin-top: 0; }
.projects-subhead span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.project-card h4 {
  font-size: 1rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.project-card p { color: var(--text-dim); font-size: 0.9rem; }
.project-card-link { cursor: pointer; }
.project-card-link .ext-icon { color: var(--text-faint); flex-shrink: 0; transition: color 0.2s ease, transform 0.2s ease; }
.project-card-link:hover { transform: translateY(-4px); border-color: var(--accent); background: var(--surface-2); }
.project-card-link:hover .ext-icon { color: var(--accent); transform: translate(2px, -2px); }

.project-card-detailed { grid-column: span 2; }
.project-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.project-detail-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.project-detail-list li {
  position: relative;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.55;
}
.project-detail-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 8px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-2);
}

@media (max-width: 700px) {
  .project-card-detailed { grid-column: span 1; }
}

/* ============ Education ============ */
.edu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
}
.edu-col-title {
  font-size: 1rem;
  color: var(--accent);
  font-family: var(--font-mono);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.edu-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.edu-item:last-child { border-bottom: none; }
.edu-item h4 { font-size: 1rem; margin-bottom: 6px; }
.edu-meta { color: var(--text-dim); font-size: 0.88rem; }

/* ============ Research ============ */
.research-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  display: flex;
  gap: 22px;
  align-items: flex-start;
}
.research-icon { color: var(--accent); flex-shrink: 0; margin-top: 4px; }
.research-card h3 { font-size: 1.15rem; margin-bottom: 10px; line-height: 1.4; }
.research-venue { color: var(--text-dim); font-size: 0.92rem; margin-bottom: 22px; }
.research-abstract-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.research-abstract {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.7;
  margin-bottom: 18px;
}
.research-index-terms { margin-bottom: 24px; }

/* ============ Blog ============ */
.blog-lede { color: var(--text-dim); margin-top: -30px; margin-bottom: 40px; max-width: 520px; }
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.blog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.blog-card:hover { transform: translateY(-4px); border-color: var(--accent); background: var(--surface-2); }
.blog-index {
  position: absolute;
  top: 22px;
  right: 22px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}
.blog-card:hover .blog-index { color: var(--accent); }
.blog-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}
.blog-card h3 { font-size: 1.05rem; margin-bottom: 10px; line-height: 1.4; }
.blog-excerpt { color: var(--text-dim); font-size: 0.9rem; line-height: 1.65; margin-bottom: 18px; }
.blog-readmore {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
}
.blog-readmore .ext-icon { color: var(--text-faint); transition: color 0.2s ease, transform 0.2s ease; }
.blog-card:hover .blog-readmore .ext-icon { color: var(--accent); transform: translate(2px, -2px); }

/* ============ Blog post page ============ */
.post-wrap { max-width: 760px; margin: 0 auto; padding: 72px 24px 104px; }
.post-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 36px;
  transition: color 0.2s ease;
}
.post-back:hover { color: var(--accent); }
.post-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.post-title { font-size: clamp(1.9rem, 4.5vw, 2.7rem); line-height: 1.18; font-weight: 800; margin-bottom: 16px; }
.post-byline {
  color: var(--text-faint);
  font-size: 0.88rem;
  padding-bottom: 28px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}
.post-body { color: var(--text-dim); font-size: 1.03rem; line-height: 1.8; }
.post-body p { margin-bottom: 22px; }
.post-body h2 { color: var(--text); font-size: 1.42rem; font-weight: 700; margin: 46px 0 16px; }
.post-body h3 { color: var(--text); font-size: 1.1rem; font-weight: 700; margin: 30px 0 12px; }
.post-body ul { list-style: disc; padding-left: 22px; margin-bottom: 22px; }
.post-body li { margin-bottom: 10px; }
.post-body li::marker { color: var(--accent); }
.post-body strong { color: var(--text); font-weight: 600; }
.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 18px;
  margin: 0 0 24px;
  color: var(--text);
  font-style: italic;
}
.post-footer {
  margin-top: 60px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
.post-footer p { color: var(--text-faint); font-size: 0.88rem; margin: 0; }

/* ============ Contact ============ */
.contact-lede { color: var(--text-dim); margin-top: -30px; margin-bottom: 40px; max-width: 480px; }
.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 640px) {
  .contact-grid { grid-template-columns: 1fr; }
}
.contact-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.contact-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
}
.contact-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.contact-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.contact-value {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  overflow-wrap: anywhere;
  transition: color 0.2s ease;
}
.contact-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.contact-card:hover .contact-value { color: var(--accent); }
.contact-card-static { cursor: default; }
.contact-card-static:hover { transform: none; border-color: var(--border); }
.contact-card-static:hover .contact-value { color: var(--text); }

/* ============ Footer ============ */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0; }
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.footer-copy { color: var(--text-faint); font-size: 0.85rem; }
.footer-socials { display: flex; gap: 16px; }
.footer-socials a { color: var(--text-dim); transition: color 0.2s ease; }
.footer-socials a:hover { color: var(--accent); }

/* ============ Back to top ============ */
.back-to-top {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.2s ease;
  z-index: 800;
  box-shadow: var(--shadow);
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { border-color: var(--accent); }

/* ============ Reveal animation ============ */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in-view { opacity: 1; transform: translateY(0); }

/* ============ Language switch ============ */
.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.lang-toggle svg { flex-shrink: 0; opacity: 0.7; transition: opacity 0.2s ease; }
.lang-toggle:hover { color: var(--accent); }
.lang-toggle:hover svg { opacity: 1; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ============ Resume download toast ============ */
.resume-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  width: 290px;
  max-width: calc(100vw - 40px);
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.86rem;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.resume-toast.is-visible { opacity: 1; transform: translateY(0); }
.resume-toast-row { display: flex; align-items: center; gap: 10px; }
.resume-toast-msg { flex: 1; min-width: 0; }
.resume-toast-pct { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim); }
.resume-toast-track {
  margin-top: 10px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.resume-toast-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.15s ease;
}
.resume-toast.is-indeterminate .resume-toast-bar {
  width: 40%;
  animation: resume-indeterminate 1.1s ease-in-out infinite;
}
@keyframes resume-indeterminate {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.resume-toast.is-done .resume-toast-bar { background: var(--accent); }
.resume-toast.is-error .resume-toast-bar { background: var(--accent-2); }
.resume-spinner {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: resume-spin 0.7s linear infinite;
}
.resume-toast.is-done .resume-spinner,
.resume-toast.is-error .resume-spinner { animation: none; border-top-color: var(--border); }
@keyframes resume-spin { to { transform: rotate(360deg); } }

.btn.is-loading { opacity: 0.6; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .resume-spinner,
  .resume-toast.is-indeterminate .resume-toast-bar { animation: none; }
}

/* Bengali typography: swap the font tokens, keep the wordmark Latin */
html.lang-bn {
  --font-body: 'Noto Sans Bengali', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Noto Sans Bengali', 'JetBrains Mono', 'Consolas', monospace;
}
html.lang-bn .logo { font-family: 'JetBrains Mono', 'Consolas', monospace; }
html.lang-bn body { line-height: 1.75; }
html.lang-bn .section-eyebrow,
html.lang-bn .post-eyebrow,
html.lang-bn .metrics-title { letter-spacing: 0.02em; }

/* ============ Read next (blog post pages) ============ */
#relatedPosts {
  margin-top: 56px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}
.related-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 20px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}
.related-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.related-card:hover { transform: translateY(-4px); border-color: var(--accent); background: var(--surface-2); }
.related-num {
  position: absolute;
  top: 16px; right: 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
}
.related-card:hover .related-num { color: var(--accent); }
.related-cat {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.related-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
}
.related-name .ext-icon { color: var(--text-faint); }
.related-card:hover .related-name .ext-icon { color: var(--accent); }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-photo-wrap { order: -1; }
  .about-grid { grid-template-columns: 1fr; }
  .edu-grid { grid-template-columns: 1fr; gap: 32px; }
}

@media (max-width: 760px) {
  .nav-desktop { display: none; }
  .nav-toggle { display: flex; }
  .nav-mobile { display: block; }
  .header-cta { display: none; }
  .header-actions { margin-left: auto; margin-right: 12px; gap: 0; }
  .lang-toggle { font-size: 0.88rem; }
  .hero { padding: 56px 0 64px; }
  .section { padding: 64px 0; }
  .about-stats { grid-template-columns: 1fr; }
  .research-card { flex-direction: column; }
}

@media (max-width: 480px) {
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { justify-content: center; }
  .contact-lede { margin-top: -20px; }
}
