/* ร้าน ApeX — ใช้ทุกหน้า (pricing · success · legal) */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #14171c;
  --muted: #5b6472;
  --line: #dde1e7;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --good: #1a7f37;
  --warn: #9a6700;
  --bad: #cf222e;
  --shadow: 0 1px 2px rgba(20, 23, 28, .06), 0 8px 24px rgba(20, 23, 28, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2230;
    --text: #e6edf3;
    --muted: #9aa5b4;
    --line: #2b3340;
    --accent: #4c8dff;
    --accent-ink: #0d1117;
    --good: #3fb950;
    --warn: #d29922;
    --bad: #f85149;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* ── หัว ── */
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: .2px; }
.brand svg { width: 26px; height: 26px; }
.brand small { font-weight: 500; color: var(--muted); font-size: 14px; }
.toggles { margin-left: auto; display: flex; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 12px; cursor: pointer; min-height: 32px;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ── ส่วนหัวหน้า ── */
.hero { padding: 40px 0 8px; text-align: center; }
.hero h1 { margin: 0 0 8px; font-size: clamp(26px, 5vw, 38px); line-height: 1.2; }
.hero p { margin: 0 auto; max-width: 620px; color: var(--muted); }

.notice {
  margin: 16px auto 0; max-width: 620px; padding: 10px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; text-align: center;
}
.notice.warn { border-color: var(--warn); }
.notice.bad { border-color: var(--bad); }

/* ── การ์ด plan ── */
.plans { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); padding: 28px 0 8px; }
.plan {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.plan h2 { margin: 0; font-size: 18px; }
.price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.price b { font-size: 34px; line-height: 1; letter-spacing: -.5px; }
.price span { color: var(--muted); font-size: 14px; }
.sub-price { color: var(--muted); font-size: 13px; min-height: 20px; }
.save { color: var(--good); font-weight: 600; }
.plan ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; flex: 1; }
.plan li { padding-left: 22px; position: relative; }
.plan li::before { content: ""; position: absolute; left: 2px; top: .55em; width: 10px; height: 6px; border-left: 2px solid var(--good); border-bottom: 2px solid var(--good); transform: rotate(-45deg); }
.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px; width: 100%;
  border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 700; padding: 12px 16px; min-height: 46px; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: progress; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.skeleton { min-height: 360px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.agree { display: flex; gap: 10px; align-items: flex-start; justify-content: center; font-size: 14px; color: var(--muted); padding: 8px 0 0; }
.agree input { width: 18px; height: 18px; margin-top: 2px; flex: none; }
.agree.error { color: var(--bad); }
.form-err { text-align: center; color: var(--bad); font-size: 14px; min-height: 22px; margin: 6px 0 0; }

/* ── ส่วนข้อมูล ── */
section.info { padding: 32px 0 0; }
section.info h2 { font-size: 20px; margin: 0 0 12px; }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.step { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); align-items: center; justify-content: center; font-weight: 700; font-size: 13px; margin-bottom: 8px; }
ol.steps { margin: 8px 0 0; padding-left: 20px; }
ol.steps li { margin: 4px 0; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 0 0 8px; }
summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
code, .mono { font-family: ui-monospace, Consolas, monospace; }

/* ── ท้าย ── */
footer { margin-top: 48px; border-top: 1px solid var(--line); padding: 20px 0 32px; color: var(--muted); font-size: 13px; }
footer .links { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
footer p { margin: 6px 0 0; }

/* ── success ── */
.panel { max-width: 620px; margin: 32px auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.panel h1 { margin: 0 0 6px; font-size: 24px; }
.panel .lead { margin: 0 0 16px; color: var(--muted); }
.status-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; background: var(--surface-2); }
.status-icon.ok { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.status-icon svg { width: 24px; height: 24px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0 0 16px; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.box { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 16px 0 0; background: var(--surface-2); font-size: 14px; }
.box h2 { font-size: 15px; margin: 0 0 6px; }
.box p { margin: 0 0 10px; color: var(--muted); }
.box.warn { border-color: var(--warn); }
.msg { font-size: 14px; margin: 8px 0 0; min-height: 20px; }
.msg.ok { color: var(--good); }
.msg.bad { color: var(--bad); }
[hidden] { display: none !important; }
.center-link { text-align: center; margin-top: 20px; }

/* ── legal ── */
.draft { background: var(--warn); color: #000; text-align: center; font-weight: 700; padding: 8px 16px; font-size: 14px; }
article.legal { max-width: 760px; margin: 32px auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
article.legal h1 { margin-top: 0; font-size: 26px; }
article.legal h2 { font-size: 18px; margin: 24px 0 8px; }
article.legal p, article.legal li { color: var(--text); font-size: 15px; }
.fill { background: color-mix(in srgb, var(--warn) 25%, transparent); padding: 0 4px; border-radius: 4px; }
html[lang="th"] [data-lang="en"], html[lang="en"] [data-lang="th"] { display: none !important; }

@media (max-width: 520px) {
  .top .wrap { padding-top: 8px; padding-bottom: 8px; }
  .toggles { margin-left: 0; width: 100%; justify-content: flex-end; }
  .panel, article.legal { padding: 18px; margin-top: 20px; }
  dl.facts { grid-template-columns: 1fr; gap: 2px; }
  dl.facts dd { margin-bottom: 8px; }
}
