:root {
  --bg: #ffffff; --fg: #1f2328; --muted: #59636e; --line: #d1d9e0;
  --accent: #0b5cad; --code-bg: #f6f8fa; --btn-bg: #ffffff; --quote: #eef4fb;
  --warn-line: #bf8700;
  --a-note: #0969da; --a-tip: #1a7f37; --a-important: #8250df; --a-warning: #9a6700; --a-caution: #cf222e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --fg: #e6edf3; --muted: #9198a1; --line: #30363d;
    --accent: #58a6ff; --code-bg: #161b22; --btn-bg: #21262d; --quote: #121d2f;
    --warn-line: #d29922;
    --a-note: #58a6ff; --a-tip: #3fb950; --a-important: #ab7df8; --a-warning: #d29922; --a-caution: #f85149;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --fg: #e6edf3; --muted: #9198a1; --line: #30363d;
  --accent: #58a6ff; --code-bg: #161b22; --btn-bg: #21262d; --quote: #121d2f;
  --warn-line: #d29922;
  --a-note: #58a6ff; --a-tip: #3fb950; --a-important: #ab7df8; --a-warning: #d29922; --a-caution: #f85149;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.7 -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 24px 16px 80px; }
header.bar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--muted);
}
header.bar a { color: var(--accent); text-decoration: none; }
header.bar nav.units { display: flex; flex-wrap: wrap; gap: 4px 16px; }
header.bar nav.units a { padding: 2px 0; border-bottom: 2px solid transparent; }
header.bar nav.units a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
header.bar .tools { display: flex; align-items: center; gap: 12px; }
header.bar button {
  background: var(--btn-bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit;
}
h1 { font-size: 1.9rem; line-height: 1.3; margin: 8px 0 12px; }
h2 { font-size: 1.4rem; margin: 2.2em 0 0.6em; padding-top: 0.4em; border-top: 1px solid var(--line); }
h3 { font-size: 1.2rem; margin: 1.6em 0 0.5em; }
h4 { font-size: 1.05rem; margin: 1.3em 0 0.4em; }
.sub { margin-left: 0.6rem; padding-left: 1rem; border-left: 2px solid var(--line); }
.sub > :first-child { margin-top: 0.4em; }
h1 + p, h2 + p { margin-top: 0.4em; }
a { color: var(--accent); }
p, li { overflow-wrap: anywhere; }
code {
  font: 0.92em ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 0.1em 0.35em;
}
.codewrap { position: relative; margin: 1em 0; }
pre {
  margin: 0; padding: 14px 16px; background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 8px; overflow-x: auto; line-height: 1.5;
}
pre code { background: none; border: 0; padding: 0; font-size: 0.9rem; white-space: pre; }
.copy {
  position: absolute; top: 8px; right: 8px; font-size: 12px; padding: 3px 9px;
  background: var(--btn-bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer; opacity: 0.85;
}
.copy:hover { opacity: 1; }
table { border-collapse: collapse; width: 100%; margin: 1em 0; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
th { background: var(--code-bg); }
blockquote {
  margin: 1em 0; padding: 8px 16px; background: var(--quote);
  border-left: 4px solid var(--warn-line); border-radius: 0 6px 6px 0;
}
blockquote p { margin: 0.4em 0; }
nav.toc {
  margin: 18px 0 8px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--code-bg); font-size: 15px;
}
nav.toc strong { display: block; margin-bottom: 4px; }
nav.toc ol { margin: 0; padding-left: 0; list-style: none; columns: 2; column-gap: 28px; }
nav.toc li { break-inside: avoid; }
@media (max-width: 560px) { nav.toc ol { columns: 1; } }
nav.toc a { text-decoration: none; }
nav.pager {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 3em; padding-top: 1em; border-top: 1px solid var(--line);
}
nav.pager a {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; background: var(--code-bg);
}
nav.pager .next { margin-left: auto; text-align: right; }
footer { margin-top: 2em; padding-top: 1em; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
#status { color: var(--muted); }

blockquote.alert { background: var(--code-bg); border-left-width: 4px; }
blockquote.alert .alert-title { font-weight: 700; margin-bottom: 2px; }
blockquote.alert-note { border-left-color: var(--a-note); } blockquote.alert-note .alert-title { color: var(--a-note); }
blockquote.alert-tip { border-left-color: var(--a-tip); } blockquote.alert-tip .alert-title { color: var(--a-tip); }
blockquote.alert-important { border-left-color: var(--a-important); } blockquote.alert-important .alert-title { color: var(--a-important); }
blockquote.alert-warning { border-left-color: var(--a-warning); } blockquote.alert-warning .alert-title { color: var(--a-warning); }
blockquote.alert-caution { border-left-color: var(--a-caution); } blockquote.alert-caution .alert-title { color: var(--a-caution); }
details { margin: 1em 0; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--code-bg); }
details > summary { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

hr + h2 { border-top: 0; margin-top: 0.4em; padding-top: 0; }

#content img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; margin: 0.6em 0; }
