:root {
  --bg: #FAF9F5;
  --bg-soft: #F0EEE6;
  --text: #3D3929;
  --text-muted: #83827D;
  --accent: #D97757;
  --accent-dark: #C05B3F;
  --border: #E5E3DA;
  --card: #FFFFFF;
  --nav-bg: rgba(250, 249, 245, 0.85);
}
html[data-theme="dark"] {
  --bg: #262624;
  --bg-soft: #30302E;
  --text: #F0EEE6;
  --text-muted: #A9A79E;
  --accent: #D97757;
  --accent-dark: #E68A6C;
  --border: #3E3E3A;
  --card: #30302E;
  --nav-bg: rgba(38, 38, 36, 0.85);
}
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body, .card, .contact-item, .btn-ghost, nav, .tag, .theme-switch {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .serif {
  font-family: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  font-weight: 500;
  letter-spacing: -0.01em;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

.container { max-width: 720px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

/* Loader */
#loader {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  transition: opacity .4s ease, visibility .4s ease;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-mark {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #FAF9F5;
  display: flex; align-items: center; justify-content: center;
  font-family: Georgia, serif; font-size: 30px;
  animation: loader-pop .5s cubic-bezier(.34,1.4,.64,1) both;
}
@keyframes loader-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.loader-dots { display: flex; gap: 7px; }
.loader-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: loader-bounce 1s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { animation-delay: .15s; }
.loader-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes loader-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* 入场动画：仅在 JS 可用时应用，避免无 JS 内容不可见 */
html.js .hero > *,
html.js section {
  opacity: 0;
  transform: translateY(16px);
}
html.js.loaded .hero > *,
html.js.loaded section {
  animation: rise .6s ease forwards;
}
html.js.loaded .hero > *:nth-child(1) { animation-delay: .05s; }
html.js.loaded .hero > *:nth-child(2) { animation-delay: .15s; }
html.js.loaded .hero > *:nth-child(3) { animation-delay: .25s; }
html.js.loaded .hero > *:nth-child(4) { animation-delay: .35s; }
html.js.loaded section:nth-of-type(1) { animation-delay: .45s; }
html.js.loaded section:nth-of-type(2) { animation-delay: .55s; }
html.js.loaded section:nth-of-type(3) { animation-delay: .65s; }
@keyframes rise {
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html.js .hero > *, html.js section { opacity: 1; transform: none; animation: none; }
  #loader { display: none; }
}

/* Nav */
nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 720px; margin: 0 auto; padding: 16px 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-family: Georgia, serif; font-size: 18px; color: var(--text);
}
.logo-mark {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.nav-links { display: flex; gap: 24px; font-size: 14px; align-items: center; }
.nav-links a { color: var(--text-muted); white-space: nowrap; }
.nav-links a:hover { color: var(--text); }

/* Theme switch */
.theme-switch {
  display: flex; align-items: center; gap: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px;
}
.theme-switch button {
  width: 26px; height: 26px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s ease;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button.active {
  background: var(--accent);
  color: #fff;
}
/* 手机端：折叠为单个按钮，点击竖向展开 */
@media (max-width: 600px) {
  .nav-links { gap: 14px; }
  .theme-switch {
    position: relative;
    width: 34px; height: 34px;
    justify-content: center;
  }
  .theme-switch button {
    position: absolute;
    top: 3px; left: 3px;
    opacity: 0;
    transform: translateY(-6px) scale(0.7);
    pointer-events: none;
    transition: transform .25s cubic-bezier(.34,1.4,.64,1), opacity .2s ease;
  }
  .theme-switch button.active {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  .theme-switch.expanded button {
    opacity: 1;
    pointer-events: auto;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  }
  .theme-switch.expanded button.active {
    background: var(--accent);
    border-color: var(--accent);
  }
  /* 当前选中项始终占据第一位（圆圈处），其余按序竖向排列 */
  .theme-switch.expanded button[data-pos="0"] { transform: translateY(0); }
  .theme-switch.expanded button[data-pos="1"] { transform: translateY(32px); }
  .theme-switch.expanded button[data-pos="2"] { transform: translateY(64px); }
}

/* Hero */
.hero { padding-top: 96px; padding-bottom: 72px; }
.hero .greeting {
  display: inline-block;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px 14px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.hero .greeting .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 7px;
  animation: pulse 2s infinite;
}
@keyframes pulse { 50% { opacity: 0.4; } }
.hero h1 {
  font-size: clamp(36px, 6vw, 52px);
  line-height: 1.2;
  margin-bottom: 20px;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p.lead {
  font-size: 18px; color: var(--text-muted); max-width: 560px;
  margin-bottom: 32px;
}
.cursor {
  display: inline-block; width: 3px; height: 1em;
  background: var(--accent); vertical-align: text-bottom;
  animation: blink 1.1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 10px 22px; border-radius: 10px;
  font-size: 15px; transition: all .15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; transform: translateY(-1px); }
.btn-ghost { border: 1px solid var(--border); color: var(--text); background: var(--card); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Sections */
section { padding-top: 56px; padding-bottom: 56px; border-top: 1px solid var(--border); scroll-margin-top: 61px; }
section h2 {
  font-size: 26px; margin-bottom: 28px;
  display: flex; align-items: center; gap: 12px;
}
section h2::before {
  content: ""; width: 20px; height: 3px; border-radius: 2px;
  background: var(--accent);
}

/* About */
.about p { color: var(--text); margin-bottom: 14px; max-width: 620px; }
.about p + p { color: var(--text-muted); }

/* Cards */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; } }
.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  color: var(--text);
  transition: all .15s ease;
}
a.card:hover { color: var(--text); }
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(217, 119, 87, 0.08);
  transform: translateY(-2px);
}
.card h3 { font-size: 17px; margin-bottom: 8px; }
.card p { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 12px; padding: 2px 10px; border-radius: 100px;
  background: var(--bg-soft); color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Contact */
.contact-list { display: flex; flex-direction: column; gap: 10px; }
.contact-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text);
  transition: all .15s ease;
}
.contact-item:hover { border-color: var(--accent); color: var(--accent); }
.contact-item .label { color: var(--text-muted); font-size: 13px; min-width: 64px; }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px 48px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
footer .serif { font-style: italic; margin-bottom: 6px; }
