:root {
  color-scheme: light;
  --paper: oklch(0.985 0.003 240);
  --panel: oklch(0.972 0.005 240);
  --well: oklch(0.952 0.006 240);
  --line: oklch(0.905 0.008 240);
  --line-strong: oklch(0.83 0.01 245);
  --ink: oklch(0.24 0.02 255);
  --muted: oklch(0.48 0.015 255);
  --accent: oklch(0.5 0.17 258);
  --accent-ink: oklch(0.42 0.16 258);
  --handshake: oklch(0.53 0.17 350);
  --application: oklch(0.5 0.13 155);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 54px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[lang="zh-CN"] body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

a {
  color: var(--accent-ink);
  text-decoration-thickness: from-font;
  text-underline-offset: 3px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--paper);
  color: var(--accent-ink);
  transform: translateY(-160%);
}

.skip-link:focus-visible { transform: none; }

.site-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 max(20px, calc((100vw - 980px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.site-head nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font: 700 14px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-decoration: none;
}

.mark {
  display: flex;
  align-items: end;
  gap: 2px;
  height: 18px;
}

.mark i {
  display: block;
  width: 5px;
  border-radius: 1px;
}

.mark i:nth-child(1) { height: 10px; background: var(--muted); }
.mark i:nth-child(2) { height: 18px; background: var(--handshake); }
.mark i:nth-child(3) { height: 14px; background: var(--application); }

main {
  width: min(760px, calc(100% - 40px));
  margin: 0 auto;
  padding: 70px 0 90px;
  scroll-margin-top: 54px;
}

h1, h2, h3 {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.16;
  text-wrap: balance;
}

[lang="zh-CN"] h1,
[lang="zh-CN"] h2,
[lang="zh-CN"] h3 {
  font-family: "Noto Serif SC", "Songti SC", STSong, Georgia, serif;
}

h1 {
  margin: 0.15em 0 0.35em;
  font-size: clamp(42px, 7vw, 68px);
  letter-spacing: -0.035em;
}

h2 { margin-top: 2.1em; font-size: 32px; }
h3 { margin-top: 1.8em; font-size: 23px; }

.eyebrow {
  margin: 0;
  color: var(--handshake);
  font: 700 12px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lede {
  max-width: 65ch;
  color: var(--muted);
  font-size: 19px;
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 28px 0;
}

.actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  text-decoration: none;
}

.actions .primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.actions a:hover, .actions a:active { border-color: var(--accent); }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 24px 0 46px;
}

.tags span {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: 12px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.prose {
  max-width: 65ch;
  overflow-wrap: break-word;
}

.prose blockquote {
  margin: 24px 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--handshake);
  color: var(--muted);
}

.prose code, .prose pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.prose code {
  padding: 0.08em 0.28em;
  border-radius: 4px;
  background: var(--well);
  font-size: 0.9em;
}

.prose pre {
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--well);
  font-size: 13px;
  line-height: 1.5;
  overscroll-behavior: contain;
}

.prose table {
  display: block;
  max-width: 100%;
  overflow: auto;
  border-collapse: collapse;
  overscroll-behavior: contain;
}

.prose th, .prose td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}

.prose img, .prose svg { max-width: 100%; }
.prose h2, .prose h3 { scroll-margin-top: 74px; }
.diagram { margin: 24px 0; }

.diagram summary {
  min-height: 44px;
  color: var(--muted);
  font-size: 13px;
  line-height: 44px;
  cursor: pointer;
}

.note-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 70px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.note-nav a {
  display: flex;
  flex-direction: column;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
}

.note-nav a:hover { border-color: var(--accent); }
.note-nav a:last-child { text-align: end; }
.note-nav small { color: var(--muted); }

footer {
  padding: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.collection, .language-hub { width: min(980px, calc(100% - 40px)); }

.collection ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  list-style: none;
}

.collection li a, .language-choices a {
  display: block;
  height: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  text-decoration: none;
}

.collection li a:hover, .language-choices a:hover { border-color: var(--accent); }

.collection li span {
  display: block;
  color: var(--handshake);
  font: 700 12px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.collection li strong {
  display: block;
  margin: 5px 0;
  color: var(--ink);
  font-size: 17px;
}

.collection li p { margin: 0; color: var(--muted); font-size: 14px; }

.language-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 36px;
}

.language-choices a {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
}

.language-choices strong {
  color: var(--ink);
  font: 700 26px "Noto Serif SC", "Songti SC", STSong, Georgia, serif;
}

.language-choices span { color: var(--muted); }

@media (max-width: 680px) {
  .site-head { padding: 0 16px; }
  main { padding-top: 44px; }
  h1 { font-size: 42px; }
  .collection ol, .language-choices, .note-nav { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: oklch(0.17 0.01 255);
    --panel: oklch(0.195 0.012 255);
    --well: oklch(0.215 0.012 255);
    --line: oklch(0.29 0.012 255);
    --line-strong: oklch(0.37 0.014 255);
    --ink: oklch(0.93 0.008 255);
    --muted: oklch(0.72 0.012 255);
    --accent: oklch(0.72 0.13 258);
    --accent-ink: oklch(0.8 0.1 258);
    --handshake: oklch(0.74 0.12 350);
    --application: oklch(0.74 0.11 155);
  }

  .actions .primary { color: oklch(0.17 0.02 258); }
}

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