:root {
  --bg: #f4f2ec;
  --surface: #fbfaf6;
  --ink: #161614;
  --muted: #5e5b53;
  --line: #d9d5ca;
  --line-strong: #b9b4a6;
  --accent: #b5400f;
  --pass: #2d7a4c;
  --fail: #b42318;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --wrap: 1140px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211;
    --surface: #1a1a18;
    --ink: #ecebe5;
    --muted: #a19d92;
    --line: #2d2c28;
    --line-strong: #46443e;
    --accent: #f0844a;
    --pass: #63c08a;
    --fail: #f2785f;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121211;
  --surface: #1a1a18;
  --ink: #ecebe5;
  --muted: #a19d92;
  --line: #2d2c28;
  --line-strong: #46443e;
  --accent: #f0844a;
  --pass: #63c08a;
  --fail: #f2785f;
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }

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

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

.icon { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px;
}
.skip:focus { top: 12px; }

.mini-label, .eyebrow, .section-num, .project-num, .step-num, .job-period, .profile-label {
  font: 500 12.5px/1.4 var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.header-row { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1.5px solid var(--ink); border-radius: 6px;
  font: 500 13px/1 var(--mono); letter-spacing: .02em;
}
.brand-name { font-size: 15px; }
.nav { margin-left: auto; }
.nav ul { display: flex; gap: 4px; }
.nav a {
  display: block; padding: 8px 12px; border-radius: 6px;
  font-size: 15px; color: var(--muted); text-decoration: none;
  transition: color .15s, background-color .15s;
}
.nav a:hover { color: var(--ink); background: var(--surface); }
.nav a[aria-current="true"] { color: var(--ink); }
.header-tools { display: flex; gap: 6px; }
.tool {
  display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: transparent;
  font: 500 13px/1 var(--mono); text-decoration: none; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.tool:hover { border-color: var(--line-strong); background: var(--surface); }
.tool .icon { width: 18px; height: 18px; }
.menu-toggle { display: none; }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: 56px 64px;
  padding-top: clamp(48px, 9vw, 112px);
  padding-bottom: 32px;
}
.eyebrow { color: var(--accent); margin-bottom: 20px; }
h1 {
  font-size: clamp(44px, 7.4vw, 88px);
  line-height: .98;
  font-weight: 600;
  letter-spacing: -.035em;
  text-wrap: balance;
}
.lead { margin-top: 28px; max-width: 34em; font-size: clamp(18px, 1.9vw, 21px); line-height: 1.55; color: var(--muted); text-wrap: pretty; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 36px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 20px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 16px; font-weight: 500; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .15s;
}
.btn:hover { background: var(--surface); border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); border-color: transparent; }
.btn-meta { font: 500 11px/1 var(--mono); padding: 4px 6px; border-radius: 4px; background: color-mix(in srgb, var(--bg) 18%, transparent); }
.text-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 15px; color: var(--muted); text-decoration: underline; text-decoration-color: var(--line-strong);
}
.text-link:hover { color: var(--ink); text-decoration-color: currentColor; }
.text-link .icon { width: 14px; height: 14px; }

.profile {
  align-self: end;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 20px 22px 8px;
}
.profile-label { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.profile dl div { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.profile dl div:last-child { border-bottom: 0; }
.profile dt { font: 400 13px/1.5 var(--mono); color: var(--muted); }
.profile dd { font-size: 15px; line-height: 1.5; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--pass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pass) 22%, transparent); vertical-align: 1px; }

.facts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--ink); }
.facts li { display: flex; flex-direction: column; gap: 6px; padding: 22px 24px 0 0; }
.facts li + li { padding-left: 24px; border-left: 1px solid var(--line); }
.fact-num { font-size: clamp(32px, 4vw, 44px); font-weight: 500; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.fact-text { font-size: 15px; color: var(--muted); max-width: 18em; }

/* Sections */
.section { padding-top: clamp(80px, 11vw, 136px); }
.section-head {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1.1fr); gap: 8px 24px; align-items: baseline;
  padding-bottom: 28px; border-bottom: 1px solid var(--ink);
}
.section-num { color: var(--accent); }
h2 { font-size: clamp(30px, 4vw, 44px); line-height: 1.08; font-weight: 600; letter-spacing: -.025em; }
.section-intro { color: var(--muted); max-width: 36em; text-wrap: pretty; }

/* Projects */
.project {
  display: grid;
  grid-template-columns: 64px minmax(0, .9fr) minmax(0, 1.1fr) minmax(0, 1.3fr);
  gap: 16px 24px;
  padding: 32px 0;
  border-bottom: 1px solid var(--line);
}
.project-id { display: contents; }
.project-num { grid-column: 1; padding-top: 6px; }
.project-id h3, .project-kind, .project-links { grid-column: 2; }
.project h3 { font-size: 22px; font-weight: 600; letter-spacing: -.015em; line-height: 1.25; }
.project-kind { font-size: 15px; color: var(--muted); margin-top: -8px; }
.project-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 2px; }
.project-links a { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 500; text-decoration-color: var(--line-strong); }
.project-links a:hover { color: var(--accent); text-decoration-color: currentColor; }
.project-links .icon { width: 14px; height: 14px; }
.project-body { grid-column: 3; grid-row: 1 / span 4; }
.project-body p { color: var(--ink); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.tags li { font: 400 12.5px/1 var(--mono); padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); }
.project-checks { grid-column: 4; grid-row: 1 / span 4; }
.project-checks .mini-label { margin-bottom: 10px; }
.project-checks li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 7px 0; font-size: 15.5px; line-height: 1.5; border-top: 1px dashed var(--line); }
.project-checks li:first-child { border-top: 0; padding-top: 0; }
.project-checks .icon { width: 17px; height: 17px; margin-top: 3px; color: var(--pass); stroke-width: 2.2; }
.more { margin-top: 24px; }

/* Approach */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.steps li { padding: 28px 24px 32px 0; }
.steps li + li { padding-left: 24px; border-left: 1px solid var(--line); }
.steps h3 { font-size: 20px; font-weight: 600; margin: 14px 0 8px; letter-spacing: -.01em; }
.steps p { font-size: 15.5px; color: var(--muted); }
.step-num { color: var(--accent); }

.bug { margin-top: 48px; display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 2.2fr); gap: 24px; }
.bug figcaption { display: flex; flex-direction: column; gap: 10px; }
.bug-note { font-size: 15px; color: var(--muted); max-width: 18em; }
.bug-card { border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); overflow: hidden; }
.bug-title { padding: 20px 24px; font-size: 18px; font-weight: 600; line-height: 1.4; border-bottom: 1px solid var(--line); border-left: 3px solid var(--fail); }
.bug-fields { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.bug-fields div { padding: 12px 24px; border-right: 1px solid var(--line); }
.bug-fields dt { font: 400 12px/1.4 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bug-fields dd { font-size: 15px; font-weight: 500; }
.bug-grid { display: grid; grid-template-columns: 1fr 1fr; }
.bug-grid > div { padding: 20px 24px 24px; font-size: 15.5px; }
.bug-grid > div + div { border-left: 1px solid var(--line); }
.bug-grid .mini-label { margin: 0 0 6px; }
.bug-grid p + .mini-label { margin-top: 16px; }
.bug-grid ol { list-style: decimal; padding-left: 20px; }
.bug-grid ol li { padding: 2px 0; }
.bug-actual { color: var(--fail); }

/* Experience */
.job { display: grid; grid-template-columns: 64px minmax(0, .9fr) minmax(0, 2.4fr); gap: 8px 24px; padding: 30px 0; border-bottom: 1px solid var(--line); }
.job-period { grid-column: 1 / 3; padding-top: 6px; }
.job > div { grid-column: 3; }
.job h3 { font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.job-org { color: var(--muted); margin-bottom: 10px; }
.job ul li { position: relative; padding-left: 20px; margin-top: 6px; }
.job ul li::before { content: ""; position: absolute; left: 2px; top: .8em; width: 8px; height: 1.5px; background: var(--line-strong); }

.sub-head { margin-top: 56px; padding-bottom: 14px; border-bottom: 1px solid var(--ink); font-size: 22px; font-weight: 600; letter-spacing: -.015em; }

/* Skills */
.skills div { display: grid; grid-template-columns: 64px minmax(0, .9fr) minmax(0, 2.4fr); gap: 8px 24px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.skills dt { grid-column: 1 / 3; font-weight: 600; }
.skills dd { grid-column: 3; color: var(--muted); }

/* Contact */
.contact-mail {
  display: inline-flex; align-items: center; gap: 12px; margin-top: 40px;
  font-size: clamp(26px, 5vw, 56px); font-weight: 500; letter-spacing: -.03em; line-height: 1.1;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 8px; text-decoration-color: var(--line-strong);
  overflow-wrap: anywhere;
  transition: color .15s, text-decoration-color .15s;
}
.contact-mail:hover { color: var(--accent); text-decoration-color: currentColor; }
.contact-mail .icon { width: .7em; height: .7em; stroke-width: 1.6; }
.contact-list { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 48px; border-top: 1px solid var(--line); }
.contact-list li { display: flex; flex-direction: column; gap: 6px; padding: 20px 20px 0 0; }
.contact-list li + li { padding-left: 20px; border-left: 1px solid var(--line); }
.contact-list a { font-size: 17px; font-weight: 500; text-decoration-color: var(--line-strong); overflow-wrap: anywhere; }
.contact-list a:hover { color: var(--accent); }

/* Footer */
.site-footer { margin-top: clamp(80px, 11vw, 136px); font-size: 14px; color: var(--muted); }
.footer-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px;
  padding: 24px 0 40px; border-top: 1px solid var(--line);
}
.footer-note { margin-right: auto; }

/* Reveal: only when JS runs and motion is allowed */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s cubic-bezier(.2, .7, .2, 1); }
  .js .reveal.in { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Tablet */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 40px; }
  .profile { align-self: start; max-width: 520px; }
  .section-head { grid-template-columns: 48px 1fr; }
  .section-intro { grid-column: 2; }
  .project { grid-template-columns: 48px minmax(0, 1fr) minmax(0, 1.2fr); }
  .project-body { grid-column: 3; grid-row: 1 / span 4; }
  .project-checks { grid-column: 2 / 4; grid-row: auto; }
  .steps { grid-template-columns: 1fr 1fr; }
  .steps li:nth-child(3) { padding-left: 0; border-left: 0; }
  .steps li:nth-child(n+3) { border-top: 1px solid var(--line); }
  .bug { grid-template-columns: 1fr; }
  .job, .skills div { grid-template-columns: 48px minmax(0, .8fr) minmax(0, 2fr); }
  .contact-list { grid-template-columns: 1fr 1fr; }
  .contact-list li:nth-child(3) { padding-left: 0; border-left: 0; }
  .contact-list li { padding-bottom: 20px; }
}

/* Mobile */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .menu-toggle { display: grid; }
  .brand-name { display: none; }
  .nav {
    position: absolute; top: 64px; left: 0; right: 0;
    background: var(--bg); border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav.open { display: block; }
  .nav ul { flex-direction: column; padding: 8px var(--gutter) 16px; }
  .nav a { padding: 12px 0; font-size: 17px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .nav a:hover { background: none; }
  .header-tools { margin-left: auto; }
  .facts { grid-template-columns: 1fr; }
  .facts li, .facts li + li { flex-direction: row; align-items: baseline; gap: 16px; padding: 16px 0; border-left: 0; border-bottom: 1px solid var(--line); }
  .fact-num { min-width: 2.6em; font-size: 32px; }
  .section-head { grid-template-columns: 1fr; }
  .section-intro { grid-column: 1; }
  .project { grid-template-columns: 1fr; gap: 12px; padding: 28px 0; }
  .project-num, .project-id h3, .project-kind, .project-links, .project-body, .project-checks { grid-column: 1; grid-row: auto; }
  .project-kind { margin-top: -6px; }
  .project-checks { margin-top: 8px; }
  .steps { grid-template-columns: 1fr; }
  .steps li, .steps li + li { padding: 24px 0; border-left: 0; }
  .steps li + li { border-top: 1px solid var(--line); }
  .bug-grid { grid-template-columns: 1fr; }
  .bug-grid > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .bug-title, .bug-fields div, .bug-grid > div { padding-left: 18px; padding-right: 18px; }
  .job, .skills div { grid-template-columns: 1fr; gap: 6px; }
  .job-period, .job > div, .skills dt, .skills dd { grid-column: 1; }
  .contact-list { grid-template-columns: 1fr; }
  .contact-list li, .contact-list li + li { padding: 16px 0; border-left: 0; border-bottom: 1px solid var(--line); }
}

@media print {
  .site-header, .skip, .actions, .more { display: none; }
  .js .reveal { opacity: 1; transform: none; }
}
