:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #16181a;
  --muted: #4f545a;
  --line: #e1dfd8;
  --accent: #1d5a43;
  --accent-soft: #e4eee8;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 18px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; }
p { margin: 0; }

.wrap { width: min(1120px, 100% - 48px); margin-inline: auto; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Nav */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(247, 246, 242, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-weight: 700; font-size: 19px; text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a { text-decoration: none; font-weight: 500; font-size: 16px; color: var(--muted); }
.nav-links a:hover, .nav-links a[aria-current] { color: var(--ink); }
.nav-links .nav-cv { color: var(--ink); border: 1.5px solid var(--ink); padding: 6px 14px; border-radius: 999px; }
.nav-links .nav-cv:hover { background: var(--ink); color: #fff; }
.nav-toggle { display: none; background: none; border: 1.5px solid var(--ink); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 15px; }

/* Hero */
.hero {
  display: grid; grid-template-columns: 1.5fr 1fr; gap: 64px; align-items: center;
  padding: 80px 0 56px;
}
.kicker { font: 500 14px/1.4 var(--mono); color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.hero h1 { font-size: clamp(34px, 4.6vw, 54px); font-weight: 700; margin: 16px 0 22px; letter-spacing: -0.025em; }
.lead { font-size: 20px; color: var(--muted); max-width: 40ch; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px; border-radius: 999px;
  border: 1.5px solid var(--ink); background: transparent;
  font-weight: 600; font-size: 16px; text-decoration: none;
  transition: background .15s, color .15s;
}
.btn:hover { background: var(--ink); color: #fff; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #154533; border-color: #154533; }
.hero-photo {
  width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 30%;
  border-radius: 16px; background: #ddd;
  max-width: 400px; justify-self: end;
}

/* Stats */
.stats {
  list-style: none; margin: 0; padding: 28px 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.stats strong { display: block; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.stats span { color: var(--muted); font-size: 16px; }

/* Sections */
.section { padding: 96px 0 0; }
.section-head { margin-bottom: 36px; }
.section-head h2, .contact h2 { font-size: clamp(30px, 3.6vw, 42px); font-weight: 700; letter-spacing: -0.025em; }
.section-head p { color: var(--muted); margin-top: 8px; }
.sub-head { font-size: 22px; font-weight: 700; margin: 64px 0 20px; }

/* Featured projects */
.featured { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; }
.card {
  display: flex; flex-direction: column; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0; overflow: hidden;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { border-color: #c9c6bc; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.06); }
.card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; background: #eceae4; border-bottom: 1px solid var(--line); }
.card-body { padding: 22px 24px 26px; }
.card .tag { font: 500 13px/1.4 var(--mono); color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.card h3 { font-size: 23px; font-weight: 700; margin: 8px 0 8px; }
.card p.sum { color: var(--muted); font-size: 17px; }
.featured .card:first-child { grid-column: 1 / -1; flex-direction: row; }
.featured .card:first-child img { width: 58%; aspect-ratio: auto; min-height: 340px; border-bottom: 0; border-right: 1px solid var(--line); }
.featured .card:first-child .card-body { align-self: center; padding: 36px; }
.featured .card:first-child h3 { font-size: 30px; }

/* More projects */
.more { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mini {
  display: flex; gap: 14px; align-items: center; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px;
  transition: border-color .15s;
}
.mini:hover { border-color: #b9b6ab; }
.mini img { width: 72px; height: 72px; flex: none; object-fit: cover; border-radius: 6px; background: #eceae4; }
.mini strong { display: block; font-size: 17px; font-weight: 600; line-height: 1.3; }
.mini span { display: block; font-size: 14px; color: var(--muted); margin-top: 3px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li {
  display: grid; grid-template-columns: 180px 1fr; gap: 32px;
  padding: 28px 0; border-top: 1px solid var(--line);
}
.timeline > li:last-child { border-bottom: 1px solid var(--line); }
.when { font: 500 15px/1.6 var(--mono); color: var(--muted); padding-top: 3px; }
.timeline h3 { font-size: 22px; font-weight: 700; }
.role { color: var(--muted); margin-top: 4px; }
.timeline ul { margin: 12px 0 0; padding-left: 20px; }
.timeline ul li { margin-top: 4px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.edu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.edu-row > div, .skills > div {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px;
}
.edu h4 { font-size: 20px; font-weight: 700; }
.edu p { color: var(--muted); margin-top: 6px; }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.skills h3 { font-size: 19px; font-weight: 700; margin-bottom: 8px; }
.skills p { color: var(--muted); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 14px 0; border-top: 1px solid var(--line); }
.plain li:last-child { border-bottom: 1px solid var(--line); }
.plain a, .plain strong { font-weight: 600; text-decoration-color: var(--line); text-underline-offset: 4px; }
.plain a:hover { text-decoration-color: currentColor; }
.plain span { display: block; color: var(--muted); font-size: 16px; margin-top: 2px; }

.certs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.certs button {
  width: 100%; height: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
}
.certs button:hover { border-color: #b9b6ab; }
.certs strong { display: block; font-size: 17px; font-weight: 600; line-height: 1.3; }
.certs span { display: block; color: var(--muted); font-size: 15px; margin-top: 6px; }

/* Contact */
.contact { padding-bottom: 96px; }
.contact .lead { margin-top: 14px; max-width: 46ch; }
.links { display: flex; gap: 24px; margin-top: 28px; flex-wrap: wrap; }
.links a { font-weight: 600; text-underline-offset: 4px; }

.footer {
  display: flex; justify-content: space-between; padding: 28px 0 40px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 15px;
}
.footer a { text-decoration: none; }

/* Modal */
dialog {
  width: min(920px, 100% - 32px); max-height: calc(100vh - 48px);
  padding: 0; border: 0; border-radius: 14px;
  background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgba(15, 17, 18, 0.6); }
.modal-inner { position: relative; padding: 36px 40px 40px; }
.modal-close {
  position: absolute; top: 14px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line); font-size: 24px; line-height: 1;
}
#modal-title { font-size: 30px; font-weight: 700; margin: 8px 48px 22px 0; }
.stage { background: #eceae4; border-radius: 8px; overflow: hidden; display: grid; place-items: center; min-height: 240px; }
.stage img, .stage video { width: 100%; max-height: 62vh; object-fit: contain; }
.stage-nav { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 14px 0 24px; }
.stage-nav button { width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--ink); background: none; font-size: 18px; }
.stage-nav button:disabled { opacity: .3; cursor: default; }
.stage-nav[hidden] { display: none; }
#count { font: 500 14px var(--mono); color: var(--muted); min-width: 56px; text-align: center; }
#modal-body p { margin-bottom: 12px; }
#modal-body ul { margin: 0 0 12px; padding-left: 20px; }
#modal-body li { margin-top: 6px; }
#modal-link a { color: var(--accent); font-weight: 600; text-underline-offset: 4px; }

/* Responsive */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 40px; }
  .hero-photo { order: -1; justify-self: start; width: 132px; aspect-ratio: 1; border-radius: 50%; object-position: 50% 28%; }
  .featured { grid-template-columns: 1fr; }
  .featured .card:first-child { flex-direction: column; }
  .featured .card:first-child img { width: 100%; min-height: 0; aspect-ratio: 16 / 10; border-right: 0; border-bottom: 1px solid var(--line); }
  .featured .card:first-child .card-body { padding: 22px 24px 26px; }
  .featured .card:first-child h3 { font-size: 23px; }
  .more { grid-template-columns: 1fr 1fr; }
  .certs { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  body { font-size: 17px; }
  .wrap { width: calc(100% - 32px); }
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px 16px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 0; font-size: 18px; width: 100%; }
  .nav-links .nav-cv { width: auto; margin-top: 8px; padding: 8px 16px; }
  .lead { font-size: 18px; }
  .section { padding-top: 72px; }
  .more, .certs, .edu-row, .skills, .two-col { grid-template-columns: 1fr; }
  .two-col { gap: 0; }
  .timeline > li { grid-template-columns: 1fr; gap: 6px; }
  .modal-inner { padding: 28px 20px 28px; }
  #modal-title { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
