:root {
  --bg: #0b0f1a;
  --bg-alt: #111726;
  --card: #161d2e;
  --card-border: rgba(255, 255, 255, 0.07);
  --text: #e6e9f2;
  --text-muted: #9aa3b5;
  --primary: #6366f1;
  --primary-2: #a855f7;
  --accent: #22d3ee;
  --radius: 16px;
  --nav-h: 68px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
}

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

.container {
  width: min(1080px, 92%);
  margin: 0 auto;
}

/* ---------- Navbar ---------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  z-index: 100;
  background: rgba(11, 15, 26, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}

.navbar.scrolled {
  background: rgba(11, 15, 26, 0.9);
  border-bottom-color: var(--card-border);
}

.navbar-inner {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo span {
  color: var(--primary-2);
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.95rem;
  transition: color 0.25s;
  position: relative;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.3s;
}

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

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 6px;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding-top: var(--nav-h);
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(600px 400px at 15% 20%, rgba(99, 102, 241, 0.18), transparent 65%),
    radial-gradient(700px 500px at 85% 75%, rgba(168, 85, 247, 0.14), transparent 65%),
    radial-gradient(500px 400px at 70% 15%, rgba(34, 211, 238, 0.1), transparent 60%);
}

.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.6), transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.6), transparent 75%);
}

.hero-inner {
  display: flex;
  align-items: center;
  gap: 4rem;
}

.hero-avatar {
  flex-shrink: 0;
  position: relative;
}

.avatar {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.35), 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: float 5s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.hero-greet {
  color: var(--accent);
  font-size: 1.05rem;
  letter-spacing: 2px;
  margin-bottom: 0.4rem;
}

.hero-name {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.15;
  background: linear-gradient(120deg, #fff, #c7d2fe 60%, var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-typed {
  margin: 0.6rem 0 1.1rem;
  font-size: 1.25rem;
  color: var(--primary-2);
  font-weight: 600;
  min-height: 1.7em;
}

.hero-typed .cursor {
  display: inline-block;
  width: 2px;
  margin-left: 2px;
  background: var(--primary-2);
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.hero-bio {
  color: var(--text-muted);
  max-width: 520px;
  margin-bottom: 1.8rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.25s, box-shadow 0.25s, background 0.25s;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.5);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--card-border);
}

.btn-ghost:hover {
  border-color: var(--primary);
}

.btn-block {
  width: 100%;
}

.hero-social {
  display: flex;
  gap: 1rem;
}

.social-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}

.social-link:hover {
  color: var(--text);
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.scroll-hint {
  position: absolute;
  bottom: 2.2rem;
  left: 50%;
  transform: translateX(-50%);
}

.mouse {
  width: 24px;
  height: 38px;
  border: 2px solid var(--text-muted);
  border-radius: 14px;
  display: flex;
  justify-content: center;
  padding-top: 6px;
}

.wheel {
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: var(--text-muted);
  animation: wheel 1.6s ease-in-out infinite;
}

@keyframes wheel {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(12px); opacity: 0; }
}

/* ---------- Sections ---------- */
.section {
  padding: 5.5rem 0;
  position: relative;
}

.section-alt {
  background: var(--bg-alt);
}

.section-title {
  text-align: center;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  margin-bottom: 3rem;
  position: relative;
}

.section-title::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  width: 48px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.6rem;
}

.about-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2rem;
  transition: transform 0.3s, border-color 0.3s;
}

.about-card:hover {
  transform: translateY(-6px);
  border-color: rgba(99, 102, 241, 0.45);
}

.about-icon {
  font-size: 2rem;
  margin-bottom: 0.9rem;
}

.about-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.6rem;
}

.about-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------- Skills ---------- */
.skills-wrap {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.6rem;
}

.skill-group {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.8rem 1.6rem;
}

.skill-group h3 {
  font-size: 1.05rem;
  margin-bottom: 1.4rem;
  color: var(--accent);
}

.skill-item {
  margin-bottom: 1.1rem;
}

.skill-name {
  display: block;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.skill-bar {
  display: block;
  height: 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.skill-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Projects ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.6rem;
}

.project-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}

.project-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

.project-thumb {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.project-body {
  padding: 1.4rem 1.5rem 1.6rem;
}

.project-body h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.project-body p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

.project-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.project-tags span {
  font-size: 0.75rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.14);
  color: #a5b4fc;
}

.project-link {
  color: var(--primary-2);
  font-size: 0.92rem;
  font-weight: 600;
}

.project-link:hover {
  text-decoration: underline;
}

/* ---------- Timeline ---------- */
.timeline {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding-left: 1.5rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--primary), var(--primary-2), transparent);
}

.timeline-item {
  position: relative;
  padding: 0 0 2.2rem 1.6rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -1.5rem;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25);
}

.timeline-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  transition: transform 0.3s, border-color 0.3s;
}

.timeline-card:hover {
  transform: translateX(6px);
  border-color: rgba(99, 102, 241, 0.45);
}

.timeline-date {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(34, 211, 238, 0.1);
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  margin-bottom: 0.7rem;
}

.timeline-card h3 {
  font-size: 1.1rem;
}

.timeline-card h4 {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.timeline-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* ---------- Contact ---------- */
.contact-sub {
  text-align: center;
  color: var(--text-muted);
  margin: -1.5rem 0 2.5rem;
}

.contact-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2rem;
  align-items: start;
}

.contact-form {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.8rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.25s, background 0.25s;
  resize: vertical;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
}

.form-tip {
  margin-top: 0.8rem;
  font-size: 0.9rem;
  color: var(--accent);
  text-align: center;
  min-height: 1.4em;
}

.contact-info {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.8rem;
}

.contact-info h3 {
  font-size: 1.1rem;
  margin-bottom: 1.2rem;
}

.contact-info ul {
  list-style: none;
}

.contact-info li {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}

.contact-note {
  margin-top: 1.2rem;
  color: var(--accent);
  font-size: 0.9rem;
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--card-border);
  padding: 1.8rem 0;
  background: var(--bg-alt);
}

.footer-inner {
  display: flex;
  justify-content: center;
  text-align: center;
}

.footer p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Back to top ---------- */
.back-top {
  position: fixed;
  right: 1.6rem;
  bottom: 1.6rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  z-index: 90;
}

.back-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-top:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
}

/* ---------- Reveal animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

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

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .about-grid,
  .skills-wrap,
  .projects-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-inner {
    flex-direction: column;
    text-align: center;
    gap: 2.2rem;
    padding-top: 1rem;
  }

  .hero-bio {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-actions,
  .hero-social {
    justify-content: center;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .nav-links {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: center;
    gap: 0;
    background: rgba(11, 15, 26, 0.97);
    padding: 1.2rem 0;
    border-bottom: 1px solid var(--card-border);
    transform: translateY(-120%);
    transition: transform 0.35s;
  }

  .nav-links.open {
    transform: translateY(0);
  }

  .nav-links a {
    padding: 0.8rem 0;
    width: 100%;
    text-align: center;
  }

  .nav-toggle {
    display: flex;
  }

  .about-grid,
  .skills-wrap,
  .projects-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .avatar {
    width: 170px;
    height: 170px;
  }
}
