/* NERD SCHOOL · สมัครเข้าเรียน | พื้น #101214 | ขอบ #2F3132 | ฟ้า #0AA8F3 | Kanit */
:root {
    --bg: #0b0d0f;
    --panel: rgba(16, 18, 20, 0.85);
    --soft: rgba(255, 255, 255, 0.04);
    --line: #2F3132;
    --blue: #0AA8F3;
    --blue-d: #0786C4;
    --ok: #34D399;
    --warn: #FBBF24;
    --bad: #F87171;
    --text: #EEF2F5;
    --muted: rgba(238, 242, 245, 0.58);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { min-height: 100vh; font-family: 'Kanit', system-ui, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }

/* พื้นหลัง: แสงฟ้ามุมบน (ไม่มีตาราง) */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background:
    radial-gradient(900px 500px at 15% -10%, rgba(10,168,243,.16), transparent 70%),
    radial-gradient(700px 500px at 110% 110%, rgba(10,168,243,.08), transparent 70%),
    var(--bg); }

/* ---------- ของตกแต่งพื้นหลัง: เมฆ / ดาว / ตัวละคร ลอยช้า ๆ (อยู่หลังเนื้อหา) ---------- */
.deco { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.d { position: absolute; user-select: none; -webkit-user-drag: none; will-change: transform; }
/* เมฆ: สีขาวตามรูป (ทึบพอ ไม่ให้กลายเป็นสีเทาบนพื้นดำ) */
.cl1, .cl2, .cl3, .cl4 { filter: drop-shadow(0 10px 24px rgba(0,0,0,.35)); }
.cl1 { width: 560px; left: -150px; top: -170px; opacity: .92; animation: drift 26s ease-in-out infinite; }
.cl2 { width: 640px; right: -200px; bottom: -230px; opacity: .9; animation: drift 32s ease-in-out infinite reverse; }
.cl3 { width: 260px; left: 36%; top: 64%; opacity: .9; animation: drift 38s ease-in-out infinite; }
.cl4 { width: 420px; right: 10%; top: -150px; opacity: .75; animation: drift 30s ease-in-out infinite reverse; }
/* ดาว */
.st1 { width: 46px; left: 7%; top: 30%; animation: twinkle 5s ease-in-out infinite; }
.st2 { width: 26px; left: 44%; top: 9%; opacity: .85; animation: twinkle 6s 1s ease-in-out infinite; }
.st3 { width: 34px; right: 6%; top: 62%; animation: twinkle 5.5s .5s ease-in-out infinite; }
.st4 { width: 20px; left: 23%; bottom: 8%; opacity: .8; animation: twinkle 7s 2s ease-in-out infinite; }
/* ตัวละคร: กล่องนอก = เส้นทางบิน | รูปข้างใน = หายใจ/ยืดหด/เอียง (คนละจังหวะ -> ดูมีชีวิต) */
.kid { width: 230px; pointer-events: auto; cursor: pointer; }
.kid img { display: block; width: 100%; transform-origin: 50% 60%; filter: drop-shadow(0 14px 22px rgba(0,0,0,.4)); }
.kshadow { position: absolute; left: 22%; right: 22%; bottom: -26px; height: 18px; border-radius: 50%; background: radial-gradient(closest-side, rgba(10,168,243,.35), transparent); animation: kshadow 2.6s ease-in-out infinite; }
.kid1 { right: 2.5%; top: 5%; animation: inR 1.3s cubic-bezier(.2,.9,.3,1.2) both; }
.kid2 { width: 250px; left: 1.5%; bottom: 5%; animation: inL 1.3s .3s cubic-bezier(.2,.9,.3,1.2) both; }
.kid1.ready { animation: path1 9s ease-in-out infinite; }
.kid2.ready { animation: path2 11s ease-in-out infinite; }
.kid1 img { animation: breathe 2.6s ease-in-out infinite; }
.kid2 img { animation: breathe2 2.2s .4s ease-in-out infinite; }
.kid.ready:hover img { animation: wiggle .6s ease-in-out infinite; }
.kid.boing img { animation: flip .9s cubic-bezier(.3,.7,.4,1) !important; }
.kid.loop img { animation: loopy 1.4s cubic-bezier(.4,.1,.3,1) !important; }
/* ประกายตามหลังตอนบิน */
.trail { position: fixed; z-index: -1; pointer-events: none; color: #fff; font-size: 14px; line-height: 1; text-shadow: 0 0 8px rgba(10,168,243,.9); animation: trail 1.4s ease-out forwards; }
@keyframes trail { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1) rotate(90deg); } }
/* เส้นทางบิน: วนเลข 8 ช้า ๆ */
@keyframes path1 { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(-28px, -18px); } 50% { transform: translate(-8px, 14px); } 75% { transform: translate(18px, -10px); } }
@keyframes path2 { 0%, 100% { transform: translate(0, 0); } 30% { transform: translate(30px, -26px); } 55% { transform: translate(54px, -6px); } 80% { transform: translate(16px, 8px); } }
/* หายใจ: ยืด-หด + เอียงหัว */
@keyframes breathe { 0%, 100% { transform: rotate(-4deg) scale(1, 1); } 30% { transform: rotate(2deg) scale(1.03, .97); } 55% { transform: rotate(5deg) scale(.97, 1.04) translateY(-6px); } 80% { transform: rotate(-1deg) scale(1.02, .98); } }
@keyframes breathe2 { 0%, 100% { transform: rotate(4deg) scale(1, 1); } 35% { transform: rotate(-3deg) scale(.97, 1.04) translateY(-8px); } 65% { transform: rotate(-6deg) scale(1.04, .96); } }
@keyframes kshadow { 0%, 100% { transform: scaleX(1); opacity: .9; } 55% { transform: scaleX(.75); opacity: .5; } }
/* ตีลังกาเองนาน ๆ ครั้ง */
@keyframes loopy { 0% { transform: rotate(0) scale(1); } 20% { transform: translateY(8px) scale(1.08, .9); } 60% { transform: translateY(-50px) rotate(-360deg) scale(1.05); } 80% { transform: translateY(4px) rotate(-360deg) scale(1.06, .94); } 100% { transform: rotate(-360deg) scale(1); } }
@keyframes drift { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(40px); } }
@keyframes inR { from { opacity: 0; transform: translate(260px, -200px) rotate(25deg) scale(.6); } to { opacity: 1; transform: translate(0, 0); } }
@keyframes inL { from { opacity: 0; transform: translate(-280px, 220px) rotate(-25deg) scale(.6); } to { opacity: 1; transform: translate(0, 0); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0) scale(1.06); } 20% { transform: rotate(-9deg) scale(1.08); } 40% { transform: rotate(8deg) scale(1.08); } 60% { transform: rotate(-6deg) scale(1.07); } 80% { transform: rotate(4deg) scale(1.06); } }
@keyframes flip { 0% { transform: translateY(0) rotate(0) scale(1); } 35% { transform: translateY(-70px) rotate(-200deg) scale(1.12); } 70% { transform: translateY(-20px) rotate(-360deg) scale(1.05); } 85% { transform: translateY(6px) scale(1.1, .9); } 100% { transform: translateY(0) rotate(-360deg) scale(1); } }
/* ตัวละครกด/ชี้ได้ (เนื้อหาเว็บยังกดได้ปกติ) */
.layout { pointer-events: none; }
.intro, .sheet { pointer-events: auto; }
/* อนุภาคตอนคลิก: หัวใจ/ดาว เด้งกระจาย */
.pop { position: fixed; z-index: 50; pointer-events: none; font-size: 22px; line-height: 1; animation: pop 1s ease-out forwards; }
@keyframes pop { 0% { opacity: 1; transform: translate(-50%, -50%) scale(.4); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.1) rotate(var(--r)); } }
/* ดาว: ระยิบ + เด้ง */
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; } 30% { transform: scale(1.25) rotate(-12deg); } 60% { transform: scale(.75) rotate(16deg); opacity: .65; } }
/* ---------- โครง 2 คอลัมน์ ---------- */
.layout { max-width: 1040px; min-height: 100vh; margin: 0 auto; padding: 48px 20px; display: grid; grid-template-columns: 1fr 1.05fr; gap: 56px; align-items: center; }

.intro { display: flex; flex-direction: column; gap: 16px; }
.logo { width: 132px; border-radius: 16px; border: 1px solid var(--line); }
.kicker { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; letter-spacing: .12em; color: var(--blue); }
.kicker i { width: 26px; height: 2px; background: var(--blue); border-radius: 2px; }
h1 { font-size: clamp(30px, 4.2vw, 44px); font-weight: 600; line-height: 1.15; }
h1 .srv { color: var(--blue); font-weight: 700; }
.lead { color: var(--muted); font-size: 16px; font-weight: 300; line-height: 1.6; max-width: 400px; }

/* ไทม์ไลน์ขั้นตอน (แนวตั้ง) */
.timeline { list-style: none; margin-top: 8px; counter-reset: s; }
.timeline li { position: relative; padding: 0 0 22px 52px; counter-increment: s; }
.timeline li::before {
    content: counter(s); position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center; font-weight: 600; font-size: 15px;
    background: var(--soft); border: 1px solid var(--line); color: var(--muted); transition: all .25s;
}
.timeline li::after { content: ''; position: absolute; left: 16px; top: 40px; bottom: 4px; width: 2px; border-radius: 2px; background: var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline b { display: block; font-size: 16px; font-weight: 500; color: var(--muted); line-height: 1.3; transition: color .25s; }
.timeline span { font-size: 13.5px; color: rgba(238,242,245,.38); font-weight: 300; }
.timeline li.on::before { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 0 0 5px rgba(10,168,243,.15); }
.timeline li.on b { color: var(--text); }
.timeline li.done::before { content: '✓'; background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.5); color: var(--ok); }
.timeline li.done::after { background: rgba(52,211,153,.45); }
.timeline li.done b { color: var(--text); }

/* ---------- แผ่นงานด้านขวา ---------- */
.sheet { position: relative; padding: 32px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 30px 60px rgba(0,0,0,.4); min-height: 300px; }
.view { display: flex; flex-direction: column; gap: 16px; animation: in .35s ease both; }
.tag { align-self: flex-start; padding: 4px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 500; color: var(--blue); background: rgba(10,168,243,.1); border: 1px solid rgba(10,168,243,.3); }
.tag.warn { color: var(--warn); background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.35); }
.tag.ok { color: var(--ok); background: rgba(52,211,153,.08); border-color: rgba(52,211,153,.35); }
h2 { font-size: 26px; font-weight: 600; line-height: 1.25; margin-top: -4px; }
.muted { color: var(--muted); font-size: 14.5px; line-height: 1.6; font-weight: 300; }
.muted.sm { font-size: 13px; }
.srv { font-weight: 500; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.join { display: flex; gap: 16px; align-items: center; padding: 14px; border-radius: 14px; background: var(--soft); border: 1px dashed var(--line); }
.join b { font-size: 15px; font-weight: 500; }
.join .btn { margin-top: 8px; }
.qr { flex: none; width: 96px; height: 96px; padding: 6px; border-radius: 10px; background: #fff; }
.qr canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.qr.img { padding: 0; background: none; border-radius: 12px; overflow: hidden; }
.qr img { width: 100%; height: 100%; display: block; }

.me { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.me img { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; }
.me small { display: block; font-size: 12px; color: var(--muted); }
.me b { font-size: 15px; font-weight: 500; }

/* ---------- ปุ่ม ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; border: 1px solid transparent; padding: 11px 20px; border-radius: 10px; font-size: 15px; font-weight: 500; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--blue); color: #fff; box-shadow: 0 8px 24px rgba(10,168,243,.25); }
.btn.primary:hover { background: #26b3f5; }
.btn.ghost { background: var(--soft); border-color: var(--line); }
.btn.ghost:hover { border-color: rgba(10,168,243,.6); }
.btn.link { background: none; color: var(--muted); padding: 11px 8px; }
.btn.link:hover { color: var(--text); }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.btn.big { width: 100%; padding: 14px 20px; font-size: 16px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions .btn.primary { flex: 1; }

/* ---------- ฟอร์ม ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13.5px; font-weight: 500; color: var(--muted); }
.field small { font-weight: 300; margin-left: 4px; opacity: .8; }
.field input { width: 100%; padding: 11px 13px; border-radius: 10px; outline: none; background: rgba(0,0,0,.3); border: 1px solid var(--line); font-size: 16px; transition: border-color .15s, box-shadow .15s; }
.field input::placeholder { color: rgba(238,242,245,.25); }
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(10,168,243,.18); }
.field input.bad { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(248,113,113,.15); }
.field input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: 10px; background: rgba(0,0,0,.3); border: 1px solid var(--line); }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 8px 2px; border-radius: 8px; font-size: 13.5px; color: var(--muted); transition: all .15s; }
.seg input:checked + span { background: var(--blue); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--blue); }
.preview { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--soft); border-left: 3px solid var(--blue); }
.preview span { font-size: 13px; color: var(--muted); }
.preview b { font-size: 17px; font-weight: 600; text-align: right; word-break: break-word; }
.err { color: var(--bad); font-size: 13.5px; }
.err:empty { display: none; }

/* ---------- บัตรนักเรียน (แนวตั้ง สีธีมเซิร์ฟ + สายคล้องคอ) ---------- */
.lanyard { position: relative; display: flex; flex-direction: column; align-items: center; padding-top: 46px; }
.strap { position: absolute; top: 0; left: 50%; width: 24px; height: 40px; transform: translateX(-50%); border-radius: 0 0 4px 4px; background: linear-gradient(90deg, #0786C4, var(--blue) 50%, #0786C4); }
.clip { position: absolute; top: 34px; left: 50%; z-index: 2; width: 38px; height: 24px; transform: translateX(-50%); border-radius: 6px; background: linear-gradient(180deg, #e3e9ee, #9aa7b1); box-shadow: 0 3px 6px rgba(0,0,0,.4); }
.clip::after { content: ''; position: absolute; left: 50%; bottom: 5px; width: 14px; height: 4px; transform: translateX(-50%); border-radius: 2px; background: rgba(0,0,0,.3); }
.sc-wrap { width: min(290px, 100%); container-type: inline-size; animation: drop .6s cubic-bezier(.2,.9,.3,1.15) both; transform-origin: top center; }
.sc {
    position: relative; display: flex; flex-direction: column; align-items: center; overflow: hidden;
    border-radius: 18px; border: 1px solid #34383b;
    background: radial-gradient(120% 60% at 50% 0%, rgba(10,168,243,.22), transparent 60%), linear-gradient(180deg, #161b20, #101214);
    box-shadow: 0 24px 50px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.06);
}
.sc-head { margin-top: 10cqw; text-align: center; } /* หัวบัตร: ตัวหนังสืออย่างเดียว กึ่งกลาง (คลิปอยู่ขอบบน) */
.sc-head b { display: block; font-size: 7cqw; font-weight: 700; line-height: 1.1; letter-spacing: .02em; }
.sc-head small { display: inline-block; margin-top: 1.6cqw; padding: .6cqw 3cqw; border-radius: 99px; font-size: 3.1cqw; color: var(--blue); letter-spacing: .24em; font-weight: 500; background: rgba(10,168,243,.1); border: 1px solid rgba(10,168,243,.3); }
.sc-photo { position: relative; width: 42cqw; aspect-ratio: 1; margin-top: 7cqw; border-radius: 50%; padding: 1.2cqw; background: conic-gradient(from 200deg, var(--blue), #7dd3fc, var(--blue-d), var(--blue)); box-shadow: 0 0 0 1.6cqw rgba(10,168,243,.12), 0 1.5cqw 6cqw rgba(10,168,243,.25); }
.sc-photo img { width: 100%; height: 100%; display: block; border-radius: 50%; object-fit: cover; background: #1b2329; border: 1.4cqw solid #121619; }
.sc-name { margin-top: 5cqw; padding: 0 6cqw; font-size: 7.6cqw; font-weight: 600; line-height: 1.15; text-align: center; word-break: break-word; }
.sc-name span { color: var(--blue); }
.sc-role { margin-top: 1cqw; font-size: 3.9cqw; color: var(--muted); font-weight: 300; }
.sc-rows { width: 86%; margin-top: 5cqw; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2cqw; }
.sc-rows div { padding: 2.4cqw 0; border-radius: 3cqw; text-align: center; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); }
.sc-rows dt { font-size: 3.2cqw; color: var(--muted); }
.sc-rows dd { font-size: 4.8cqw; font-weight: 500; }
.sc-code { width: 100%; margin-top: 6cqw; padding: 4cqw 9cqw 4.4cqw; display: flex; flex-direction: column; align-items: center; gap: 1.6cqw; background: #eef3f6; color: #12181d; }
.sc-code canvas { width: 100%; height: 11cqw; display: block; }
.sc-code b { font-size: 4cqw; letter-spacing: .32em; font-weight: 600; }
/* ---------- ยืนยัน ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(5,8,10,.72); backdrop-filter: blur(4px); animation: fade .2s both; }
.modal-box { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; padding: 26px; border-radius: 16px; background: #121518; border: 1px solid var(--line); animation: in .25s both; }
.modal-box h3 { font-size: 19px; font-weight: 600; }
.name-preview { padding: 16px; border-radius: 12px; background: rgba(10,168,243,.08); border: 1px solid rgba(10,168,243,.35); font-size: 24px; font-weight: 600; text-align: center; word-break: break-word; }

/* ---------- อื่น ๆ ---------- */
.loading { display: flex; justify-content: center; gap: 8px; padding: 110px 0; }
.loading i { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); animation: dot 1s ease-in-out infinite; }
.loading i:nth-child(2) { animation-delay: .15s; } .loading i:nth-child(3) { animation-delay: .3s; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; padding: 10px 18px; border-radius: 10px; background: #121518; border: 1px solid var(--line); font-size: 14px; transition: all .25s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: var(--bad); color: #fecaca; }

@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes drop { 0% { opacity: 0; transform: translateY(-40px) rotate(-6deg); } 60% { opacity: 1; transform: translateY(4px) rotate(2deg); } 100% { transform: none; } }
@keyframes dot { 0%, 100% { transform: scale(.6); opacity: .4; } 50% { transform: scale(1); opacity: 1; } }

@media (max-width: 860px) {
    .kid1 { width: 120px; right: -10px; top: 8px; opacity: .9; }
    .kid2 { width: 100px; left: -8px; top: 118px; bottom: auto; opacity: .9; }
    .cl3, .cl4, .st2, .st4 { display: none; }
    .cl1 { width: 380px; } .cl2 { width: 420px; }
    .st1 { width: 30px; top: 22%; } .st3 { width: 24px; }
}
@media (min-width: 861px) and (max-width: 1260px) { .kid1 { width: 170px; } .kid2 { width: 180px; } }
@media (max-width: 520px) { .kid2, .st1 { display: none; } .kid1 { width: 92px; right: -6px; top: 4px; } } /* จอมือถือแคบ: เหลือตัวละครตัวเดียว ไม่บังหัวข้อ */
@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; gap: 24px; padding: 28px 16px; align-items: start; }
    .intro { align-items: center; text-align: center; gap: 12px; }
    .logo { width: 104px; }
    .lead { font-size: 14.5px; }
    .timeline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; text-align: center; }
    .timeline li { padding: 42px 0 0; }
    .timeline li::before { left: 50%; transform: translateX(-50%); }
    .timeline li::after { display: none; }
    .timeline b { font-size: 13.5px; }
    .timeline span { display: none; }
    .sheet { padding: 22px 18px; }
}
@media (max-width: 440px) {
    .grid2 { grid-template-columns: 1fr; }
    .join { flex-direction: column; text-align: center; }
}
/* ไม่ปิดอนิเมชันตาม prefers-reduced-motion: เครื่องที่ปิดเอฟเฟกต์ Windows จะได้เห็นตัวละครขยับด้วย */
