:root {
  --bg: #0b0d12;
  --bg-soft: #12151d;
  --surface: #161a23;
  --surface-2: #1d2230;
  --text: #e8ecf4;
  --text-dim: #9aa3b5;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #6c8cff;
  --accent-2: #b06cff;
  --accent-glow: rgba(108, 140, 255, 0.35);
  --radius: 18px;
  --max: 1160px;
}

html[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-soft: #eef1f8;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #10131a;
  --text-dim: #5a6479;
  --line: rgba(16, 19, 26, 0.1);
  --accent: #3b5bdb;
  --accent-2: #9c36b5;
  --accent-glow: rgba(59, 91, 219, 0.25);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

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

.cursor-glow {
  position: fixed;
  top: 0; left: 0;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 65%);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
  filter: blur(40px);
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max);
  margin: 0 auto;
  padding: 22px 28px;
  z-index: 100;
  transition: padding 0.3s ease, background 0.3s ease, backdrop-filter 0.3s ease;
}

.nav.scrolled {
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.nav__logo {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.5px;
  z-index: 101;
}
.nav__logo span { color: var(--accent); }

.nav__links { display: flex; gap: 34px; }
.nav__links a {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-dim);
  position: relative;
  transition: color 0.25s ease;
}
.nav__links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -6px;
  width: 100%; height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.nav__links a:hover { color: var(--text); }
.nav__links a:hover::after { transform: scaleX(1); }

.nav__toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 101;
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.nav__toggle:hover { border-color: var(--accent); transform: translateY(-2px); }
.icon-sun { display: none; }
html[data-theme="light"] .icon-sun { display: block; }
html[data-theme="light"] .icon-moon { display: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  align-items: center;
  gap: 40px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 120px 28px 80px;
  z-index: 1;
}

.hero__bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, var(--accent-glow), transparent 40%),
    radial-gradient(circle at 85% 75%, color-mix(in srgb, var(--accent-2) 28%, transparent), transparent 45%);
  z-index: -1;
  filter: blur(20px);
}

.hero__eyebrow {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 3px;
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.hero__title {
  font-size: clamp(3rem, 8vw, 5.5rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -2px;
  margin-bottom: 18px;
}
.hero__title .accent { color: var(--accent); }

.hero__subtitle {
  font-size: clamp(1.2rem, 3vw, 1.7rem);
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 22px;
  min-height: 2.2rem;
}
.typed { color: var(--text); font-weight: 600; }
.caret { color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.hero__desc {
  max-width: 480px;
  color: var(--text-dim);
  margin-bottom: 32px;
  font-size: 1.02rem;
}

.hero__actions { display: flex; gap: 16px; margin-bottom: 36px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.btn--primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 30px -10px var(--accent-glow);
}
.btn--primary:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -12px var(--accent-glow); }
.btn--ghost {
  border: 1px solid var(--line);
  color: var(--text);
}
.btn--ghost:hover { border-color: var(--accent); transform: translateY(-3px); }
.btn--lg { padding: 16px 40px; font-size: 1rem; }

.hero__socials { display: flex; gap: 26px; }
.hero__socials a {
  font-size: 0.9rem;
  color: var(--text-dim);
  position: relative;
  transition: color 0.25s ease;
}
.hero__socials a:hover { color: var(--accent); }

.hero__avatar {
  position: relative;
  justify-self: center;
  width: 280px; height: 280px;
  display: grid;
  place-items: center;
}
.avatar__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed var(--line);
  animation: spin 26s linear infinite;
}
.avatar__ring::before {
  content: "";
  position: absolute;
  top: -5px; left: 50%;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent);
  transform: translateX(-50%);
}
@keyframes spin { to { transform: rotate(360deg); } }

.avatar__inner {
  width: 210px; height: 210px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 20px 60px -20px var(--accent-glow);
  animation: float 6s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-14px); } }

.scroll-hint {
  position: absolute;
  bottom: 34px; left: 50%;
  transform: translateX(-50%);
  width: 26px; height: 42px;
  border: 2px solid var(--line);
  border-radius: 14px;
  display: grid;
  place-items: start center;
  padding-top: 8px;
}
.scroll-hint span {
  width: 4px; height: 8px;
  border-radius: 2px;
  background: var(--accent);
  animation: scroll 1.6s ease-in-out infinite;
}
@keyframes scroll { 0% { opacity: 0; transform: translateY(-4px);} 50% { opacity: 1; } 100% { opacity: 0; transform: translateY(10px);} }

/* ---------- Sections ---------- */
.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: 100px 28px;
  position: relative;
  z-index: 1;
}

.section__head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 52px;
}
.section__index {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.section__title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  position: relative;
}
.section__title::after {
  content: "";
  position: absolute;
  left: calc(100% + 20px);
  top: 50%;
  width: 80px; height: 1px;
  background: var(--line);
}

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
}
.about__text p { color: var(--text-dim); margin-bottom: 20px; }
.about__facts {
  display: flex;
  gap: 40px;
  list-style: none;
  margin-top: 32px;
}
.about__facts strong {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.about__facts span { font-size: 0.85rem; color: var(--text-dim); }

.code-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}
.code-block__bar {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot--red { background: #ff5f57; }
.dot--yellow { background: #febc2e; }
.dot--green { background: #28c840; }
.code-block pre {
  padding: 24px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.9;
  overflow-x: auto;
}
.c-kw { color: #c792ea; }
.c-var { color: #82aaff; }
.c-key { color: #7fdbca; }
.c-str { color: #c3e88d; }
.c-num { color: #f78c6c; }

/* ---------- Skills ---------- */
.skills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 26px 56px;
}
.skill__top {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 10px;
}
.skill__top span:last-child { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.skill__bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.skill__bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 1.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.skill.is-visible .skill__bar i { width: var(--w); }

/* ---------- Projects ---------- */
.projects {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
.project {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}
.project:hover {
  transform: translateY(-8px);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}
.project__visual {
  position: relative;
  height: 170px;
  display: flex;
  align-items: flex-end;
  padding: 20px;
}
.project__visual--a { background: linear-gradient(135deg, #3b5bdb, #7048e8); }
.project__visual--b { background: linear-gradient(135deg, #0b7285, #1098ad); }
.project__visual--c { background: linear-gradient(135deg, #9c36b5, #c2255c); }
.project__num {
  font-size: 3.4rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.22);
  line-height: 1;
}
.project__body { padding: 24px; }
.project__body h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 10px; }
.project__body p { font-size: 0.9rem; color: var(--text-dim); margin-bottom: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tags span {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.project__link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  transition: letter-spacing 0.25s ease;
}
.project__link:hover { letter-spacing: 1px; }

/* ---------- Contact ---------- */
.section--contact { text-align: center; }
.contact {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 70px 30px;
  position: relative;
  overflow: hidden;
}
.contact::before {
  content: "";
  position: absolute;
  inset: -50% 20% auto;
  height: 300px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  z-index: 0;
  filter: blur(30px);
}
.contact > * { position: relative; z-index: 1; }
.contact .section__index { display: block; margin-bottom: 10px; }
.contact__title { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -1px; margin-bottom: 16px; }
.contact__desc { color: var(--text-dim); max-width: 480px; margin: 0 auto 34px; }
.contact__socials {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 34px;
}
.contact__socials a { font-size: 0.9rem; color: var(--text-dim); transition: color 0.25s ease; }
.contact__socials a:hover { color: var(--accent); }

/* ---------- Footer ---------- */
.footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 0.85rem;
}
.footer__top { transition: color 0.25s ease; }
.footer__top:hover { color: var(--accent); }

/* ---------- Reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; text-align: center; padding-top: 130px; gap: 60px; }
  .hero__desc { margin-left: auto; margin-right: auto; }
  .hero__actions, .hero__socials { justify-content: center; }
  .hero__avatar { order: -1; width: 220px; height: 220px; }
  .avatar__inner { width: 160px; height: 160px; font-size: 2.4rem; }
  .scroll-hint { display: none; }
  .about { grid-template-columns: 1fr; gap: 40px; }
  .about__facts { justify-content: center; }
  .projects { grid-template-columns: 1fr; }
  .nav__links { gap: 22px; }
  .section__title::after { display: none; }
}

@media (max-width: 640px) {
  .nav { padding: 16px 20px; }
  .nav__links { display: none; }
  .skills { grid-template-columns: 1fr; }
  .section { padding: 70px 20px; }
  .footer { flex-direction: column; gap: 12px; text-align: center; }
  .about__facts { gap: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  .skill__bar i { width: var(--w); }
}
