:root {
  --ink: #f0f3ed;
  --muted: #aeb9b1;
  --faint: #6e7a73;
  --ground: #101413;
  --ground-raised: #151c19;
  --ground-deep: #0b0f0e;
  --line: #31423b;
  --line-soft: #26332e;
  --accent: #72e1b7;
  --accent-deep: #1d7860;
  --amber: #ecb35c;
  --shell: min(1280px, calc(100% - 64px));
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--ground);
  font-family: var(--sans);
  line-height: 1.55;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0.26;
  background-image: linear-gradient(rgba(114, 225, 183, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(114, 225, 183, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

a { color: inherit; text-decoration: none; }

img { display: block; max-width: 100%; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 10px;
  left: 10px;
  padding: 9px 12px;
  transform: translateY(-180%);
  color: var(--ground);
  background: var(--accent);
  font: 700 12px var(--mono);
}

.skip-link:focus { transform: translateY(0); }

.section-shell { width: var(--shell); margin: 0 auto; }

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  min-height: 70px;
  padding: 0 max(32px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid rgba(72, 92, 83, 0.68);
  background: rgba(16, 20, 19, 0.94);
  backdrop-filter: blur(14px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; width: max-content; font: 800 13px var(--mono); letter-spacing: 0.07em; }

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 10px;
}

.site-nav { display: flex; align-items: stretch; height: 70px; gap: 0; }

.site-nav a {
  position: relative;
  display: grid;
  align-items: center;
  padding: 0 13px;
  color: var(--muted);
  font: 500 12px var(--mono);
  white-space: nowrap;
}

.site-nav a::after { position: absolute; right: 12px; bottom: 0; left: 12px; height: 2px; content: ""; background: transparent; }
.site-nav a:hover, .site-nav a.is-active { color: var(--ink); }
.site-nav a.is-active::after { background: var(--accent); }

.header-actions { display: flex; justify-self: end; align-items: center; gap: 9px; }
.language-toggle { position: relative; display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 9px; border: 1px solid var(--line); color: var(--muted); background: transparent; cursor: pointer; font: 700 10px var(--mono); letter-spacing: 0.04em; transition: border-color 160ms ease, color 160ms ease, background 160ms ease; }
.language-toggle:hover, .language-toggle:focus-visible { border-color: var(--accent); color: var(--accent); background: rgba(114, 225, 183, 0.08); }
.language-toggle::after { position: absolute; top: calc(100% + 9px); right: 0; display: none; padding: 4px 7px; color: var(--ground); background: var(--accent); content: attr(data-tooltip); font: 600 10px var(--mono); white-space: nowrap; }
.language-toggle:hover::after { display: block; }
.language-label-en { color: var(--accent); }
.language-toggle.is-zh .language-label-en { color: var(--muted); }
.language-toggle.is-zh .language-label-zh { color: var(--accent); }
.language-divider { color: var(--faint); }
.menu-toggle { display: none; cursor: pointer; }
button { font: inherit; }

:where(a, button):focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 4px;
}

.icon-button {
  position: relative;
  justify-self: end;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.icon-button svg { width: 17px; height: 17px; }
.icon-button:hover { border-color: var(--accent); color: var(--accent); background: rgba(114, 225, 183, 0.08); }
.icon-button::after {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  display: none;
  padding: 4px 7px;
  color: var(--ground);
  background: var(--accent);
  content: attr(data-tooltip);
  font: 600 10px var(--mono);
  white-space: nowrap;
}
.icon-button:hover::after { display: block; }

.hero { display: grid; grid-template-columns: minmax(0, 0.91fr) minmax(420px, 1.09fr); gap: clamp(42px, 6vw, 92px); padding-top: clamp(64px, 8vw, 108px); padding-bottom: 64px; }
.hero-copy { align-self: center; padding-bottom: 20px; }

.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 18px; color: var(--accent); font: 700 11px var(--mono); letter-spacing: 0.11em; }
.eyebrow > span:first-child { flex: 0 0 21px; width: 21px; height: 1px; background: currentColor; }
.eyebrow > span:not(:first-child) { width: auto; height: auto; background: none; }

h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 750px; margin-bottom: 23px; font-size: clamp(42px, 5.15vw, 76px); font-weight: 720; line-height: 1.05; letter-spacing: 0; }
.hero-lead { max-width: 620px; margin-bottom: 20px; color: var(--muted); font-size: clamp(17px, 1.45vw, 21px); line-height: 1.62; }
.identity-line { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0 0 27px; color: var(--faint); font: 500 12px var(--mono); }
.identity-line span::before { margin-right: 7px; color: var(--accent); content: "/"; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 30px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 43px; padding: 0 15px; border: 1px solid var(--line); font: 700 12px var(--mono); transition: transform 160ms ease, color 160ms ease, background 160ms ease, border-color 160ms ease; }
.button svg { width: 16px; height: 16px; }
.button:hover { transform: translateY(-2px); }
.button-primary { border-color: var(--accent); color: var(--ground); background: var(--accent); }
.button-primary:hover { background: #9bedcb; }
.button-secondary { color: var(--ink); background: rgba(21, 28, 25, 0.78); }
.button-secondary:hover { border-color: var(--accent); color: var(--accent); }

.skill-pills { display: flex; flex-wrap: wrap; gap: 7px; padding: 0; margin: 0; list-style: none; }
.skill-pills li { padding: 6px 9px; border: 1px solid var(--line-soft); color: #c0cbc3; background: rgba(21, 28, 25, 0.82); font: 500 11px var(--mono); }

.hero-evidence { position: relative; min-width: 0; }
.image-panel { margin: 0; overflow: hidden; border: 1px solid var(--line); background: var(--ground-raised); }
.hero-primary img { width: 100%; aspect-ratio: 1.55 / 1; object-fit: cover; }
.hero-primary figcaption { display: grid; gap: 5px; padding: 14px 16px; border-top: 1px solid var(--line); }
.figure-kicker { color: var(--accent); font: 700 10px var(--mono); letter-spacing: 0.1em; }
.hero-primary strong { font-size: 15px; font-weight: 650; }

.evidence-strip { display: grid; grid-template-columns: 1fr 1.26fr; gap: 14px; margin-top: 14px; }
.mini-evidence { min-width: 0; margin: 0; border: 1px solid var(--line-soft); background: var(--ground-raised); }
.mini-evidence img { width: 100%; height: 132px; object-fit: cover; }
.mini-evidence:first-child img { object-position: center 40%; }
.mini-evidence figcaption { display: grid; gap: 3px; padding: 10px 12px; }
.mini-evidence span { color: var(--faint); font: 600 9px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.mini-evidence strong { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.proof-band { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--ground-deep); }
.proof-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 72px; padding: 56px 0; }
.proof-statement h2, .section-heading h2, .site-footer h2 { margin-bottom: 12px; font-size: clamp(29px, 3vw, 47px); line-height: 1.13; letter-spacing: 0; }
.proof-statement p:not(.eyebrow) { max-width: 600px; margin: 0; color: var(--muted); font-size: 16px; }
.proof-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-left: 1px solid var(--line); }
.proof-stats div { padding: 5px 20px; border-right: 1px solid var(--line); }
.proof-stats dt { margin-bottom: 4px; color: var(--amber); font: 700 clamp(32px, 3.4vw, 52px)/1 var(--mono); }
.proof-stats dd { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.work-section { padding-top: 100px; padding-bottom: 100px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 42px; margin-bottom: 45px; }
.section-heading h2 { max-width: 800px; margin-bottom: 0; }
.section-note { max-width: 315px; margin: 0 0 3px; color: var(--muted); font-size: 14px; }
.project-list { border-top: 1px solid var(--line); }
.project-row { position: relative; display: grid; grid-template-columns: 55px minmax(250px, 0.95fr) minmax(260px, 0.88fr); gap: clamp(24px, 4vw, 68px); align-items: center; padding: 40px 0; border-bottom: 1px solid var(--line); }
.project-row-reverse { grid-template-columns: 55px minmax(260px, 0.88fr) minmax(250px, 0.95fr); }
.project-index { align-self: start; padding-top: 2px; color: var(--accent); font: 700 13px var(--mono); }
.project-image { overflow: hidden; border: 1px solid var(--line); background: #0c1210; }
.project-image > img { width: 100%; height: 278px; object-fit: cover; transition: transform 400ms ease; }
.project-row:hover .project-image > img { transform: scale(1.025); }
.project-content { align-self: center; min-width: 0; }
.project-type { margin-bottom: 10px; color: var(--accent); font: 700 10px var(--mono); letter-spacing: 0.09em; }
.project-content h3 { margin-bottom: 11px; font-size: clamp(25px, 2.2vw, 34px); line-height: 1.15; }
.project-meta { display: flex; flex-wrap: wrap; gap: 7px 15px; margin: -2px 0 14px; color: var(--faint); font: 500 10px var(--mono); }
.project-meta span + span::before { margin-right: 10px; color: var(--accent-deep); content: "/"; }
.project-content > p:not(.project-type) { margin-bottom: 18px; color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.project-tags { display: flex; flex-wrap: wrap; gap: 7px; padding: 0; margin: 0 0 22px; list-style: none; }
.project-tags li { padding: 4px 7px; border: 1px solid var(--line-soft); color: #c3cdc6; font: 500 10px var(--mono); }
.project-loop { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px; margin: 0 0 21px; color: #cbd5ce; font: 500 11px/1.5 var(--mono); }
.project-loop span { flex: 0 0 auto; color: var(--amber); font-weight: 700; letter-spacing: 0.08em; }
.project-loop span:last-child { flex: 1 1 0; width: 0; min-width: 0; overflow-wrap: anywhere; }
.text-link { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; color: var(--ink); border-bottom: 1px solid var(--accent); padding-bottom: 3px; font: 700 12px var(--mono); }
.text-link svg { width: 15px; height: 15px; color: var(--accent); transition: transform 160ms ease; }
.text-link:hover svg { transform: translate(2px, -2px); }

.pcb-stack { display: grid; grid-template-columns: 0.75fr 1.25fr; gap: 1px; background: var(--line); }
.pcb-stack > img { min-width: 0; height: 278px; background: #0b100e; object-fit: cover; }
.pcb-stack > img:first-child { object-position: center; }
.thermal-stack { grid-template-columns: 1.35fr 0.65fr; }
.thermal-stack > img:last-child { object-position: center 36%; }

.systems-band { padding: 90px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #111815; }
.split-heading { align-items: end; }
.system-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.system-grid article { position: relative; min-height: 290px; padding: 26px 23px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.system-grid article > svg { width: 25px; height: 25px; margin: 26px 0 26px; color: var(--accent); stroke-width: 1.5; }
.system-number { color: var(--faint); font: 600 11px var(--mono); }
.system-grid h3 { margin-bottom: 8px; font-size: 20px; }
.system-grid p { min-height: 88px; margin-bottom: 14px; color: var(--muted); font-size: 14px; }
.system-grid article > span:last-child { color: #cbd5ce; font: 500 10px var(--mono); line-height: 1.5; }

.skills-section { padding-top: 100px; padding-bottom: 100px; }
.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.skills-grid article { padding: 27px 30px 30px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.skill-group { margin-bottom: 16px; color: var(--accent); font: 700 11px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.skills-grid ul { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.skills-grid li { position: relative; padding-left: 15px; color: var(--muted); font-size: 14px; }
.skills-grid li::before { position: absolute; left: 0; color: var(--amber); content: "›"; }

.site-footer { border-top: 1px solid var(--line); background: var(--ground-deep); }
.footer-content { display: flex; align-items: end; justify-content: space-between; gap: 50px; padding: 76px 0 58px; }
.site-footer h2 { max-width: 760px; margin: 0; }
.footer-links { display: grid; justify-items: end; gap: 10px; min-width: max-content; }
.footer-links a { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 5px; font: 500 12px var(--mono); }
.footer-links a:hover { color: var(--accent); border-color: var(--accent); }
.footer-links svg { width: 14px; height: 14px; }
.footer-links .footer-mail { color: var(--accent); font-weight: 700; }
.footer-meta { display: flex; justify-content: space-between; gap: 22px; padding: 15px 0 22px; border-top: 1px solid var(--line-soft); color: var(--faint); font: 500 10px var(--mono); }

@media (max-width: 1050px) {
  .site-header { position: sticky; grid-template-columns: 1fr auto; }
  .menu-toggle { display: grid; }
  .site-nav { position: absolute; top: 100%; right: 18px; left: 18px; display: none; height: auto; padding: 7px; border: 1px solid var(--line); background: rgba(11, 15, 14, 0.98); box-shadow: 0 14px 26px rgba(0, 0, 0, 0.28); }
  .site-nav.is-open { display: grid; }
  .site-nav a { min-height: 43px; padding: 0 13px; }
  .site-nav a::after { right: 0; bottom: 0; left: 0; }
  .hero { grid-template-columns: 1fr; gap: 45px; padding-top: 75px; }
  .hero-copy { max-width: 790px; }
  .hero-primary img { aspect-ratio: 1.9 / 1; }
  .proof-grid { grid-template-columns: 1fr; gap: 38px; }
  .proof-stats { max-width: 680px; }
  .project-row, .project-row-reverse { grid-template-columns: 45px minmax(0, 1fr) minmax(260px, 0.84fr); gap: 25px; }
  .system-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  :root { --shell: min(100% - 36px, 1280px); }
  .site-header { min-height: 60px; padding: 0 18px; }
  .github-button::after { display: none; }
  .language-toggle { min-height: 30px; padding: 0 7px; }
  .language-toggle::after { display: none; }
  .brand { font-size: 11px; }
  .brand-mark { width: 25px; height: 25px; }
  .hero { padding-top: 52px; padding-bottom: 48px; }
  h1 { font-size: clamp(38px, 12vw, 53px); }
  .hero-lead { font-size: 16px; }
  .hero-actions { display: grid; grid-template-columns: 1fr; }
  .button { width: 100%; }
  .hero-primary img { aspect-ratio: 1.25 / 1; }
  .evidence-strip { grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 9px; }
  .mini-evidence img { height: 104px; }
  .mini-evidence figcaption { padding: 8px; }
  .mini-evidence strong { font-size: 10px; }
  .proof-grid { padding: 46px 0; }
  .proof-stats { grid-template-columns: 1fr; border-top: 1px solid var(--line); }
  .proof-stats div { display: grid; grid-template-columns: 72px 1fr; align-items: center; padding: 12px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .proof-stats dt { margin: 0; font-size: 30px; }
  .work-section, .skills-section { padding-top: 68px; padding-bottom: 68px; }
  .section-heading, .footer-content { display: grid; gap: 16px; }
  .section-note { max-width: 100%; }
  .project-row, .project-row-reverse { grid-template-columns: 32px minmax(0, 1fr); gap: 15px; padding: 30px 0; }
  .project-index { grid-row: 1 / span 2; }
  .project-image { grid-column: 2; }
  .project-content { grid-column: 2; }
  .project-image > img, .pcb-stack > img { height: 205px; }
  .project-meta { gap: 5px 11px; }
  .project-meta span + span::before { margin-right: 7px; }
  .project-loop { font-size: 10px; }
  .systems-band { padding: 66px 0; }
  .system-grid { grid-template-columns: 1fr; }
  .system-grid article { min-height: 0; }
  .system-grid article > svg { margin: 18px 0; }
  .system-grid p { min-height: 0; }
  .skills-grid { grid-template-columns: 1fr; }
  .skills-grid article { padding: 24px 20px; }
  .footer-content { padding: 56px 0 38px; }
  .footer-links { justify-items: start; min-width: 0; }
  .footer-meta { display: grid; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 1ms !important; }
}
