:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --text: #1c1c22;
  --muted: #5d5f6b;
  --accent: #0f8b6f;
  --accent-soft: #e2f4ef;
  --border: #e6e6e1;
  --shadow: 0 6px 24px rgba(20, 20, 30, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318;
    --surface: #191c23;
    --text: #e8e9ee;
    --muted: #9a9dab;
    --accent: #4fd1b0;
    --accent-soft: #1b2e2b;
    --border: #262a33;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #111318;
  --surface: #191c23;
  --text: #e8e9ee;
  --muted: #9a9dab;
  --accent: #4fd1b0;
  --accent-soft: #1b2e2b;
  --border: #262a33;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

a { color: inherit; text-decoration: none; }

.mono { font-family: "JetBrains Mono", monospace; }
.accent { color: var(--accent); }
.muted { color: var(--muted); }

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem clamp(1rem, 5vw, 4rem);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.logo { font-family: "JetBrains Mono", monospace; font-weight: 600; color: var(--accent); }
.nav nav { display: flex; align-items: center; gap: 1.25rem; font-size: 0.95rem; }
.nav nav a:hover { color: var(--accent); }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  font-size: 1rem;
}
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: inline; }
}

main { max-width: 1040px; margin: 0 auto; padding: 0 1rem; }

/* Hero */
.hero {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  min-height: 70vh;
  padding: 4rem 0;
}
.avatar {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 4px solid var(--accent-soft);
  flex-shrink: 0;
}
.hero h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1.1; margin: 0.25rem 0 1rem; }
.lead { font-size: 1.15rem; max-width: 38rem; color: var(--muted); }
.hero-links { display: flex; gap: 0.75rem; margin-top: 1.75rem; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 0.7rem 1.3rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 500;
  transition: transform 0.15s, opacity 0.15s;
}
.btn:hover { transform: translateY(-2px); opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }

/* Sections */
.section { padding: 4rem 0; }
.section h2 { font-size: 1.75rem; margin-bottom: 2rem; }
.section-intro { margin: -1rem 0 2rem; max-width: 40rem; }

/* Featured projects */
.project {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}
.project.reverse .project-img { order: 2; }
.project-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 10px;
}
.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(135deg, var(--accent), #2b6cb0);
  color: #fff;
  font-weight: 700;
  font-size: 1.5rem;
}
.project h3, .card h3 { font-size: 1.25rem; margin-bottom: 0.6rem; }
.project p, .card p { color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 1rem 0; }
.tags li {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.project-links { display: flex; gap: 1rem; font-weight: 500; }
.project-links a { color: var(--accent); }
.project-links a:hover { text-decoration: underline; }

/* Challenge grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.5rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-4px); }
.card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
}
.card-body { padding: 1.25rem; display: flex; flex-direction: column; flex: 1; }
.card-body .project-links { margin-top: auto; }

.contact { text-align: center; }
.contact p { margin-bottom: 1.5rem; }
.contact-links { display: flex; justify-content: center; gap: 0.75rem; flex-wrap: wrap; }

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .nav nav a:not(:last-of-type) { display: none; }
  .hero { flex-direction: column; text-align: center; min-height: auto; padding: 3rem 0; }
  .hero-links { justify-content: center; }
  .avatar { width: 120px; height: 120px; }
  .project { grid-template-columns: 1fr; padding: 1rem; }
  .project.reverse .project-img { order: 0; }
}

/* Experience & education timeline */
.timeline { list-style: none; border-left: 2px solid var(--border); margin-left: 0.5rem; }
.timeline > li { position: relative; padding: 0 0 2rem 1.75rem; }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li::before {
  content: "";
  position: absolute;
  left: -0.45rem;
  top: 0.35rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}
.timeline .when { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; }
.timeline h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.timeline .org { color: var(--accent); font-weight: 500; }
.timeline > li > ul:not(.tags) { color: var(--muted); padding-left: 1.1rem; }
.timeline > li > ul:not(.tags) li { margin-bottom: 0.3rem; }
#education { padding-top: 0; }

.timeline .grade { font-weight: 500; margin-bottom: 0.4rem; }
.badge {
  font-size: 0.7rem;
  font-weight: 500;
  vertical-align: middle;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  margin-left: 0.4rem;
  white-space: nowrap;
  display: inline-block;
}

/* Skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.skills > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.skills h3 { font-size: 1rem; }
.skills .tags { margin-bottom: 0; }
