/* ---------- Tokens ---------- */
:root {
  --bg: #f8f9f7;
  --surface: #ffffff;
  --text: #17201d;
  --muted: #5b6763;
  --line: #e2e7e4;
  --accent: #0b8a72;
  --accent-soft: rgba(11, 138, 114, 0.12);
  --observed: #17201d;
  --shadow: 0 1px 2px rgba(16, 24, 22, 0.04), 0 8px 24px rgba(16, 24, 22, 0.06);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1211;
    --surface: #141b19;
    --text: #e4ebe8;
    --muted: #93a19c;
    --line: #24302c;
    --accent: #34d3ae;
    --accent-soft: rgba(52, 211, 174, 0.14);
    --observed: #e4ebe8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d1211;
  --surface: #141b19;
  --text: #e4ebe8;
  --muted: #93a19c;
  --line: #24302c;
  --accent: #34d3ae;
  --accent-soft: rgba(52, 211, 174, 0.14);
  --observed: #e4ebe8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s, color .25s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 14px; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.nav-name { font-family: var(--mono); font-size: 15px; color: var(--text); font-weight: 600; }
.nav-name span { color: var(--accent); }
.nav-name:hover { text-decoration: none; }
.nav-links { display: flex; gap: 22px; margin-left: auto; }
.nav-links a { color: var(--muted); font-size: 14px; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.theme-toggle {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 18px; height: 18px; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 48px;
  align-items: center;
  padding-top: 72px;
  padding-bottom: 48px;
}
.hero-id { display: flex; align-items: center; gap: 18px; margin-bottom: 28px; }
.avatar {
  width: 88px; height: 88px; border-radius: 50%; object-fit: cover; flex: none;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
}
.hero h1 { font-size: clamp(30px, 4.4vw, 42px); letter-spacing: -0.02em; font-weight: 700; }
.role { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.lead { font-size: clamp(19px, 2.2vw, 22px); line-height: 1.5; margin: 0 0 14px; letter-spacing: -0.005em; }
.lead strong { color: var(--accent); font-weight: 600; }
.location { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin: 0 0 28px; }
.location svg { width: 16px; height: 16px; }

.links { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-size: 14px; font-weight: 500;
  transition: border-color .15s, transform .15s;
}
.btn:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn-primary:hover { filter: brightness(1.08); }

/* Forecast card */
.chart-card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
}
.chart-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  margin-bottom: 6px;
}
.live { display: inline-flex; align-items: center; gap: 6px; }
.live i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
#forecast { display: block; width: 100%; height: 240px; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 16px;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  margin-top: 6px;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { display: inline-block; width: 16px; height: 2px; background: var(--observed); }
.chart-legend .lg-p50 { background: var(--accent); }
.chart-legend .lg-band { height: 9px; background: var(--accent-soft); border-radius: 2px; }

/* ---------- Key figures ---------- */
.figures {
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.figures > div {
  padding: 20px 16px 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
@media (max-width: 860px) {
  .figures > div:nth-child(-n+2) { border-bottom: none; }
}
.figures b {
  display: block; font-size: 26px; font-weight: 650; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.figures span { color: var(--muted); font-size: 13.5px; }

/* ---------- Sections ---------- */
.section {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 32px;
  padding-top: 64px;
  padding-bottom: 8px;
}
.section-label {
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent);
  padding-top: 4px;
}
.section-body { min-width: 0; }
.prose p { margin: 0 0 14px; max-width: 68ch; }

.when {
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  white-space: nowrap; flex: none;
}

/* Experience */
.company { margin-bottom: 36px; }
.company-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.company-head h3 { font-size: 19px; font-weight: 650; }
.company-note { color: var(--muted); font-size: 14px; margin: 2px 0 18px; }
.company.compact { margin-bottom: 22px; }
.company.compact h3 { font-size: 16.5px; }
.company.compact p { margin: 4px 0 0; color: var(--muted); font-size: 15px; max-width: 68ch; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px;
  width: 1px; background: var(--line);
}
.timeline > li { position: relative; padding-left: 28px; margin-bottom: 22px; }
.timeline > li::before {
  content: ""; position: absolute; left: 0; top: 7px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.timeline > li:first-child::before { background: var(--accent); }
.tl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.tl-head h4 { font-size: 16px; font-weight: 600; }
.timeline ul, .plain { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 15px; }
.timeline ul li, .plain li { margin-bottom: 5px; }
.timeline ul li::marker, .plain li::marker { color: var(--accent); }
.timeline strong { color: var(--text); font-weight: 600; }

/* Research */
.thesis { font-style: italic; margin: 6px 0 4px; font-size: 16.5px; }
.jury { margin-top: 10px; font-size: 14px; color: var(--muted); }
.jury summary { cursor: pointer; font-family: var(--mono); font-size: 12.5px; color: var(--accent); }
.jury .plain { font-size: 14px; }

.sub {
  font-size: 13px; font-family: var(--mono); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  margin: 8px 0 14px;
}
.sub.first { margin-top: 4px; }

.pubs { list-style: none; padding: 0; margin: 0 0 10px; }
.pubs li { padding: 12px 0; border-top: 1px solid var(--line); }
.pubs li:last-child { border-bottom: 1px solid var(--line); }
.pubs a { color: var(--text); font-weight: 550; }
.pubs a:hover { color: var(--accent); }
.pub-meta { display: block; color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.edu { list-style: none; padding: 0; margin: 28px 0 0; }
.edu li {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-top: 1px solid var(--line); font-size: 15px;
}
.edu .muted { font-size: 14px; }
#research .sub:not(:first-of-type) { margin-top: 36px; }

/* Skills */
.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 32px; }
.skills h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.tags span {
  font-size: 13px; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text);
}

/* Projects */
.projects { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.project {
  display: block; padding: 18px 18px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--text);
  transition: border-color .15s, transform .15s;
}
.project:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.project h3 { font-size: 15.5px; font-weight: 600; margin-bottom: 6px; }
.project h3 span { color: var(--accent); font-weight: 400; }
.project p { margin: 0; color: var(--muted); font-size: 14px; }

/* Beyond code */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.kv { list-style: none; padding: 0; margin: 0; }
.kv li {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px;
}

/* Contact */
.contact { padding-bottom: 40px; }
.contact-lead { margin: 0 0 8px; color: var(--muted); }
.contact-mail { font-size: clamp(20px, 3.4vw, 28px); font-weight: 600; letter-spacing: -0.01em; word-break: break-all; }

.footer {
  display: flex; justify-content: space-between;
  padding-top: 24px; padding-bottom: 40px; margin-top: 40px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
}
.footer a { color: var(--muted); }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .live i { animation: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 36px; padding-top: 44px; }
  .figures { grid-template-columns: 1fr 1fr; }
  .section { grid-template-columns: 1fr; gap: 16px; padding-top: 52px; }
}
@media (max-width: 600px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .nav-links { display: none; }
  .nav-inner { justify-content: space-between; }
  .hero-id { gap: 14px; }
  .avatar { width: 72px; height: 72px; }
  #forecast { height: 200px; }
  .skills, .projects, .two-col { grid-template-columns: 1fr; }
  .company-head, .tl-head { flex-direction: column; gap: 2px; }
  .edu li { flex-direction: column; gap: 2px; }
  .figures b { font-size: 22px; }
}
