@font-face { font-family: "Sarabun"; src: url("/fonts/Sarabun-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Sarabun"; src: url("/fonts/Sarabun-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #0d0f22;
  --bg2: #14162e;
  --card: rgba(255, 255, 255, 0.045);
  --card-hi: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.1);
  --fg: #f3f1ff;
  --muted: #a9a6c4;
  --pink: #ff6b8f;
  --amber: #ffb347;
  --violet: #8b6dff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 18px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--fg); font: 17px/1.7 "Sarabun", system-ui, -apple-system, "Noto Sans Thai", sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(139, 109, 255, 0.22), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(255, 107, 143, 0.16), transparent 60%),
    var(--bg);
  min-height: 100vh; overflow-x: hidden;
}
a { color: var(--amber); text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
section { padding: 72px 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- แถบนำทาง ---------- */
.nav { position: sticky; top: 0; z-index: 50; backdrop-filter: blur(14px); background: rgba(13, 15, 34, 0.6); border-bottom: 1px solid transparent; transition: border-color .3s, background .3s; }
.nav.scrolled { border-color: var(--line); background: rgba(13, 15, 34, 0.82); }
.nav .wrap { display: flex; align-items: center; gap: 22px; height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 700; font-size: 1.15rem; }
.brand img { width: 36px; height: 36px; border-radius: 10px; transition: transform .5s var(--ease); }
.brand:hover img { transform: rotate(-8deg) scale(1.1); }
.nav ul { display: flex; gap: 4px; list-style: none; margin: 0 0 0 auto; padding: 0; }
.nav li a { color: var(--muted); padding: 8px 12px; border-radius: 10px; position: relative; font-size: .98rem; transition: color .2s; }
.nav li a::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 4px; height: 2px; background: linear-gradient(90deg, var(--pink), var(--amber)); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease); }
.nav li a:hover, .nav li a.active { color: var(--fg); }
.nav li a.btn { color: #1b1330; padding: 8px 16px; }
.nav li a.btn::after { display: none; }
.nav li a.btn:hover { color: #1b1330; }
.nav li a:hover::after, .nav li a.active::after { transform: scaleX(1); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--fg); border-radius: 10px; padding: 6px 12px; font: inherit; cursor: pointer; }

/* ---------- ปุ่ม ---------- */
.btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; font: inherit; font-weight: 700; color: #1b1330;
  background: linear-gradient(135deg, var(--amber), var(--pink)); padding: 12px 24px; border-radius: 14px; box-shadow: 0 8px 28px rgba(255, 107, 143, 0.3);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), filter .25s; will-change: transform; }
.btn:hover { box-shadow: 0 12px 36px rgba(255, 107, 143, 0.5); filter: brightness(1.06); }
.btn:active { transform: scale(.97) !important; }
.btn.ghost { background: var(--card); color: var(--fg); box-shadow: none; border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--card-hi); box-shadow: none; }
.btn.small { padding: 8px 14px; font-size: .92rem; border-radius: 10px; }
.btn.danger { background: linear-gradient(135deg, #ff8a8a, #f87171); color: #2a0a0a; box-shadow: none; }
.btn.ok { background: linear-gradient(135deg, #86efac, #4ade80); color: #062312; box-shadow: none; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.55); transform: scale(0); animation: ripple .65s ease-out forwards; pointer-events: none; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 24px; }
.hero .wrap { display: grid; grid-template-columns: 1.05fr .95fr; gap: 28px; align-items: center; }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); font-size: .9rem; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 0 rgba(251, 191, 36, .6); }
.dot.on { background: var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); } 70% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
.hero h1 { font-size: clamp(3rem, 8vw, 5.4rem); margin: .25em 0 .1em; background: linear-gradient(120deg, #fff 10%, var(--amber) 55%, var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { font-size: 1.2rem; color: var(--muted); max-width: 34ch; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 10px; }
.hero .note { font-size: .92rem; color: var(--muted); max-width: 46ch; }

.stage { position: relative; aspect-ratio: 1 / 1; max-width: 520px; width: 100%; margin: 0 auto; perspective: 1100px; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.logo-float { position: absolute; left: 50%; top: 50%; width: 38%; margin: -19% 0 0 -19%; animation: float 6s ease-in-out infinite; }
.logo-tilt { transform-style: preserve-3d; transition: transform .15s ease-out; filter: drop-shadow(0 24px 40px rgba(255, 107, 143, 0.35)); }
.logo-tilt img { display: block; width: 100%; border-radius: 22%; }
@keyframes float { 0%, 100% { transform: translateY(-8px); } 50% { transform: translateY(10px); } }

/* ---------- การ์ด ---------- */
.grid { display: grid; gap: 16px; }
.grid.f3 { grid-template-columns: repeat(3, 1fr); }
.grid.f2 { grid-template-columns: repeat(2, 1fr); }
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; overflow: hidden;
  transition: transform .35s var(--ease), border-color .3s, background .3s; transform-style: preserve-3d; will-change: transform; }
.card::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 179, 71, 0.16), transparent 60%); }
.card:hover { border-color: rgba(255, 179, 71, 0.45); background: var(--card-hi); }
.card:hover::before { opacity: 1; }
.card h3 { font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.card .ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #1b1330; background: linear-gradient(135deg, var(--amber), var(--pink)); flex: none; transition: transform .5s var(--ease); }
.card:hover .ico { transform: rotate(-10deg) scale(1.12); }
.card p { color: var(--muted); margin: 0; font-size: .98rem; }
.tag { display: inline-block; margin: 8px 6px 0 0; padding: 2px 10px; border-radius: 99px; background: var(--card-hi); border: 1px solid var(--line); font-size: .8rem; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 12px 0 0; }
.stat { text-align: center; padding: 18px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.stat b { display: block; font-size: 2.2rem; line-height: 1.1; background: linear-gradient(120deg, var(--amber), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { color: var(--muted); font-size: .92rem; }

/* ---------- ตาราง ---------- */
table { width: 100%; border-collapse: collapse; font-size: .96rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 400; font-size: .86rem; letter-spacing: .02em; }
tr { transition: background .2s; }
tbody tr:hover { background: var(--card); }
.tablebox { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--card); }
.hl { color: var(--amber); font-weight: 700; }

/* ---------- ขั้นตอน ---------- */
.steps { counter-reset: s; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.step { position: relative; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.step::before { counter-increment: s; content: counter(s); position: absolute; top: -16px; left: 18px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #1b1330; background: linear-gradient(135deg, var(--amber), var(--pink)); }
.step h3 { margin-top: 8px; font-size: 1.05rem; }
.step p { color: var(--muted); margin: 0; font-size: .95rem; }

/* ---------- เดโมแชท ---------- */
.chat { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg2); padding: 16px; min-height: 260px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.chat .bar { display: flex; gap: 6px; margin-bottom: 12px; }
.chat .bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.msg { display: flex; gap: 10px; margin: 12px 0; opacity: 0; transform: translateY(8px); animation: msgin .5s var(--ease) forwards; }
.msg .av { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--card-hi); }
.msg.bot .av { padding: 0; overflow: hidden; background: none; }
.msg.bot .av img { width: 100%; height: 100%; }
.msg .b { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; max-width: 90%; font-size: .95rem; }
.msg .file { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 4px 10px; border-radius: 8px; background: var(--card-hi); font-size: .85rem; }
.caret::after { content: ""; display: inline-block; width: 2px; height: 1em; background: var(--amber); margin-left: 2px; vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@keyframes msgin { to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- ฟอร์ม ---------- */
.form { display: grid; gap: 14px; max-width: 640px; }
label { font-size: .92rem; color: var(--muted); display: grid; gap: 6px; }
input, textarea, select { font: inherit; color: var(--fg); background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; transition: border-color .2s, box-shadow .2s; width: 100%; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 4px rgba(255, 179, 71, 0.18); }
textarea { min-height: 110px; resize: vertical; }
input[type="file"] { padding: 9px; }
fieldset.choice { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 14px; margin: 0; display: grid; gap: 10px; }
fieldset.choice legend { color: var(--muted); font-size: .92rem; padding: 0 6px; }
label.radio { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--fg); transition: border-color .2s, background .2s, transform .2s; }
label.radio:hover { background: var(--card); transform: translateY(-1px); }
label.radio:has(input:checked) { border-color: var(--amber); background: var(--card-hi); }
label.radio input { width: auto; margin-top: 6px; accent-color: var(--amber); }
label.radio span { display: grid; line-height: 1.35; }
label.radio small { color: var(--muted); font-size: .86rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.alert { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); animation: msgin .4s var(--ease) both; }
.alert.ok { border-color: rgba(74, 222, 128, .5); }
.alert.bad { border-color: rgba(248, 113, 113, .6); }
.hide { display: none !important; }
.note-box { border-left: 3px solid var(--amber); padding: 10px 16px; background: var(--card); border-radius: 0 12px 12px 0; color: var(--muted); font-size: .95rem; }

.prose { max-width: 760px; }
.prose h2 { font-size: 1.4rem; margin-top: 1.6em; }
.prose li { margin: .35em 0; }
.page-head { padding: 56px 0 8px; }
.page-head h1 { font-size: clamp(2rem, 5vw, 3rem); background: linear-gradient(120deg, #fff 10%, var(--amber) 60%, var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }

footer { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: .92rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 28px; justify-content: space-between; }
footer a { color: var(--muted); }
footer a:hover { color: var(--amber); }

/* ---------- เปิดเผยตอนเลื่อน ---------- */
.reveal { opacity: 0; transform: translateY(24px) scale(.98); transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: var(--d, 0ms); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- แอดมิน ---------- */
.admin-top { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 18px; }
.tab { background: var(--card); border: 1px solid var(--line); color: var(--muted); padding: 8px 16px; border-radius: 10px; cursor: pointer; font: inherit; transition: all .2s; }
.tab:hover { color: var(--fg); }
.tab.on { color: #1b1330; background: linear-gradient(135deg, var(--amber), var(--pink)); border-color: transparent; font-weight: 700; }
.badge { display: inline-block; min-width: 20px; padding: 0 7px; margin-left: 6px; border-radius: 99px; background: var(--bad); color: #1b0a0a; font-size: .78rem; text-align: center; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .82rem; border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: rgba(74, 222, 128, .5); }
.pill.warn { color: var(--warn); border-color: rgba(251, 191, 36, .5); }
.pill.bad { color: var(--bad); border-color: rgba(248, 113, 113, .5); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kv .card { padding: 16px; }
.kv .card b { display: block; font-size: 1.5rem; }
.bar-bg { height: 8px; background: var(--card-hi); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar-fg { height: 100%; width: 0; background: linear-gradient(90deg, var(--amber), var(--pink)); border-radius: 99px; transition: width 1s var(--ease); }
.slip { max-width: 100%; max-height: 70vh; border-radius: 12px; border: 1px solid var(--line); }
.logbox { font: 13px/1.5 ui-monospace, Consolas, monospace; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; max-height: 480px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
dialog { background: var(--bg2); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius); max-width: min(92vw, 720px); padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); }

@media (max-width: 880px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .stage { max-width: 380px; order: -1; }
  .grid.f3 { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr 1fr; gap: 28px 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .nav-toggle { display: block; }
  .nav ul { display: none; position: absolute; top: 66px; left: 0; right: 0; flex-direction: column; padding: 10px 20px 18px; background: var(--bg2); border-bottom: 1px solid var(--line); }
  .nav ul.open { display: flex; }
}
@media (max-width: 560px) {
  .grid.f3, .grid.f2, .steps { grid-template-columns: 1fr; }
  section { padding: 52px 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .reveal { opacity: 1; transform: none; }
  .msg { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

/* ---------- เข้าสู่ระบบด้วย Discord + เลือกเซิร์ฟเวอร์ ---------- */
.idbox { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--card); display: grid; gap: 10px; }
.idbox .idsteps { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; color: var(--muted); }
.idbox .idsteps li::marker { color: var(--accent, currentColor); font-weight: 700; }
.idbox .codeline { display: flex; gap: 10px; }
.idbox .codeline input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .14em; font-weight: 600; }
.idbox .me { display: flex; align-items: center; gap: 12px; }
.idbox .me img { width: 40px; height: 40px; border-radius: 50%; }
.idbox .me .who { display: grid; line-height: 1.3; }
.idbox .me .who small { color: var(--muted); }
.idbox .me a.out { margin-left: auto; font-size: .88rem; color: var(--muted); }
.btn.discord { background: #5865f2; color: #fff; box-shadow: 0 8px 28px rgba(88, 101, 242, .35); }
.btn.discord:hover { box-shadow: 0 12px 36px rgba(88, 101, 242, .55); }
.picker { display: grid; gap: 8px; }
.picker input[type="search"] { margin: 0; }
.glist { display: grid; gap: 8px; max-height: 320px; overflow: auto; padding-right: 2px; }
.grow { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .2s, background .2s, transform .2s; }
.grow:hover { background: var(--card-hi); transform: translateY(-1px); }
.grow.sel { border-color: var(--amber); background: var(--card-hi); }
.grow.dis { opacity: .55; cursor: not-allowed; }
.grow .ic { width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--card-hi); font-weight: 700; overflow: hidden; }
.grow .ic img { width: 100%; height: 100%; }
.grow .nm { display: grid; line-height: 1.3; min-width: 0; flex: 1; }
.grow .nm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow .nm small { color: var(--muted); }
.grow a.inv { font-size: .85rem; white-space: nowrap; }
