/* ==========================================================================
   ใบฮับ · ลูกเล่นชุด v4
   1) ธีมมืด  2) ปุ่มกด 3 มิติแบบ School Gradebook (.btn-push)  3) กล่องอัปโหลดแบบสมุดจด
   4) ซองจดหมายบินตอนส่งงาน  5) หน้าเข้าสู่ระบบแบบเคลื่อนไหว
   ทุกการเคลื่อนไหวปิดเองเมื่อผู้ใช้ตั้ง prefers-reduced-motion
   ========================================================================== */

/* ---------- 1) ธีมมืด ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0e1712; --paper-2: #15221a; --surface: #142019; --surface-2: #18261e;
  --line: #243529; --line-2: #31483a;
  --ink: #e3efe6; --ink-2: #b4c8ba; --muted: #88a291; --faint: #5f796a;
  --leaf-600: #63c48a; --leaf-700: #8fdcac; --leaf-50: #1a2e22; --leaf-100: #21402d;
  --sprout: #2c4a35; --sage: #5d8a6a; --lime-ink: #2b3a0a;
  --st-sent: #63c48a; --st-sent-bg: #1b3324; --st-ok: #9be6b8; --st-ok-bg: #1f3d2a;
  --st-late: #f0b450; --st-late-bg: #3a2d12; --st-miss: #f39a85; --st-miss-bg: #3d211b;
  --st-back: #86bfe0; --st-back-bg: #16293a;
  --shadow-sm: 0 1px 0 rgba(0,0,0,.25);
  --shadow: 0 10px 28px -12px rgba(0,0,0,.65);
  --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.75);
}
html[data-theme="dark"] body { background: var(--paper); }
html[data-theme="dark"] .side { background: linear-gradient(180deg, #111c15 0%, #0d1611 100%); }
html[data-theme="dark"] .topbar { background: rgba(14, 23, 18, .86); }
html[data-theme="dark"] .side-card,
html[data-theme="dark"] .leafbox.dark,
html[data-theme="dark"] .bulkbar { background: #1f4a31; border-color: #1f4a31; }
html[data-theme="dark"] .toast { background: #22382a; color: #eaf6e4; }
html[data-theme="dark"] .table tbody tr:hover { background: #18261e; }
html[data-theme="dark"] .cal-day.we:not(.off) { background: #111c16; }
html[data-theme="dark"] .my-card.urgent { border-color: #5a2d24; background: linear-gradient(90deg, #2a1814, var(--surface) 40%); }
html[data-theme="dark"] .my-card.done { background: linear-gradient(90deg, #15291c, var(--surface) 40%); }
html[data-theme="dark"] .file.err { background: #2a1814; border-color: #5a2d24; }
html[data-theme="dark"] .notice.ann { background: linear-gradient(90deg, #2c3c12, #1f2c0f); color: #d7f08a; }
html[data-theme="dark"] .btn-lime { color: #1e3a2b; }
html[data-theme="dark"] .demo-hint code { background: var(--surface-2); color: var(--leaf-700); }
html[data-theme="dark"] .empty .art, html[data-theme="dark"] .hero-badge { opacity: .92; }
html[data-theme="dark"] .mc.approved { background: #2f8051; }
html[data-theme="dark"] .logo-preview { background: #f3f8ee; }
html[data-theme="dark"] .brand img.school-logo { background: #f3f8ee; border-radius: 10px; padding: 2px; }
html.theme-anim, html.theme-anim * { transition: background-color .45s ease, color .45s ease, border-color .45s ease, box-shadow .45s ease !important; }

.top-actions .theme-switch { margin-right: 4px; }
@media (max-width: 640px) { .top-actions .theme-switch { --toggle-size: 11px !important; } }

/* ---------- 2) ปุ่มกดแบบ 3 มิติ (ต้นแบบ .btn-push ของ School Gradebook) ----------
   หน้าปุ่มสีทึบ ขอบเข้ม และฐานทึบสีเดียวกับขอบยื่นลงมาใต้ปุ่ม
   ชี้ = ยกขึ้น 2px · กด = ปุ่มจมลงนั่งบนฐานพอดี (ฐานหายไป)
   ทุกคู่สีหน้าปุ่ม/ตัวอักษรผ่าน AA 4.5 — ขาวบนเขียว #1f7d48 = 5.1 · ขาวบนแดง #c8452f = 4.8 */
.btn {
  --push-face: var(--surface); --push-ink: var(--ink-2);
  --push-edge: color-mix(in srgb, var(--push-face) 52%, #000);
  --push-lift: 4px;
  height: auto; min-height: 42px; padding: 7px 18px;
  background: var(--push-face); color: var(--push-ink);
  border: 2px solid var(--push-edge); border-radius: 12px;
  font-family: var(--font-display); font-weight: 700; font-size: 14.5px; line-height: 1.35;
  box-shadow: 0 var(--push-lift) 0 var(--push-edge);
  margin-bottom: var(--push-lift);
  transform: translateY(0);
  transition: transform .1s ease, box-shadow .1s ease, filter .15s ease, background .15s;
}
.btn:hover { color: var(--push-ink); filter: brightness(1.05); transform: translateY(-2px); box-shadow: 0 calc(var(--push-lift) + 2px) 0 var(--push-edge); }
.btn:active { transform: translateY(var(--push-lift)); box-shadow: 0 0 0 var(--push-edge); }
.btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--push-face) 70%, #fff); outline-offset: 3px; }
.btn[disabled], .btn.disabled { filter: grayscale(.5); opacity: .6; transform: none; }
.btn-sm { --push-lift: 3px; min-height: 34px; padding: 4px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { --push-lift: 5px; min-height: 50px; padding: 9px 24px; font-size: 16px; border-radius: 14px; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn-row { align-items: flex-start; }

.btn-primary { --push-face: #1f7d48; --push-ink: #fff; }
.btn-lime    { --push-face: #d7f08a; --push-ink: #1e3a2b; --push-edge: #4f6a12; }
.btn-soft    { --push-face: #ebf6e7; --push-ink: #23663f; --push-edge: #2f8051; }
.btn-ghost   { --push-face: #fff;    --push-ink: #2c4a38; --push-edge: #8fb39a; }
.btn-danger  { --push-face: #c8452f; --push-ink: #fff; }
.btn-line    { --push-face: #06c755; --push-ink: #053d1c; --push-edge: #037a33; }
.btn-white   { --push-face: #fff;    --push-ink: #1e3a2b; --push-edge: #10301f; }
/* ทุกแบบเก็บสีไว้เหมือนเดิมตอนชี้ — ใช้ความสว่างแทนการเปลี่ยนพื้น */
.btn-primary:hover, .btn-lime:hover, .btn-soft:hover, .btn-ghost:hover, .btn-danger:hover, .btn-line:hover, .btn-white:hover { background: var(--push-face); color: var(--push-ink); }

/* ปุ่มไอคอนบนแถบบน หัวกล่อง และประกาศ — แบน ไม่มีฐาน (ไม่ใช่ปุ่มสั่งงาน) */
.btn-flat, .topbar .btn-icon, .modal-head > .btn-icon, .notice .btn-icon, .bell-menu .btn {
  --push-lift: 0px; border-color: transparent; background: transparent; box-shadow: none; margin-bottom: 0;
}
.btn-flat:hover, .topbar .btn-icon:hover, .modal-head > .btn-icon:hover, .notice .btn-icon:hover, .bell-menu .btn:hover {
  background: var(--leaf-50); transform: none; box-shadow: none; filter: none;
}
.bell-menu .btn { color: var(--leaf-600); }

html[data-theme="dark"] .btn-primary { --push-face: #2f8a55; --push-edge: #0f2e1c; }
html[data-theme="dark"] .btn-soft    { --push-face: #1f3a29; --push-ink: #a6e6bd; --push-edge: #0b1a11; }
html[data-theme="dark"] .btn-ghost   { --push-face: #1b2a21; --push-ink: #d4e4d9; --push-edge: #0b1510; }
html[data-theme="dark"] .btn-danger  { --push-face: #b9432e; --push-edge: #4a160c; }
html[data-theme="dark"] .btn-lime    { --push-edge: #2d3c08; }

@media (max-width: 575px) {
  .btn { padding: 6px 14px; }
  .btn-icon { padding: 0; }
}
/* ลดการเคลื่อนไหว: ตัดการลอยตอนชี้ แต่ยังคงการจมตอนกดไว้ให้รู้ว่ากดแล้ว */
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:hover { transform: none; box-shadow: 0 var(--push-lift) 0 var(--push-edge); }
}

/* ---------- 3) กล่องอัปโหลดแบบสมุดจด ---------- */
.dd-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dd-note { font-size: 12.5px; color: var(--muted); text-align: center; max-width: 340px; }
.dd {
  --dd-ink: #1e3a2b; --dd-ink-fixed: #1e3a2b;
  --dd-zone: #fdfef9; --dd-line: #d6edcc;
  --dd-back: #3e9b63; --dd-front: #bfe6a0; --dd-front-hi: #d7f08a;
  --dd-btn: #d7f08a; --dd-btn-hi: #3e9b63; --dd-accent: #4f8fb3; --dd-sparkle: #c9e77a;
  --dd-paper: #fff; --dd-sub: #5b6e62;
  position: relative; isolation: isolate;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 280px; max-width: 100%; min-height: 280px; padding: 20px; margin: 14px 0 4px;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1);
}
.dd::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(var(--dd-zone) 20px, transparent 20px) 0 0 / 100% 24px,
    linear-gradient(var(--dd-line) 2px, transparent 2px) 0 20px / 100% 24px var(--dd-zone);
  border: 3px dashed var(--dd-ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  box-shadow: 8px 8px 0 rgba(30, 58, 43, .15);
  filter: url(#ddJitter);
  transition: box-shadow .4s ease, border-radius .4s ease;
}
.dd-input { position: absolute; inset: 0; z-index: 20; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dd-input:disabled { cursor: progress; }
.dd:has(.dd-input:focus-visible)::before { outline: 3px solid var(--dd-accent); outline-offset: 5px; }
.dd-folder { position: relative; display: block; z-index: 2; width: 130px; height: 100px; margin-bottom: 22px; animation: ddFloat 3.5s infinite ease-in-out; }
.dd-back { position: absolute; bottom: 0; left: 0; z-index: 1; display: block; width: 100%; height: 85px; background: var(--dd-back);
  border: 3px solid var(--dd-ink-fixed); border-radius: 10px 255px 15px 225px / 255px 10px 225px 15px; box-shadow: inset 0 0 12px rgba(0,0,0,.15); }
.dd-tab { position: absolute; top: -15px; left: 10px; display: block; width: 45px; height: 20px; background: var(--dd-back);
  border: 3px solid var(--dd-ink-fixed); border-bottom: none; border-radius: 10px 15px 0 0 / 255px 255px 0 0; }
.dd-front { position: absolute; bottom: -2px; left: -4px; z-index: 3; display: block; width: calc(100% + 8px); height: 70px;
  background: var(--dd-front); color: var(--dd-ink-fixed); border: 3px solid var(--dd-ink-fixed);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; box-shadow: 4px 4px 0 rgba(30,58,43,.15);
  transform-origin: bottom center; transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), background .3s ease; }
.dd-smile { position: absolute; bottom: 15px; left: 50%; width: 30px; height: 30px; transform: translateX(-50%); }
.dd-papers { position: absolute; bottom: 10px; left: 0; z-index: 2; display: block; width: 100%; height: 100%; }
.dd-paper { position: absolute; bottom: 10px; display: block; width: 55px; height: 70px; padding: 8px; background: var(--dd-paper);
  border: 2px solid var(--dd-ink-fixed); border-radius: 4px; box-shadow: 2px 2px 0 rgba(30,58,43,.1);
  transition: transform .5s cubic-bezier(.34, 1.56, .64, 1); }
.dd-paper.is-1 { left: 15px; transform: rotate(-5deg); }
.dd-paper.is-2 { right: 15px; transform: rotate(5deg); }
.dd-paper i { display: block; height: 4px; width: 100%; margin-bottom: 6px; border-radius: 2px; background: var(--dd-ink-fixed); opacity: .8; }
.dd-paper i.is-short { width: 60%; }
.dd-paper svg { display: block; width: 100%; height: 26px; margin-bottom: 6px; fill: none; stroke: var(--dd-back); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dd-paper svg circle { fill: var(--dd-sparkle); stroke: var(--dd-back); }
.dd-btn { position: relative; z-index: 3; display: block; max-width: 100%; padding: 11px 24px; background: var(--dd-btn);
  border: 3px solid var(--dd-ink-fixed); border-radius: 15px 255px 15px 225px / 255px 15px 225px 15px;
  box-shadow: 4px 4px 0 var(--dd-ink-fixed);
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), background .3s ease, box-shadow .3s ease; }
.dd-btn-t { display: block; min-width: 0; text-align: center; overflow-wrap: anywhere; text-wrap: balance;   /* ข้อความยาวตัดบรรทัดในกรอบ ไม่ล้นกล่อง */
  font: 700 1.05rem/1.25 var(--font-display); font-variant-numeric: tabular-nums;
  color: var(--dd-ink-fixed); text-shadow: 2px 2px 0 #fff; transition: color .3s ease, text-shadow .3s ease; }
/* จอโทรศัพท์: ชื่อปุ่มยาว (มีชื่อโฟลเดอร์ต่อท้าย) ให้ขึ้นบรรทัดใหม่ ไม่ดันกล่องล้นจอ */
@media (max-width: 640px) { .dd-btn { padding: 10px 16px; } }
.dd-sub { position: relative; z-index: 3; display: block; max-width: 230px; margin-top: 12px; font-size: .78rem; line-height: 1.4; text-align: center; color: var(--dd-sub); }
.dd-sub[data-tone="bad"] { color: var(--st-miss); font-weight: 700; }
.dd-sub[data-tone="ok"] { color: var(--leaf-600); font-weight: 700; }
.dd-decor { position: absolute; z-index: 5; pointer-events: none; opacity: 0; transition: transform .4s cubic-bezier(.175, .885, .32, 1.275), opacity .3s ease; }
.dd-decor path { stroke: var(--dd-ink); stroke-width: 1.5; }
.dd-decor.is-sparkle { top: 30px; right: 40px; width: 24px; transform: scale(0); }
.dd-decor.is-sparkle path { fill: var(--dd-sparkle); }
.dd-decor.is-star { top: 50px; left: 30px; width: 30px; transform: scale(0); }
.dd-decor.is-star path { fill: var(--dd-accent); }
.dd-clip { position: absolute; top: -15px; left: 20px; z-index: 10; width: 40px; height: 40px; color: var(--dd-ink); transform: rotate(-15deg); }
@media (hover: hover) {
  .dd:hover:not(.is-busy) { transform: translateY(-4px); }
  .dd:hover:not(.is-busy)::before { box-shadow: 10px 10px 0 var(--dd-ink); border-radius: 15px 225px 15px 255px / 255px 15px 225px 15px; }
  .dd:hover:not(.is-busy) .dd-front { transform: scaleY(.85) skewX(-5deg); background: var(--dd-front-hi); }
  .dd:hover:not(.is-busy) .dd-paper.is-1 { animation: ddWiggle1 1.5s infinite ease-in-out; }
  .dd:hover:not(.is-busy) .dd-paper.is-2 { animation: ddWiggle2 1.5s infinite ease-in-out .2s; }
  .dd:hover:not(.is-busy) .dd-btn { background: var(--dd-btn-hi); transform: scale(1.08) rotate(-3deg) translateY(-4px); box-shadow: 6px 6px 0 var(--dd-ink-fixed); }
  .dd:hover:not(.is-busy) .dd-btn-t { color: #fff; text-shadow: 2px 2px 0 var(--dd-ink-fixed); }
  .dd:hover:not(.is-busy) .dd-decor { opacity: 1; }
  .dd:hover:not(.is-busy) .dd-decor.is-sparkle { transform: scale(1.2) rotate(15deg); }
  .dd:hover:not(.is-busy) .dd-decor.is-star { transform: scale(1.3) rotate(-20deg); }
}
.dd.is-over { transform: translateY(-4px) scale(1.02); }
.dd.is-over::before { border-style: solid; box-shadow: 10px 10px 0 var(--dd-ink); }
.dd.is-over .dd-front { transform: scaleY(.85) skewX(-5deg); background: var(--dd-front-hi); }
.dd.is-over .dd-paper.is-1 { animation: ddWiggle1 1.5s infinite ease-in-out; }
.dd.is-over .dd-paper.is-2 { animation: ddWiggle2 1.5s infinite ease-in-out .2s; }
.dd.is-over .dd-decor { opacity: 1; }
.dd.is-over .dd-decor.is-sparkle { transform: scale(1.2) rotate(15deg); }
.dd.is-over .dd-decor.is-star { transform: scale(1.3) rotate(-20deg); }
.dd:active:not(.is-busy) { transform: translate(6px, 6px); }
.dd:active:not(.is-busy)::before { box-shadow: 2px 2px 0 var(--dd-ink); }
.dd.is-picked .dd-btn { background: var(--dd-front-hi); }
.dd.is-busy { cursor: progress; }
.dd.is-busy .dd-btn { background: var(--dd-btn-hi); }
.dd.is-busy .dd-btn-t { color: #fff; text-shadow: 2px 2px 0 var(--dd-ink-fixed); }
.dd.is-busy .dd-paper.is-1 { animation: ddSend1 1.1s infinite ease-in-out; }
.dd.is-busy .dd-paper.is-2 { animation: ddSend2 1.1s infinite ease-in-out .35s; }
.dd.is-busy .dd-front { background: var(--dd-front-hi); }
.dd.is-done .dd-btn { background: #8ce99a; }
.dd.is-compact { width: 220px; min-height: 220px; padding: 14px; }
.dd.is-compact .dd-folder { transform: scale(.78); margin-bottom: 4px; }
.dd.is-compact .dd-clip { width: 32px; height: 32px; }
@keyframes ddFloat { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(2deg); } }
.dd.is-compact .dd-folder { animation-name: ddFloatSm; }
@keyframes ddFloatSm { 0%, 100% { transform: scale(.78) translateY(0) rotate(0); } 50% { transform: scale(.78) translateY(-6px) rotate(2deg); } }
@keyframes ddWiggle1 { 0%, 100% { transform: rotate(-15deg) translateY(-40px); } 50% { transform: rotate(-10deg) translateY(-45px); } }
@keyframes ddWiggle2 { 0%, 100% { transform: rotate(18deg) translateY(-35px); } 50% { transform: rotate(22deg) translateY(-30px); } }
@keyframes ddSend1 { 0% { transform: rotate(-8deg) translateY(-42px); } 60% { transform: rotate(-4deg) translateY(4px); } 100% { transform: rotate(-8deg) translateY(-42px); } }
@keyframes ddSend2 { 0% { transform: rotate(10deg) translateY(-36px); } 60% { transform: rotate(4deg) translateY(4px); } 100% { transform: rotate(10deg) translateY(-36px); } }
html[data-theme="dark"] .dd { --dd-ink: #e3efe6; --dd-zone: #17241c; --dd-line: rgba(156, 195, 166, .18); --dd-sub: #a9bfb0; }
html[data-theme="dark"] .dd::before { box-shadow: 8px 8px 0 rgba(0, 0, 0, .4); }

/* ---------- 4) ตู้ไปรษณีย์กินจดหมาย (ส่งงาน / ส่งข้อมูลสำเร็จ) ----------
   ต้นแบบ "Animated Email Box": ตัวอักษรในก้อนเมฆสั่นดุ๊กดิ๊ก แล้วบินเข้าปากตัวละคร
   ตัวละครเป็นของเราเอง: "น้องตู้ใบ" ตู้ไปรษณีย์สีเขียวมีต้นอ่อนบนหัว
   จังหวะ: อ้าปาก → ตัวอักษรสั่น → บินเข้าปาก (ตัวท้ายไปก่อน) → หุบปากเคี้ยว → ยกธง → ข้อความสำเร็จ */
.mailfly { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: rgba(14, 23, 18, .42); backdrop-filter: blur(4px);
  animation: mfIn .25s ease both; cursor: pointer; }
.mailfly.out { animation: mfOut .35s ease both; }
.mf-card { width: min(400px, calc(100vw - 32px)); padding: 22px 22px 22px; border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-lg);
  text-align: center; animation: mfPop .45s cubic-bezier(.2, 1.3, .4, 1) both; }
.mf-stage { position: relative; display: grid; grid-template-columns: 1.7fr 1fr; align-items: end; gap: 6px; height: 160px; margin-bottom: 10px; }

/* ก้อนเมฆถือข้อความ */
.mf-cloud { position: relative; align-self: center; height: 104px; }
.mf-cloud svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 6px 12px rgba(30, 58, 43, .12)); }
.mf-cloud svg path { fill: var(--leaf-50); stroke: var(--line-2); stroke-width: 1.5; }
.mf-text { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; padding: 0 22px;
  font: 700 17px/1.4 var(--font-display); color: var(--leaf-700); white-space: nowrap; }
.mf-text .g { display: inline-block; white-space: pre; transform-origin: 50% 100%; will-change: transform; }

/* น้องตู้ใบ */
.mf-box { position: relative; width: 100%; max-width: 128px; justify-self: center; }
.mf-box svg { display: block; width: 100%; overflow: visible; }
.mf-box .mb-body { transform-box: fill-box; transform-origin: 50% 100%; }
.mf-box .mb-mouth { transform-box: fill-box; transform-origin: 50% 50%; transform: scaleY(.25); transition: transform .22s cubic-bezier(.3, 1.6, .5, 1); }
.mf-box .mb-eye { transform-box: fill-box; transform-origin: 50% 50%; animation: mbBlink 3.2s 1s infinite; }
.mf-box .mb-flag { transform-box: view-box; transform-origin: 104px 78px; transform: rotate(90deg); transition: transform .45s cubic-bezier(.3, 1.7, .5, 1); }
.mf-box .mb-sprout { transform-box: fill-box; transform-origin: 50% 100%; animation: sproutSway 2.6s ease-in-out infinite; }
.mf-box .mb-cheek { opacity: .55; transition: opacity .2s; }
.mf-stage.mb-open .mb-mouth { transform: scaleY(1); }
.mf-stage.mb-chomp .mb-mouth { transform: scaleY(.12); transition-duration: .12s; }
.mf-stage.mb-chomp .mb-body { animation: mbChomp .55s ease both; }
.mf-stage.mb-chomp .mb-cheek { opacity: 1; }
.mf-stage.mb-flag .mb-flag { transform: rotate(0); }
.mf-spark { position: absolute; right: 8%; top: 18%; width: 64px; height: 64px; pointer-events: none; }
.mf-spark i { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: var(--lime); opacity: 0; }
.mf-stage.mb-flag .mf-spark i { animation: mbSpark .6s ease-out both; }
.mf-spark i:nth-child(1) { --tx: -30px; --ty: -26px; } .mf-spark i:nth-child(2) { --tx: 28px; --ty: -30px; background: #9cd67a; }
.mf-spark i:nth-child(3) { --tx: 34px; --ty: 6px; } .mf-spark i:nth-child(4) { --tx: -32px; --ty: 10px; background: #9cd67a; }
.mf-spark i:nth-child(5) { --tx: 0; --ty: -40px; }

.mf-card b { display: block; font: 700 19px/1.35 var(--font-display); color: var(--ink); opacity: 0; }
.mf-card p { margin-top: 4px; font-size: 14px; color: var(--muted); opacity: 0; }
.mf-card.is-done b { animation: mfText .4s ease both; }
.mf-card.is-done p { animation: mfText .4s .1s ease both; }
@keyframes mfIn { from { opacity: 0; } }
@keyframes mfOut { to { opacity: 0; } }
@keyframes mfPop { from { opacity: 0; transform: translateY(16px) scale(.94); } }
@keyframes mfText { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes mbBlink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes mbChomp { 0% { transform: scale(1); } 25% { transform: scale(1.1, .86); } 50% { transform: scale(.95, 1.06); } 75% { transform: scale(1.03, .97); } 100% { transform: scale(1); } }
@keyframes mbSpark { 0% { opacity: 1; transform: translate(0, 0) scale(.4); } 100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(1); } }
html[data-theme="dark"] .mf-cloud svg path { fill: #1f3528; stroke: #31483a; }
html[data-theme="dark"] .mf-text { color: #b9eccb; }
@media (max-width: 420px) { .mf-stage { height: 140px; } .mf-text { font-size: 15px; padding: 0 16px; } }

/* ---------- 5) หน้าเข้าสู่ระบบแบบเคลื่อนไหว ---------- */
.auth-form { position: relative; overflow: hidden; }
.auth-switch { position: absolute; top: 20px; right: 24px; z-index: 5; }
.auth-blob { position: absolute; z-index: 0; border-radius: 50%; filter: blur(50px); opacity: .6; pointer-events: none; animation: blobDrift 18s ease-in-out infinite alternate; }
.auth-blob.b1 { width: 380px; height: 380px; top: -120px; right: -100px; background: #e3f4b8; }
.auth-blob.b2 { width: 320px; height: 320px; bottom: -120px; left: -80px; background: #cfe8b5; animation-duration: 22s; animation-direction: alternate-reverse; }
html[data-theme="dark"] .auth-blob { opacity: .18; }
.auth-leaves { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.auth-leaves i { position: absolute; bottom: -50px; left: calc(6% + var(--i) * 16%); color: var(--sage); opacity: .3;
  animation: leafRise calc(13s + var(--i) * 2.2s) linear infinite; animation-delay: calc(var(--i) * -3.4s); }
.auth-leaves .ic { width: calc(18px + var(--i) * 3px); height: calc(18px + var(--i) * 3px); }
.auth-box { position: relative; z-index: 2; }
.auth-box > * { animation: authRise .6s cubic-bezier(.2, .8, .2, 1) both; }
.auth-box > *:nth-child(2) { animation-delay: .05s; } .auth-box > *:nth-child(3) { animation-delay: .1s; }
.auth-box > *:nth-child(4) { animation-delay: .15s; } .auth-box > *:nth-child(5) { animation-delay: .2s; }
.auth-box > *:nth-child(6) { animation-delay: .25s; } .auth-box > *:nth-child(7) { animation-delay: .3s; }
.auth-box > *:nth-child(8) { animation-delay: .35s; } .auth-box > *:nth-child(9) { animation-delay: .4s; }
.auth-box > *:nth-child(10) { animation-delay: .45s; } .auth-box > *:nth-child(11) { animation-delay: .5s; }
.auth-badge { position: relative; display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 18px;
  border-radius: 16px 5px 16px 5px; background: var(--lime); color: var(--lime-ink); }
.auth-badge::after { content: ""; position: absolute; inset: -6px; border-radius: 20px 8px 20px 8px; border: 2px solid var(--lime); opacity: 0; animation: badgePulse 2.6s 1s ease-out infinite; }
.auth-badge .ic { animation: sproutSway 3s ease-in-out infinite; transform-origin: 50% 100%; }
.fl { position: relative; display: block; margin-bottom: 16px; }
.fl input { width: 100%; height: 58px; padding: 22px 48px 6px 48px; font: inherit; font-size: 15.5px; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 16px; outline: none;
  transition: border-color .2s, box-shadow .25s, background .2s; }
.fl input:hover { border-color: var(--sage); }
.fl input:focus { border-color: var(--leaf); box-shadow: 0 0 0 5px var(--leaf-50); }
.fl-label { position: absolute; left: 48px; top: 50%; transform: translateY(-50%); font-size: 15px; color: var(--muted); pointer-events: none;
  transition: top .2s cubic-bezier(.2, .8, .2, 1), font-size .2s, color .2s; }
.fl input:focus ~ .fl-label, .fl input:not(:placeholder-shown) ~ .fl-label { top: 16px; font-size: 12px; font-weight: 600; color: var(--leaf-600); }
.fl-ic { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); transition: color .2s, transform .3s cubic-bezier(.2, .9, .3, 1.4); }
.fl input:focus ~ .fl-ic { color: var(--leaf); transform: translateY(-50%) scale(1.12); }
.fl-line { position: absolute; left: 18px; right: 18px; bottom: 0; height: 2.5px; border-radius: 2px; background: linear-gradient(90deg, var(--leaf), var(--lime));
  transform: scaleX(0); transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
.fl input:focus ~ .fl-line { transform: scaleX(1); }
/* ช่องเลือกชื่อ (หน้าเข้าสู่ระบบ) — หน้าตาเดียวกับช่องพิมพ์ ป้ายลอยอยู่ด้านบนเสมอ */
.fl select { width: 100%; height: 58px; padding: 22px 44px 6px 48px; font: inherit; font-size: 15.5px; color: var(--ink); cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%237b9384' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center / 18px;
  border: 1.5px solid var(--line-2); border-radius: 16px; outline: none; appearance: none; transition: border-color .2s, box-shadow .25s; }
.fl select:hover { border-color: var(--sage); }
.fl select:focus { border-color: var(--leaf); box-shadow: 0 0 0 5px var(--leaf-50); }
.fl select ~ .fl-label { top: 16px; font-size: 12px; font-weight: 600; color: var(--leaf-600); }
.fl select:focus ~ .fl-ic { color: var(--leaf); }
.fl select:focus ~ .fl-line { transform: scaleX(1); }
.fl input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
.fl-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: none; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.fl-eye:hover { background: var(--leaf-50); color: var(--leaf-600); }
.fl-eye::after { content: ""; position: absolute; width: 22px; height: 2px; border-radius: 2px; background: currentColor; transform: rotate(-45deg) scaleX(0); transition: transform .25s; }
.fl-eye.on::after { transform: rotate(-45deg) scaleX(1); }
.auth-row { display: flex; align-items: center; gap: 10px; margin: -4px 2px 18px; }
.auth-row [data-caps] { display: inline-flex; align-items: center; gap: 4px; color: var(--st-late); }
.auth-go { position: relative; overflow: hidden; display: grid; place-items: center; width: 100%; height: 54px; border: 0; border-radius: 999px; cursor: pointer;
  font: 600 16px/1 var(--font-body); color: #fff; background: linear-gradient(120deg, #23663f, #3e9b63 45%, #64b97d);
  background-size: 160% 100%; box-shadow: 0 12px 24px -12px rgba(47, 128, 81, .8); transition: transform .2s, box-shadow .2s, background-position .5s; }
.auth-go::before { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; transform: skewX(-20deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent); animation: shimmer 3.8s 1.2s ease-in-out infinite; }
.auth-go:hover { transform: translateY(-2px); background-position: 100% 0; box-shadow: 0 16px 28px -12px rgba(47, 128, 81, .9); }
.auth-go:active { transform: translateY(1px); }
.auth-go-t { display: inline-flex; align-items: center; gap: 8px; transition: opacity .2s, transform .3s; }
.auth-go-t .ic { transition: transform .3s; }
.auth-go:hover .auth-go-t .ic { transform: translateX(4px); }
.auth-go-spin { position: absolute; opacity: 0; transition: opacity .2s; }
.auth-go-spin .ic { width: 24px; height: 24px; animation: spin 1s linear infinite; }
.auth-go.is-loading { pointer-events: none; }
.auth-go.is-loading .auth-go-t { opacity: 0; transform: translateY(8px); }
.auth-go.is-loading .auth-go-spin { opacity: 1; }
.notice.shake { animation: shake .45s cubic-bezier(.36, .07, .19, .97) both; }
.auth-art .art { animation: artFloat 7s ease-in-out infinite; }
.auth-art h2, .auth-art p { animation: authRise .8s .2s cubic-bezier(.2, .8, .2, 1) both; }
.auth-art p { animation-delay: .35s; }
@keyframes authRise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes blobDrift { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-40px, 30px) scale(1.08); } 100% { transform: translate(30px, -20px) scale(.95); } }
@keyframes leafRise { 0% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(30px, -55vh) rotate(180deg); } 100% { transform: translate(-10px, -115vh) rotate(360deg); } }
@keyframes badgePulse { 0% { opacity: .9; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes sproutSway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes shimmer { 0% { left: -60%; } 40%, 100% { left: 130%; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
@keyframes artFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

@media (prefers-reduced-motion: reduce) {
  .dd, .dd::before, .dd *, .auth-blob, .auth-leaves i, .auth-box > *, .auth-badge::after, .auth-badge .ic,
  .auth-go::before, .auth-art .art, .auth-art h2, .auth-art p, .notice.shake { animation: none !important; transition: none !important; }
  .mailfly *, .mailfly { animation-duration: .01s !important; animation-delay: 0s !important; transition: none !important; }
  .lt-in, .lt-flash, .line-typing i, .lt-preset span, .lt-token { animation: none !important; transition: none !important; }
}
/* แบบข้อความ LINE: ธีมมืด — จอโทรศัพท์คงสีแบบ LINE ส่วนกล่องแก้ข้อความใช้สีของธีม */
html[data-theme="dark"] .lt-presets { background: #0b130e; }
html[data-theme="dark"] .lt-preset input:checked + span { background: var(--leaf-100); color: var(--leaf-700); }
html[data-theme="dark"] .lt-token { background: var(--leaf-50); color: var(--leaf-700); }
html[data-theme="dark"] .lt-token:hover { background: var(--leaf-100); }
html[data-theme="dark"] .pg-phone .lt-status, html[data-theme="dark"] .pg-phone .nm { color: #d5e6da; }
.auth-row [data-caps][hidden] { display: none; }

/* ---------- แพนด้าเฝ้าฟอร์ม login (ต้นแบบ "Animated Login Page") ---------- */
.auth-stack { position: relative; z-index: 2; width: min(400px, 100%); }
.panda { --pd-dark: #2c4a38; --pd-line: #1e3a2b; position: relative; font-size: 16px; padding-top: 9.35em; }
.panda > div, .panda > svg { position: absolute; }
.pd-ear { top: 1.75em; width: 2.81em; height: 2.5em; background: var(--pd-dark); border: .18em solid var(--pd-line); border-radius: 2.5em 2.5em 0 0; }
.pd-ear.l { left: calc(50% - 4.875em); transform: rotate(-38deg); }
.pd-ear.r { left: calc(50% + 2.065em); transform: rotate(38deg); }
.pd-sprout { top: .2em; left: calc(50% - 1.25em); width: 2.5em; z-index: 1; transform-origin: 50% 100%; animation: sproutSway 3s ease-in-out infinite; }
.pd-face { top: 2em; left: calc(50% - 4.2em); z-index: 3; width: 8.4em; height: 7.5em; background: #fff; border: .18em solid var(--pd-line); border-radius: 7.5em 7.5em 5.62em 5.62em; }
.pd-blush { position: absolute; top: 4em; width: 1.37em; height: 1em; border-radius: 50%; background: #ffadc0; }
.pd-blush.l { left: 1em; transform: rotate(25deg); } .pd-blush.r { right: 1em; transform: rotate(-25deg); }
.pd-eye { position: absolute; top: 2.18em; width: 2em; height: 2.18em; border-radius: 2em; background: var(--pd-dark); }
.pd-eye.l { left: 1.37em; transform: rotate(-20deg); } .pd-eye.r { right: 1.37em; transform: rotate(20deg); }
.pd-ball { position: absolute; left: .6em; top: .6em; width: .6em; height: .6em; border-radius: 50%; background: #fff;
  transform: translate(var(--lx, 0), var(--ly, 0)); transition: transform .35s ease; }
.pd-nose { position: absolute; top: 4.37em; left: 0; right: 0; margin: auto; width: 1em; height: 1em; background: var(--pd-dark); border-radius: 1.2em 0 0 .25em; transform: rotate(45deg); }
.pd-mouth, .pd-mouth::before { position: absolute; width: .93em; height: .75em; border-radius: 50%; box-shadow: 0 .18em var(--pd-dark); }
.pd-mouth { top: 5.31em; left: 3.12em; } .pd-mouth::before { content: ""; left: .87em; }
.pd-hand { top: 8.4em; z-index: 4; width: 2.5em; height: 2.81em; background: var(--pd-dark); border: .18em solid var(--pd-line);
  border-radius: .6em .6em 2.18em 2.18em; transition: all .8s cubic-bezier(.5, 1.4, .5, 1); }
.pd-hand.l { left: calc(50% - 8.125em); } .pd-hand.r { left: calc(50% + 5.625em); }
.pd-paw { bottom: -1.6em; z-index: 4; width: 3.12em; height: 3.12em; background: var(--pd-dark); border: .18em solid var(--pd-line); border-radius: 2.5em 2.5em 1.2em 1.2em; }
.pd-paw.l { left: calc(50% - 5.625em); } .pd-paw.r { left: calc(50% + 2.505em); }
.pd-paw::before { content: ""; position: absolute; top: 1.12em; left: .55em; width: 1.75em; height: 1.37em; background: #fff; border-radius: 1.56em 1.56em .6em .6em; }
.pd-paw::after { content: ""; position: absolute; top: .31em; left: 1.12em; width: .5em; height: .5em; border-radius: 50%; background: #fff; box-shadow: .87em .37em #fff, -.87em .37em #fff; }
.auth-card { position: relative; z-index: 2; padding: 2.4em 2em 2.2em; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 24px; }
.auth-card > p { margin: 4px 0 20px; color: var(--muted); }
.auth-stack .demo-hint { margin-top: 30px; }
/* พิมพ์ชื่อผู้ใช้ = มองลงที่ตัวอักษร · พิมพ์รหัสผ่าน = เอามือปิดตา · กดดูรหัส = แอบมอง */
.panda.is-user .pd-ball { --ly: .5em; }
.panda.is-pass .pd-hand.l { left: calc(50% - 3.875em); top: 3.87em; height: 6.56em; transform: rotate(-155deg); }
.panda.is-pass .pd-hand.r { left: calc(50% + 1.375em); top: 3.87em; height: 6.56em; transform: rotate(155deg); }
/* แอบมอง: มือขวาเลื่อนลงต่ำกว่าตานิดเดียว (ยังอยู่บนหน้า) ไม่ตกลงไปที่ขอบการ์ด */
.panda.is-pass.is-peek .pd-hand.r { left: calc(50% + 2.1em); top: 5.9em; height: 5.2em; transform: rotate(165deg); }
.panda.is-sad .pd-face { animation: shake .5s .2s both; }
.panda.is-happy .pd-ball { --ly: -.15em; } .panda.is-happy .pd-blush { background: #ff8fab; }
@media (max-width: 480px) { .panda { font-size: 13px; } }/* กินหมดแล้ว ก้อนเมฆยุบหายไป */
.mf-cloud { transition: transform .45s cubic-bezier(.5, -0.4, .6, 1.4), opacity .4s; transform-origin: 80% 60%; }
.mf-stage.mb-chomp .mf-cloud { transform: scale(.55) translateX(30%); opacity: 0; }
.mf-box { transition: transform .5s cubic-bezier(.3, 1.4, .5, 1); }
.mf-stage.mb-flag .mf-box { transform: translateX(var(--hop, 0)); }
.mf-stage.mb-flag .mf-box svg { animation: mbHop .5s ease-out both; }
@keyframes mbHop { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-16px); } }
