/* ==========================================================
   e-Service design system · โรงเรียนวรราชาทินัดดามาตุวิทยา
   - กฎส่วนใหญ่อยู่ใต้ .es (body class) เพื่อไม่กระทบหน้าระบบย่อยที่ยังไม่ได้ปรับดีไซน์
   - เคารพ prefers-reduced-motion และรองรับโหมดมืด
   ========================================================== */

:root {
  --es-1: #4f46e5;   /* indigo */
  --es-2: #7c3aed;   /* violet */
  --es-3: #db2777;   /* pink */
  --es-4: #06b6d4;   /* cyan */
  --es-grad: linear-gradient(120deg, var(--es-1), var(--es-2) 50%, var(--es-3));
  --es-bg: #f6f5ff;
  --es-ink: #1e1b4b;
  --es-ink-2: #4b5563;
  --es-ink-3: #8b8fa8;
  --es-card: rgba(255, 255, 255, .72);
  --es-card-solid: #ffffff;
  --es-line: rgba(99, 102, 241, .14);
  --es-shadow: 0 1px 2px rgba(30, 27, 75, .04), 0 12px 32px -12px rgba(76, 29, 149, .22);
  --es-shadow-lg: 0 30px 70px -24px rgba(76, 29, 149, .45);
  --es-radius: 22px;
  --es-ease: cubic-bezier(.22, 1, .36, 1);
  --es-spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --es-bg: #0b0a1a;
    --es-ink: #eef0ff;
    --es-ink-2: #c3c6e0;
    --es-ink-3: #8a8eb0;
    --es-card: rgba(28, 26, 56, .62);
    --es-card-solid: #17152e;
    --es-line: rgba(165, 160, 255, .14);
    --es-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -14px rgba(0, 0, 0, .6);
    --es-shadow-lg: 0 34px 80px -24px rgba(0, 0, 0, .75);
    color-scheme: dark;
  }
}

/* ---------- เปลี่ยนหน้าแบบลื่น (Chrome/Edge รองรับ, เบราว์เซอร์อื่นข้ามไป) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: es-vt-out .22s var(--es-ease) both; }
::view-transition-new(root) { animation: es-vt-in .38s var(--es-ease) both; }
@keyframes es-vt-out { to { opacity: 0; transform: scale(.985); filter: blur(4px); } }
@keyframes es-vt-in { from { opacity: 0; transform: translateY(10px) scale(1.01); filter: blur(6px); } }

/* ---------- ฐาน ---------- */
.es {
  font-family: 'IBM Plex Sans Thai', 'Kanit', system-ui, sans-serif;
  background: var(--es-bg);
  color: var(--es-ink);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.es h1, .es h2, .es h3, .es .es-display { font-family: 'Kanit', 'IBM Plex Sans Thai', sans-serif; letter-spacing: -.01em; }
.es ::selection { background: rgba(124, 58, 237, .22); }
.es :focus-visible { outline: 3px solid rgba(124, 58, 237, .45); outline-offset: 2px; border-radius: 12px; }

/* ---------- พื้นหลังออโรรา: ก้อนสีลอยช้า ๆ + ตาราง + เกรน ---------- */
.es-aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.es-aurora i {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; will-change: transform;
  animation: es-float 26s ease-in-out infinite alternate;
}
.es-aurora i:nth-child(1) { width: 48vmax; height: 48vmax; left: -14vmax; top: -18vmax; background: #a5b4fc; }
.es-aurora i:nth-child(2) { width: 40vmax; height: 40vmax; right: -12vmax; top: 6vmax; background: #f0abfc; animation-duration: 32s; animation-delay: -8s; }
.es-aurora i:nth-child(3) { width: 36vmax; height: 36vmax; left: 22vmax; bottom: -20vmax; background: #67e8f9; opacity: .38; animation-duration: 38s; animation-delay: -14s; }
.es-aurora::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(var(--es-line) 1px, transparent 1px), linear-gradient(90deg, var(--es-line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
  opacity: .55;
}
.es-aurora::after {
  content: ''; position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: .05; mix-blend-mode: overlay;
}
@media (prefers-color-scheme: dark) {
  .es-aurora i:nth-child(1) { background: #4338ca; opacity: .42; }
  .es-aurora i:nth-child(2) { background: #a21caf; opacity: .32; }
  .es-aurora i:nth-child(3) { background: #0e7490; opacity: .28; }
}
@keyframes es-float {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50%  { transform: translate3d(6vmax, 4vmax, 0) rotate(40deg) scale(1.12); }
  100% { transform: translate3d(-4vmax, 7vmax, 0) rotate(-20deg) scale(.95); }
}

/* ---------- ปรากฏทีละชิ้น (ใส่ --d เป็นลำดับ) ---------- */
.es-reveal { opacity: 0; animation: es-rise .8s var(--es-ease) both; animation-delay: calc(var(--d, 0) * 70ms + 80ms); }
@keyframes es-rise {
  from { opacity: 0; transform: translateY(22px) scale(.98); filter: blur(8px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* ---------- แถบบน (กระจก) ---------- */
.es-topbar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  background: color-mix(in srgb, var(--es-bg) 72%, transparent);
  border-bottom: 1px solid var(--es-line);
  padding-top: env(safe-area-inset-top);
  view-transition-name: es-topbar;
}
.es-topbar-in { max-width: 1180px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 14px; }
.es-brand { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; color: inherit; }
.es-logo {
  width: 42px; height: 42px; flex: none; border-radius: 13px; display: grid; place-items: center;
  background: var(--es-grad); box-shadow: 0 8px 22px -8px rgba(124, 58, 237, .7), inset 0 1px 0 rgba(255,255,255,.35);
  view-transition-name: es-logo;
}
.es-logo svg { width: 26px; height: 26px; }
.es-brand b { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 17px; line-height: 1.1; display: block; }
.es-brand small { display: block; font-size: 11.5px; color: var(--es-ink-3); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- ปุ่ม ---------- */
.es-btn {
  --bg: var(--es-card-solid); --fg: var(--es-ink);
  position: relative; overflow: hidden; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 14px; border: 1px solid var(--es-line);
  background: var(--bg); color: var(--fg); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: transform .25s var(--es-spring), box-shadow .25s var(--es-ease), background .2s;
  box-shadow: var(--es-shadow);
}
.es-btn:hover { transform: translateY(-1px); }
.es-btn:active { transform: translateY(1px) scale(.98); }
.es-btn-primary { --bg: var(--es-grad); --fg: #fff; border-color: transparent; background: var(--es-grad); box-shadow: 0 12px 28px -12px rgba(124, 58, 237, .8); }
.es-btn-primary::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform .8s var(--es-ease);
}
.es-btn-primary:hover::after { transform: translateX(120%); }
.es-btn-ghost { background: transparent; box-shadow: none; }
.es-btn-danger { --fg: #dc2626; }
.es-btn-lg { padding: 14px 20px; border-radius: 16px; font-size: 15.5px; }
.es-btn .es-ripple {
  position: absolute; border-radius: 50%; transform: scale(0); pointer-events: none; z-index: -1;
  background: currentColor; opacity: .18; animation: es-ripple .6s var(--es-ease);
}
@keyframes es-ripple { to { transform: scale(4); opacity: 0; } }

/* ---------- ผู้ใช้ / เมนู ---------- */
.es-user { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 5px; border-radius: 16px; border: 1px solid var(--es-line); background: var(--es-card); cursor: pointer; }
.es-avatar {
  width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; flex: none;
  font-family: 'Kanit', sans-serif; font-weight: 600; color: #fff; background: var(--es-grad);
}
.es-user-meta { line-height: 1.2; min-width: 0; }
.es-user-meta b { display: block; font-size: 13px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.es-user-meta small { font-size: 11px; color: var(--es-ink-3); }
.es-menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 230px; padding: 8px;
  border-radius: 18px; background: var(--es-card-solid); border: 1px solid var(--es-line); box-shadow: var(--es-shadow-lg);
  transform-origin: top right; animation: es-pop .28s var(--es-spring);
}
.es-menu a, .es-menu button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  font-size: 14px; color: var(--es-ink); background: none; border: 0; cursor: pointer; text-align: left; text-decoration: none;
}
.es-menu a:hover, .es-menu button:hover { background: rgba(124, 58, 237, .08); }
@keyframes es-pop { from { opacity: 0; transform: scale(.92) translateY(-6px); } }

/* ---------- หน้าหลัก ---------- */
.es-main { max-width: 1180px; margin: 0 auto; padding: 34px 20px 120px; }
.es-hero { display: grid; gap: 18px; grid-template-columns: 1fr; align-items: end; margin-bottom: 26px; }
@media (min-width: 900px) { .es-hero { grid-template-columns: 1fr auto; } }
.es-hello { font-size: 14px; font-weight: 600; color: var(--es-2); display: flex; align-items: center; gap: 8px; }
.es-hello .es-wave { display: inline-block; transform-origin: 70% 70%; animation: es-wave 2.4s ease-in-out 1s 2; }
@keyframes es-wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-8deg); } }
.es-title { font-size: clamp(28px, 4.4vw, 44px); font-weight: 700; line-height: 1.12; margin: 6px 0 8px; }
.es-gradient-text {
  background: linear-gradient(100deg, var(--es-1), var(--es-2), var(--es-3), var(--es-2), var(--es-1));
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: es-shine 9s linear infinite;
}
@keyframes es-shine { to { background-position: 300% 0; } }
.es-sub { color: var(--es-ink-2); font-size: 15px; }
.es-today { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--es-ink-2); padding: 8px 12px; border-radius: 999px; border: 1px solid var(--es-line); background: var(--es-card); }
.es-live-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: es-ping 2s infinite; }
@keyframes es-ping { 70% { box-shadow: 0 0 0 9px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }

/* ค้นหาระบบ */
.es-search { position: relative; max-width: 460px; }
.es-search input {
  width: 100%; padding: 13px 16px 13px 44px; border-radius: 16px; border: 1px solid var(--es-line);
  background: var(--es-card); color: var(--es-ink); font: inherit; font-size: 14.5px; box-shadow: var(--es-shadow);
  backdrop-filter: blur(12px); transition: border-color .2s, box-shadow .2s;
}
.es-search input:focus { outline: none; border-color: rgba(124, 58, 237, .5); box-shadow: 0 0 0 5px rgba(124, 58, 237, .14), var(--es-shadow); }
.es-search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--es-ink-3); }
.es-search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 600 11px/1 'IBM Plex Sans Thai', sans-serif; color: var(--es-ink-3); border: 1px solid var(--es-line); border-radius: 7px; padding: 4px 7px; background: var(--es-card-solid); }

.es-section-title { display: flex; align-items: center; gap: 10px; margin: 30px 0 14px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--es-ink-3); }
.es-section-title::after { content: ''; flex: 1; height: 1px; background: var(--es-line); }

/* ---------- การ์ดระบบ: กระจก + แสงตามเมาส์ + เอียง 3 มิติ + ขอบเรืองแสง ---------- */
.es-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 268px), 1fr)); }
.es-card {
  --c1: var(--es-1); --c2: var(--es-2); --mx: 50%; --my: 50%; --rx: 0deg; --ry: 0deg;
  position: relative; display: flex; flex-direction: column; min-height: 196px; padding: 20px;
  border-radius: var(--es-radius); text-decoration: none; color: var(--es-ink); overflow: hidden; isolation: isolate;
  background: var(--es-card); border: 1px solid var(--es-line); box-shadow: var(--es-shadow);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .45s var(--es-ease), box-shadow .45s var(--es-ease), border-color .3s;
}
.es-card::before { /* แสงตามเมาส์ */
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .35s;
  background: radial-gradient(420px circle at var(--mx) var(--my), color-mix(in srgb, var(--c1) 22%, transparent), transparent 60%);
}
.es-card::after { /* ขอบไล่สี */
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; z-index: -1; opacity: 0;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  transition: opacity .35s;
}
.es-card:hover { box-shadow: var(--es-shadow-lg); border-color: transparent; }
.es-card:hover::before, .es-card:hover::after, .es-card:focus-visible::after { opacity: 1; }
.es-card-icon {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--c1), var(--c2)); color: #fff;
  box-shadow: 0 14px 26px -12px var(--c1), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .5s var(--es-spring);
}
.es-card:hover .es-card-icon { transform: translateY(-4px) rotate(-6deg) scale(1.06); }
.es-card h3 { font-size: 18px; font-weight: 600; line-height: 1.3; margin: 0; }
.es-card p { font-size: 13.5px; color: var(--es-ink-2); margin: 6px 0 0; line-height: 1.55; }
.es-card-go {
  margin-top: auto; padding-top: 16px; display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--c1);
}
.es-card-go span:last-child {
  width: 32px; height: 32px; border-radius: 11px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c1) 12%, transparent); transition: transform .4s var(--es-spring), background .3s, color .3s;
}
.es-card:hover .es-card-go span:last-child { transform: translateX(4px); background: var(--c1); color: #fff; }
.es-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--c1) 12%, transparent); color: var(--c1); }
.es-card[hidden] { display: none; }

/* สีของแต่ละระบบ */
.es-c-leave   { --c1: #10b981; --c2: #0d9488; }
.es-c-car     { --c1: #0ea5e9; --c2: #1d4ed8; }
.es-c-room    { --c1: #8b5cf6; --c2: #a21caf; }
.es-c-repair  { --c1: #f97316; --c2: #dc2626; }
.es-c-nithet  { --c1: #6366f1; --c2: #0891b2; }
.es-c-photo   { --c1: #ec4899; --c2: #e11d48; }
.es-c-library { --c1: #d946ef; --c2: #7e22ce; }
.es-c-budget  { --c1: #f59e0b; --c2: #c2410c; }
.es-c-research{ --c1: #14b8a6; --c2: #0e7490; }
.es-c-admin   { --c1: #475569; --c2: #1e1b4b; }
.es-c-cards   { --c1: #4f46e5; --c2: #312e81; }

.es-empty { text-align: center; padding: 50px 16px; color: var(--es-ink-3); }

/* ---------- แถบนำทางล่าง (มือถือ / แอป) ---------- */
.es-dock {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 45;
  display: flex; gap: 4px; padding: 7px; border-radius: 22px;
  background: color-mix(in srgb, var(--es-card-solid) 82%, transparent); border: 1px solid var(--es-line);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--es-shadow-lg); animation: es-dock-in .7s var(--es-spring) .4s both;
}
.es-dock a {
  display: grid; place-items: center; gap: 2px; min-width: 62px; padding: 7px 6px 6px; border-radius: 16px;
  text-decoration: none; color: var(--es-ink-2); font-size: 10.5px; font-weight: 600; transition: background .2s, transform .3s var(--es-spring);
}
.es-dock a span:first-child { font-size: 21px; line-height: 1; }
.es-dock a:active { transform: scale(.92); }
.es-dock a.on, .es-dock a:hover { background: rgba(124, 58, 237, .1); color: var(--es-2); }
@keyframes es-dock-in { from { opacity: 0; transform: translate(-50%, 30px) scale(.9); } }
@media (min-width: 900px) { .es-dock { display: none; } .es-main { padding-bottom: 60px; } }

/* ---------- หน้าเข้าสู่ระบบ ---------- */
.es-auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 980px) { .es-auth { grid-template-columns: 1.05fr 1fr; } }
.es-auth-art {
  position: relative; overflow: hidden; color: #fff; padding: 56px; display: none; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 0% 0%, #6366f1 0%, transparent 60%), radial-gradient(900px 700px at 100% 100%, #db2777 0%, transparent 55%), #1e1b4b;
}
@media (min-width: 980px) { .es-auth-art { display: flex; } }
.es-auth-art h1 { font-size: 46px; line-height: 1.12; font-weight: 700; margin: 18px 0 14px; }
.es-auth-art p { color: rgba(255,255,255,.78); font-size: 16px; max-width: 460px; line-height: 1.7; }
.es-orbit { position: absolute; right: -120px; top: 50%; width: 520px; height: 520px; transform: translateY(-50%); pointer-events: none; }
.es-orbit span { position: absolute; inset: 0; border-radius: 50%; border: 1px dashed rgba(255,255,255,.18); animation: es-spin 60s linear infinite; }
.es-orbit span:nth-child(2) { inset: 70px; animation-duration: 40s; animation-direction: reverse; }
.es-orbit span:nth-child(3) { inset: 140px; animation-duration: 28s; }
.es-orbit b {
  position: absolute; width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; font-size: 26px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(8px);
  box-shadow: 0 18px 40px -16px rgba(0,0,0,.6); animation: es-bob 5s ease-in-out infinite;
}
@keyframes es-spin { to { transform: rotate(360deg); } }
@keyframes es-bob { 50% { transform: translateY(-12px); } }
.es-feature { display: flex; gap: 12px; align-items: center; margin-top: 14px; font-size: 15px; color: rgba(255,255,255,.88); }
.es-feature i { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; font-style: normal; background: rgba(255,255,255,.14); }
.es-auth-panel { display: grid; place-items: center; padding: 32px 18px calc(32px + env(safe-area-inset-bottom)); }
.es-auth-card {
  position: relative; width: 100%; max-width: 420px; padding: 34px 28px; border-radius: 28px;
  background: var(--es-card); border: 1px solid var(--es-line); box-shadow: var(--es-shadow-lg);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
}
.es-auth-card::before { /* ขอบไล่สีหมุน */
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; z-index: -1;
  background: conic-gradient(from var(--es-angle, 0deg), var(--es-1), var(--es-3), var(--es-4), var(--es-1));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: es-angle 6s linear infinite; opacity: .8;
}
@property --es-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes es-angle { to { --es-angle: 360deg; } }
.es-google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 18px; border-radius: 16px;
  border: 1px solid var(--es-line); background: var(--es-card-solid); color: var(--es-ink); font-weight: 600; font-size: 15.5px; text-decoration: none;
  box-shadow: var(--es-shadow); transition: transform .3s var(--es-spring), box-shadow .3s;
}
.es-google:hover { transform: translateY(-2px); box-shadow: var(--es-shadow-lg); }
.es-field { display: block; margin-bottom: 14px; }
.es-field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--es-ink-2); }
.es-field input {
  width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--es-line); background: var(--es-card-solid);
  color: var(--es-ink); font: inherit; font-size: 15px; transition: border-color .2s, box-shadow .2s;
}
.es-field input:focus { outline: none; border-color: rgba(124, 58, 237, .5); box-shadow: 0 0 0 5px rgba(124, 58, 237, .14); }
.es-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; font-size: 12px; color: var(--es-ink-3); }
.es-divider::before, .es-divider::after { content: ''; flex: 1; height: 1px; background: var(--es-line); }
.es-alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; font-size: 13.5px; margin-bottom: 16px; background: rgba(239, 68, 68, .1); color: #b91c1c; border: 1px solid rgba(239, 68, 68, .25); }
details.es-more > summary { list-style: none; cursor: pointer; text-align: center; font-size: 13.5px; color: var(--es-ink-2); font-weight: 600; padding: 6px; border-radius: 10px; }
details.es-more > summary::-webkit-details-marker { display: none; }
details.es-more[open] > summary { color: var(--es-2); }
details.es-more[open] form { animation: es-rise .5s var(--es-ease); }

/* ---------- โหลด / หน้าต่าง ---------- */
.es-loader { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; background: color-mix(in srgb, var(--es-bg) 70%, transparent); backdrop-filter: blur(6px); }
.es-loader.hidden { display: none !important; }
.es-loader-ring { width: 64px; height: 64px; border-radius: 50%; padding: 4px; background: conic-gradient(var(--es-1), var(--es-3), var(--es-4), var(--es-1)); animation: es-spin 1s linear infinite; -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px)); mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px)); }
.es-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 12, 41, .5); backdrop-filter: blur(6px); animation: es-fade .25s ease; }
.es-modal.hidden { display: none !important; }
.es-modal > div { animation: es-pop .35s var(--es-spring); }
@keyframes es-fade { from { opacity: 0; } }

/* ---------- แถบติดตั้งแอป / อัปเดต ---------- */
.es-toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  width: min(440px, calc(100% - 24px)); display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 18px;
  background: #1e1b4b; color: #fff; box-shadow: var(--es-shadow-lg); animation: es-toast-in .55s var(--es-spring);
  font-family: 'IBM Plex Sans Thai', 'Kanit', system-ui, sans-serif; font-size: 14px;
}
@media (min-width: 900px) { .es-toast { bottom: 24px; } }
.es-toast img { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.es-toast div { flex: 1; line-height: 1.35; }
.es-toast small { color: rgba(255,255,255,.7); font-size: 12px; }
.es-toast button { border: 0; border-radius: 12px; padding: 9px 13px; font-family: inherit; font-weight: 600; font-size: 13px; line-height: 1; cursor: pointer; }
.es-toast .ok { background: #fff; color: #4c1d95; }
.es-toast .no { background: transparent; color: rgba(255,255,255,.75); }
@keyframes es-toast-in { from { opacity: 0; transform: translate(-50%, 24px) scale(.96); } }

.es-footer { text-align: center; font-size: 12px; color: var(--es-ink-3); padding: 26px 16px 8px; }
.es-footer b { color: var(--es-ink-2); font-weight: 600; }

/* ---------- ลดการเคลื่อนไหว ---------- */
@media (prefers-reduced-motion: reduce) {
  .es *, .es *::before, .es *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .es-reveal { opacity: 1; }
  .es-card { transform: none !important; }
}

/* ซ่อนด้วยแอตทริบิวต์ hidden เสมอ (กัน .es-btn/.es-card ทับ) */
.es [hidden] { display: none !important; }
@media (max-width: 639px) { .es .es-install-top { display: none !important; } }

/* ---------- มือถือ: การ์ดเป็นไทล์ 2 คอลัมน์แบบหน้าแอป ---------- */
@media (max-width: 560px) {
  .es-main { padding: 22px 14px 120px; }
  .es-title { font-size: 26px; }
  .es-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .es-card { min-height: 0; padding: 16px 14px 14px; border-radius: 20px; }
  .es-card-icon { width: 50px; height: 50px; border-radius: 16px; font-size: 26px; margin-bottom: 12px; }
  .es-card h3 { font-size: 15px; }
  .es-card p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; }
  .es-card-go { padding-top: 10px; font-size: 12px; }
  .es-card-go span:last-child { width: 28px; height: 28px; border-radius: 9px; }
}

/* แถบบอกว่าเป็นเครื่องทดลอง (SVC_ENV=staging) */
.es-staging { position: relative; z-index: 41; text-align: center; font-size: 12.5px; padding: 6px 12px; color: #78350f; background: repeating-linear-gradient(-45deg, #fde68a, #fde68a 12px, #fcd34d 12px, #fcd34d 24px); }
