:root {
  --bg: #283c28;
  --bg-post: #28283c;
  --card: #3c503c;
  --card-hover: #285028;
  --accent: #3cb371;
  --accent-soft: #b4ffb4;
  --text: #fff;
  --muted: #c4d4c4;
  --line: #ffffff26;
  --serif: Newsreader, "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --brush-zh: "Zhi Mang Xing", "STXingkai", "STKaiti", "KaiTi", cursive;
  --brush-en: "Dancing Script", "Snell Roundhand", "Segoe Script", cursive;
  --mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 3rem;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  line-height: 1.6;
}
body.post-page { background-color: var(--bg-post); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 2.25rem; line-height: 1.25; margin: 1.5rem 0 1rem; }
h2 { margin: 2rem 0 1rem; }

/* ---------- nav ---------- */
.site-nav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4rem;
  padding: 0 1rem;
  background: linear-gradient(to top, #0000, #000);
}
.site-nav a { color: #fff; font-weight: 700; }
.site-nav a:hover { text-decoration: none; opacity: 0.8; }
.site-title h2 { margin: 0; font-weight: 400; font-size: 1.75rem; white-space: nowrap; }
.site-title .brush-zh { font-family: var(--brush-zh); font-size: 2rem; }
.site-title .brush-en { font-family: var(--brush-en); font-weight: 700; }
.nav-right { display: flex; align-items: center; gap: 1.5rem; white-space: nowrap; }

.lang { position: relative; }
.lang button {
  background: none;
  border: 0;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
#langToggle { display: flex; align-items: center; gap: 0.15rem; padding: 0.25rem 0; }
#langSelect {
  position: absolute;
  right: 0;
  top: 2.5rem;
  display: grid;
  gap: 0.15rem;
  min-width: 7rem;
  padding: 0.4rem;
  background: #000d;
  animation: fadeInFromTop 0.5s ease-out;
}
#langSelect button { text-align: left; padding: 0.35rem 0.6rem; }
#langSelect button:hover { background: var(--card); }
#langSelect button.active { color: var(--accent); }
[hidden] { display: none !important; }

@keyframes fadeInFromTop {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- layout ---------- */
main {
  margin: 0 max(1rem, 10vw);
  animation: fadeInFromLeft 1s ease-out;
}
@keyframes fadeInFromLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}
.site-footer { margin: 4rem max(1rem, 10vw) 0; color: #ffffff80; font-size: 0.9rem; }

/* ---------- home ---------- */
.contacts { margin: -0.25rem 0 1rem; }
.shortcuts { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1.5rem 0 0.5rem; }
.shortcut {
  display: inline-flex;
  align-items: center;
  width: 17rem;
  max-width: 100%;
  height: 4rem;
  padding: 0 1rem;
  background-color: var(--card);
  color: #fff;
  font-size: 1.25rem;
  transition: background-color 0.2s;
}
.shortcut:hover { background-color: var(--card-hover); text-decoration: none; }

#edu { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 0; list-style: disc; }
#edu > li > h4, #edu > li > p { margin: 0.5rem; }
#edu > li > p { font-size: 0.75rem; }
#edu > li > p:first-child { font-size: 1rem; }

#post-list {
  display: flex;
  gap: 1rem;
  height: 8rem;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 80%, transparent 100%);
  mask-image: linear-gradient(to right, #000 0%, #000 80%, transparent 100%);
}
#post-list > li {
  position: relative;
  flex: 0 0 auto;
  width: 18rem;
  max-width: 80vw;
  background-color: var(--card);
  transition: background-color 0.2s;
}
#post-list > li > a {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0 1rem 1rem;
  color: #fff;
  font-size: 1.25rem;
}
#post-list > li > a > p { margin: 1rem 0 0; line-height: 1.35; }
#post-list > li > a > span { color: var(--accent); text-align: right; font-size: 1rem; }

#material-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 18rem));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
#material-list > li { position: relative; height: 4rem; background-color: var(--card); transition: background-color 0.2s; }
#material-list > li > a {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  color: #fff;
  font-size: 1.25rem;
}
#material-list .count { color: var(--accent); font-size: 1rem; }
#post-list > li:hover, #material-list > li:hover { background-color: var(--card-hover); }
#post-list > li > a:hover, #material-list > li > a:hover { text-decoration: none; }

/* ---------- timeline ---------- */
.timeline-window {
  position: relative;
  margin: 2rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  background-color: #141e1499;
}
.timeline-track { position: relative; min-width: 100%; }
.timeline-axis { position: absolute; left: 0; right: 0; bottom: 3.5rem; height: 2px; background-color: #fff; }
.timeline-mark { position: absolute; bottom: 3.5rem; width: 2px; height: 0.6rem; background: #fff; transform: translateX(-50%); }
.timeline-tick { position: absolute; bottom: 1.6rem; transform: translateX(-50%); font-size: 0.9rem; white-space: nowrap; }
.timeline-now {
  position: absolute;
  top: 0;
  bottom: 3.5rem;
  border-left: 2px dashed var(--accent-soft);
  opacity: 0.7;
}
.timeline-now span {
  position: absolute;
  bottom: -3.25rem;
  left: 0.3rem;
  color: var(--accent-soft);
  font-size: 0.8rem;
  white-space: nowrap;
}
.timeline-interval, .timeline-point {
  position: absolute;
  overflow: hidden;
  padding: 0.8rem 1rem;
  line-height: 1.3;
}
.timeline-interval small, .timeline-point small, .exp-list p { display: block; margin-top: 0.3rem; color: var(--muted); font-size: 0.85rem; }
.timeline-interval time, .timeline-point time { display: block; margin-bottom: 0.4rem; color: var(--accent-soft); font-weight: 700; }
.timeline-shade-1 { background-color: #306c46bf; }
.timeline-shade-2 { background-color: #44844ebf; }
.timeline-shade-3 { background-color: #245c40bf; }
.timeline-shade-4 { background-color: #58965abf; }
.timeline-point { border-left: 2px solid var(--accent-soft); background: #141e14b3; }
.timeline-dot {
  position: absolute;
  bottom: calc(3.5rem - 5px);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-soft);
  transform: translateX(-50%);
}

.exp-list { list-style: none; padding: 0; margin: 0; }
.exp-list > li { display: flex; gap: 1.5rem; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.exp-list time { flex: 0 0 11rem; color: var(--accent-soft); font-variant-numeric: tabular-nums; }
.exp-list p { margin-bottom: 0; }

/* ---------- category ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.chip { display: inline-flex; gap: 0.5rem; padding: 0.3rem 0.85rem; background: var(--card); color: #fff; transition: background-color 0.2s; }
.chip span { color: var(--accent); }
.chip:hover { background: var(--card-hover); text-decoration: none; }
.chip.active { background: var(--accent); color: #10261a; }
.chip.active span { color: #10261a; }

.post-rows { list-style: none; padding: 0; margin: 0; }
.post-rows > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1.25rem; padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.post-rows time { min-width: 6.5rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.post-rows a { color: #fff; font-size: 1.15rem; }
.post-rows .tag { margin-left: auto; color: var(--accent); font-size: 0.9rem; }

/* ---------- post ---------- */
.post { max-width: 48rem; }
.post-meta { margin-top: -0.5rem; color: var(--muted); }
.notice { padding: 0.5rem 1rem; background: #ffffff14; color: var(--muted); }
.post-body { font-size: 1.1rem; }
.post-body img { max-width: 100%; }
.post-body blockquote { margin: 1rem 0; padding: 0.25rem 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.post-body code { font-family: var(--mono); font-size: 0.88em; }
.post-body :not(pre) > code { padding: 0.1em 0.35em; background: #ffffff1f; border-radius: 3px; }
.post-body pre { margin: 1rem 0; padding: 0; background: #141428; overflow-x: auto; }
.post-body pre code, .md-fallback { display: block; padding: 1rem; line-height: 1.5; }
.post-body pre code.hljs { background: transparent; padding: 1rem; }
.md-fallback { white-space: pre-wrap; background: #141428; font-family: var(--mono); }
.post-body table { border-collapse: collapse; display: block; overflow-x: auto; }
.post-body th, .post-body td { border: 1px solid #fff; padding: 0.5rem; text-align: left; }
.post-body thead { background-color: #3c3c50; }
.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.post-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: start;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.post-nav > span:last-child { text-align: right; }
.post-nav small { color: var(--muted); }

/* ---------- resume ---------- */
.resume-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.button {
  display: inline-flex;
  padding: 0.5rem 1rem;
  border: none;
  background-color: var(--card);
  color: #fff;
  font: inherit;
  cursor: pointer;
  transition: background-color 0.2s;
}
.button:hover { background-color: var(--card-hover); }
.skills { padding-left: 1.25rem; }
.skills li { margin: 0.3rem 0; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .site-nav { height: auto; min-height: 4rem; flex-wrap: wrap; padding: 0.5rem 1rem; }
  .nav-right { gap: 1rem; }
  h1 { font-size: 1.9rem; }
  .exp-list > li { flex-direction: column; gap: 0.25rem; }
  .exp-list time { flex: none; }
  .post-rows .tag { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  main, #langSelect { animation: none; }
}

/* ---------- print (简历导出 PDF) ---------- */
@media print {
  body, body.post-page { background: #fff; color: #000; padding: 0; }
  .site-nav, .site-footer, .no-print { display: none !important; }
  main { margin: 0; animation: none; }
  a { color: #000; }
  .exp-list > li { border-color: #ccc; }
  .exp-list time, .exp-list p { color: #333; }
}
