:root {
  --bg: #fafafa;
  --bg-alt: #ffffff;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #5b5b6e;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.08);
  --border: #e6e6ee;
  --shadow: 0 1px 3px rgba(20, 20, 40, 0.06), 0 8px 24px rgba(20, 20, 40, 0.06);
  --radius: 14px;
  --maxw: 1080px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-alt: #141722;
  --surface: #1a1e2c;
  --text: #e8e9f0;
  --text-muted: #9a9db0;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.12);
  --border: #262b3d;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* Language visibility */
.lang-zh, .lang-en { display: none; }
html[data-lang="zh"] .lang-zh { display: block; }
html[data-lang="zh"] span.lang-zh, html[data-lang="zh"] a.lang-zh,
html[data-lang="zh"] b.lang-zh, html[data-lang="zh"] dd.lang-zh { display: inline; }
html[data-lang="zh"] li > span.lang-zh { display: inline; }
html[data-lang="en"] .lang-en { display: block; }
html[data-lang="en"] span.lang-en, html[data-lang="en"] a.lang-en,
html[data-lang="en"] b.lang-en, html[data-lang="en"] dd.lang-en { display: inline; }
html[data-lang="en"] li > span.lang-en { display: inline; }
a.lang-zh, a.lang-en { display: none; }
html[data-lang="zh"] a.lang-zh, html[data-lang="en"] a.lang-en { display: inline-block; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; font-size: 13px; font-weight: 800; letter-spacing: 0.5px;
}
.brand-name em { font-style: normal; color: var(--text-muted); font-weight: 500; font-size: 0.85em; }
.nav-links { display: flex; gap: 20px; margin-left: auto; font-size: 14.5px; }
.nav-links a { color: var(--text-muted); text-decoration: none; transition: color 0.2s; }
.nav-links a:hover { color: var(--accent); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-btn {
  border: 0; background: transparent; color: var(--text-muted);
  font-size: 12.5px; font-weight: 600; padding: 5px 10px; cursor: pointer;
  font-family: inherit;
}
.lang-btn.active { background: var(--accent); color: #fff; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-sun { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ===== Hero ===== */
.hero { padding: 96px 0 72px; position: relative; overflow: hidden; }
.hero::before {
  content: "";
  position: absolute; inset: -40% -20% auto;
  height: 480px;
  background:
    radial-gradient(600px 300px at 20% 40%, var(--accent-soft), transparent 70%),
    radial-gradient(500px 280px at 80% 30%, rgba(124, 58, 237, 0.08), transparent 70%);
  pointer-events: none;
}
.hero-inner { position: relative; }
.hero-kicker { margin: 0 0 8px; color: var(--accent); font-weight: 600; font-size: 15px; }
.hero-title { margin: 0 0 10px; font-size: clamp(38px, 6vw, 58px); line-height: 1.15; letter-spacing: -0.02em; }
.hero-title .latin { font-size: 0.55em; color: var(--text-muted); font-weight: 600; }
.hero-role { margin: 0 0 18px; font-size: clamp(17px, 2.2vw, 21px); font-weight: 600; color: var(--accent); }
.hero-desc { max-width: 640px; color: var(--text-muted); font-size: 16px; margin: 0 0 30px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 52px; }
.btn {
  display: inline-block; padding: 11px 26px; border-radius: 10px;
  font-size: 15px; font-weight: 600; text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px var(--accent-soft); }
.btn-ghost { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 0; }
.hero-stats > div {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.hero-stats dt { font-size: 26px; font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }
.hero-stats dd { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }

/* ===== Sections ===== */
.section { padding: 80px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { margin: 0 0 36px; font-size: clamp(24px, 3.4vw, 32px); letter-spacing: -0.01em; }
.section-title.center { text-align: center; }

/* About */
.about-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 40px; align-items: start; }
.prose p { margin: 0 0 16px; color: var(--text-muted); font-size: 16px; }
.prose p:last-child { margin-bottom: 0; }
.intent-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
}
.intent-card h3 { margin: 0 0 16px; font-size: 17px; }
.intent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.intent-list li { display: grid; gap: 2px; font-size: 14.5px; }
.intent-list span { color: var(--text-muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.intent-list b { font-weight: 600; }

/* Skills */
.skill-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.skill-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 26px; box-shadow: var(--shadow);
}
.skill-wide { grid-column: 1 / -1; }
.skill-card h3 { margin: 0 0 14px; font-size: 16px; }
.skill-card h3 em { font-style: normal; color: var(--text-muted); font-weight: 500; font-size: 0.85em; margin-left: 6px; }
.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  font-size: 13px; font-family: var(--font-mono);
  padding: 4px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid transparent;
}
.tags li.hl { background: var(--accent); color: #fff; font-weight: 600; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 168px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.tl-item { display: grid; grid-template-columns: 150px 1fr; gap: 34px; padding-bottom: 44px; position: relative; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: 163px; top: 8px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
}
.tl-meta { text-align: right; padding-top: 2px; }
.tl-period { font-size: 13px; font-weight: 600; color: var(--text-muted); font-family: var(--font-mono); }
.tl-body h3 { margin: 0 0 12px; font-size: 18px; }
.bullets { margin: 0; padding-left: 18px; display: grid; gap: 10px; }
.bullets li { color: var(--text-muted); font-size: 15px; }
.bullets li::marker { color: var(--accent); }

/* Education & Awards */
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; align-items: start; }
.edu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.edu-list li {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow);
}
.edu-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.edu-head h3 { margin: 0; font-size: 17px; }
.edu-list p { margin: 6px 0 0; color: var(--text-muted); font-size: 14.5px; }
.award-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.award-list li {
  position: relative; padding-left: 26px; font-size: 15px; color: var(--text-muted);
}
.award-list li::before {
  content: "★"; position: absolute; left: 0; top: 0; color: var(--accent); font-size: 14px;
}

/* Contact */
.contact-box { text-align: center; }
.contact-lead { color: var(--text-muted); margin: -16px 0 34px; }
.contact-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.contact-item {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 15px; font-weight: 500;
  box-shadow: var(--shadow); transition: border-color 0.2s, transform 0.15s;
}
.contact-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.contact-item svg { color: var(--accent); flex-shrink: 0; }
.contact-item.static { cursor: default; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-muted); }
.footer-inner p { margin: 0; }

/* Reveal animation */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.revealed { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .nav-links { display: none; }
  .about-grid, .two-col { grid-template-columns: 1fr; gap: 28px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 64px 0 56px; }
  .section { padding: 56px 0; }
  .timeline::before { left: 5px; }
  .tl-item { grid-template-columns: 1fr; gap: 6px; padding-left: 28px; padding-bottom: 36px; }
  .tl-item::before { left: 0; top: 6px; }
  .tl-meta { text-align: left; }
  .skill-grid { grid-template-columns: 1fr; }
  .footer-inner { justify-content: center; text-align: center; }
}
@media (max-width: 480px) {
  .container { padding: 0 18px; }
  .hero-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .contact-grid { flex-direction: column; align-items: stretch; }
}

/* ===== Blog list ===== */
.blog-toolbar { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: -20px 0 28px; }
.blog-lead { color: var(--text-muted); margin: 0; }
.rss-link { font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: none; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; }
.rss-link:hover { border-color: var(--accent); }
.post-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.post-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 26px; box-shadow: var(--shadow);
  transition: border-color 0.2s, transform 0.15s;
}
.post-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.post-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.post-card time { font-size: 12.5px; font-family: var(--font-mono); color: var(--text-muted); }
.post-card-title { display: block; font-size: 19px; font-weight: 700; color: var(--text); text-decoration: none; margin: 6px 0 4px; }
.post-card-title:hover { color: var(--accent); }
.post-card-excerpt { margin: 4px 0 0; color: var(--text-muted); font-size: 14.5px; }
.post-tags em { font-style: normal; font-size: 12.5px; color: var(--accent); margin-right: 8px; }
.blog-empty { color: var(--text-muted); text-align: center; padding: 40px 0; }
.blog-more { text-align: center; margin: 32px 0 0; }
.tags-lg li { font-size: 14px; padding: 6px 16px; }
.tags-lg { justify-content: flex-start; }

/* ===== Post page ===== */
.post { max-width: 780px; margin: 0 auto; padding: 64px 24px 80px; }
.post-back { display: inline-block; font-size: 13.5px; color: var(--text-muted); text-decoration: none; margin-bottom: 20px; }
.post-back:hover { color: var(--accent); }
.post-header h1 { margin: 0 0 10px; font-size: clamp(26px, 4.5vw, 38px); line-height: 1.25; letter-spacing: -0.01em; }
.post-meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; color: var(--text-muted); font-size: 13.5px; margin: 0 0 36px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.post-meta time { font-family: var(--font-mono); }
.post-content { font-size: 16.5px; }
.post-content h2 { margin: 40px 0 14px; font-size: 24px; }
.post-content h3 { margin: 30px 0 10px; font-size: 19px; }
.post-content p { margin: 0 0 18px; }
.post-content ul, .post-content ol { margin: 0 0 18px; padding-left: 24px; }
.post-content li { margin-bottom: 6px; }
.post-content a { color: var(--accent); }
.post-content blockquote { margin: 0 0 18px; padding: 12px 20px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; color: var(--text-muted); }
.post-content blockquote p { margin: 0; }
.post-content img { max-width: 100%; border-radius: 10px; }
.post-content table { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: 15px; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.post-content th { background: var(--bg-alt); }
.post-content code { font-family: var(--font-mono); font-size: 0.88em; background: var(--accent-soft); border-radius: 5px; padding: 2px 6px; }
.post-content pre { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; overflow-x: auto; margin: 0 0 22px; }
.post-content pre code { background: transparent; padding: 0; font-size: 13.5px; line-height: 1.6; }
.post-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border); font-size: 14.5px; }
.post-nav a { color: var(--accent); text-decoration: none; max-width: 46%; }
.post-nav a:hover { text-decoration: underline; }
.highlight .c, .highlight .cm, .highlight .c1 { color: #7f848e; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn { color: #c678dd; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .se { color: #98c379; }
.highlight .nf, .highlight .fm { color: #61afef; }
.highlight .mi, .highlight .m { color: #d19a66; }
.highlight .nt, .highlight .nc { color: #e06c75; }
[data-theme="dark"] .highlight { background: transparent; }

@media (max-width: 860px) {
  .post { padding-top: 44px; }
  .blog-toolbar { flex-direction: column; align-items: flex-start; }
}
