/* Tang La site stylesheet — the one CSS file every page links.
   Where pages disagree on a rule, each variant is scoped to the pages that use it with
   :where(html.pg-<page>:lang(<lang>)) — zero specificity, so the cascade is exactly what it was
   when each page carried its own <style>. Those scopes match the <html> element's lang and its
   class: pg-home / pg-privacy / pg-patterns / pg-api, plus pg-doc on the last three.
   Editing a shared rule here changes every page that uses it. */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-sunken: #f0eee7;
  --ink: #1e2420;
  --ink-soft: #4a5450;
  --ink-faint: #7c8580;
  --border: #dedace;
  --border-soft: #eae7de;
  --accent: #2e7d5b;
  --accent-bg: #e8f3ee;
  --accent-ink: #1e5a41;
  --shadow: 0 1px 2px rgba(30, 36, 32, 0.04), 0 8px 24px -12px rgba(30, 36, 32, 0.12);
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

:root:where(.pg-api, .pg-home, .pg-privacy, .pg-patterns) {
  --accent-dark: #1e5a41;
}

:root:where(.pg-home, .pg-privacy) {
  --good-bg: #eef6ef;
  --good-ink: #285c3c;
}

:root:where(.pg-home:lang(th), .pg-privacy:lang(th), .pg-patterns:lang(th)) {
  --font-display: "Fraunces", "Trirong", "IBM Plex Sans Thai", ui-serif, Georgia, serif;
  --font-body: "IBM Plex Sans Thai", ui-sans-serif, system-ui, sans-serif;
}

:root:where(.pg-home:lang(en), .pg-privacy:lang(en)) {
  --font-display: "Fraunces", "IBM Plex Sans Thai", ui-serif, Georgia, serif;
}

:root:where(.pg-api:lang(en), .pg-patterns:lang(en)) {
  --font-display: "Fraunces", "IBM Plex Sans", ui-serif, Georgia, serif;
}

:root:where(.pg-api:lang(th)) {
  --font-display: "Trirong", "IBM Plex Sans Thai", ui-serif, Georgia, serif;
  --font-body: "IBM Plex Sans Thai", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
}

:root:where(:lang(en)) {
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
}

/* IBM Plex Mono has no Thai glyphs, so Thai text in a pill / eyebrow / label fell back to
   whatever the OS picked. Plex Sans Thai comes next so those glyphs match the rest of the page. */
:root:where(:lang(th)) {
  --font-mono: "IBM Plex Mono", "IBM Plex Sans Thai", ui-monospace, "SF Mono", Consolas, monospace;
}

:root:where(.pg-api, .pg-patterns) {
  --code-bg: #f0eee7;
  --code-ink: #2e3b35;
  --token-bg: #e8f3ee;
  --token-ink: #1e5a41;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1b1f22;
    --surface-sunken: #21262a;
    --ink: #eceeec;
    --ink-soft: #abb3af;
    --ink-faint: #767f7b;
    --border: #33393d;
    --border-soft: #282e32;
    --accent: #4caf82;
    --accent-bg: #1b2d25;
    --accent-ink: #7bc9a2;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }

  :root:where(.pg-api, .pg-home, .pg-privacy, .pg-patterns) {
    --accent-dark: #7bc9a2;
  }

  :root:where(.pg-home, .pg-privacy) {
    --good-bg: #17251c;
    --good-ink: #7bc9a2;
  }

  :root:where(.pg-api, .pg-patterns) {
    --code-bg: #21262a;
    --code-ink: #c6d0ca;
    --token-bg: #1b2d25;
    --token-ink: #7bc9a2;
  }
}

* {
  box-sizing: border-box;
}

html:where(.pg-home) {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

:where(html:lang(th)) body {
  line-height: 1.75;
}

:where(html.pg-home:lang(en), html.pg-privacy:lang(en)) body {
  line-height: 1.65;
}

:where(html.pg-api:lang(en), html.pg-patterns:lang(en)) body {
  line-height: 1.7;
}

a {
  color: var(--accent-ink);
}

:where(html.pg-doc) a {
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

:where(html.pg-api, html.pg-patterns) a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

:where(html.pg-home, html.pg-privacy) a:focus-visible, :where(html.pg-home, html.pg-privacy) button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.shell {
  margin: 0 auto;
  padding: 0 24px;
}

:where(html.pg-privacy, html.pg-api) .shell {
  max-width: 1180px;
}

:where(html.pg-patterns) .shell {
  max-width: 720px;
}

:where(html.pg-home) .shell {
  max-width: 1080px;
}

:where(html.pg-doc) .lang-link, :where(html.pg-doc) .home-link {
  position: fixed;
  top: 18px;
  z-index: 30;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  text-decoration: none;
}

.lang-link {
  right: 18px;
}

:where(html.pg-home) .lang-link {
  position: fixed;
  top: 18px;
  z-index: 30;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  text-decoration: none;
}

:where(html.pg-home) .lang-link:hover {
  color: var(--accent-ink);
}

:where(html.pg-doc) .home-link {
  left: 18px;
}

:where(html.pg-doc) .lang-link:hover, :where(html.pg-doc) .home-link:hover {
  color: var(--accent-ink);
}

@media (max-width: 620px) {

  :where(html.pg-api, html.pg-home, html.pg-privacy, html.pg-patterns) .lang-link {
    top: auto;
    bottom: 18px;
    right: 18px;
  }

  :where(html.pg-api, html.pg-privacy, html.pg-patterns) .home-link {
    top: auto;
    bottom: 18px;
    left: 18px;
  }
}

/* ---------- Hero ---------- */
:where(html.pg-doc) header.hero {
  border-bottom: 1px solid var(--border-soft);
  padding: 56px 0 40px;
}

:where(html.pg-home) header.hero {
  padding: 88px 0 40px;
  overflow: hidden;
}

:where(html.pg-home, html.pg-privacy, html.pg-api) .hero-inner {
  max-width: 720px;
  margin: 0 auto;
}

:where(html.pg-home) .hero-inner {
  text-align: center;
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

:where(html.pg-doc) .badge-row {
  margin-bottom: 22px;
}

:where(html.pg-home) .badge-row {
  justify-content: center;
  margin-bottom: 28px;
}

.mark {
  background: #4caf87;
  display: grid;
  place-items: center;
  flex: none;
}

:where(html.pg-doc) .mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
}

:where(html.pg-home) .mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
}

:where(html.pg-doc) .brand-name {
  font-size: 17px;
}

:where(html.pg-home) .brand-name {
  font-size: 18px;
}

:where(html.pg-home) h1.headline {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  margin: 0 0 20px;
  text-wrap: balance;
  color: var(--ink);
}

:where(html.pg-home:lang(th)) h1.headline {
  line-height: 1.08;
  letter-spacing: -0.01em;
}

:where(html.pg-home:lang(en)) h1.headline {
  line-height: 1.05;
  letter-spacing: -0.015em;
}

:where(html.pg-home) .hero-sub {
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: 46ch;
  margin: 0 auto 28px;
  text-wrap: balance;
}

:where(html.pg-home) .trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 56px;
}

:where(html.pg-doc) .brand-sub {
  font-size: 13px;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

:where(html.pg-doc) h1 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 14px;
  text-wrap: balance;
}

:where(html.pg-privacy:lang(th)) h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--ink);
}

:where(html.pg-privacy:lang(en)) h1 {
  font-size: clamp(2.1rem, 4.2vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}

:where(html.pg-patterns:lang(th)) h1 {
  font-size: clamp(2rem, 4vw, 2.7rem);
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--ink);
}

:where(html.pg-api:lang(en), html.pg-patterns:lang(en)) h1 {
  font-size: clamp(2rem, 4vw, 2.7rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
}

:where(html.pg-api:lang(th)) h1 {
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
}

:where(html.pg-doc) .lede {
  color: var(--ink-soft);
}

:where(html.pg-privacy:lang(th)) .lede {
  font-size: 1.08rem;
  max-width: 62ch;
  margin: 0 0 24px;
}

:where(html.pg-privacy:lang(en)) .lede {
  font-size: 1.1rem;
  max-width: 60ch;
  margin: 0 0 24px;
}

:where(html.pg-patterns, html.pg-api:lang(en)) .lede {
  font-size: 1.08rem;
  margin: 0;
}

:where(html.pg-api:lang(th)) .lede {
  font-size: 1.06rem;
  margin: 0;
}

:where(html.pg-privacy) .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

:where(html.pg-home, html.pg-privacy) .pill {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--surface-sunken);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
}

:where(html.pg-privacy) .pill {
  padding: 5px 11px;
}

:where(html.pg-home) .pill {
  padding: 5px 12px;
}

:where(html.pg-home, html.pg-privacy) .pill.good {
  background: var(--good-bg);
  color: var(--good-ink);
  border-color: transparent;
}

/* ---------- Notification -> transaction diagram ---------- */
:where(html.pg-home) .flow-demo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 auto 8px;
}

:where(html.pg-home) .flow-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  width: 240px;
  text-align: left;
}

:where(html.pg-home) .flow-card .flow-eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

:where(html.pg-home) .flow-card .flow-icon {
  width: 15px;
  height: 15px;
  flex: none;
}

:where(html.pg-home) .flow-card .flow-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  margin-bottom: 2px;
}

:where(html.pg-home) .flow-card .flow-amount {
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--ink-soft);
}

:where(html.pg-home) .flow-card.result {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border-soft));
  background: var(--accent-bg);
}

:where(html.pg-home) .flow-card.result .flow-amount {
  color: var(--accent-ink);
  font-weight: 600;
}

:where(html.pg-home) .flow-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: none;
  color: var(--accent-ink);
}

:where(html.pg-home) .flow-arrow svg {
  width: 30px;
  height: 18px;
}

:where(html.pg-home) .flow-arrow span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  white-space: nowrap;
  color: var(--ink-faint);
}

/* ---------- Features ---------- */
:where(html.pg-home) section.features {
  padding: 56px 0 64px;
}

:where(html.pg-home) .section-head {
  max-width: 560px;
  margin: 0 auto 44px;
  text-align: center;
}

:where(html.pg-home) .eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
  font-weight: 500;
  margin-bottom: 10px;
}

:where(html.pg-home) h2.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3.4vw, 2.1rem);
  margin: 0 0 12px;
  color: var(--ink);
  text-wrap: balance;
}

:where(html.pg-home) .section-sub {
  color: var(--ink-soft);
  font-size: 1.02rem;
}

:where(html.pg-home) .feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

:where(html.pg-home) .feature-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 22px 20px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

:where(html.pg-home) .feature-card.in {
  opacity: 1;
  transform: translateY(0);
}

:where(html.pg-home) .feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent-bg);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  margin-bottom: 14px;
}

:where(html.pg-home) .feature-icon svg {
  width: 21px;
  height: 21px;
}

:where(html.pg-home) .feature-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 6px;
}

:where(html.pg-home) .feature-text {
  font-size: 13.8px;
  color: var(--ink-soft);
}

:where(html.pg-home:lang(th)) .feature-text {
  line-height: 1.6;
}

:where(html.pg-home:lang(en)) .feature-text {
  line-height: 1.55;
}

:where(html.pg-home) .pro-tag {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

/* ---------- Free vs Premium ---------- */
:where(html.pg-home) section.plans {
  padding: 8px 0 72px;
}

:where(html.pg-home) .plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 880px;
  margin: 0 auto;
}

:where(html.pg-home) .plan-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 26px 24px;
}

:where(html.pg-home) .plan-card.pro {
  background: var(--accent-bg);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border-soft));
}

:where(html.pg-home) .plan-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}

:where(html.pg-home) .plan-price {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 2px 0 14px;
}

:where(html.pg-home) .plan-list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.7;
}

:where(html.pg-home) .plan-note {
  max-width: 60ch;
  margin: 18px auto 0;
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
}

@media (max-width: 620px) {
  :where(html.pg-home) .plan-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Privacy callout ---------- */
:where(html.pg-home) section.privacy-cta {
  padding: 8px 0 72px;
}

:where(html.pg-home) .privacy-card {
  max-width: 720px;
  margin: 0 auto;
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border-soft));
  border-radius: 20px;
  padding: 34px 36px;
  text-align: center;
}

:where(html.pg-home) .privacy-card .feature-icon {
  margin: 0 auto 16px;
  background: var(--surface);
}

:where(html.pg-home) .privacy-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0 0 10px;
  color: var(--accent-ink);
}

:where(html.pg-home) .privacy-card p {
  color: var(--ink-soft);
  max-width: 48ch;
  margin: 0 auto 18px;
}

:where(html.pg-home) .privacy-card a.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 22px;
  border-radius: 999px;
}

:where(html.pg-home) .privacy-card a.btn:hover {
  background: var(--accent-dark);
}

:where(html.pg-home) .privacy-card .cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

:where(html.pg-home) .privacy-card a.btn.ghost {
  background: transparent;
  color: var(--accent-ink);
  border: 1px solid var(--border);
}

:where(html.pg-home) .privacy-card a.btn.ghost:hover {
  background: var(--surface);
}

:where(html.pg-privacy, html.pg-api) .layout {
  display: grid;
  gap: 56px;
  justify-content: center;
  padding: 44px 0 90px;
  align-items: start;
}

:where(html.pg-privacy:lang(th), html.pg-api:lang(th)) .layout {
  grid-template-columns: 260px minmax(0, 720px);
}

:where(html.pg-privacy:lang(en), html.pg-api:lang(en)) .layout {
  grid-template-columns: 240px minmax(0, 720px);
}

:where(html.pg-privacy, html.pg-api) nav.toc {
  position: sticky;
  top: 28px;
  font-size: 14px;
}

:where(html.pg-privacy, html.pg-api) nav.toc .toc-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

:where(html.pg-privacy, html.pg-api) nav.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

:where(html.pg-privacy, html.pg-api) nav.toc li a {
  display: block;
  padding: 7px 0 7px 16px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

:where(html.pg-api) nav.toc li a .n {
  display: inline-block;
  width: 2.1em;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-ink);
}

:where(html.pg-privacy, html.pg-api) nav.toc li a:hover {
  color: var(--ink);
}

:where(html.pg-privacy, html.pg-api) nav.toc li a.current {
  color: var(--accent-ink);
  border-left-color: var(--accent);
  font-weight: 500;
}

:where(html.pg-privacy, html.pg-api) main {
  min-width: 0;
}

:where(html.pg-api, html.pg-patterns) main {
  padding: 40px 0 90px;
}

:where(html.pg-api) .layout > main {
  padding: 0;
}

:where(html.pg-api, html.pg-patterns) section {
  margin-bottom: 44px;
  scroll-margin-top: 24px;
}

:where(html.pg-privacy) section.doc-section {
  padding-top: 8px;
  margin-bottom: 46px;
  scroll-margin-top: 24px;
}

:where(html.pg-privacy) section.doc-section:first-of-type {
  padding-top: 0;
}

:where(html.pg-api, html.pg-privacy, html.pg-patterns) .sec-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-ink);
  font-weight: 500;
}

:where(html.pg-doc) h2 {
  font-family: var(--font-display);
  font-weight: 600;
  text-wrap: balance;
}

:where(html.pg-patterns, html.pg-api:lang(en), html.pg-privacy:lang(th)) h2 {
  font-size: 1.4rem;
  margin: 4px 0 16px;
  color: var(--ink);
}

:where(html.pg-privacy:lang(en)) h2 {
  font-size: 1.5rem;
  margin: 4px 0 16px;
  color: var(--ink);
}

:where(html.pg-api:lang(th)) h2 {
  font-size: 1.38rem;
  margin: 4px 0 16px;
  color: var(--ink);
}

:where(html.pg-api, html.pg-patterns) h3 {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
  margin: 22px 0 8px;
}

:where(html.pg-api) h3 code {
  font-size: 0.92em;
}

:where(html.pg-doc) p {
  margin: 0 0 15px;
  color: var(--ink-soft);
}

:where(html.pg-doc) p strong, :where(html.pg-doc) li strong {
  color: var(--ink);
  font-weight: 600;
}

:where(html.pg-api, html.pg-patterns) ol, :where(html.pg-api, html.pg-patterns) ul {
  margin: 0 0 15px;
  padding-left: 22px;
  color: var(--ink-soft);
}

:where(html.pg-privacy) ul {
  margin: 0 0 15px;
  padding-left: 22px;
  color: var(--ink-soft);
}

:where(html.pg-privacy) li {
  margin-bottom: 7px;
}

:where(html.pg-api, html.pg-patterns) li {
  margin-bottom: 8px;
}

:where(html.pg-api, html.pg-patterns) section > *:last-child {
  margin-bottom: 0;
}

:where(html.pg-api, html.pg-patterns) code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 2px 6px;
  border-radius: 5px;
}

:where(html.pg-api, html.pg-patterns) .tok {
  font-family: var(--font-mono);
  font-size: 0.86em;
  font-weight: 500;
  background: var(--token-bg);
  color: var(--token-ink);
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
}

:where(html.pg-api) .method {
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent-ink);
}

:where(html.pg-api) pre {
  background: var(--surface-sunken);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0 0 18px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--code-ink);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

:where(html.pg-api) pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

:where(html.pg-patterns) .example {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 14px 0 18px;
  box-shadow: var(--shadow);
}

:where(html.pg-patterns) .example .row {
  display: grid;
  gap: 6px 12px;
  align-items: baseline;
}

:where(html.pg-patterns:lang(th)) .example .row {
  grid-template-columns: 96px 1fr;
}

:where(html.pg-patterns:lang(en)) .example .row {
  grid-template-columns: 108px 1fr;
}

:where(html.pg-patterns) .example .row + .row {
  margin-top: 8px;
}

:where(html.pg-patterns) .example .k {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 2px;
}

:where(html.pg-patterns) .example .v {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--code-ink);
  line-height: 1.6;
  word-break: break-word;
}

:where(html.pg-patterns) .example .v.txt {
  font-family: var(--font-body);
  color: var(--ink-soft);
}

@media (max-width: 560px) {
  :where(html.pg-patterns) .example .row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

:where(html.pg-api, html.pg-patterns) .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 4px 0 18px;
}

:where(html.pg-api, html.pg-patterns) table.ph {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
}

:where(html.pg-api, html.pg-patterns) table.ph th, :where(html.pg-api, html.pg-patterns) table.ph td {
  text-align: left;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

:where(html.pg-api, html.pg-patterns) table.ph th {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  background: var(--surface-sunken);
  font-weight: 500;
}

:where(html.pg-api, html.pg-patterns) table.ph tr:last-child td {
  border-bottom: none;
}

:where(html.pg-api) table.ph code {
  white-space: nowrap;
}

:where(html.pg-patterns, html.pg-api:lang(en)) table.ph td:first-child {
  white-space: nowrap;
}

:where(html.pg-privacy) .doc-section > *:last-child {
  margin-bottom: 0;
}

:where(html.pg-doc) .callout {
  border-radius: 14px;
  box-shadow: var(--shadow);
}

:where(html.pg-privacy) .callout {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  padding: 20px 22px;
  margin: 18px 0 22px;
}

:where(html.pg-api, html.pg-patterns) .callout {
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border-soft));
  background: var(--accent-bg);
  padding: 18px 20px;
  margin: 18px 0;
}

:where(html.pg-privacy) .callout.accent {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border-soft));
  background: var(--accent-bg);
}

:where(html.pg-doc) .callout-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
}

:where(html.pg-privacy) .callout-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}

:where(html.pg-api, html.pg-patterns) .callout-title {
  color: var(--accent-ink);
}

:where(html.pg-privacy) .callout.accent .callout-title {
  color: var(--accent-ink);
}

:where(html.pg-api, html.pg-privacy, html.pg-patterns) .callout p:last-child {
  margin-bottom: 0;
}

:where(html.pg-api, html.pg-privacy, html.pg-patterns) .callout p {
  color: var(--ink-soft);
  font-size: 14.5px;
}

:where(html.pg-privacy) .not-list {
  list-style: none;
  margin: 0 0 15px;
  padding: 0;
  display: grid;
  gap: 9px;
}

:where(html.pg-privacy) .not-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14.5px;
  color: var(--ink-soft);
  margin-bottom: 0;
}

:where(html.pg-privacy) .not-list .tick {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--good-bg);
  color: var(--good-ink);
  display: grid;
  place-items: center;
  font-size: 12px;
  margin-top: 1px;
}

:where(html.pg-privacy) .perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 4px 0 20px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
}

:where(html.pg-privacy) .perm-table th, :where(html.pg-privacy) .perm-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

:where(html.pg-privacy) .perm-table th {
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  background: var(--surface-sunken);
  font-weight: 500;
}

:where(html.pg-privacy) .perm-table tr:last-child td {
  border-bottom: none;
}

:where(html.pg-privacy) .perm-table td.perm-name {
  color: var(--accent-ink);
  white-space: nowrap;
}

:where(html.pg-privacy:lang(th)) .perm-table td.perm-name {
  font-weight: 500;
}

:where(html.pg-privacy:lang(en)) .perm-table td.perm-name {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

:where(html.pg-privacy) .perm-table td.perm-why {
  color: var(--ink-soft);
}

:where(html.pg-privacy) .overflow-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

footer {
  border-top: 1px solid var(--border-soft);
}

:where(html.pg-home, html.pg-privacy) footer {
  padding: 34px 0 60px;
}

:where(html.pg-api, html.pg-patterns) footer {
  padding: 30px 0 60px;
}

:where(html.pg-home, html.pg-privacy, html.pg-api) footer .shell {
  max-width: 720px;
  margin: 0 auto;
}

:where(html.pg-privacy) footer .shell {
  padding: 0 24px;
}

:where(html.pg-home) footer .shell {
  text-align: center;
}

footer p {
  font-size: 13.5px;
  color: var(--ink-faint);
  margin: 0 0 6px;
}

:where(html.pg-home) footer a {
  color: var(--accent-ink);
  font-weight: 600;
}

@media (max-width: 880px) {
  :where(html.pg-home) .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  :where(html.pg-home) .feature-grid {
    grid-template-columns: 1fr;
  }

  /* Stack the notification→transaction diagram vertically so it lays out
     identically regardless of how wide the translated labels render —
     a flex row here wrapped differently in Thai vs English and could
     overflow the viewport. */
  :where(html.pg-home) .flow-demo {
    flex-direction: column;
  }

  :where(html.pg-home) .flow-card {
    width: 100%;
    max-width: 320px;
  }

  :where(html.pg-home) .flow-arrow svg {
    transform: rotate(90deg);
  }
}

/* ---------- Home-screen widgets ---------- */
:where(html.pg-home) section.widgets {
  padding: 8px 0 64px;
}

:where(html.pg-home) .widget-stage {
  --wg-surface: #ffffff;
  --wg-ink: #1e2420;
  --wg-muted: #79716b;
  --wg-faint: #a8a29e;
  --wg-track: #eeeae4;
  --wg-line: #e4ded6;
  --wg-income: #3b9374;
  --wg-expense: #d15f52;
  --wg-amber: #d9922e;
  --wg-blue: #4a7fc9;
  --wg-red: #d6453e;
  --wg-transfer: #5f7c92;
  max-width: 720px;
  margin: 0 auto;
  padding: 30px 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 22px 26px;
  align-items: flex-start;
  justify-content: center;
  background: linear-gradient(135deg, #e7eee9, #f0eee7);
  border: 1px solid var(--border-soft);
  border-radius: 22px;
}

@media (prefers-color-scheme: dark) {
  :where(html.pg-home) .widget-stage {
    --wg-surface: #1b1f22;
    --wg-ink: #f7f8f8;
    --wg-muted: #9ca3af;
    --wg-faint: #6b7280;
    --wg-track: #2b3034;
    --wg-line: #2e3338;
    background: linear-gradient(135deg, #1b2620, #1a1e1c);
  }
}

:where(html.pg-home) .widget-fig {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

:where(html.pg-home) .widget-fig figcaption {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  text-align: center;
}

:where(html.pg-home) .wg {
  background: var(--wg-surface);
  border-radius: 20px;
  padding: 14px 15px;
  box-shadow: 0 1px 2px rgba(30, 36, 32, 0.08), 0 14px 30px -14px rgba(30, 36, 32, 0.28);
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  color: var(--wg-ink);
  line-height: 1.4;
}

:where(html.pg-home) .wg-2x2 {
  width: 158px;
  height: 158px;
}

:where(html.pg-home) .wg-4x2 {
  width: 300px;
  height: 158px;
}

:where(html.pg-home) .wg-4x1 {
  width: 300px;
  height: 74px;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

:where(html.pg-home) .wg-lbl {
  font-size: 11px;
  color: var(--wg-muted);
}

:where(html.pg-home) .wg-amt {
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

:where(html.pg-home) .wg-amt.big {
  font-size: 23px;
}

:where(html.pg-home) .wg-amt.mid {
  font-size: 17px;
}

:where(html.pg-home) .wg-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--wg-track);
  overflow: hidden;
}

:where(html.pg-home) .wg-bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--wg-income);
}

:where(html.pg-home) .wg-bar.amber > i {
  background: var(--wg-amber);
}

:where(html.pg-home) .wg-bar.blue > i {
  background: var(--wg-blue);
}

:where(html.pg-home) .wg-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--wg-track);
  color: var(--wg-muted);
  letter-spacing: 0.02em;
}

:where(html.pg-home) .wg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

:where(html.pg-home) .wg-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  flex: none;
}

:where(html.pg-home) .wg-grow {
  flex: 1;
}

:where(html.pg-home) .wg-mt {
  margin-top: auto;
}

:where(html.pg-home) .wg-catrow {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

:where(html.pg-home) .wg-catrow .nm {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

:where(html.pg-home) .wg-catrow .amt {
  font-size: 10.5px;
  color: var(--wg-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

:where(html.pg-home) .wg-catrow .trk {
  grid-column: 1 / -1;
}

:where(html.pg-home) .wg-qa {
  display: flex;
  gap: 7px;
  flex: 1;
}

:where(html.pg-home) .wg-qa span {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 11px;
  padding: 7px 0;
  border-radius: 12px;
}

:where(html.pg-home) .wg-qa .exp {
  background: rgba(209, 95, 82, 0.13);
  color: var(--wg-expense);
}

:where(html.pg-home) .wg-qa .inc {
  background: rgba(59, 147, 116, 0.13);
  color: var(--wg-income);
}

:where(html.pg-home) .wg-qa .xfer {
  background: rgba(95, 124, 146, 0.16);
  color: var(--wg-transfer);
}

:where(html.pg-home) .wg-sc {
  border-radius: 20px;
  color: #fff;
  display: flex;
  align-items: center;
  box-shadow: 0 1px 2px rgba(30, 36, 32, 0.08), 0 14px 30px -14px rgba(30, 36, 32, 0.28);
}

:where(html.pg-home) .wg-sc.s1 {
  width: 74px;
  height: 74px;
  justify-content: center;
}

:where(html.pg-home) .wg-sc.s2 {
  width: 152px;
  height: 74px;
  gap: 10px;
  padding: 0 15px;
}

:where(html.pg-home) .wg-sc.exp {
  background: #d15f52;
}

:where(html.pg-home) .wg-sc.xfer {
  background: #5f7c92;
}

:where(html.pg-home) .wg-sc .g {
  font-size: 30px;
  line-height: 1;
}

:where(html.pg-home) .wg-sc.s2 .g {
  font-size: 24px;
}

:where(html.pg-home) .wg-sc .nm {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

:where(html.pg-home) .wg-sc .am {
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

:where(html.pg-home) .wg-scwrap {
  display: flex;
  gap: 14px;
  align-items: center;
}

@media (max-width: 520px) {
  :where(html.pg-home) .widget-stage {
    padding: 26px 16px;
  }

  :where(html.pg-home) .wg-4x2, :where(html.pg-home) .wg-4x1 {
    width: 280px;
  }
}

/* ---------- Screenshot gallery ---------- */
:where(html.pg-home) section.gallery {
  padding: 8px 0 56px;
}

:where(html.pg-home) .shots-wrap {
  position: relative;
  max-width: 1128px;
  margin: 0 auto;
}

:where(html.pg-home) .shots {
  display: flex;
  gap: 18px;
  padding: 10px 24px 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

:where(html.pg-home) .shots.dragging {
  scroll-snap-type: none;
  cursor: grabbing;
  user-select: none;
}

@media (hover: hover) {
  :where(html.pg-home) .shots {
    cursor: grab;
  }
}

:where(html.pg-home) .shot img {
  -webkit-user-drag: none;
  user-select: none;
}

/* Arrow buttons for mouse users; touch users just swipe. */
:where(html.pg-home) .shots-nav {
  position: absolute;
  top: 240px;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}

:where(html.pg-home) .shots-nav[hidden] {
  display: none;
}

:where(html.pg-home) .shots-nav:hover {
  color: var(--accent);
}

:where(html.pg-home) .shots-nav svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:where(html.pg-home) .shots-nav.prev {
  left: 6px;
}

:where(html.pg-home) .shots-nav.next {
  right: 6px;
}

@media (hover: none) {
  :where(html.pg-home) .shots-nav {
    display: none;
  }
}

:where(html.pg-home) .shots::-webkit-scrollbar {
  display: none;
}

:where(html.pg-home) .shot {
  flex: 0 0 auto;
  width: 216px;
  margin: 0;
  scroll-snap-align: center;
}

:where(html.pg-home) .shot img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 22px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow);
  background: var(--surface);
}

:where(html.pg-home) .shot figcaption {
  margin-top: 12px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  line-height: 1.4;
}

/* Desktop: JS adds .pin so the page scroll drives the strip sideways
   (see the gallery script). Track height is set by JS. */
:where(html.pg-home) .gallery.pin .gallery-stick {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  padding-top: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

:where(html.pg-home) .gallery.pin .shots-wrap {
  max-width: none;
}

:where(html.pg-home) .gallery.pin .shots {
  width: max-content;
  overflow: visible;
  scroll-snap-type: none;
  cursor: default;
  padding-left: var(--pin-pad, 24px);
  padding-right: var(--pin-pad, 24px);
  will-change: transform;
}

:where(html.pg-home) .gallery.pin .shots-nav {
  display: none;
}

@media (max-width: 520px) {
  :where(html.pg-home) .shot {
    width: 190px;
  }
}

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

  :where(html.pg-home) .feature-card {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

:where(html.pg-privacy) footer a.contact {
  font-weight: 600;
  color: var(--accent-ink);
}

@media (max-width: 880px) {
  :where(html.pg-privacy, html.pg-api) .layout {
    grid-template-columns: 1fr;
    padding-top: 28px;
  }

  :where(html.pg-privacy, html.pg-api) nav.toc {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:where(.pg-api, .pg-privacy, .pg-patterns), :where(html.pg-api, html.pg-privacy, html.pg-patterns) * {
    transition: none !important;
  }
}
