:root {
  --bg: #f7f7fa;
  --surface: #ffffff;
  --text: #0f1218;
  --muted: #596070;
  --border: #e3e5ec;
  --accent: #7c4ff0;
  --accent-text: #ffffff;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Space Grotesk", "DM Sans", system-ui, sans-serif;
  --max: 44rem;
  --wide: 62rem;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="dark"] {
  --bg: #0a0c11;
  --surface: #11141b;
  --text: #eef0f5;
  --muted: #9aa2b1;
  --border: #222633;
  --accent: #b794ff;
  --accent-text: #0a0c11;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s, color 0.25s;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  z-index: 20;
}
.skip-link:focus { top: 1rem; }

a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

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

/* Scroll progress bar */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 30;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--accent);
  pointer-events: none;
}

/* Header */
.site-header {
  padding: 1.1rem max(1.25rem, calc((100% - var(--wide)) / 2));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s;
}

@media (min-width: 40rem) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}
.site-header.scrolled { border-bottom-color: var(--border); }

.brand {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.03em;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text);
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  align-items: center;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.nav > a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.nav > a:hover { color: var(--text); border-bottom-color: var(--border); }
.nav > a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

.header-tools { display: flex; align-items: center; gap: 0.4rem; margin-left: 0.25rem; }

.theme-toggle,
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.2s, color 0.2s;
}
.theme-toggle:hover,
.icon-link:hover { border-color: var(--border); color: var(--text); }

/* Layout */
main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 4.5rem 1.25rem 5rem;
}
main.home { max-width: var(--wide); padding-top: 5rem; }

h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.5rem, 7.5vw, 4.25rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0 0 1rem;
}
h1 em { color: var(--accent); font-style: normal; }
h2 { font-family: var(--display); font-weight: 500; letter-spacing: -0.02em; font-size: 1.5rem; margin: 0 0 0.25rem; line-height: 1.2; }

.lead { font-size: 1.2rem; color: var(--muted); margin: 0 0 2.25rem; line-height: 1.55; max-width: 38rem; }
p { margin: 0 0 1.25rem; }

.section-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 3.5rem 0 0;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
main > section:first-of-type .section-title { margin-top: 2rem; }

/* Homepage panels */
.panels {
  list-style: none;
  margin: 3.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.panels .wide-panel { grid-column: 1 / -1; }

.panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 1rem;
  min-height: 11.5rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.25s, background-color 0.25s;
}
.panel .num { align-self: start; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel h2 { font-size: 1.9rem; margin-bottom: 0.35rem; }
.panel p { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.panel .arrow { font-size: 1.4rem; color: var(--muted); transition: transform 0.3s var(--ease), color 0.25s; }
.panel:hover { border-color: var(--accent); }
.panel:hover .arrow { transform: translateX(6px); color: var(--accent); }

/* Cards */
.card-list { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; gap: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 1.5rem 1.75rem;
  transition: border-color 0.3s;
}
@media (hover: hover) {
  .card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
}
.card p:last-child { margin-bottom: 0; }
.meta { color: var(--muted); font-size: 0.88rem; margin: 0 0 0.75rem; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; margin: 0.75rem 0 0; }
.tags li {
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.1rem 0.6rem;
  color: var(--muted);
}

/* Buttons */
.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 500;
  padding: 0.7rem 1.3rem;
  border-radius: 0.3rem;
  border: 1px solid var(--accent);
  transition: background-color 0.2s, color 0.2s;
}
.button:hover { background: transparent; color: var(--accent); }
.button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.button.secondary:hover { border-color: var(--text); color: var(--text); }
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

/* Experience / project cards */
.job h3 { font-family: var(--display); font-weight: 500; letter-spacing: -0.02em; font-size: 1.35rem; margin: 0; line-height: 1.2; }
.company-note { font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 0.88rem; }
.job-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; }
.job-head .meta { text-align: right; margin: 0; }
.role { margin: 0; color: var(--accent); font-weight: 500; font-size: 0.95rem; }

.stats { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0; padding: 0; margin: 1.25rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.stats li {
  padding: 0.85rem 1rem 0.85rem 0;
  display: flex;
  flex-direction: column;
  transition: opacity 0.6s var(--ease) calc(0.25s + var(--i, 0) * 0.09s), transform 0.6s var(--ease) calc(0.25s + var(--i, 0) * 0.09s);
}
.stat-num { font-family: var(--display); font-weight: 500; letter-spacing: -0.03em; font-size: 1.9rem; line-height: 1.1; color: var(--text); }
.stat-label { font-size: 0.78rem; color: var(--muted); line-height: 1.35; }

.bullets { margin: 0; padding-left: 1.1rem; font-size: 0.96rem; }
.bullets li { margin-bottom: 0.5rem; }
.bullets li::marker { color: var(--accent); }

section .tags { margin-top: 1rem; }
.sub-title { font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 1.5rem 0 0.5rem; }

/* Interests */
.photo-placeholder {
  border: 1px dashed var(--border);
  border-radius: 0.375rem;
  min-height: 9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin: 1rem 0 0.5rem;
}
.photo-placeholder p { margin: 0; }

/* Contact */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 14rem);
  gap: 3rem;
  align-items: start;
}
.contact-form { display: grid; gap: 0.4rem; }
.contact-form label { font-weight: 500; font-size: 0.9rem; margin-top: 0.75rem; }
.contact-form label:first-child { margin-top: 0; }
.contact-form input,
.contact-form textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  padding: 0.7rem 0.9rem;
  width: 100%;
  transition: border-color 0.2s;
}
.contact-form textarea { resize: vertical; min-height: 9rem; }
.contact-form input:focus,
.contact-form textarea:focus { border-color: var(--accent); outline: none; }
.contact-form .button { margin-top: 1rem; justify-self: start; cursor: pointer; font: inherit; font-weight: 500; }
.contact-form .button:disabled { opacity: 0.6; cursor: wait; }
.form-note { color: var(--muted); font-size: 0.88rem; margin: 0.5rem 0 0; }
.contact-side p { color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-footer {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}

/* Scroll reveal (classes are added by reveal.js, so content is visible without JS) */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.8s var(--ease) var(--d, 0s), transform 0.8s var(--ease) var(--d, 0s);
}
.reveal.in { opacity: 1; transform: none; }
.card.reveal:not(.in) .stats li { opacity: 0; transform: translateY(10px); }

@media (max-width: 40rem) {
  .contact-grid { grid-template-columns: 1fr; gap: 2rem; }
  .panels { grid-template-columns: 1fr; }
  .panel { min-height: 9rem; }
}

@media (max-width: 30rem) {
  body { font-size: 1rem; }
  .nav { justify-content: flex-start; order: 3; flex-basis: 100%; }
  main, main.home { padding-top: 2.5rem; }
  .card { padding: 1.25rem; }
  .job-head .meta { text-align: left; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
