:root {
  --bg: #ffffff;
  --bg-soft: #f7f5f2;
  --bg-dark: #1c1917;
  --text: #1c1917;
  --muted: #57534e;
  --accent: #c2410c;
  --accent-strong: #9a3412;
  --border: #e7e5e4;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(28, 25, 23, 0.08);
  --maxw: 1080px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Language toggle: show only the active language */
.lang-zh [data-en] { display: none !important; }
.lang-en [data-zh] { display: none !important; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text);
}
.brand-logo { font-size: 1.4rem; }
.nav { display: flex; align-items: center; gap: 18px; }
.nav-link {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}
.nav-link:hover { color: var(--accent); }
.lang-toggle {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font);
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* Hero */
.hero {
  background: radial-gradient(1200px 500px at 70% -10%, #fde9d9 0%, transparent 60%),
    var(--bg-dark);
  color: #fafaf9;
  padding: 80px 0 72px;
}
.hero-inner { text-align: center; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  color: #fdba74;
  margin: 0 0 14px;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.15;
  margin: 0 0 18px;
  font-weight: 800;
}
.hero-sub {
  max-width: 640px;
  margin: 0 auto 28px;
  color: #e7e5e4;
  font-size: 1.08rem;
}
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; color: #fafaf9; border: 1px solid rgba(255,255,255,0.3); }
.btn-ghost:hover { border-color: #fdba74; }
.btn.block { display: block; margin-top: 10px; text-align: center; }

.code-card {
  max-width: 460px;
  margin: 40px auto 0;
  background: #0c0a09;
  border: 1px solid #292524;
  border-radius: var(--radius);
  padding: 20px 22px;
  text-align: left;
  color: #fde9d9;
  font-family: var(--mono);
  font-size: 0.95rem;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.hero-cover {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
  margin: 44px auto 0;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid #292524;
}

/* Sections */
.section { padding: 72px 0; }
.section-alt { background: var(--bg-soft); }
.section-title {
  text-align: center;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  margin: 0 0 36px;
}
.section-title.left { text-align: left; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: var(--shadow);
}
.card-icon { font-size: 1.8rem; margin-bottom: 10px; }
.card h3 { margin: 0 0 8px; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.97rem; }

.chapter-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.chapter-grid li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.ch-num {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1rem;
}
.ch-name { font-weight: 500; }

/* About */
.about-inner {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 40px;
  align-items: start;
}
.about-inner p { color: var(--muted); }
.meta-list { list-style: none; padding: 0; margin: 18px 0 0; }
.meta-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.95rem;
}
.cta-box {
  background: var(--bg-dark);
  color: #fafaf9;
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.cta-box h3 { margin: 0 0 8px; font-size: 1.3rem; }
.cta-box p { color: #e7e5e4; margin: 0 0 8px; }

/* Footer */
.site-footer {
  background: var(--bg-dark);
  color: #a8a29e;
  padding: 36px 0;
}
.footer-inner { text-align: center; }
.footer-brand { color: #fafaf9; font-weight: 700; margin: 0 0 12px; }
.footer-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.footer-links a { color: #d6d3d1; text-decoration: none; font-size: 0.92rem; }
.footer-links a:hover { color: #fdba74; }
.footer-copy { margin: 0; font-size: 0.85rem; }

/* Focus visibility (a11y) */
a:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .about-inner { grid-template-columns: 1fr; }
  .nav { gap: 12px; }
  .nav-link { display: none; }
}
