:root {
  color-scheme: light;
  --bg: #f3f5ef;
  --ink: #1a2926;
  --muted: #4d625a;
  --line: #c6d0c6;
  --accent: #00664f;
  --tag: #e4ede6;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121d1a;
  --ink: #eaf1e7;
  --muted: #b1c4ba;
  --line: #3d554b;
  --accent: #a9ee8a;
  --tag: #22372f;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.65 "Segoe UI", system-ui, sans-serif; }
a { color: inherit; text-underline-offset: .24em; }
a:hover { color: var(--accent); }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
h1, h2, h3, p { margin: 0; }
.shell { width: min(1120px, calc(100% - 3rem)); margin-inline: auto; }
.top { min-height: 80px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { font: 800 1.45rem/1 "Segoe UI", sans-serif; text-decoration: none; }
.brand span, h1 span { color: var(--accent); }
nav, .controls { display: flex; gap: clamp(.65rem, 2.6vw, 2rem); align-items: center; }
nav a { text-decoration: none; font-weight: 600; }
.controls { gap: .5rem; }
button { background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; font: inherit; min-height: 42px; min-width: 60px; padding: .3rem .7rem; cursor: pointer; }
button:hover { border-color: var(--accent); }
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: clamp(2rem, 8vw, 7rem); align-items: center; padding-block: clamp(4rem, 9vw, 7rem); }
.eyebrow, .metric-label, dt { font: 500 .875rem/1.5 Consolas, "Microsoft YaHei", monospace; }
.eyebrow { color: var(--accent); margin-bottom: 1.25rem; }
h1 { font-size: clamp(5.1rem, 12.5vw, 10rem); line-height: .82; letter-spacing: -.09em; margin-left: -.055em; }
.hero h2 { font-size: clamp(1.35rem, 3vw, 2rem); margin-top: 2rem; line-height: 1.25; }
.intro, .interests { max-width: 52ch; margin-top: .8rem; color: var(--muted); }
.direction { max-width: 52ch; margin: .9rem 0 1.3rem; font-weight: 600; }
.primary { display: inline-block; border: 1px solid var(--accent); padding: .55rem 1rem; border-radius: 4px; font-weight: 700; color: var(--accent); text-decoration: none; }
.primary:hover { background: var(--accent); color: var(--bg); }
.portrait { justify-self: center; width: min(100%, 330px); margin: 0; }
.portrait img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.section { border-top: 1px solid var(--line); padding-block: 2.6rem; scroll-margin-top: 1rem; }
.section h2 { font-size: clamp(2rem, 4.7vw, 3.25rem); line-height: 1.1; letter-spacing: -.055em; margin-bottom: 1.3rem; }
.project { display: grid; grid-template-columns: minmax(160px, .48fr) 1fr; gap: 1.25rem 2rem; padding: 1.5rem 0; border-bottom: 1px solid var(--line); }
.project:last-child { border-bottom: 0; padding-bottom: 0; }
.metric { font-size: clamp(1.9rem, 4vw, 3rem); letter-spacing: -.055em; color: var(--accent); font-weight: 750; line-height: 1.15; }
.metric-label { color: var(--muted); }
h3 { font-size: 1.2rem; line-height: 1.3; }
.project p { margin-top: .45rem; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: .65rem 0 0; }
.tags li { background: var(--tag); border: 1px solid var(--line); color: var(--ink); border-radius: 5px; font-size: .875rem; line-height: 1.35; padding: .22rem .55rem; }
details { margin-top: .6rem; }
summary { cursor: pointer; color: var(--accent); width: fit-content; font-weight: 600; }
.project a { display: inline-block; margin-top: .65rem; font-weight: 650; }
.experience { display: grid; grid-template-columns: 1.25fr 1fr; gap: 2rem 4rem; }
dl { margin: 0; }
.role { padding: .85rem 0; border-top: 1px solid var(--line); }
dt { color: var(--muted); }
dd { margin: .25rem 0 0; }
.role dt { display: flex; justify-content: space-between; gap: .75rem; }
.country { text-align: right; }
.skill-group { margin-top: .8rem; }
.skill-group .tags { margin-top: .35rem; }
dd span { display: block; color: var(--muted); }
.background { align-self: start; border: 1px solid var(--line); padding: 1.35rem; border-radius: 8px; }
.background p { margin-top: .45rem; }
.background h3:not(:first-child) { margin-top: 1.3rem; }
.contact div { display: flex; flex-wrap: wrap; gap: .75rem 1.7rem; }
footer { padding: 1rem 0 2rem; border-top: 1px solid var(--line); color: var(--muted); }
@media (max-width: 700px) {
  .shell { width: calc(100% - 2rem); }
  .hero, .experience { grid-template-columns: 1fr; }
  .portrait { justify-self: start; width: min(100%, 280px); }
  .top { flex-wrap: wrap; padding-block: .65rem; gap: .4rem 1rem; }
  nav { order: 3; width: 100%; gap: 1.25rem; }
  nav a { min-height: 40px; display: grid; align-content: center; }
}
@media (max-width: 460px) { .project { grid-template-columns: 1fr; gap: .65rem; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.back-to-top {
  position: fixed;
  inset-inline-end: max(1rem, env(safe-area-inset-right));
  inset-block-end: max(1rem, env(safe-area-inset-bottom));
  z-index: 1;
  padding: .55rem .85rem;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--bg);
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}
.back-to-top:hover {
  background: var(--accent);
  color: var(--bg);
}
