:root {
  --bg: #faf8f4;
  --bg-alt: #f1ede4;
  --surface: #ffffff;
  --text: #1d1b18;
  --muted: #5f5a52;
  --line: #e2ddd2;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fbe8dc;
  --good: #15803d;
  --bad: #b91c1c;
  --code-bg: #1e1f24;
  --radius: 14px;
  --font: 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15140f; --bg-alt: #1c1b16; --surface: #22211b; --text: #ece8df; --muted: #a9a397;
    --line: #34322a; --accent: #fb923c; --accent-ink: #1a0f06; --accent-soft: #3a2414;
    --good: #4ade80; --bad: #f87171; --code-bg: #0f0f12; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15140f; --bg-alt: #1c1b16; --surface: #22211b; --text: #ece8df; --muted: #a9a397;
  --line: #34322a; --accent: #fb923c; --accent-ink: #1a0f06; --accent-soft: #3a2414;
  --good: #4ade80; --bad: #f87171; --code-bg: #0f0f12; color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.75; font-size: 17px; }
a { color: var(--accent); }
img { max-width: 100%; height: auto; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 99; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* header / footer */
.site-head { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.head-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand-mark { font-family: var(--mono); font-size: 12px; font-weight: 600; background: var(--text); color: var(--bg); padding: 3px 7px; border-radius: 6px; letter-spacing: .04em; }
.head-nav { display: flex; gap: 4px; }
.head-nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 15px; white-space: nowrap; }
.head-nav a:hover { color: var(--text); background: var(--bg-alt); }
@media (max-width: 420px) { .brand > span:last-child { display: none; } }
.site-foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding: 28px 0 40px; margin-top: 40px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1.5px solid var(--text); color: var(--text); text-decoration: none; font-weight: 700; font-size: 16px; }
.btn:hover { background: var(--bg-alt); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }

/* home */
.eyebrow { font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
.hero { padding: 64px 0 56px; border-bottom: 1px solid var(--line); }
.hero h1 { font-size: clamp(34px, 7vw, 64px); line-height: 1.15; font-weight: 900; letter-spacing: -.01em; margin: 0 0 20px; }
.hero-sub { font-size: clamp(17px, 2.2vw, 20px); color: var(--muted); max-width: 36em; margin: 0 0 28px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 44px; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0; }
@media (min-width: 760px) { .facts { grid-template-columns: repeat(4, 1fr); } }
.facts div { background: var(--surface); padding: 16px 18px; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 700; }

.section { padding: 64px 0; }
.section.alt { background: var(--bg-alt); }
.section h2 { font-size: clamp(26px, 4vw, 36px); line-height: 1.25; margin: 0 0 28px; }
.section h2.mt { margin-top: 48px; }
.more { margin: 24px 0 0; font-weight: 700; }

.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 0 0 22px 20px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.timeline li.break::before { background: var(--line); }
.timeline .t { font-family: var(--mono); font-weight: 600; color: var(--muted); padding-top: 2px; }
.timeline h3 { margin: 0; font-size: 18px; }
.timeline p { margin: 2px 0 0; color: var(--muted); font-size: 16px; }
.timeline li.break h3 { color: var(--muted); font-weight: 500; }

.five { list-style: none; counter-reset: f; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 860px) { .five { grid-template-columns: repeat(2, 1fr); } }
.five li { counter-increment: f; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 18px 64px; position: relative; display: flex; flex-direction: column; gap: 6px; }
.five li::before { content: counter(f); position: absolute; left: 20px; top: 16px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 900; display: grid; place-items: center; }
.five b { font-size: 18px; }
.five span { font-size: 15px; line-height: 1.6; }
.five .bad { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--bad); }
.five .bad::before { content: '✗ '; color: var(--bad); text-decoration: none; display: inline-block; }
.five .good::before { content: '✓ '; color: var(--good); font-weight: 700; }

.cards { display: grid; gap: 16px; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-kicker { font-size: 13px; color: var(--muted); }
.card h3 { margin: 4px 0 6px; font-size: 22px; }
.card p { margin: 0 0 14px; color: var(--muted); font-size: 16px; flex: 1; }
.card-go { color: var(--accent); font-weight: 700; font-size: 15px; }

.demos { display: grid; gap: 24px; }
@media (min-width: 860px) { .demos { grid-template-columns: repeat(2, 1fr); } }
.demo { margin: 0; }
.demo-frame { display: block; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; position: relative; }
.demo-frame img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.demo-frame:hover img { transform: scale(1.02); }
.demo figcaption { margin-top: 12px; font-size: 16px; color: var(--muted); }
.demo figcaption b { color: var(--text); margin-right: 6px; }
.demo figcaption a { margin-left: 6px; font-weight: 700; white-space: nowrap; }

/* docs */
.doc-layout { display: grid; gap: 24px; padding-top: 32px; }
@media (min-width: 1000px) { .doc-layout { grid-template-columns: 240px minmax(0, 1fr); gap: 48px; } }
.toc { font-size: 14px; }
.toc details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.toc summary { cursor: pointer; font-weight: 700; }
.toc ol { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow: auto; }
.toc li a { display: block; color: var(--muted); text-decoration: none; padding: 4px 0; line-height: 1.45; }
.toc li a:hover, .toc li a.on { color: var(--accent); }
.toc li.l3 a { padding-left: 14px; font-size: 13px; }
@media (min-width: 1000px) {
  .toc { position: sticky; top: 84px; align-self: start; }
  .toc details { background: none; border: 0; padding: 0; }
  .toc ol { max-height: calc(100vh - 140px); }
}
.doc { min-width: 0; max-width: 780px; }
.crumb { margin: 0 0 4px; font-size: 14px; }
.crumb a { color: var(--muted); }
.doc > h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.25; margin: 0 0 10px; }
.lede { color: var(--muted); font-size: 18px; margin: 0 0 18px; }
.doc-actions { margin-bottom: 18px; }

.prose { overflow-wrap: anywhere; }
.prose h2 { font-size: 26px; line-height: 1.35; margin: 48px 0 14px; padding-top: 18px; border-top: 1px solid var(--line); }
.prose > h2:first-child { border-top: 0; margin-top: 16px; padding-top: 0; }
.prose h3 { font-size: 21px; margin: 32px 0 10px; }
.prose h4 { font-size: 18px; margin: 24px 0 8px; }
.prose h2, .prose h3, .prose h4 { position: relative; }
.anchor { position: absolute; left: -1em; opacity: 0; color: var(--muted); text-decoration: none; font-weight: 400; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor { opacity: 1; }
.prose hr { display: none; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 4px 0; }
.prose blockquote { margin: 16px 0; padding: 4px 18px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.prose :not(pre) > code { font-family: var(--mono); font-size: .88em; background: var(--bg-alt); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: 10px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; }
.prose th, .prose td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--bg-alt); }
.prose tr:last-child td { border-bottom: 0; }
.code { position: relative; margin: 14px 0 20px; }
.code pre { margin: 0; background: var(--code-bg); color: #e6e6e6; border-radius: 10px; padding: 16px 18px; overflow-x: auto; font-size: 14px; line-height: 1.6; max-height: 560px; }
.code pre code { font-family: var(--mono); background: none; padding: 0; white-space: pre; }
.code pre code.nohighlight { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font); font-size: 15px; }
.copy { position: absolute; top: 8px; right: 8px; min-height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid #ffffff33; background: #ffffff14; color: #ddd; font: inherit; font-size: 13px; cursor: pointer; }
.copy:hover { background: #ffffff26; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 56px 0 0; }
.pager a { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; text-decoration: none; color: var(--text); font-weight: 700; background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.pager .next { text-align: right; }

.notfound { padding: 96px 16px; text-align: center; }
.notfound h1 { font-size: 36px; margin: 0 0 8px; }
.notfound p { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .card { transition: none; } }
