/* ---------- tokens ---------- */
:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 320px;
  --content-w: 880px;
  --radius: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

html[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-soft: #0e141b;
  --surface: #111a22;
  --surface-hover: #16222c;
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .20);
  --text: #e8eef3;
  --text-soft: #b3c0cc;
  --muted: #7d8c9a;
  --accent: #5eead4;
  --accent-soft: rgba(94, 234, 212, .11);
  --on-accent: #06231f;
  --shadow: 0 20px 48px rgba(0, 0, 0, .28);
}

html[data-theme="light"] {
  --bg: #fafaf8;
  --bg-soft: #f2f3f0;
  --surface: #ffffff;
  --surface-hover: #f6f9f8;
  --border: rgba(16, 24, 32, .10);
  --border-strong: rgba(16, 24, 32, .22);
  --text: #1a222a;
  --text-soft: #3c4a55;
  --muted: #697783;
  --accent: #0d8f7c;
  --accent-soft: rgba(13, 143, 124, .09);
  --on-accent: #ffffff;
  --shadow: 0 20px 48px rgba(16, 24, 32, .08);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 12px; z-index: 200;
  padding: 10px 16px; background: var(--accent); color: var(--on-accent); border-radius: 8px;
}
.skip-link:focus { left: 16px; }

.scroll-progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 100; pointer-events: none; }
.scroll-progress span {
  display: block; height: 100%; background: var(--accent);
  transform: scaleX(0); transform-origin: 0 50%; will-change: transform;
}

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); max-width: 1500px; margin: 0 auto; }
.sidebar { border-right: 1px solid var(--border); }
.sidebar-inner {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 56px 44px 36px;
}
main { min-width: 0; }

/* ---------- sidebar ---------- */
.brand { display: block; }
.brand-mark { display: block; font-size: 30px; font-weight: 600; letter-spacing: -.05em; line-height: 1.1; }
.brand-mark .dot { color: var(--accent); }
.brand-sub { display: block; margin-top: 10px; font-size: 12.5px; color: var(--muted); letter-spacing: .01em; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 68px; }
.nav-link {
  position: relative; display: flex; align-items: baseline; gap: 14px;
  padding: 9px 0; font-size: 15px; color: var(--muted);
  transition: color .25s var(--ease), transform .25s var(--ease);
}
.nav-link::before {
  content: ""; position: absolute; left: -20px; top: 50%; width: 0; height: 1px;
  background: var(--accent); transition: width .3s var(--ease);
}
.nav-num { font-family: var(--font-mono); font-size: 11px; color: var(--muted); opacity: .7; }
.nav-link:hover { color: var(--text); transform: translateX(3px); }
.nav-link.active { color: var(--accent); font-weight: 500; }
.nav-link.active::before { width: 12px; }
.nav-link.active .nav-num { color: var(--accent); opacity: 1; }

.sidebar-bottom { margin-top: auto; }
.socials, .contact-socials { display: flex; flex-wrap: wrap; gap: 8px; }
.socials a, .contact-socials a {
  font-size: 12.5px; color: var(--muted); padding: 5px 11px;
  border: 1px solid var(--border); border-radius: 999px;
  transition: color .25s, border-color .25s, background-color .25s, transform .25s var(--ease);
}
.socials a:hover, .contact-socials a:hover {
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px);
}
.sidebar-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; }
.local-time { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 2.4s infinite; }
.theme-toggle {
  width: 34px; height: 34px; display: grid; place-items: center;
  color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 50%;
  transition: color .25s, border-color .25s, transform .3s var(--ease);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(25deg); }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(94, 234, 212, .45); }
  70% { box-shadow: 0 0 0 7px rgba(94, 234, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); }
}

/* ---------- hero ---------- */
.hero { position: relative; min-height: 100vh; display: flex; align-items: center; padding: 80px clamp(28px, 7vw, 96px); overflow: hidden; }
.hero-glow {
  position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background: radial-gradient(420px circle at var(--mx, 70%) var(--my, 30%), var(--accent-soft), transparent 70%);
}
.hero-inner { position: relative; max-width: 820px; width: 100%; }
.availability {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-soft);
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-soft);
}
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 2.4s infinite; }
.hero-title {
  margin: 36px 0 0;
  font-size: clamp(2.6rem, 5.4vw, 4.5rem);
  line-height: 1.18; font-weight: 600; letter-spacing: -.035em;
}
.accent { color: var(--accent); }
.hero-lead { margin-top: 28px; max-width: 600px; font-size: 17px; line-height: 1.9; color: var(--text-soft); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 38px; }
.hero-scroll {
  display: flex; align-items: center; gap: 12px; margin-top: 88px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase;
}
.scroll-line { display: block; width: 42px; height: 1px; background: var(--border-strong); position: relative; overflow: hidden; }
.scroll-line::after {
  content: ""; position: absolute; inset: 0; background: var(--accent);
  transform: translateX(-100%); animation: sweep 2.6s var(--ease) infinite;
}
@keyframes sweep { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 22px; border-radius: 999px; font-size: 14px; font-weight: 500;
  border: 1px solid transparent; background: transparent;
  transition: transform .25s var(--ease), background-color .25s, border-color .25s, color .25s, box-shadow .25s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { box-shadow: 0 10px 24px var(--accent-soft); }
.btn-ghost { color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- sections ---------- */
.section { padding: 108px clamp(28px, 7vw, 96px); border-top: 1px solid var(--border); }
.section > * { max-width: var(--content-w); }
.section-head { margin-bottom: 44px; }
.eyebrow { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.section-head h2 { margin-top: 12px; font-size: clamp(1.9rem, 3.2vw, 2.6rem); font-weight: 600; letter-spacing: -.03em; line-height: 1.25; }
.section-intro { margin-top: -24px; margin-bottom: 36px; color: var(--muted); font-size: 15px; }

/* ---------- about ---------- */
.about-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .9fr); gap: clamp(28px, 5vw, 64px); }
.prose p { color: var(--text-soft); font-size: 15.5px; line-height: 1.95; }
.prose p + p { margin-top: 20px; }
.stack-group + .stack-group { margin-top: 26px; }
.stack-group h3 { font-family: var(--font-mono); font-size: 11.5px; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tags span {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-soft);
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-soft);
}

/* ---------- timeline ---------- */
.timeline-item {
  display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 24px;
  padding: 26px 0; border-bottom: 1px solid var(--border);
}
.timeline-item:first-child { padding-top: 0; }
.timeline-period { font-family: var(--font-mono); font-size: 12px; color: var(--muted); padding-top: 5px; }
.timeline-body { position: relative; padding-left: 22px; border-left: 1px solid var(--border); }
.timeline-body::before {
  content: ""; position: absolute; left: -4.5px; top: 10px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}
.timeline-body h3 { font-size: 17px; font-weight: 500; letter-spacing: -.01em; }
.timeline-body .at { color: var(--muted); font-weight: 400; font-size: 14px; }
.timeline-body p { margin-top: 10px; color: var(--text-soft); font-size: 14.5px; line-height: 1.85; }

/* ---------- projects ---------- */
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.project-card {
  display: flex; flex-direction: column; min-height: 226px; padding: 26px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .3s var(--ease), border-color .3s, background-color .3s, box-shadow .3s;
}
.project-card:hover { transform: translateY(-5px); border-color: var(--accent); background: var(--surface-hover); box-shadow: var(--shadow); }
.card-top { display: flex; align-items: center; justify-content: space-between; }
.card-index { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.card-arrow { font-size: 17px; color: var(--muted); transition: transform .3s var(--ease), color .3s; }
.project-card:hover .card-arrow { transform: translate(3px, -3px); color: var(--accent); }
.project-card h3 { margin-top: 20px; font-size: 19px; font-weight: 500; letter-spacing: -.02em; }
.project-card p { margin-top: 10px; color: var(--text-soft); font-size: 14px; line-height: 1.8; flex: 1; }
.project-card .tags { margin-top: 20px; }

/* ---------- writing ---------- */
.post-list { border-top: 1px solid var(--border); }
.post {
  display: grid; grid-template-columns: 100px minmax(0, 1fr) 64px 20px; gap: 16px; align-items: center;
  padding: 20px 12px; border-bottom: 1px solid var(--border);
  transition: background-color .25s, padding-left .3s var(--ease);
}
.post:hover { background: var(--surface); padding-left: 20px; }
.post time { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.post-title { font-size: 15px; color: var(--text); transition: color .25s; }
.post:hover .post-title { color: var(--accent); }
.post-tag { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); text-align: right; }
.post-arrow { color: var(--muted); font-size: 14px; text-align: right; transition: transform .25s var(--ease), color .25s; }
.post:hover .post-arrow { transform: translate(2px, -2px); color: var(--accent); }

/* ---------- contact ---------- */
.contact-box {
  padding: clamp(30px, 5vw, 56px); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.contact-title { font-size: clamp(2rem, 4.4vw, 3.4rem); font-weight: 600; letter-spacing: -.035em; line-height: 1.25; }
.contact-box p { margin-top: 20px; max-width: 460px; color: var(--text-soft); font-size: 15px; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.contact-socials { margin-top: 28px; }

/* ---------- footer ---------- */
.footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 28px clamp(28px, 7vw, 96px); border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted);
}
.footer-right { display: flex; align-items: center; gap: 24px; }
.footer-right a { transition: color .25s; }
.footer-right a:hover { color: var(--accent); }

/* ---------- reveal + toast ---------- */
.js .reveal { opacity: 0; transform: translateY(22px); transition: opacity .75s var(--ease), transform .75s var(--ease); }
.js .reveal.visible { opacity: 1; transform: none; }
.toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 120;
  padding: 10px 20px; border-radius: 999px; font-size: 13px;
  background: var(--text); color: var(--bg);
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  :root { --sidebar-w: 270px; }
  .sidebar-inner { padding: 48px 30px 32px; }
  .nav { margin-top: 52px; }
  .about-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
  .sidebar-inner { position: static; height: auto; padding: 24px 24px 20px; }
  .brand-mark { font-size: 26px; }
  .brand-sub { margin-top: 6px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
  .nav-link {
    padding: 6px 13px; font-size: 13.5px;
    border: 1px solid var(--border); border-radius: 999px;
  }
  .nav-link::before, .nav-num { display: none; }
  .nav-link:hover { transform: none; }
  .nav-link.active { border-color: var(--accent); background: var(--accent-soft); }
  .sidebar-bottom { margin-top: 18px; }
  .sidebar-meta { margin-top: 14px; }
  .hero { min-height: auto; padding: 88px 24px 72px; }
  .hero-scroll { margin-top: 56px; }
  .section { padding: 76px 24px; }
  .project-grid { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 1fr; gap: 8px; }
  .timeline-period { padding-top: 0; }
  .post { grid-template-columns: 82px minmax(0, 1fr) 18px; gap: 10px; }
  .post-tag { display: none; }
  .footer { padding: 24px; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 2.35rem; }
  .hero-lead { font-size: 15.5px; }
  .desktop-only { display: none; }
  .hero-actions .btn { flex: 1 1 auto; }
  .post { grid-template-columns: 1fr 18px; }
  .post time { grid-column: 1 / -1; }
  .footer-right { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}
