:root {
  --primary: #a16207;
  --secondary: #713f12;
  --accent: #7c3aed;
  --bg: #ffffff;
  --surface: #fefce8;
  --surface-alt: #fef9c3;
  --text: #713f12;
  --muted: #6b7280;
  --border: #fef08a;
  --row-alt: #fefce8;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(113,63,18,0.08);
  --shadow-lg: 0 6px 24px rgba(113,63,18,0.14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0;
  font-family: "Sarabun", "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(115deg, #a16207 0%, #713f12 60%, #7c3aed 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand img { width: 38px; height: 38px; border-radius: 8px; background: #fff; padding: 3px; }

nav.primary { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; align-items: center; }

nav.primary a {
  color: #fff;
  text-decoration: none;
  font-size: 0.98rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  transition: background 0.15s;
}

nav.primary a:hover { background: rgba(255,255,255,0.16); }

/* Hero */
.hero {
  background: radial-gradient(1200px 400px at 12% -10%, rgba(124,58,237,0.18), transparent 55%),
              radial-gradient(900px 380px at 100% 0%, rgba(161,98,7,0.16), transparent 60%),
              linear-gradient(180deg, var(--surface-alt) 0%, var(--surface) 100%);
  padding: 2.4rem 0 2rem;
  border-bottom: 3px solid var(--border);
}

.hero h1 {
  margin: 0 0 0.6rem;
  font-size: 1.9rem;
  line-height: 1.35;
  color: var(--secondary);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.byline {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0.35rem 0 1rem;
}

.byline strong { color: var(--secondary); }

.hero p.lead {
  font-size: 1.08rem;
  margin: 0.4rem 0;
  color: var(--text);
}

.cta-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--primary), var(--accent));
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }

.btn.alt {
  background: #fff;
  color: var(--secondary);
  border: 2px solid var(--primary);
}

/* Main content */
main { padding: 2rem 0 3rem; }

article h2 {
  margin-top: 2.4rem;
  margin-bottom: 0.9rem;
  font-size: 1.42rem;
  color: var(--secondary);
  padding: 0.6rem 0.9rem;
  border-left: 6px solid var(--primary);
  background: linear-gradient(90deg, var(--surface) 0%, transparent 100%);
  border-radius: 0 var(--radius) var(--radius) 0;
  scroll-margin-top: 90px;
}

article h3 {
  color: var(--secondary);
  margin-top: 1.6rem;
  font-size: 1.15rem;
}

article p { margin: 0.75rem 0; }

article a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
article a:hover { color: var(--primary); }

/* TOC */
nav.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

nav.toc strong {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--secondary);
  font-size: 1rem;
}

nav.toc ol { margin: 0.4rem 0 0; padding-left: 1.2rem; }
nav.toc li { margin: 0.2rem 0; }
nav.toc a { color: var(--secondary); text-decoration: none; }
nav.toc a:hover { color: var(--accent); text-decoration: underline; }

/* Lists */
article ul { list-style: none; padding-left: 0; }
article ul li {
  position: relative;
  padding-left: 1.6rem;
  margin: 0.4rem 0;
}
article ul li::before {
  content: "\27A4";
  color: var(--primary);
  position: absolute;
  left: 0;
  top: 0;
  font-size: 0.95rem;
}

article ol { counter-reset: item; list-style: none; padding-left: 0; }
article ol li {
  counter-increment: item;
  position: relative;
  padding-left: 2.4rem;
  margin: 0.55rem 0;
}
article ol li::before {
  content: counter(item);
  position: absolute;
  left: 0;
  top: 0.15rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 1.2rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.97rem;
  background: #fff;
}

table thead {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  color: #fff;
}

table th, table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table tbody tr:nth-child(even) { background: var(--row-alt); }
table tbody tr:hover { background: var(--surface-alt); }

/* FAQ */
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin: 0.55rem 0;
  transition: background 0.15s;
}
details[open] { background: var(--surface-alt); }
details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--secondary);
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: "\25BC";
  color: var(--primary);
  transition: transform 0.2s;
  font-size: 0.9rem;
}
details[open] summary::after { transform: rotate(180deg); }
details p { margin: 0.6rem 0 0; }

/* Blockquote / callouts */
.callout {
  background: var(--surface);
  border-left: 6px solid var(--accent);
  padding: 0.9rem 1.1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.2rem 0;
}

/* In-content SVG figures */
figure.inline-svg {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
figure.inline-svg svg { max-width: 100%; height: auto; }
figure figcaption { color: var(--muted); font-size: 0.9rem; margin-top: 0.5rem; }

/* Author box */
.author-box {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: linear-gradient(120deg, var(--surface-alt), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin: 2.4rem 0 1rem;
  box-shadow: var(--shadow);
}
.author-box img {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  background: #fff;
  flex-shrink: 0;
}
.author-box .who { font-weight: 700; color: var(--secondary); font-size: 1.05rem; }
.author-box .role { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.35rem; }
.author-box p { margin: 0.35rem 0 0; font-size: 0.98rem; }

/* Footer */
footer.site-footer {
  background: linear-gradient(115deg, #713f12 0%, #a16207 55%, #7c3aed 100%);
  color: #fef9c3;
  padding: 2.2rem 0 1.2rem;
  margin-top: 3rem;
}
footer.site-footer a { color: #fff; text-decoration: none; }
footer.site-footer a:hover { text-decoration: underline; }
.foot-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
  margin-bottom: 1.4rem;
}
.foot-cols h4 { margin: 0 0 0.5rem; color: #fff; font-size: 1rem; }
.foot-cols ul { list-style: none; padding: 0; margin: 0; }
.foot-cols ul li { margin: 0.25rem 0; }
.foot-cols ul li::before { content: none; }
.foot-legal { border-top: 1px solid rgba(255,255,255,0.2); padding-top: 0.9rem; font-size: 0.9rem; }

/* Responsive */
@media (min-width: 700px) {
  body { font-size: 17px; }
  .hero h1 { font-size: 2.35rem; }
  .foot-cols { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 980px) {
  .hero h1 { font-size: 2.6rem; }
  article h2 { font-size: 1.55rem; }
}

/* Utility */
.small { font-size: 0.9rem; color: var(--muted); }
.tag {
  display: inline-block;
  background: var(--surface-alt);
  color: var(--secondary);
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  margin: 0.1rem 0.15rem;
}

/* a11y additions */
.skip-link{position:absolute;left:-9999px;top:0;background:var(--primary);color:#fff;padding:10px 16px;border-radius:4px;z-index:1000;text-decoration:none;font-weight:700}
.skip-link:focus{left:12px;top:12px}
a:focus-visible,button:focus-visible,summary:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion: reduce){*,*::before,*::after{transition-duration:.01ms !important;animation-duration:.01ms !important}}
