:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #5f6368;
  --border: #e3e3e0;
  --accent: #2458c6;
  --code-bg: #f3f3f1;
  --pitfall: #b3401e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314;
    --surface: #1b1c1e;
    --text: #e8e8e6;
    --muted: #a0a3a8;
    --border: #2e3033;
    --accent: #7fa7ff;
    --code-bg: #232427;
    --pitfall: #ff8a65;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", sans-serif;
}

.top, main, footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-top: 8px;
  padding-bottom: 8px;
}

.top-row { display: flex; justify-content: space-between; align-items: center; }
.home { color: var(--muted); text-decoration: none; font-size: 14px; }

.lang {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

h1 { font-size: 1.5rem; margin: 4px 0 0; }
.subtitle { margin: 0 0 8px; color: var(--muted); }

#search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

#toc { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 14px; }
#toc a { color: var(--accent); text-decoration: none; }

section { scroll-margin-top: 190px; }
h2 { font-size: 1.25rem; margin: 28px 0 8px; border-bottom: 2px solid var(--border); padding-bottom: 4px; }

.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
  scroll-margin-top: 190px;
}
.entry h3 { margin: 0 0 6px; font-size: 1.05rem; }
.entry p { margin: 4px 0; }
.entry.pitfall h3 { color: var(--pitfall); }
.notes { margin: 6px 0; padding-left: 20px; }
.problems a { color: var(--accent); margin-right: 6px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0 3px;
}

.code { position: relative; margin-top: 8px; }
pre {
  margin: 0;
  padding: 32px 12px 12px;                /* top room for the copy button */
  background: var(--code-bg);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
pre code { background: none; padding: 0; font-size: inherit; }

.copy {
  position: absolute;
  top: 6px;
  right: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 4px;
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

.empty { color: var(--muted); padding: 24px 0; }
footer { color: var(--muted); font-size: 13px; padding-top: 16px; padding-bottom: 32px; }

/* Phones: a sticky header this tall would cover a third of the screen, so let it scroll away. */
@media (max-width: 640px) {
  .top { position: static; }
  section, .entry { scroll-margin-top: 8px; }
  h1 { font-size: 1.3rem; }
}
