:root {
  --bg: #ffffff;
  --side: #f7f8fa;
  --text: #111827;
  --muted: #4b5563;
  --faint: #6b7280;
  --line: #e5e7eb;
  --accent: #1e40af;
  --code-bg: #f6f8fa;
  --code-text: #1f2937;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --side: #11161e; --text: #e6edf3; --muted: #a3acb9; --faint: #8b949e;
    --line: #262c36; --accent: #8fb4ff; --code-bg: #161b22; --code-text: #d1d9e0;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --side: #11161e; --text: #e6edf3; --muted: #a3acb9; --faint: #8b949e;
  --line: #262c36; --accent: #8fb4ff; --code-bg: #161b22; --code-text: #d1d9e0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.65 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

.layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; min-height: 100vh; }

/* sidebar */
.side { background: var(--side); border-right: 1px solid var(--line); }
.side-inner {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 64px 40px 40px; display: flex; flex-direction: column;
}
.side h1 { font-size: 34px; line-height: 1.15; letter-spacing: -0.025em; font-weight: 700; }
.role { font-size: 17px; font-weight: 500; margin-top: 8px; }
.focus { color: var(--faint); font-size: 14px; margin-top: 2px; }
.intro { color: var(--muted); font-size: 15px; margin-top: 20px; max-width: 32ch; }
.loc { color: var(--faint); font-size: 14px; margin-top: 12px; }
.loc:empty { display: none; }

.toc { display: flex; flex-direction: column; margin-top: 40px; border-left: 1px solid var(--line); }
.toc a {
  padding: 6px 0 6px 16px; margin-left: -1px; border-left: 2px solid transparent;
  color: var(--faint); font-size: 14px; font-weight: 500; transition: color 0.15s, border-color 0.15s;
}
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--text); border-left-color: var(--accent); }

.side-links { display: flex; flex-wrap: wrap; gap: 18px; margin-top: auto; padding-top: 40px; font-size: 14px; font-weight: 500; }
.side-links a { color: var(--muted); border-bottom: 1px solid var(--line); }
.side-links a:hover { color: var(--accent); border-color: var(--accent); }
.theme {
  align-self: flex-start; margin-top: 20px; display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--line); border-radius: 6px; color: var(--faint);
  font: 500 13px Inter, system-ui, sans-serif; padding: 5px 10px; cursor: pointer;
}
.theme:hover { color: var(--text); }

/* content */
.content { padding: 64px 56px 40px; max-width: 840px; min-width: 0; }
section { padding-bottom: 64px; margin-bottom: 64px; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; margin-bottom: 0; }
h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint);
  font-weight: 600; margin-bottom: 24px;
}
.lead { color: var(--muted); margin-bottom: 24px; }
.prose p { color: var(--muted); font-size: 17px; line-height: 1.75; }
.prose p + p { margin-top: 16px; }
.prose p:first-child { color: var(--text); }

.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; margin: 40px 0 0; }
.facts div { border-top: 2px solid var(--text); padding-top: 12px; }
.facts dt { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.facts dd { margin: 4px 0 0; color: var(--faint); font-size: 13px; line-height: 1.45; }

.expertise { display: grid; }
.exp-row { display: grid; grid-template-columns: 160px 1fr; gap: 24px; padding: 14px 0; border-top: 1px solid var(--line); }
.exp-row:last-child { border-bottom: 1px solid var(--line); }
.exp-row h3 { font-size: 15px; }
.exp-row p { color: var(--muted); font-size: 15px; }

.featured { margin-bottom: 40px; }
.feat-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.feat-head img { border-radius: 10px; }
.kicker { font-size: 13px; color: var(--faint); font-weight: 500; }
.feat-head h3 { font-size: 24px; }
.featured > p { color: var(--muted); }
.points { margin: 16px 0 24px; padding-left: 18px; color: var(--muted); font-size: 15px; }
.points li { margin: 4px 0; }
.points li::marker { color: var(--faint); }
.code {
  margin: 0 0 24px; background: var(--code-bg); color: var(--code-text); border: 1px solid var(--line);
  border-radius: 8px; padding: 18px 20px; overflow-x: auto;
  font: 13px/1.65 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ports { width: 100%; border-collapse: collapse; font-size: 14px; }
.ports th { text-align: left; font-weight: 500; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.ports td { padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.ports td strong { color: var(--text); font-weight: 600; }
.ports .r { text-align: right; white-space: nowrap; }
.ports a, .entries h3 a:hover, .feat-head h3 a:hover { color: var(--accent); }
.ports a:hover { text-decoration: underline; }

.entries { list-style: none; margin: 0; padding: 0; }
.entries li { padding: 20px 0; border-top: 1px solid var(--line); }
.entries li:last-child { border-bottom: 1px solid var(--line); }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 6px; }
.entries h3 { font-size: 17px; }
.entries p { color: var(--muted); font-size: 15px; }
.meta { color: var(--faint); font-size: 13px; white-space: nowrap; }
p.meta { margin-top: 8px; white-space: normal; }
.arr { margin-left: 4px; vertical-align: 1px; opacity: 0.6; }

.contact-links { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; padding: 10px 18px; border-radius: 6px;
  border: 1px solid var(--line); font-weight: 500; font-size: 15px; transition: border-color 0.15s;
}
.btn:hover { border-color: var(--text); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }

.foot { color: var(--faint); font-size: 13px; padding-top: 8px; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .side-inner { position: static; height: auto; padding: 48px 20px 32px; }
  .toc { display: none; }
  .side-links { margin-top: 0; padding-top: 24px; }
  .intro { max-width: none; }
  .content { padding: 48px 20px 32px; }
  section { padding-bottom: 48px; margin-bottom: 48px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .exp-row { grid-template-columns: 1fr; gap: 4px; }
  .entry-head { flex-direction: column; gap: 2px; }
  .ports th:nth-child(2), .ports td:nth-child(2) { display: none; }
}

/* CV export */
.print-contact { display: none; }
.cv-btn {
  align-self: flex-start; margin-top: 24px; display: inline-flex; align-items: center; gap: 8px;
  background: var(--text); color: var(--bg); border: 1px solid var(--text); border-radius: 6px;
  font: 500 14px Inter, system-ui, sans-serif; padding: 9px 14px; cursor: pointer;
}
.cv-btn:hover { opacity: 0.88; }
button.btn { background: none; color: inherit; font-family: inherit; cursor: pointer; }

/* Printing the page (or "Save as PDF") produces a CV, not a screenshot of the site. */
@page { size: A4; margin: 14mm 15mm; }
@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    --bg: #fff; --side: #fff; --text: #111; --muted: #333; --faint: #555; --line: #cfcfcf;
    --accent: #111; --code-bg: #fff; --code-text: #111;
  }
  html { scroll-behavior: auto; }
  body { font-size: 10pt; line-height: 1.45; background: #fff; }
  .layout { display: block; min-height: 0; }

  /* header */
  .side { background: none; border: 0; border-bottom: 1.5pt solid #111; margin-bottom: 12pt; padding-bottom: 8pt; }
  .side-inner { position: static; height: auto; overflow: visible; padding: 0; display: block; }
  .side h1 { font-size: 24pt; letter-spacing: -0.01em; }
  .role { font-size: 12pt; margin-top: 2pt; display: inline; }
  .focus { display: inline; font-size: 10pt; margin: 0; }
  .focus::before { content: "  |  "; white-space: pre; }
  .intro { display: none; }
  .loc { display: none; }
  .print-contact { display: flex; flex-wrap: wrap; gap: 2pt 0; margin-top: 6pt; font-size: 9.5pt; color: #333; }
  .print-contact span + span::before { content: "•"; margin: 0 7pt; color: #888; }
  .toc, .side-links, .theme, .cv-btn, .contact-links, .foot, .arr, #contact, .code { display: none !important; }

  /* body */
  .content { padding: 0; max-width: none; }
  section { padding: 0; margin: 0 0 12pt; border: 0; }
  h2 {
    font-size: 10pt; letter-spacing: 1pt; color: #111; margin-bottom: 6pt;
    padding-bottom: 2pt; border-bottom: 0.75pt solid #999; break-after: avoid;
  }
  #about h2 { font-size: 0; }
  #about h2::after { content: "Profile"; font-size: 10pt; }
  #domains h2 { font-size: 0; }
  #domains h2::after { content: "Selected project experience"; font-size: 10pt; }
  .lead { display: none; }
  .prose p, .prose p:first-child { font-size: 10pt; line-height: 1.5; color: #222; }
  .prose p + p { margin-top: 4pt; }
  .facts { display: none; }

  .exp-row { grid-template-columns: 90pt 1fr; gap: 10pt; padding: 2pt 0; border: 0 !important; }
  .exp-row h3, .exp-row p { font-size: 10pt; }

  .featured { margin-bottom: 6pt; }
  .feat-head { margin-bottom: 4pt; gap: 0; }
  .feat-head img { display: none; }
  .feat-head > div { display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: baseline; width: 100%; }
  .feat-head h3 { font-size: 11pt; }
  .kicker { font-size: 9pt; }
  .featured > p { font-size: 10pt; }
  .points { margin: 3pt 0 4pt; padding-left: 13pt; font-size: 10pt; }
  .points li { margin: 0; }
  .ports { font-size: 9.5pt; }
  .ports thead { display: none; }
  .ports td { padding: 1pt 0; border: 0; }
  .ports .r a { display: none; }
  .ports .r { font-size: 0; }
  .ports .r a:last-child { display: inline; font-size: 9pt; }
  .ports .r a:last-child::after { content: attr(href); }
  .ports .r a:last-child { font-size: 0; }
  .ports .r a:last-child::after { font-size: 9pt; color: #444; }

  .entries li { padding: 4pt 0; border: 0 !important; break-inside: avoid; }
  .entry-head { margin-bottom: 1pt; }
  .entries h3 { font-size: 10.5pt; }
  .entries p { font-size: 10pt; }
  .meta, p.meta { font-size: 9pt; margin-top: 1pt; color: #444; }
  #oss h3 a::after { content: "  " attr(href); font-weight: 400; font-size: 8.5pt; color: #555; white-space: pre; }
  .featured, .exp-row { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
