:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #4a5060;
  --border: #dfe1e6;
  --accent: #1d4ed8;
  --accent-soft: #e6edfd;
  --badge-bg: #fff4d6;
  --badge-text: #6b4a00;
  --danger: #b42318;
  --focus: #1d4ed8;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #eceef2;
    --muted: #a9afbd;
    --border: #2a2f3a;
    --accent: #8fb0ff;
    --accent-soft: #1c2640;
    --badge-bg: #3a2f10;
    --badge-text: #ffd97a;
    --danger: #ff8a80;
    --focus: #8fb0ff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --text: #eceef2;
  --muted: #a9afbd;
  --border: #2a2f3a;
  --accent: #8fb0ff;
  --accent-soft: #1c2640;
  --badge-bg: #3a2f10;
  --badge-text: #ffd97a;
  --danger: #ff8a80;
  --focus: #8fb0ff;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Noto Sans Thai", "Sukhumvit Set", "Thonburi", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

a { color: var(--accent); text-underline-offset: 3px; cursor: pointer; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface); color: var(--text); padding: 12px 16px;
}
.skip:focus { left: 16px; top: 16px; z-index: 10; }

header.site {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
header.site .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; min-height: 64px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none;
  min-height: 44px;
}
.brand svg { width: 28px; height: 28px; flex: none; }
nav.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav.site-nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  color: var(--muted); text-decoration: none; font-weight: 500; border-radius: 8px;
}
nav.site-nav a:hover, nav.site-nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); }

main { padding: 48px 0 64px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--badge-bg); color: var(--badge-text);
  font-size: 14px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
}
.badge svg { width: 14px; height: 14px; }

h1 { font-size: clamp(32px, 6vw, 48px); line-height: 1.15; margin: 16px 0 12px; letter-spacing: -0.02em; }
h2 { font-size: 26px; line-height: 1.25; margin: 48px 0 16px; letter-spacing: -0.01em; }
h3 { font-size: 19px; line-height: 1.35; margin: 0 0 6px; }

.lead { font-size: 20px; color: var(--muted); margin: 0 0 8px; max-width: 42em; }
.lead-th { color: var(--muted); margin: 0; max-width: 42em; }

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px;
}
.card .icon {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft);
  color: var(--accent); display: grid; place-items: center; margin-bottom: 12px;
}
.card .icon svg { width: 22px; height: 22px; }
.card p { margin: 0; color: var(--muted); }
.card .th { margin-top: 8px; font-size: 15px; }

.note {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 10px; padding: 16px 20px; margin: 24px 0;
}
.note p { margin: 0; }
.note p + p { margin-top: 8px; }

.prose h2 { font-size: 23px; margin-top: 40px; }
.prose h3 { margin-top: 24px; }
.prose ul { padding-left: 1.25em; }
.prose li + li { margin-top: 6px; }
.prose p, .prose li { max-width: 44em; }

.meta { color: var(--muted); font-size: 15px; margin: 0; }

.toc { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; }
.toc ol { margin: 8px 0 0; padding-left: 1.25em; }
.toc a { display: inline-block; padding: 4px 0; }

.th-block { border-top: 1px solid var(--border); margin-top: 48px; padding-top: 8px; }

footer.site {
  border-top: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 15px;
}
footer.site .wrap { padding-top: 24px; padding-bottom: 24px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
footer.site a { color: var(--muted); display: inline-flex; align-items: center; min-height: 44px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

.closing { margin-top: 32px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
