:root {
  color-scheme: light;
  --bg: #f7f8f3;
  --surface: #ffffff;
  --surface-strong: #f0f2ec;
  --ink: #171a17;
  --muted: #626961;
  --line: #dde3d9;
  --accent: #27745f;
  --accent-strong: #185745;
  --accent-soft: #e4f0ea;
  --coral: #c86f5a;
  --blue: #526f9f;
  --yellow: #d7a64f;
  --shadow: 0 18px 54px rgba(28, 36, 31, 0.1);
  --radius: 8px;
  --max: 1160px;
  --header-height: 72px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", "PingFang SC", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151816;
  --surface: #202421;
  --surface-strong: #2a302c;
  --ink: #f2f5ef;
  --muted: #b7c0b8;
  --line: #3c453f;
  --accent: #66c4a4;
  --accent-strong: #9dddc7;
  --accent-soft: #1b3b31;
  --coral: #e99480;
  --blue: #95acd8;
  --yellow: #e7c478;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 18px);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(39, 116, 95, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(82, 111, 159, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
  letter-spacing: 0;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

body.no-scroll {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
}

::selection {
  color: var(--bg);
  background: var(--accent-strong);
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  transform: translateY(-140%);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(18px);
  transition:
    border-color 180ms ease,
    background 180ms ease;
}

.site-header.is-scrolled {
  border-color: var(--line);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
}

.nav {
  width: calc(100% - 32px);
  max-width: var(--max);
  min-height: var(--header-height);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
  font-weight: 760;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-left: auto;
}

.nav-links a {
  min-height: 40px;
  padding: 10px 13px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.95rem;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  background: var(--surface-strong);
  color: var(--ink);
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--ink);
  cursor: pointer;
  transition:
    background 160ms ease,
    transform 160ms ease,
    border-color 160ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--surface);
  transform: translateY(-1px);
}

.icon-button svg,
.button svg,
.text-link svg,
.project-link svg,
.site-footer svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.icon-fallback {
  display: inline-block;
  font-size: 1.1rem;
  line-height: 1;
}

.icon-button svg + .icon-fallback {
  display: none;
}

.nav-toggle {
  display: none;
  margin-left: auto;
}

.hero {
  position: relative;
  min-height: clamp(680px, calc(100svh - 132px), 900px);
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 14px;
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0 20%,
    var(--coral) 20% 36%,
    var(--blue) 36% 56%,
    var(--yellow) 56% 72%,
    var(--ink) 72% 86%,
    transparent 86% 100%
  );
  opacity: 0.72;
}

.hero-media {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.hero-media::before {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  z-index: 1;
}

.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 78%, transparent) 52%, transparent 100%),
    linear-gradient(0deg, var(--bg) 0%, transparent 30%);
  z-index: 2;
}

.hero-media img {
  position: absolute;
  right: clamp(-80px, 3vw, 48px);
  top: 50%;
  width: min(56vw, 610px);
  min-width: 340px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  transform: translateY(-50%);
  filter: saturate(0.86) contrast(1.02);
  opacity: 0.58;
}

.hero-inner {
  width: calc(100% - 32px);
  max-width: var(--max);
  margin: 0 auto;
  padding: 78px 0 92px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(4rem, 18vw, 12rem);
  line-height: 0.86;
  font-weight: 900;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 710px;
  margin: 30px 0 0;
  color: var(--muted);
  font-size: clamp(1.08rem, 1.8vw, 1.36rem);
  line-height: 1.72;
}

.hero-actions,
.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 740;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-2px);
}

.button.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.button.secondary {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.button.ghost {
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--ink);
}

.profile-stats {
  width: min(100%, 820px);
  margin: 42px 0 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.profile-stats div {
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
}

.profile-stats div:last-child {
  border-right: 0;
}

.profile-stats dt {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1;
  font-weight: 880;
}

.profile-stats dd {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.section {
  width: calc(100% - 32px);
  max-width: var(--max);
  margin: 0 auto;
  padding: 82px 0;
}

.intro-section {
  padding-top: 58px;
}

.section-heading {
  max-width: 780px;
  margin-bottom: 30px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.row-heading {
  max-width: none;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
}

.intro-grid p,
.contact-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.9;
}

.focus-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.focus-item {
  min-height: 240px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(22, 28, 24, 0.055);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.focus-item:hover {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  box-shadow: 0 18px 42px rgba(22, 28, 24, 0.08);
  transform: translateY(-3px);
}

.focus-item svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.focus-item h3,
.stack-column h3,
.project-card h3 {
  margin: 18px 0 10px;
  font-size: 1.18rem;
  line-height: 1.3;
}

.focus-item p,
.project-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.78;
}

.text-link,
.project-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-strong);
  font-weight: 760;
}

.text-link {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 0;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.project-card {
  position: relative;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(22, 28, 24, 0.055);
  overflow: hidden;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.project-card:hover {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  box-shadow: 0 18px 42px rgba(22, 28, 24, 0.085);
  transform: translateY(-3px);
}

.project-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--accent);
}

.project-card:nth-child(2n)::before {
  background: var(--coral);
}

.project-card:nth-child(3n)::before {
  background: var(--blue);
}

.project-card.featured {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 70%, transparent), transparent 58%),
    var(--surface);
}

.project-topline {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.project-language {
  color: var(--accent-strong);
  text-align: right;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.tag-row span,
.skill-list span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 680;
}

.project-link {
  margin-top: auto;
  padding-top: 24px;
}

.project-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: auto;
  padding-top: 24px;
}

.project-actions .project-link {
  margin-top: 0;
  padding-top: 0;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

.project-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.stack-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  overflow: hidden;
}

.stack-column {
  min-width: 0;
  padding: 24px;
  border-right: 1px solid var(--line);
}

.stack-column:last-child {
  border-right: 0;
}

.stack-column h3 {
  margin-top: 0;
}

.skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.contact-section {
  padding-bottom: 64px;
}

.contact-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: center;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}

.contact-panel .eyebrow,
.contact-panel p {
  color: color-mix(in srgb, var(--bg) 78%, transparent);
}

.contact-panel h2 {
  margin: 0 0 14px;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1.12;
}

.contact-panel .button.primary {
  border-color: var(--bg);
  background: var(--bg);
  color: var(--ink);
}

.contact-panel .button.secondary {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--bg));
  background: var(--accent);
  color: #f7f8f3;
}

.contact-panel .button.ghost {
  border-color: color-mix(in srgb, var(--bg) 28%, transparent);
  background: transparent;
  color: var(--bg);
}

.site-footer {
  width: calc(100% - 32px);
  max-width: var(--max);
  min-height: 78px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer a {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 500ms ease,
    transform 500ms ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .focus-grid,
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stack-layout,
  .intro-grid,
  .contact-panel {
    grid-template-columns: 1fr;
  }

  .stack-column {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stack-column:last-child {
    border-bottom: 0;
  }

  .contact-actions {
    margin-top: 0;
  }
}

@media (max-width: 760px) {
  :root {
    --header-height: 64px;
  }

  .nav {
    width: calc(100% - 24px);
    gap: 10px;
    justify-content: flex-start;
  }

  .nav-toggle {
    display: inline-grid;
    margin-left: auto;
  }

  .theme-toggle {
    display: none;
  }

  .nav-links {
    position: fixed;
    inset: var(--header-height) 12px auto;
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition:
      opacity 160ms ease,
      transform 160ms ease;
  }

  .nav-links.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-links a {
    width: 100%;
  }

  .hero {
    min-height: auto;
  }

  .hero-inner {
    width: calc(100% - 24px);
    padding: 64px 0 86px;
  }

  .hero-media img {
    right: -110px;
    top: 40%;
    min-width: 300px;
    opacity: 0.38;
  }

  .hero-media::after {
    background:
      linear-gradient(90deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 72%, transparent) 70%, transparent 100%),
      linear-gradient(0deg, var(--bg) 0%, transparent 34%);
  }

  .hero h1 {
    font-size: clamp(4.2rem, 24vw, 7rem);
  }

  .profile-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-stats div {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .profile-stats div:nth-child(2n) {
    border-right: 0;
  }

  .profile-stats div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .section {
    width: calc(100% - 24px);
    padding: 64px 0;
  }

  .row-heading {
    align-items: start;
    flex-direction: column;
  }

  .focus-grid,
  .project-grid {
    grid-template-columns: 1fr;
  }

  .focus-item,
  .project-card {
    min-height: auto;
  }

  .contact-panel {
    padding: 26px;
  }
}

@media (max-width: 420px) {
  .brand span {
    max-width: 112px;
  }

  .button {
    width: 100%;
  }

  .hero-actions,
  .contact-actions {
    width: 100%;
  }

  .profile-stats {
    grid-template-columns: 1fr;
  }

  .profile-stats div,
  .profile-stats div:nth-child(2n),
  .profile-stats div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .profile-stats div:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
