:root {
  --bg: #05060b;
  --bg-alt: #0a0c16;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-strong: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eef1fb;
  --text-dim: #8b93ac;
  --accent: #00e5ff;
  --accent-2: #a855f7;
  --accent-3: #4dffb4;
  --grad: linear-gradient(120deg, var(--accent), var(--accent-2));
  --shadow-glow: 0 0 0 1px var(--border), 0 20px 60px -20px rgba(0, 229, 255, 0.15);
  --max-width: 860px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  --bg: #f4f5fb;
  --bg-alt: #ffffff;
  --surface: rgba(10, 12, 30, 0.035);
  --surface-strong: rgba(10, 12, 30, 0.06);
  --border: rgba(10, 12, 30, 0.1);
  --border-strong: rgba(10, 12, 30, 0.2);
  --text: #0d0e1a;
  --text-dim: #565c72;
  --accent: #0091b3;
  --accent-2: #7c1fd6;
  --accent-3: #00946a;
  --shadow-glow: 0 0 0 1px var(--border), 0 20px 60px -20px rgba(124, 31, 214, 0.18);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

.icon { flex-shrink: 0; vertical-align: -3px; }

/* ---------- Background FX ---------- */
.bg-fx {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 900px;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

body { position: relative; }

.nav, main, .footer {
  position: relative;
  z-index: 1;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.35;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 90%);
}

.glow {
  position: absolute;
  width: 46vw;
  height: 46vw;
  max-width: 640px;
  max-height: 640px;
  border-radius: 50%;
  opacity: 0.55;
  animation: drift 22s ease-in-out infinite alternate;
}
.glow-a { top: -12%; left: -10%; background: radial-gradient(circle, var(--accent), transparent 60%); }
.glow-b { top: 8%; right: -14%; background: radial-gradient(circle, var(--accent-2), transparent 60%); animation-delay: -8s; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(4%, 6%, 0) scale(1.08); }
}

.spotlight {
  position: absolute;
  inset: 0;
  background: radial-gradient(320px circle at var(--x, 50%) var(--y, 20%), rgba(0, 229, 255, 0.08), transparent 60%);
  transition: background 0.1s ease;
}

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

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--bg);
  background: var(--grad);
  box-shadow: 0 0 20px -2px var(--accent);
}

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

.nav-links {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-links a:hover { color: var(--text); background: var(--surface); }
.nav-links a.active { color: var(--accent); }

.nav-links .idx {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.7;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--border-strong); }
.icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }

/* ---------- Layout ---------- */
main { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; position: relative; }

.section { padding: 72px 0; border-bottom: 1px solid var(--border); }
.section:last-of-type { border-bottom: none; }

.section-title { margin: 0 0 32px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
}

.lead { color: var(--text-dim); font-size: 16px; max-width: 640px; }

/* ---------- Hero ---------- */
.hero { padding: 96px 0 64px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 20px;
}

.hero h1 {
  font-size: clamp(38px, 7vw, 64px);
  margin: 0 0 18px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.headline {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text);
  margin: 0 0 24px;
  min-height: 24px;
}
.prompt { color: var(--accent-3); font-weight: 700; }
.caret {
  display: inline-block;
  width: 8px;
  background: var(--accent);
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.summary { color: var(--text-dim); font-size: 16px; max-width: 620px; margin: 0 0 32px; }

.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 44px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  background: var(--surface);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 8px 24px -8px var(--accent); }

.btn-primary {
  background: var(--grad);
  color: #04060d;
  border-color: transparent;
}
.btn-primary:hover { box-shadow: 0 8px 30px -6px var(--accent-2); }

.stat-row {
  display: flex;
  gap: 36px;
  flex-wrap: wrap;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-num {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-label { font-size: 12px; color: var(--text-dim); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; }

.timeline-item {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 16px;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 40px;
  bottom: -20px;
  width: 1px;
  background: var(--border);
}

.node {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  z-index: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.timeline-item:hover .card {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}
.timeline-item:hover .node { color: var(--bg); background: var(--grad); border-color: transparent; }

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.timeline-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.timeline-date { font-family: var(--mono); font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.timeline-org { margin: 6px 0 0; color: var(--text-dim); font-size: 14px; }
.timeline-desc { margin: 6px 0 0; font-size: 13px; color: var(--text-dim); }

/* ---------- Skills ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 36px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.subhead {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 22px 0 12px;
  font-family: var(--mono);
}
.subhead:first-child { margin-top: 0; }

.chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.award-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.award-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
}
.award-card .icon { color: var(--accent-2); }

/* ---------- Publications ---------- */
.pub {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 24px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.pub:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.pub .icon { color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.pub h3 { margin: 0; font-size: 16px; font-weight: 600; }
.pub-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text-dim);
}
.pub-meta .icon { color: var(--text-dim); margin-top: 0; }

/* ---------- Projects ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.project-card {
  display: block;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.project-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow-glow); }
.project-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.project-card h3 .icon { color: var(--accent-3); flex-shrink: 0; }
.project-card p { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.5; }

.inline-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 14px;
}
.inline-link:hover { text-decoration: underline; }

/* ---------- Contact ---------- */
.contact-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.contact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  font-family: var(--mono);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.contact-card:hover { border-color: var(--accent); transform: translateX(4px); color: var(--accent); }

/* ---------- Footer ---------- */
.footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 56px;
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--mono);
}

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

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}
